-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathPrintEvents.C
More file actions
310 lines (269 loc) · 12.5 KB
/
PrintEvents.C
File metadata and controls
310 lines (269 loc) · 12.5 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
//
// This macro prints the a couple of leaves from each branch
// to test direct access to the branches via RooUtil's Event class
//
#include "EventNtuple/rooutil/inc/RooUtil.hh"
#include <iostream>
using namespace rooutil;
void PrintEvents(std::string filename) {
RooUtil util(filename);
// util.Debug(true);
std::cout << filename << " has " << util.GetNEvents() << " events" << std::endl;
// Only print one event
for (int i_event = 0; i_event < 1; ++i_event) {
const auto& event = util.GetEvent(i_event);
// evtinfo branch
if (event.evtinfo != nullptr) {
std::cout << "evtinfo: "<< event.evtinfo->run << "," << event.evtinfo->subrun << "," << event.evtinfo->event << "," << event.evtinfo->nprotons << "," << event.evtinfo->pbtime << "," << event.evtinfo->pbterr << std::endl;
}
// evtinfomc branch
if (event.evtinfomc != nullptr) {
std::cout << "evtinfomc: " << event.evtinfomc->nprotons << "," << event.evtinfomc->pbtime << std::endl;
}
// trk branch
if (event.trk != nullptr) {
for (const auto& trk : *(event.trk)) {
std::cout << "trk: " << trk.status << "," << trk.nhits << "," << trk.nactive << "," << trk.avgedep << std::endl;
}
}
// trkmc branch
if (event.trkmc != nullptr) {
for (const auto& trkmc : *(event.trkmc)) {
std::cout << "trkmc: " << trkmc.valid << "," << trkmc.nhits << "," << trkmc.nactive << "," << trkmc.t0 << std::endl;
}
}
// trksegs branch
if (event.trksegs != nullptr) {
for (const auto& trksegs : *(event.trksegs)) {
std::cout << "New Track!" << std::endl;
for (const auto& trkseg : trksegs) {
std::cout << "trksegs: time = " << trkseg.time << " ns, p_mag = " << trkseg.mom.R() << " MeV/c, sid = " << trkseg.sid << ", p_z = " << trkseg.mom.z() << " MeV/c, z = " << trkseg.pos.z() << " mm, momerr = " << trkseg.momerr << " MeV/c" << std::endl;
}
}
}
// trksegsmc branch
if (event.trksegsmc != nullptr) {
for (const auto& trksegsmc : *(event.trksegsmc)) {
std::cout << "New Track!" << std::endl;
for (const auto& trksegmc : trksegsmc) {
std::cout << "trksegsmc: t = " << trksegmc.time << " ns, p_mag = " << trksegmc.mom.R() << " MeV/c, sid = " << trksegmc.sid << ", p_z = " << trksegmc.mom.z() << " MeV/c, z = " << trksegmc.pos.z() << " mm" <<std::endl;
}
}
}
// trkcalohit branch
if (event.trkcalohit != nullptr) {
for (const auto& trkcalohit : *(event.trkcalohit)) {
std::cout << "trkcalohit: " << trkcalohit.active << "," << trkcalohit.mom.R() << "," << trkcalohit.edep << "," << trkcalohit.edeperr << std::endl;
}
}
// trkcalohitmc branch
if (event.trkcalohitmc != nullptr) {
for (const auto& trkcalohitmc : *(event.trkcalohitmc)) {
std::cout << "trkcalohitmc: " << trkcalohitmc.nsim << "," << trkcalohitmc.etot << "," << trkcalohitmc.prel.relationship() << std::endl;
}
}
// crvcoincs branch
if (event.crvcoincs != nullptr) {
for (const auto& crvcoinc : *(event.crvcoincs)) {
std::cout << "crvcoinc: " << crvcoinc.sectorType << "," << crvcoinc.PEs << "," << crvcoinc.angle << std::endl;
for (const auto& layer_PE : crvcoinc.PEsPerLayer) {
std::cout << "crvcoinc layer PE: " << layer_PE << std::endl;
}
}
}
// crvcoincsmc branch
if (event.crvcoincsmc != nullptr) {
for (const auto& crvcoincmc : *(event.crvcoincsmc)) {
std::cout << "crvcoincmc: " << crvcoincmc.valid << "," << crvcoincmc.pdgId << "," << crvcoincmc.depositedEnergy << std::endl;
}
}
if (event.trkmcsim != nullptr) {
for (const auto& trkmcsim : *(event.trkmcsim)) {
std::cout << "New Track!" << std::endl;
for (const auto& sim : trkmcsim) {
std::cout << "trkmcsim: valid = " << sim.valid << ", nhits = " << sim.nhits << ", pdg = " << sim.pdg << ", p = " << sim.mom.R() << ", prirel = " << (int)sim.prirel.relationship() << ", trkrel = " << (int)sim.trkrel.relationship() << std::endl;
}
}
}
// trkqual branch
if (event.trkqual != nullptr) {
for (const auto& trkqual : *(event.trkqual)) {
std::cout << "trkqual: " << trkqual.valid << ", " << trkqual.result << std::endl;
}
}
// trkpid branch
if (event.trkpid != nullptr) {
for (const auto& trkpid : *(event.trkpid)) {
std::cout << "trkpid: " << trkpid.valid << ", " << trkpid.result << std::endl;
}
}
// trksegpars_lh
if (event.trksegpars_lh != nullptr) { // might not have this branch
for (const auto& track : *(event.trksegpars_lh)) {
std::cout << "New Track!" << std::endl;
for (const auto& trksegpars : track) {
std::cout << "trksegpars_lh: " << trksegpars.maxr << ", " << trksegpars.t0 << ", " << trksegpars.t0err << std::endl;
}
}
}
// trksegpars_ch
if (event.trksegpars_ch != nullptr) { // might not have this branch
for (const auto& track : *(event.trksegpars_ch)) {
std::cout << "New Track!" << std::endl;
for (const auto& trksegpars : track) {
std::cout << "trksegpars_ch: " << trksegpars.d0 << ", " << trksegpars.t0 << ", " << trksegpars.t0err << ", " << trksegpars.maxr << std::endl;
}
}
}
// trksegpars_kl
if (event.trksegpars_kl != nullptr) { // might not have this branch
for (const auto& track : *(event.trksegpars_kl)) {
std::cout << "New Track!" << std::endl;
for (const auto& trksegpars : track) {
std::cout << "trksegpars_kl: " << trksegpars.d0 << ", " << trksegpars.t0 << ", " << trksegpars.t0err << std::endl;
}
}
}
// trkhits
if (event.trkhits != nullptr) { // might not have this branch
for (const auto& trkhits : *(event.trkhits)) {
std::cout << "New Track!" << std::endl;
for (const auto& hit : trkhits) {
std::cout << "trkhits: " << hit.plane << ", " << hit.panel << ", " << hit.layer << ", " << hit.straw << ", " << hit.dactive << std::endl;
}
}
}
// trkhitsmc
if (event.trkhitsmc != nullptr) { // might not have this branch
for (const auto& trkhitsmc : *(event.trkhitsmc)) {
std::cout << "New Track!" << std::endl;
for (const auto& hitmc : trkhitsmc) {
std::cout << "trkhitsmc: " << hitmc.pdg << ", " << hitmc.startCode << ", " << hitmc.t0 << ", " << hitmc.cpos.z() << std::endl;
}
}
}
// trkmats
if (event.trkmats != nullptr) { // might not have this branch
for (const auto& trkmats : *(event.trkmats)) {
std::cout << "New Track!" << std::endl;
for (const auto& mat : trkmats) {
std::cout << "trkmats: " << mat.active << ", " << mat.plane << ", " << mat.panel << ", " << mat.layer << ", " << mat.straw << ", " << mat.radlen << std::endl;
}
}
}
// trkhitcalibs
if (event.trkhitcalibs != nullptr) { // might not have this branch
for (const auto& trkhitcalibs : *(event.trkhitcalibs)) {
std::cout << "New Track!" << std::endl;
for (const auto& hit : trkhitcalibs) {
std::cout << "trkhitcalibs: " << hit.dDdX << ", " << hit.dDdPlane[0] << ", " << hit.dDdPanel[0] << ", " << hit.dDdP[0] << ", " << hit.dLdP[0] << std::endl;
}
}
}
// hitcount
if (event.hitcount != nullptr) {
auto hitcount = *(event.hitcount);
std::cout << "hitcount: " << hitcount.nsd << ", " << hitcount.nesel << ", " << hitcount.nrsel << ", " << hitcount.ntsel << ", " << hitcount.nbkg << std::endl;
}
// crvsummary
if (event.crvsummary != nullptr) {
auto crvsummary = *(event.crvsummary);
std::cout << "crvsummary: " << crvsummary.totalPEs << ", " << crvsummary.nHitCounters << std::endl;
}
// crvsummarymc
if (event.crvsummarymc != nullptr) {
auto crvsummarymc = *(event.crvsummarymc);
std::cout << "crvsummarymc: " << crvsummarymc.totalEnergyDeposited << ", " << crvsummarymc.minPathLayer << ", " << crvsummarymc.pdgId << std::endl;
}
// crvdigis
if (event.crvdigis != nullptr) {
for (const auto& crvdigi : *(event.crvdigis)) {
std::cout << "crvdigi: " << crvdigi.adc << "," << crvdigi.time << "," << crvdigi.SiPMId << std::endl;
}
}
// crvpulses branch
if (event.crvpulses != nullptr) {
for (const auto& crvpulse : *(event.crvpulses)) {
std::cout << "crvpulse: " << crvpulse.pos.x() << "," << crvpulse.barId << "," << crvpulse.time << std::endl;
}
}
// crvpulsesmc branch
if (event.crvpulsesmc != nullptr) {
for (const auto& crvpulsemc : *(event.crvpulsesmc)) {
std::cout << "crvpulsemc: " << crvpulsemc.valid << "," << crvpulsemc.pdgId << "," << crvpulsemc.depositedEnergy << std::endl;
}
}
// crvcoincsmcplane branch
if (event.crvcoincsmcplane != nullptr) {
for (const auto& crvcoincmcplane : *(event.crvcoincsmcplane)) {
std::cout << "crvcoincmcplane: " << crvcoincmcplane.pdgId << "," << crvcoincmcplane.primary.z() << ", " << crvcoincmcplane.kineticEnergy << ", " << crvcoincmcplane.dataSource << std::endl;
}
}
// timeclusters branch
if (event.timeclusters != nullptr) {
for (const auto& cluster : *(event.timeclusters)) {
std::cout << "timecluster: "
<< cluster.nhits << ", "
<< cluster.nStrawHits << ", "
<< cluster.t0 << ", "
<< cluster.pos.x() << ", "
<< cluster.pos.y() << ", "
<< cluster.pos.z() << ", "
<< cluster.ecalo << ", "
<< cluster.tcalo
<< std::endl;
}
}
// caloclusters branch
if (event.caloclusters != nullptr) {
for (const auto& calocluster : *(event.caloclusters)) {
std::cout << "calocluster: " << calocluster.diskID_ << ", " << calocluster.time_ << ", " << calocluster.timeErr_ << ", " << calocluster.energyDep_ << ", " << calocluster.energyDepErr_ << ", " << calocluster.isSplit_ << std::endl;
}
}
// calohits branch
if (event.calohits != nullptr) {
for (const auto& calohit : *(event.calohits)) {
std::cout << "calohit: " << calohit.crystalId_ << ", " << calohit.time_ << ", " << calohit.timeErr_ << ", " << calohit.eDep_ << ", " << calohit.eDepErr_ << ", " << calohit.clusterIdx_ << std::endl;
}
}
// calorecodigis branch
if (event.calorecodigis != nullptr) {
for (const auto& calorecodigi : *(event.calorecodigis)) {
std::cout << "calorecodigi: " << calorecodigi.time_ << ", " << calorecodigi.timeErr_ << ", " << calorecodigi.eDep_ << ", " << calorecodigi.eDepErr_ << ", " << calorecodigi.caloHitIdx_ << std::endl;
}
}
// calodigis branch
if (event.calodigis != nullptr) {
for (const auto& calodigi : *(event.calodigis)) {
std::cout << "calodigi: " << calodigi.SiPMID_ << ", " << calodigi.t0_ << ", " << calodigi.peakpos_ << ", " << calodigi.caloRecoDigiIdx_ << std::endl;
}
}
// caloclustersmc branch
if (event.caloclustersmc != nullptr) {
for (const auto& caloclustermc : *(event.caloclustersmc)) {
std::cout << "caloclustermc: " << caloclustermc.nsim << ", " << caloclustermc.etot << ", " << caloclustermc.tavg << ", " << caloclustermc.eprimary << ", " << caloclustermc.tprimary << ", " << caloclustermc.prel.relationship() << std::endl;
}
}
if (event.calomcsim != nullptr) {
for (const auto& sim : *(event.calomcsim)) {
std::cout << "calomcsim: valid = " << sim.valid << ", nhits = " << sim.nhits << ", pdg = " << sim.pdg << ", p = " << sim.mom.R() << ", prirel = " << (int)sim.prirel.relationship() << ", trkrel = " << (int)sim.trkrel.relationship() << std::endl;
}
}
// calohitsmc branch
if (event.calohitsmc != nullptr) {
for (const auto& calohitmc : *(event.calohitsmc)) {
std::cout << "calohitmc: " << calohitmc.nsim << ", " << calohitmc.eDep << ", " << calohitmc.eDepG4 << ", " << calohitmc.clusterIdx_ << std::endl;
}
}
// trigger branches
for (const auto& pair : event.trigger.NameToIndexMap()) {
std::cout << pair.first << ": " << event.trigger.Fired(pair.second) << std::endl;
}
// mcsteps_virtualdetector branch
if (event.mcsteps_virtualdetector != nullptr) {
for (const auto& vdstep : *(event.mcsteps_virtualdetector)) {
std::cout << "vdstep: " << vdstep.vid << ", " << vdstep.time << ", " << vdstep.mom << ", " << vdstep.pos << ", " << vdstep.pdg << ", " << vdstep.startCode << ", " << vdstep.stopCode << std::endl;
}
}
}
}