Skip to content

Commit 5b5dccf

Browse files
committed
test files
1 parent d66d31c commit 5b5dccf

2 files changed

Lines changed: 190 additions & 0 deletions

File tree

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
int External()
2+
{
3+
std::string path{"o2sim_Kine.root"};
4+
const int pdgMother = 3124; // Lambda(1520)0
5+
const int triggerRatio = 3; // must match generator_Lstar(N) in the .ini file
6+
7+
TFile file(path.c_str(), "READ");
8+
if (file.IsZombie()) {
9+
std::cerr << "Cannot open ROOT file " << path << "\n";
10+
return 1;
11+
}
12+
auto tree = (TTree *)file.Get("o2sim");
13+
if (!tree) {
14+
std::cerr << "Cannot find tree o2sim in file " << path << "\n";
15+
return 1;
16+
}
17+
std::vector<o2::MCTrack> *tracks{};
18+
tree->SetBranchAddress("MCTrack", &tracks);
19+
20+
const auto nEvents = tree->GetEntries();
21+
int nMother = 0;
22+
int nNotDecayed = 0;
23+
int nBadDecay = 0; // mothers not decaying exactly to Lambda + gamma
24+
int nEventsWrongCount = 0; // events with the wrong number of injected mothers
25+
int nGapEvents = 0; // events expected to contain the injected mother
26+
27+
for (int i = 0; i < nEvents; i++) {
28+
tree->GetEntry(i);
29+
30+
// the generator injects in every triggerRatio-th event (it counts events from 1)
31+
const bool isGapEvent = ((i + 1) % triggerRatio == 0);
32+
if (isGapEvent) {
33+
nGapEvents++;
34+
}
35+
36+
int nInEvent = 0;
37+
for (auto &track : *tracks) {
38+
const int pdg = track.GetPdgCode();
39+
if (std::abs(pdg) != pdgMother) {
40+
continue;
41+
}
42+
nInEvent++;
43+
nMother++;
44+
45+
if (track.getFirstDaughterTrackId() < 0) {
46+
nNotDecayed++;
47+
continue;
48+
}
49+
const int expectedLambda = (pdg > 0) ? 3122 : -3122;
50+
int nLambda = 0, nGamma = 0, nDau = 0;
51+
for (int j = track.getFirstDaughterTrackId(); j <= track.getLastDaughterTrackId(); ++j) {
52+
const int pdgDau = tracks->at(j).GetPdgCode();
53+
nDau++;
54+
if (pdgDau == expectedLambda) nLambda++;
55+
if (pdgDau == 22) nGamma++;
56+
}
57+
if (nDau != 2 || nLambda != 1 || nGamma != 1) {
58+
nBadDecay++;
59+
std::cerr << "Unexpected decay of " << pdg << " (" << nDau << " daughters)\n";
60+
}
61+
}
62+
63+
const int nExpected = isGapEvent ? 1 : 0;
64+
if (nInEvent != nExpected) {
65+
nEventsWrongCount++;
66+
std::cerr << "Event " << i << ": found " << nInEvent
67+
<< " Lambda(1520), expected " << nExpected << "\n";
68+
}
69+
}
70+
71+
std::cout << "--------------------------------\n";
72+
std::cout << "# Events: " << nEvents << "\n";
73+
std::cout << "# Gap-trigger events: " << nGapEvents << " (ratio " << triggerRatio << ")\n";
74+
std::cout << "# Lambda(1520) + anti: " << nMother << "\n";
75+
std::cout << "# not decayed: " << nNotDecayed << "\n";
76+
std::cout << "# unexpected decays: " << nBadDecay << "\n";
77+
std::cout << "# events wrong count: " << nEventsWrongCount << "\n";
78+
std::cout << "--------------------------------\n";
79+
80+
if (nMother != nGapEvents) {
81+
std::cerr << "Expected one injected Lambda(1520) per gap-trigger event\n";
82+
return 1;
83+
}
84+
if (nEventsWrongCount > 0) {
85+
std::cerr << "Lambda(1520) must appear in every gap-triggered events\n";
86+
return 1;
87+
}
88+
if (nNotDecayed > 0 || nBadDecay > 0) {
89+
std::cerr << "Lambda(1520) must always decay to Lambda + gamma\n";
90+
return 1;
91+
}
92+
return 0;
93+
}
94+
95+
void GeneratorLF_Strangeness_ppLStar() { External(); }
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
int External()
2+
{
3+
std::string path{"o2sim_Kine.root"};
4+
const int pdgMother = 3124; // Lambda(1520)0
5+
const int triggerRatio = 4; // must match generator_Lstar(N) in the .ini file
6+
7+
TFile file(path.c_str(), "READ");
8+
if (file.IsZombie()) {
9+
std::cerr << "Cannot open ROOT file " << path << "\n";
10+
return 1;
11+
}
12+
auto tree = (TTree *)file.Get("o2sim");
13+
if (!tree) {
14+
std::cerr << "Cannot find tree o2sim in file " << path << "\n";
15+
return 1;
16+
}
17+
std::vector<o2::MCTrack> *tracks{};
18+
tree->SetBranchAddress("MCTrack", &tracks);
19+
20+
const auto nEvents = tree->GetEntries();
21+
int nMother = 0;
22+
int nNotDecayed = 0;
23+
int nBadDecay = 0; // mothers not decaying exactly to Lambda + gamma
24+
int nEventsWrongCount = 0; // events with the wrong number of injected mothers
25+
int nGapEvents = 0; // events expected to contain the injected mother
26+
27+
for (int i = 0; i < nEvents; i++) {
28+
tree->GetEntry(i);
29+
30+
// the generator injects in every triggerRatio-th event (it counts events from 1)
31+
const bool isGapEvent = ((i + 1) % triggerRatio == 0);
32+
if (isGapEvent) {
33+
nGapEvents++;
34+
}
35+
36+
int nInEvent = 0;
37+
for (auto &track : *tracks) {
38+
const int pdg = track.GetPdgCode();
39+
if (std::abs(pdg) != pdgMother) {
40+
continue;
41+
}
42+
nInEvent++;
43+
nMother++;
44+
45+
if (track.getFirstDaughterTrackId() < 0) {
46+
nNotDecayed++;
47+
continue;
48+
}
49+
const int expectedLambda = (pdg > 0) ? 3122 : -3122;
50+
int nLambda = 0, nGamma = 0, nDau = 0;
51+
for (int j = track.getFirstDaughterTrackId(); j <= track.getLastDaughterTrackId(); ++j) {
52+
const int pdgDau = tracks->at(j).GetPdgCode();
53+
nDau++;
54+
if (pdgDau == expectedLambda) nLambda++;
55+
if (pdgDau == 22) nGamma++;
56+
}
57+
if (nDau != 2 || nLambda != 1 || nGamma != 1) {
58+
nBadDecay++;
59+
std::cerr << "Unexpected decay of " << pdg << " (" << nDau << " daughters)\n";
60+
}
61+
}
62+
63+
const int nExpected = isGapEvent ? 1 : 0;
64+
if (nInEvent != nExpected) {
65+
nEventsWrongCount++;
66+
std::cerr << "Event " << i << ": found " << nInEvent
67+
<< " Lambda(1520), expected " << nExpected << "\n";
68+
}
69+
}
70+
71+
std::cout << "--------------------------------\n";
72+
std::cout << "# Events: " << nEvents << "\n";
73+
std::cout << "# Gap-trigger events: " << nGapEvents << " (ratio " << triggerRatio << ")\n";
74+
std::cout << "# Lambda(1520) + anti: " << nMother << "\n";
75+
std::cout << "# not decayed: " << nNotDecayed << "\n";
76+
std::cout << "# unexpected decays: " << nBadDecay << "\n";
77+
std::cout << "# events wrong count: " << nEventsWrongCount << "\n";
78+
std::cout << "--------------------------------\n";
79+
80+
if (nMother != nGapEvents) {
81+
std::cerr << "Expected one injected Lambda(1520) per gap-trigger event\n";
82+
return 1;
83+
}
84+
if (nEventsWrongCount > 0) {
85+
std::cerr << "Lambda(1520) must appear in every gap-triggered events\n";
86+
return 1;
87+
}
88+
if (nNotDecayed > 0 || nBadDecay > 0) {
89+
std::cerr << "Lambda(1520) must always decay to Lambda + gamma\n";
90+
return 1;
91+
}
92+
return 0;
93+
}
94+
95+
void GeneratorLF_Strangeness_ppLStar() { External(); }

0 commit comments

Comments
 (0)