|
DD4hep
1.30.0
Detector Description Toolkit for High Energy Physics
|
Go to the documentation of this file.
24 #ifndef DD4HEP_DDG4_LCIOFILEREADER_H
25 #define DD4HEP_DDG4_LCIOFILEREADER_H
34 using namespace lcio ;
37 namespace IO {
class LCReader; }
46 template <
class T=EVENT::LCParameters>
void EventParameters::ingestParameters(T
const& source) {
47 EVENT::StringVec intKeys;
48 EVENT::StringVec floatKeys;
49 EVENT::StringVec stringKeys;
50 source.getIntKeys(intKeys);
51 source.getFloatKeys(floatKeys);
52 source.getStringKeys(stringKeys);
53 for(
auto const&
key: intKeys) {
55 source.getIntVals(
key,intVec);
56 m_intValues[
key] = std::move(intVec);
58 for(
auto const&
key: floatKeys) {
59 EVENT::FloatVec floatVec;
60 source.getFloatVals(
key,floatVec);
61 m_fltValues[
key] = std::move(floatVec);
63 for(
auto const&
key: stringKeys) {
64 EVENT::StringVec stringVec;
65 source.getStringVals(
key,stringVec);
66 m_strValues[
key] = std::move(stringVec);
90 virtual EventReaderStatus readParticleCollection(
int event_number, EVENT::LCCollection** particles);
93 virtual EventReaderStatus setParameters(std::map< std::string, std::string >& parameters);
97 #endif // DD4HEP_DDG4_LCIOFILEREADER_H
101 #include <UTIL/ILDConf.h>
111 , m_collectionName(LCIO::MCPARTICLE)
113 m_reader = ::lcio::LCFactory::getInstance()->createLCReader(LCReader::directAccess);
114 printout(INFO,
"LCIOFileReader",
"Created file reader. Try to open input %s",nam.c_str());
121 dd4hep::detail::deletePtr(
m_reader);
130 if( m_currEvent == 0 && event_number != 0 ) {
131 m_reader->skipNEvents( event_number ) ;
132 printout(INFO,
"LCIOFileReader::moveToEvent",
"Skipping the first %d events ", event_number );
133 printout(INFO,
"LCIOFileReader::moveToEvent",
"Event number before skipping: %d", m_currEvent );
134 m_currEvent = event_number;
135 printout(INFO,
"LCIOFileReader::moveToEvent",
"Event number after skipping: %d", m_currEvent );
137 return EVENT_READER_OK;
144 ::lcio::LCEvent* evt =
m_reader->readNextEvent();
148 *particles = evt->getCollection(m_collectionName);
150 printout(INFO,
"LCIOFileReader",
"read collection %s from event %d in run %d ",
151 m_collectionName.c_str(), evt->getEventNumber(), evt->getRunNumber());
165 return EVENT_READER_OK;
168 return EVENT_READER_EOF;
175 _getParameterValue( parameters,
"MCParticleCollectionName", m_collectionName, std::string(LCIO::MCPARTICLE));
176 return EVENT_READER_OK;
std::string m_collectionName
virtual EventReaderStatus moveToEvent(int event_number)
moveToSpecifiedEvent, a.k.a. skipNEvents
EventReaderStatus
Status codes of the event reader object. Anything with NOT low-bit set is an error.
void exception(const std::string &src, const std::string &msg)
Base class to read lcio files.
void setRunNumber(int runNumber)
Set the event parameters.
Plugin to read lcio files.
virtual EventReaderStatus readParticleCollection(int event_number, EVENT::LCCollection **particles)
Read an event and fill a vector of MCParticles.
void setEventNumber(int eventNumber)
#define DECLARE_GEANT4_EVENT_READER_NS(name_space, name)
Plugin defintion to create event reader objects.
Geant4Event & event() const
Access the geant4 event – valid only between BeginEvent() and EndEvent()!
UriReader * m_reader
Pointer to URI reader.
LCIOFileReader(const std::string &nam)
Initializing constructor.
virtual EventReaderStatus skipEvent()
Skip event. To be implemented for sequential sources.
void ingestParameters(T const &source)
Copy the parameters from source.
LCIO namespace. See http://lcio.desy.de.
IO::LCReader * m_reader
Reference to reader object.
bool m_directAccess
Flag if direct event access is supported. To be explicitly set by subclass constructors.
void * addExtension(unsigned long long int k, ExtensionEntry *e)
Add an extension object to the detector element.
Namespace for the Geant4 based simulation part of the AIDA detector description toolkit.
Event extension to pass input event data to output event.
Namespace for the AIDA detector description toolkit.
virtual EventReaderStatus setParameters(std::map< std::string, std::string > ¶meters)
virtual ~LCIOFileReader()
Default destructor.
Generic context to extend user, run and event information.