Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// $Id: Geant4Converter.cpp 603 2013-06-13 21:15:14Z markus.frank $
//====================================================================
// AIDA Detector description implementation for LCD
//--------------------------------------------------------------------
//
//====================================================================
// Framework include files
#include "EventReader.h"
/*
* DD4hep namespace declaration
*/
namespace DD4hep {
/*
* lcio namespace declaration
*/
namespace lcio {
/** @class LcioEventReader LcioEventReader.h DDG4/LcioEventReader.h
*
* Base class to read lcio event files
*
* @author P.Kostka (main author)
* @author M.Frank (code reshuffeling into new DDG4 scheme)
* @version 1.0
*/
struct LcioEventReader : public EventReader {
protected:
/// Reference to reader object
IO::LCReader* m_reader;
public:
/// Initializing constructor
LcioEventReader(const std::string& nam, int);
/// Default destructor
virtual ~LcioEventReader();
/// Read an event and return a LCCollectionVec of MCParticles.
virtual Particles *readEvent();
};
}
}
#include "DD4hep/Printout.h"
#include "lcio.h"
#include "EVENT/LCIO.h"
#include "IO/LCReader.h"
using namespace EVENT;
// Factory entry
typedef DD4hep::lcio::LcioEventReader LcioEventReader;
DECLARE_LCIO_EVENT_READER(LcioEventReader)
/// Initializing constructor
LcioEventReader::LcioEventReader(const std::string& nam, int /* arg */)
: EventReader(nam)
{
m_reader = ::lcio::LCFactory::getInstance()->createLCReader();
printout(INFO,"LcioEventReader","Created file reader. Try to open input %s",nam.c_str());
m_reader->open(nam);
}
/// Default destructor
LcioEventReader::~LcioEventReader() {
deletePtr(m_reader);
}
/// Read an event and return a LCCollectionVec of MCParticles.
DD4hep::lcio::EventReader::Particles *LcioEventReader::readEvent() {
::lcio::LCEvent* evt = m_reader->readNextEvent();
if ( evt ) {
Particles* mcVec = (Particles*)evt->getCollection(LCIO::MCPARTICLE);
return mcVec;
}
return 0;
}