-
Notifications
You must be signed in to change notification settings - Fork 22
/
simplewrite.cc
68 lines (51 loc) · 1.47 KB
/
simplewrite.cc
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
// Data model
#include "datamodel/EventInfo.h"
#include "datamodel/EventInfoCollection.h"
#include "datamodel/Particle.h"
#include "datamodel/ParticleCollection.h"
#include "datamodel/LorentzVector.h"
// Utility functions
#include "utilities/VectorUtils.h"
// ROOT
#include "TLorentzVector.h"
#include "TBranch.h"
#include "TFile.h"
#include "TTree.h"
// STL
#include <iostream>
#include <vector>
// podio specific includes
#include "podio/EventStore.h"
#include "podio/ROOTWriter.h"
// testing tools
#include "utilities/DummyGenerator.h"
int main(){
std::cout<<"start processing"<<std::endl;
auto store = podio::EventStore();
podio::ROOTWriter writer("simpleexample.root", &store);
unsigned nevents=10000;
auto& evinfocoll = store.create<fcc::EventInfoCollection>("evtinfo");
auto& pcoll = store.create<fcc::ParticleCollection>("mcparticles");
writer.registerForWrite("evtinfo");
writer.registerForWrite("mcparticles");
for(unsigned iev=0; iev<nevents; ++iev) {
if(iev % 1000 == 0)
std::cout<<"processing event "<<iev<<std::endl;
// fill event information
auto evinfo = fcc::EventInfo(); // evinfocoll.create();
evinfo.number(iev);
evinfocoll.push_back(evinfo);
auto ptc = fcc::Particle();
ptc.pdgId(25);
auto& p4 = ptc.p4();
p4.px = static_cast<float>(iev);
p4.py = 0.;
p4.pz = 0.;
p4.mass = 126.;
pcoll.push_back(ptc);
writer.writeEvent();
store.clearCollections();
}
writer.finish();
return 0;
}