forked from MFT-MCHMatching/GlobalMuonTracking
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRead_Kine_O2.C
More file actions
42 lines (33 loc) · 1.12 KB
/
Copy pathRead_Kine_O2.C
File metadata and controls
42 lines (33 loc) · 1.12 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
#if !defined(__CLING__) || defined(__ROOTCLING__)
#include <TFile.h>
#include <TTree.h>
#include "SimulationDataFormat/MCTrack.h"
#endif
void Read_Kine_O2() {
// DataFormats/simulation/include/SimulationDataFormat/MCTrack.h
using o2::MCTrack;
TFile fileK("o2sim_Kine.root");
TTree *kineTree = (TTree *)fileK.Get("o2sim");
std::vector<o2::MCTrack> mcTrkVec, *mcTrkVecP = &mcTrkVec;
kineTree->SetBranchAddress("MCTrack", &mcTrkVecP);
int nEvents = kineTree->GetEntries();
printf("Number of events %d \n", nEvents);
for (int iev = 0; iev < nEvents; ++iev) {
kineTree->GetEntry(iev);
int nMCTracks = mcTrkVec.size();
printf("Event %d has %d MC tracks\n", iev, nMCTracks);
int nt = 0;
for (auto mcTrack : mcTrkVec) {
if (mcTrack.isSecondary())
continue;
printf("MCTrack ID %4d PDG %4d name %s isSec %d E %7.3f \n", nt,
mcTrack.GetPdgCode(),
TDatabasePDG::Instance()
->GetParticle(mcTrack.GetPdgCode())
->GetName(),
mcTrack.isSecondary(), mcTrack.GetEnergy());
++nt;
}
}
fileK.Close();
}