Skip to content
Snippets Groups Projects
Commit 76f24549 authored by Andre Sailer's avatar Andre Sailer
Browse files

DDG4 LCIO Output: ingest potential run parameters

parent 0a294c4b
No related branches found
No related tags found
No related merge requests found
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "DDG4/Geant4OutputAction.h" #include "DDG4/Geant4OutputAction.h"
#include "DDG4/EventParameters.h" #include "DDG4/EventParameters.h"
#include "DDG4/RunParameters.h"
// Geant4 headers // Geant4 headers
#include "G4Threading.hh" #include "G4Threading.hh"
#include "G4AutoLock.hh" #include "G4AutoLock.hh"
...@@ -62,6 +63,23 @@ namespace dd4hep { ...@@ -62,6 +63,23 @@ namespace dd4hep {
#endif #endif
} }
template <class T=lcio::LCRunHeaderImpl> void RunParameters::extractParameters(T& runHeader){
auto& lcparameters = runHeader.parameters();
for(auto const& ival: this->intParameters()) {
lcparameters.setValues(ival.first, ival.second);
}
for(auto const& ival: this->fltParameters()) {
lcparameters.setValues(ival.first, ival.second);
}
for(auto const& ival: this->strParameters()) {
lcparameters.setValues(ival.first, ival.second);
}
#if LCIO_VERSION_GE(2, 17)
for(auto const& ival: this->dblParameters()) {
lcparameters.setValues(ival.first, ival.second);
}
#endif
}
class Geant4ParticleMap; class Geant4ParticleMap;
...@@ -250,6 +268,10 @@ void Geant4Output2LCIO::saveRun(const G4Run* run) { ...@@ -250,6 +268,10 @@ void Geant4Output2LCIO::saveRun(const G4Run* run) {
rh->parameters().setValue("DD4HEPVersion", versionString()); rh->parameters().setValue("DD4HEPVersion", versionString());
rh->setRunNumber(m_runNo); rh->setRunNumber(m_runNo);
rh->setDetectorName(context()->detectorDescription().header().name()); rh->setDetectorName(context()->detectorDescription().header().name());
auto* parameters = context()->run().extension<RunParameters>(false);
if (parameters) {
parameters->extractParameters(*rh);
}
m_file->writeRunHeader(rh); m_file->writeRunHeader(rh);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment