From f34bf84a59331624851ef5ad52c8472de65622f8 Mon Sep 17 00:00:00 2001 From: Andre Sailer <andre.philippe.sailer@cern.ch> Date: Fri, 28 Feb 2020 16:42:41 +0100 Subject: [PATCH] LCIOFileReader: ingest LCParameters to EventParameters; remove superseded LCIOEventParameters --- DDG4/lcio/LCIOEventParameters.cpp | 83 ------------------------------- DDG4/lcio/LCIOEventParameters.h | 59 ---------------------- DDG4/lcio/LCIOFileReader.cpp | 34 +++++++++++-- 3 files changed, 30 insertions(+), 146 deletions(-) delete mode 100644 DDG4/lcio/LCIOEventParameters.cpp delete mode 100644 DDG4/lcio/LCIOEventParameters.h diff --git a/DDG4/lcio/LCIOEventParameters.cpp b/DDG4/lcio/LCIOEventParameters.cpp deleted file mode 100644 index 9d11785ee..000000000 --- a/DDG4/lcio/LCIOEventParameters.cpp +++ /dev/null @@ -1,83 +0,0 @@ -//========================================================================== -// AIDA Detector description implementation -//-------------------------------------------------------------------------- -// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) -// All rights reserved. -// -// For the licensing terms see $DD4hepINSTALL/LICENSE. -// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. -// -// @author R.Ete (main author) -// -//==================================================================== - -// Framework include files -#include "LCIOEventParameters.h" - -using namespace std; -using namespace dd4hep; -using namespace dd4hep::sim; - -/// Initializing constructor -LCIOEventParameters::LCIOEventParameters() - : m_runNumber(0), m_eventNumber(0) -{ -} - -/// Default destructor -LCIOEventParameters::~LCIOEventParameters() { -} - -/// Set the event parameters -void LCIOEventParameters::setParameters(int rNumber, - int evtNumber, - const EVENT::LCParameters& parameters) -{ - m_runNumber = rNumber; - m_eventNumber = evtNumber; - copyLCParameters(parameters, m_eventParameters); -} - -/// Get the run number -int LCIOEventParameters::runNumber() const { - return m_runNumber; -} - -/// Get the event number -int LCIOEventParameters::eventNumber() const { - return m_eventNumber; -} - -/// Get the event parameters -const IMPL::LCParametersImpl& LCIOEventParameters::eventParameters() const { - return m_eventParameters; -} - -/// Copy the paramaters from source to destination -void LCIOEventParameters::copyLCParameters(const EVENT::LCParameters& source, - EVENT::LCParameters& destination) -{ - EVENT::StringVec intKeys; source.getIntKeys(intKeys); - EVENT::StringVec floatKeys; source.getFloatKeys(floatKeys); - EVENT::StringVec stringKeys; source.getStringKeys(stringKeys); - - for(unsigned int i=0; i<intKeys.size(); ++i ) { - EVENT::IntVec intVec; - source.getIntVals(intKeys.at(i),intVec); - destination.setValues(intKeys.at(i),intVec); - } - - for(unsigned int i=0; i<floatKeys.size(); ++i ) { - EVENT::FloatVec floatVec; - source.getFloatVals(floatKeys.at(i),floatVec); - destination.setValues(floatKeys.at(i),floatVec); - } - - for(unsigned int i=0; i<stringKeys.size(); ++i ) { - EVENT::StringVec stringVec; - source.getStringVals(stringKeys.at(i),stringVec); - destination.setValues(stringKeys.at(i),stringVec); - } -} - - diff --git a/DDG4/lcio/LCIOEventParameters.h b/DDG4/lcio/LCIOEventParameters.h deleted file mode 100644 index 66e890487..000000000 --- a/DDG4/lcio/LCIOEventParameters.h +++ /dev/null @@ -1,59 +0,0 @@ -//========================================================================== -// AIDA Detector description implementation -//-------------------------------------------------------------------------- -// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) -// All rights reserved. -// -// For the licensing terms see $DD4hepINSTALL/LICENSE. -// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. -// -// Author : R.Ete -// -//========================================================================== -#ifndef DD4HEP_DDG4_LCIOEVENTPARAMETERS_H -#define DD4HEP_DDG4_LCIOEVENTPARAMETERS_H - -// lcio include files -#include "lcio.h" -#include "IMPL/LCParametersImpl.h" - -/// Namespace for the AIDA detector description toolkit -namespace dd4hep { - - /// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit - namespace sim { - - /// Event extension to pass input LCIO event data to output LCIO event - /** - * \author R.Ete (main author) - * \version 1.0 - * \ingroup DD4HEP_SIMULATION - */ - class LCIOEventParameters { - private: - int m_runNumber; - int m_eventNumber; - IMPL::LCParametersImpl m_eventParameters; - - public: - /// Initializing constructor - LCIOEventParameters(); - /// Default destructor - ~LCIOEventParameters(); - - /// Set the event parameters - void setParameters(int runNumber, int eventNumber, const EVENT::LCParameters& parameters); - /// Get the run number - int runNumber() const; - /// Get the event number - int eventNumber() const; - /// Get the event parameters - const IMPL::LCParametersImpl& eventParameters() const; - - /// Copy the paramaters from source to destination - static void copyLCParameters(const EVENT::LCParameters& source, EVENT::LCParameters& destination); - }; - - } /* End namespace sim */ -} /* End namespace dd4hep */ -#endif /* DD4HEP_DDG4_LCIOEVENTPARAMETERS_H */ diff --git a/DDG4/lcio/LCIOFileReader.cpp b/DDG4/lcio/LCIOFileReader.cpp index 40d43780f..4e9bafbf4 100644 --- a/DDG4/lcio/LCIOFileReader.cpp +++ b/DDG4/lcio/LCIOFileReader.cpp @@ -27,7 +27,9 @@ // Framework include files #include "LCIOEventReader.h" -#include "LCIOEventParameters.h" + +#include "DDG4/EventParameters.h" + #include "lcio.h" using namespace lcio ; @@ -41,6 +43,28 @@ namespace dd4hep { /// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit namespace sim { + /// get the parameters from the input LCIO Event and store them in the EventParameters extension + template <class T=EVENT::LCParameters> void EventParameters::ingestParameters(T const& source) { + EVENT::StringVec intKeys; source.getIntKeys(intKeys); + EVENT::StringVec floatKeys; source.getFloatKeys(floatKeys); + EVENT::StringVec stringKeys; source.getStringKeys(stringKeys); + for(auto const& key: intKeys) { + EVENT::IntVec intVec; + source.getIntVals(key,intVec); + m_intValues[key] = intVec; + } + for(auto const& key: floatKeys) { + EVENT::FloatVec floatVec; + source.getFloatVals(key,floatVec); + m_fltValues[key] = floatVec; + } + for(auto const& key: stringKeys) { + EVENT::StringVec stringVec; + source.getStringVals(key,stringVec); + m_strValues[key] = stringVec; + } + } + /// Base class to read lcio event files /** * \author P.Kostka (main author) @@ -127,9 +151,11 @@ dd4hep::sim::LCIOFileReader::readParticleCollection(int /*event_number*/, EVENT: // Create input event parameters context try { Geant4Context* ctx = context(); - LCIOEventParameters *parameters = new LCIOEventParameters(); - parameters->setParameters(evt->getRunNumber(), evt->getEventNumber(), evt->parameters()); - ctx->event().addExtension<LCIOEventParameters>( parameters ); + EventParameters *parameters = new EventParameters(); + parameters->setRunNumber(evt->getRunNumber()); + parameters->setEventNumber(evt->getEventNumber()); + parameters->ingestParameters(evt->parameters()); + ctx->event().addExtension<EventParameters>(parameters); } catch(std::exception &) { -- GitLab