forked from AliceO2Group/O2DPG
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGeneratorHF_Non_Hfe.C
More file actions
61 lines (49 loc) · 1.69 KB
/
GeneratorHF_Non_Hfe.C
File metadata and controls
61 lines (49 loc) · 1.69 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
int Hybrid() {
std::string path{"o2sim_Kine.root"};
const int pdgPi0 = 111;
const int pdgEta = 221;
const double yMin = -1.5;
const double yMax = 1.5;
const int minNb = 1;
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");
if (!tree) {
std::cerr << "Cannot find tree o2sim\n";
return 1;
}
std::vector<o2::MCTrack>* tracks{};
tree->SetBranchAddress("MCTrack", &tracks);
int nEvents = tree->GetEntries();
int nAccepted = 0;
int totalPi0 = 0, totalEta = 0;
for (int i = 0; i < nEvents; ++i) {
tree->GetEntry(i);
int count = 0;
for (auto& track : *tracks) {
int pdg = std::abs(track.GetPdgCode());
double y = track.GetRapidity();
if ((pdg == pdgPi0 || pdg == pdgEta) && y >= yMin && y <= yMax) {
count++;
if (pdg == pdgPi0) totalPi0++;
if (pdg == pdgEta) totalEta++;
}
}
if (count < minNb) {
std::cerr << " Trigger violation in event " << i
<< " (found " << count << " π0/η in rapidity window)\n";
return 1;
}
nAccepted++;
}
std::cout << "--------------------------------------\n";
std::cout << "Trigger test: π0/η within rapidity window\n";
std::cout << "Events tested: " << nEvents << "\n";
std::cout << "Events accepted: " << nAccepted << "\n";
std::cout << "# π0: " << totalPi0 << ", # η: " << totalEta << "\n";
std::cout << "Trigger test PASSED\n";
return 0;
}