Skip to content

Commit 1940e6d

Browse files
committed
generalize the test for different gap triggers
1 parent c4b086e commit 1940e6d

1 file changed

Lines changed: 35 additions & 21 deletions

File tree

‎MC/config/PWGLF/ini/tests/GeneratorLF_Strangeness_ppLStar.C‎

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
int External()
22
{
33
std::string path{"o2sim_Kine.root"};
4-
const int pdgMother = 3124; // Lambda(1520)0
5-
const int triggerRatio = 5; // must match generator_Lstar(N) in the .ini file
4+
const int pdgMother = 3124; // Lambda(1520)0
65

76
TFile file(path.c_str(), "READ");
87
if (file.IsZombie()) {
@@ -20,19 +19,12 @@ int External()
2019
const auto nEvents = tree->GetEntries();
2120
int nMother = 0;
2221
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
22+
int nBadDecay = 0; // mothers not decaying exactly to Lambda + gamma
23+
std::vector<int> motherPerEvent; // number of injected mothers in each event
2624

2725
for (int i = 0; i < nEvents; i++) {
2826
tree->GetEntry(i);
2927

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-
3628
int nInEvent = 0;
3729
for (auto &track : *tracks) {
3830
const int pdg = track.GetPdgCode();
@@ -59,30 +51,52 @@ int External()
5951
std::cerr << "Unexpected decay of " << pdg << " (" << nDau << " daughters)\n";
6052
}
6153
}
54+
motherPerEvent.push_back(nInEvent);
55+
}
6256

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";
57+
// the trigger ratio is inferred from the first event containing a mother
58+
// (the generator counts events from 1 and injects every triggerRatio-th event)
59+
int triggerRatio = 0;
60+
for (int i = 0; i < nEvents; i++) {
61+
if (motherPerEvent[i] > 0) {
62+
triggerRatio = i + 1;
63+
break;
64+
}
65+
}
66+
67+
int nEventsWrongCount = 0;
68+
int nGapEvents = 0;
69+
if (triggerRatio > 0) {
70+
for (int i = 0; i < nEvents; i++) {
71+
const bool isGapEvent = ((i + 1) % triggerRatio == 0);
72+
if (isGapEvent) {
73+
nGapEvents++;
74+
}
75+
const int nExpected = isGapEvent ? 1 : 0;
76+
if (motherPerEvent[i] != nExpected) {
77+
nEventsWrongCount++;
78+
std::cerr << "Event " << i << ": found " << motherPerEvent[i]
79+
<< " Lambda(1520), expected " << nExpected << "\n";
80+
}
6881
}
6982
}
7083

7184
std::cout << "--------------------------------\n";
7285
std::cout << "# Events: " << nEvents << "\n";
73-
std::cout << "# Gap-trigger events: " << nGapEvents << " (ratio " << triggerRatio << ")\n";
86+
std::cout << "# Inferred trigger ratio: " << triggerRatio << "\n";
87+
std::cout << "# Gap-trigger events: " << nGapEvents << "\n";
7488
std::cout << "# Lambda(1520) + anti: " << nMother << "\n";
7589
std::cout << "# not decayed: " << nNotDecayed << "\n";
7690
std::cout << "# unexpected decays: " << nBadDecay << "\n";
7791
std::cout << "# events wrong count: " << nEventsWrongCount << "\n";
7892
std::cout << "--------------------------------\n";
7993

80-
if (nMother != nGapEvents) {
81-
std::cerr << "Expected one injected Lambda(1520) per gap-trigger event\n";
94+
if (triggerRatio == 0) {
95+
std::cerr << "No Lambda(1520) found in any event\n";
8296
return 1;
8397
}
84-
if (nEventsWrongCount > 0) {
85-
std::cerr << "Lambda(1520) must appear in every gap-triggered events\n";
98+
if (nMother != nGapEvents || nEventsWrongCount > 0) {
99+
std::cerr << "Lambda(1520) must appear exactly once every triggerRatio events\n";
86100
return 1;
87101
}
88102
if (nNotDecayed > 0 || nBadDecay > 0) {

0 commit comments

Comments
 (0)