Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DD4hep
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cepc
externals
mirroring
DD4hep
Commits
9f29bd46
Commit
9f29bd46
authored
1 year ago
by
Andre Sailer
Browse files
Options
Downloads
Patches
Plain Diff
DDG4: add propagating of run parameters from input files to output files
parent
ab9a96e6
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
DDG4/hepmc/HepMC3FileReader.cpp
+29
-0
29 additions, 0 deletions
DDG4/hepmc/HepMC3FileReader.cpp
DDG4/include/DDG4/Geant4InputAction.h
+3
-0
3 additions, 0 deletions
DDG4/include/DDG4/Geant4InputAction.h
DDG4/src/Geant4InputAction.cpp
+1
-0
1 addition, 0 deletions
DDG4/src/Geant4InputAction.cpp
with
33 additions
and
0 deletions
DDG4/hepmc/HepMC3FileReader.cpp
+
29
−
0
View file @
9f29bd46
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
#include
"HepMC3EventReader.h"
#include
"HepMC3EventReader.h"
#include
"DDG4/EventParameters.h"
#include
"DDG4/EventParameters.h"
#include
"DDG4/RunParameters.h"
#include
<HepMC3/ReaderFactory.h>
#include
<HepMC3/ReaderFactory.h>
...
@@ -68,6 +69,22 @@ namespace dd4hep {
...
@@ -68,6 +69,22 @@ namespace dd4hep {
}
}
}
}
template
<
class
T
=
HepMC3
::
GenRunInfo
>
void
RunParameters
::
ingestParameters
(
T
const
&
runInfo
)
{
// This attributes is not the same return type as for GenEvent!
for
(
auto
const
&
attr
:
runInfo
.
attributes
()){
std
::
stringstream
strstr
;
if
(
auto
int_attr
=
std
::
dynamic_pointer_cast
<
HepMC3
::
IntAttribute
>
(
attr
.
second
))
{
m_intValues
[
attr
.
first
]
=
{
int_attr
->
value
()};
}
else
if
(
auto
flt_attr
=
std
::
dynamic_pointer_cast
<
HepMC3
::
FloatAttribute
>
(
attr
.
second
))
{
m_fltValues
[
attr
.
first
]
=
{
flt_attr
->
value
()};
}
else
if
(
auto
dbl_attr
=
std
::
dynamic_pointer_cast
<
HepMC3
::
DoubleAttribute
>
(
attr
.
second
))
{
m_dblValues
[
attr
.
first
]
=
{
dbl_attr
->
value
()};
}
else
{
// anything else
m_strValues
[
attr
.
first
]
=
{
attr
.
second
->
unparsed_string
()};
}
}
}
/// Base class to read hepmc3 event files
/// Base class to read hepmc3 event files
/**
/**
* \version 1.0
* \version 1.0
...
@@ -89,6 +106,9 @@ namespace dd4hep {
...
@@ -89,6 +106,9 @@ namespace dd4hep {
virtual
EventReaderStatus
moveToEvent
(
int
event_number
);
virtual
EventReaderStatus
moveToEvent
(
int
event_number
);
//virtual EventReaderStatus skipEvent() { return EVENT_READER_OK; }
//virtual EventReaderStatus skipEvent() { return EVENT_READER_OK; }
virtual
EventReaderStatus
setParameters
(
std
::
map
<
std
::
string
,
std
::
string
>&
parameters
);
virtual
EventReaderStatus
setParameters
(
std
::
map
<
std
::
string
,
std
::
string
>&
parameters
);
/// register the run parameters into an extension for the run context
virtual
void
registerRunParameters
();
};
};
}
}
}
}
...
@@ -111,6 +131,15 @@ HEPMC3FileReader::HEPMC3FileReader(const std::string& nam)
...
@@ -111,6 +131,15 @@ HEPMC3FileReader::HEPMC3FileReader(const std::string& nam)
m_directAccess
=
false
;
m_directAccess
=
false
;
}
}
void
HEPMC3FileReader
::
registerRunParameters
()
{
try
{
auto
*
parameters
=
new
RunParameters
();
parameters
->
ingestParameters
(
*
(
m_reader
->
run_info
()));
context
()
->
run
().
addExtension
<
RunParameters
>
(
parameters
);
}
catch
(
std
::
exception
&
)
{
}
}
/// moveToSpecifiedEvent, a.k.a. skipNEvents
/// moveToSpecifiedEvent, a.k.a. skipNEvents
Geant4EventReader
::
EventReaderStatus
Geant4EventReader
::
EventReaderStatus
HEPMC3FileReader
::
moveToEvent
(
int
event_number
)
{
HEPMC3FileReader
::
moveToEvent
(
int
event_number
)
{
...
...
This diff is collapsed.
Click to expand it.
DDG4/include/DDG4/Geant4InputAction.h
+
3
−
0
View file @
9f29bd46
...
@@ -137,6 +137,9 @@ namespace dd4hep {
...
@@ -137,6 +137,9 @@ namespace dd4hep {
/// make sure that all parameters have been processed, otherwise throw exceptions
/// make sure that all parameters have been processed, otherwise throw exceptions
virtual
void
checkParameters
(
std
::
map
<
std
::
string
,
std
::
string
>&
);
virtual
void
checkParameters
(
std
::
map
<
std
::
string
,
std
::
string
>&
);
/// Register Run Parameters
virtual
void
registerRunParameters
()
{}
};
};
/// Generic input action capable of using the Geant4EventReader class.
/// Generic input action capable of using the Geant4EventReader class.
...
...
This diff is collapsed.
Click to expand it.
DDG4/src/Geant4InputAction.cpp
+
1
−
0
View file @
9f29bd46
...
@@ -165,6 +165,7 @@ int Geant4InputAction::readParticles(int evt_number,
...
@@ -165,6 +165,7 @@ int Geant4InputAction::readParticles(int evt_number,
m_reader
->
setParameters
(
m_parameters
);
m_reader
->
setParameters
(
m_parameters
);
m_reader
->
checkParameters
(
m_parameters
);
m_reader
->
checkParameters
(
m_parameters
);
m_reader
->
setInputAction
(
this
);
m_reader
->
setInputAction
(
this
);
m_reader
->
registerRunParameters
();
}
}
catch
(
const
exception
&
e
)
{
catch
(
const
exception
&
e
)
{
err
=
e
.
what
();
err
=
e
.
what
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment