Skip to content

Commit 8fc1ebb

Browse files
committed
Add test for OO cocktail
1 parent b532e0f commit 8fc1ebb

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
int External()
2+
{
3+
4+
int checkPdgDecay = -11;
5+
std::string path{"o2sim_Kine.root"};
6+
TFile file(path.c_str(), "READ");
7+
if (file.IsZombie()) {
8+
std::cerr << "Cannot open ROOT file " << path << "\n";
9+
return 1;
10+
}
11+
12+
auto tree = (TTree*)file.Get("o2sim");
13+
std::vector<o2::MCTrack>* tracks{};
14+
tree->SetBranchAddress("MCTrack", &tracks);
15+
16+
int nMesons{};
17+
int nMesonsDiElectronDecay{};
18+
auto nEvents = tree->GetEntries();
19+
20+
for (int i = 0; i < nEvents; i++) {
21+
tree->GetEntry(i);
22+
for (auto& track : *tracks) {
23+
auto pdg = track.GetPdgCode();
24+
auto y = track.GetRapidity();
25+
if ((pdg == 111) || (pdg == 221) || (pdg == 331) || (pdg == 223) || (pdg == 113) || (pdg == 333)) {
26+
if ((y>-1.2) && (y<1.2)) {
27+
nMesons++;
28+
Int_t counterel = 0;
29+
Int_t counterpos = 0;
30+
int k1 = track.getFirstDaughterTrackId();
31+
int k2 = track.getLastDaughterTrackId();
32+
// k1 < k2 and no -1 for k2
33+
for (int d=k1; d <= k2; d++) {
34+
if (d>0) {
35+
auto decay = (*tracks)[d];
36+
int pdgdecay = decay.GetPdgCode();
37+
if (pdgdecay == 11) {
38+
counterel++;
39+
}
40+
if (pdgdecay == -11) {
41+
counterpos++;
42+
}
43+
}
44+
}
45+
if ((counterel>0) && (counterpos>0)) nMesonsDiElectronDecay++;
46+
}
47+
}
48+
}
49+
}
50+
51+
std::cout << "#events: " << nEvents << "\n"
52+
<< "#mesons: " << nMesons << "\n"
53+
<< "#mesons which decay semi-electronicly: " << nMesonsDiElectronDecay << "\n";
54+
if (nMesonsDiElectronDecay < nEvents) {
55+
std::cerr << "One should have at least one meson that decays into dielectrons per event.\n";
56+
return 1;
57+
}
58+
if (nMesons < nEvents) {
59+
std::cerr << "One meson per event should be produced.\n";
60+
return 1;
61+
}
62+
63+
return 0;
64+
}

0 commit comments

Comments
 (0)