forked from AliceO2Group/O2DPG
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGeneratorEMCocktail_502PbPb_0005.C
More file actions
64 lines (58 loc) · 2.13 KB
/
GeneratorEMCocktail_502PbPb_0005.C
File metadata and controls
64 lines (58 loc) · 2.13 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
int External()
{
int checkPdgDecay = -11;
std::string path{"o2sim_Kine.root"};
TFile file(path.c_str(), "READ");
if (file.IsZombie()) {
std::cerr << "Cannot open ROOT file " << path << "\n";
return 1;
}
auto tree = (TTree*)file.Get("o2sim");
std::vector<o2::MCTrack>* tracks{};
tree->SetBranchAddress("MCTrack", &tracks);
int nMesons{};
int nMesonsDiElectronDecay{};
auto nEvents = tree->GetEntries();
for (int i = 0; i < nEvents; i++) {
tree->GetEntry(i);
for (auto& track : *tracks) {
auto pdg = track.GetPdgCode();
auto y = track.GetRapidity();
if ((pdg == 111) || (pdg == 221) || (pdg == 331) || (pdg == 223) || (pdg == 113) || (pdg == 333)) {
if ((y>-1.2) && (y<1.2)) {
nMesons++;
Int_t counterel = 0;
Int_t counterpos = 0;
int k1 = track.getFirstDaughterTrackId();
int k2 = track.getLastDaughterTrackId();
// k1 < k2 and no -1 for k2
for (int d=k1; d <= k2; d++) {
if (d>0) {
auto decay = (*tracks)[d];
int pdgdecay = decay.GetPdgCode();
if (pdgdecay == 11) {
counterel++;
}
if (pdgdecay == -11) {
counterpos++;
}
}
}
if ((counterel>0) && (counterpos>0)) nMesonsDiElectronDecay++;
}
}
}
}
std::cout << "#events: " << nEvents << "\n"
<< "#mesons: " << nMesons << "\n"
<< "#mesons which decay semi-electronicly: " << nMesonsDiElectronDecay << "\n";
if (nMesonsDiElectronDecay < nEvents) {
std::cerr << "One should have at least one meson that decays into dielectrons per event.\n";
return 1;
}
if (nMesons < nEvents) {
std::cerr << "One meson per event should be produced.\n";
return 1;
}
return 0;
}