Skip to content

Commit

Permalink
DDG4 LCIO Output: ingest potential run parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
andresailer committed Jul 21, 2023
1 parent 0f7df29 commit cf7f881
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions DDG4/lcio/Geant4Output2LCIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "DDG4/Geant4OutputAction.h"

#include "DDG4/EventParameters.h"
#include "DDG4/RunParameters.h"
// Geant4 headers
#include "G4Threading.hh"
#include "G4AutoLock.hh"
Expand Down Expand Up @@ -62,6 +63,23 @@ namespace dd4hep {
#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;

Expand Down Expand Up @@ -250,6 +268,10 @@ void Geant4Output2LCIO::saveRun(const G4Run* run) {
rh->parameters().setValue("DD4HEPVersion", versionString());
rh->setRunNumber(m_runNo);
rh->setDetectorName(context()->detectorDescription().header().name());
auto* parameters = context()->run().extension<RunParameters>(false);
if (parameters) {
parameters->extractParameters(*rh);
}
m_file->writeRunHeader(rh);
}

Expand Down

0 comments on commit cf7f881

Please sign in to comment.