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
#include "EventHeaderCollection.h"
#include "MCParticleCollection.h"
#include "podio/EventStore.h"
#include "podio/ROOTReader.h"
int main(int argc, char* argv[])
{
auto reader = podio::ROOTReader();
auto store = podio::EventStore();
reader.openFile("test.root");
store.setReader(&reader);
unsigned int nEvt = reader.getEntries();
for (unsigned int i = 0; i < nEvt; ++i ) {
//if ( i%10 == 0 ) {
// std::cout << "processing event " << i << std::endl;
//}
auto& hds = store.get<plcio::EventHeaderCollection>("EvtHeaders");
if ( hds.isValid() ) {
auto header = hds[0];
std::cout << "processing event " << header.getEventNumber() << std::endl;
}
else {
return -1;
}
auto& mcc = store.get<plcio::MCParticleCollection>("MCParticles");
if ( ! mcc.isValid() ) {
return -1;
}
for ( auto p : mcc ) {
std::cout << " particle " << p.getObjectID().index << " has daughters: ";
for ( auto it = p.daughters_begin(), end = p.daughters_end(); it != end; ++it ) {
std::cout << " " << it->getObjectID().index;
}
std::cout << " and parents: ";
for ( auto it = p.parents_begin(), end = p.parents_end(); it != end ; ++it ){
std::cout << " " << it->getObjectID().index;
}
std::cout << std::endl;
}
store.clear();
reader.endOfEvent();
}
reader.closeFile();
return 0;
}