File indexing completed on 2025-01-18 09:14:18
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 #ifndef DD4HEP_DDG4_LCIOSTDHEPREADER_H
0025 #define DD4HEP_DDG4_LCIOSTDHEPREADER_H
0026
0027
0028 #include <UTIL/LCStdHepRdr.h>
0029
0030
0031 #include "LCIOEventReader.h"
0032
0033
0034 namespace dd4hep {
0035
0036
0037 namespace sim {
0038
0039
0040
0041
0042
0043
0044
0045
0046 class LCIOStdHepReader : public LCIOEventReader {
0047 protected:
0048
0049 UTIL::LCStdHepRdr* m_reader;
0050 public:
0051
0052 LCIOStdHepReader(const std::string& nam);
0053
0054 virtual ~LCIOStdHepReader();
0055
0056 virtual EventReaderStatus readParticleCollection(int event_number,
0057 EVENT::LCCollection** particles) override;
0058 virtual EventReaderStatus moveToEvent(int event_number) override;
0059 virtual EventReaderStatus skipEvent() override { return EVENT_READER_OK; }
0060
0061 };
0062 }
0063 }
0064 #endif
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080 #include <DDG4/Factories.h>
0081
0082
0083 DECLARE_GEANT4_EVENT_READER_NS(dd4hep::sim,LCIOStdHepReader)
0084
0085 using namespace dd4hep::sim;
0086
0087
0088 LCIOStdHepReader::LCIOStdHepReader(const std::string& nam)
0089 : LCIOEventReader(nam), m_reader(new UTIL::LCStdHepRdr(m_name.c_str()))
0090 {
0091 }
0092
0093
0094 LCIOStdHepReader::~LCIOStdHepReader() {
0095 dd4hep::detail::deletePtr(m_reader);
0096 }
0097
0098
0099
0100 Geant4EventReader::EventReaderStatus
0101 LCIOStdHepReader::moveToEvent(int event_number) {
0102 if( m_currEvent == 0 && event_number != 0 ) {
0103 printout(INFO,"LCIOStdHepReader::moveToEvent","Skipping the first %d events ", event_number );
0104 printout(INFO,"LCIOStdHepReader::moveToEvent","Event number before skipping: %d", m_currEvent );
0105 while ( m_currEvent < event_number ) {
0106 EVENT::LCCollection* particles = m_reader->readEvent();
0107 if ( 0 == particles ) return EVENT_READER_EOF;
0108 delete particles;
0109 ++m_currEvent;
0110 }
0111 }
0112 printout(INFO,"LCIOStdHepReader::moveToEvent","Event number after skipping: %d", m_currEvent );
0113 return EVENT_READER_OK;
0114 }
0115
0116
0117 Geant4EventReader::EventReaderStatus
0118 LCIOStdHepReader::readParticleCollection(int , EVENT::LCCollection** particles) {
0119
0120 *particles = m_reader->readEvent();
0121 ++m_currEvent;
0122
0123 if ( 0 == *particles ) return EVENT_READER_EOF;
0124 return EVENT_READER_OK;
0125 }