Skip to content

Commit db1cd10

Browse files
authored
Create the Non-HFE–enhanced dataset
We will produce a Non-HFE–enhanced dataset by generating Monte Carlo samples with increased π⁰ and η production, to improve the statistical precision of the non-HFE efficiency measurement.
1 parent 200f5ad commit db1cd10

File tree

1 file changed

+157
-0
lines changed

1 file changed

+157
-0
lines changed
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
int External() {
2+
std::string path{"o2sim_Kine.root"};
3+
4+
int checkPdgDecayElectron = 11;
5+
int checkPdgQuarkOne = 1; // d quark
6+
int checkPdgQuarkTwo = 2; // u quark
7+
int checkPdgQuarkThree = 3; // s quark
8+
float ratioTrigger = 1. / 5; // one event triggered out of 5
9+
10+
11+
TFile file(path.c_str(), "READ");
12+
if (file.IsZombie()) {
13+
std::cerr << "Cannot open ROOT file" << path << "\n";
14+
return 1;
15+
}
16+
17+
auto tree = (TTree *)file.Get("o2sim");
18+
if (!tree) {
19+
std::cerr << "Cannot find tree o2sim in file" << path << "\n";
20+
return 1;
21+
}
22+
23+
std::vector<o2::MCTrack> *tracks{};
24+
tree->SetBranchAddress("MCTrack", &tracks);
25+
o2::dataformats::MCEventHeader *eventHeader = nullptr;
26+
tree->SetBranchAddress("MCEventHeader.", &eventHeader);
27+
28+
int nEventsMB{}, nEventsInjOne{}, nEventsInjTwo{}, nEventsInjThree{};
29+
int nQuarksOne{}, nQuarksTwo{}, nQuarksThree{};
30+
int nElectrons{};
31+
auto nEvents = tree->GetEntries();
32+
33+
for (int i = 0; i < nEvents; i++) {
34+
tree->GetEntry(i);
35+
36+
// check subgenerator information
37+
if (eventHeader->hasInfo(o2::mcgenid::GeneratorProperty::SUBGENERATORID)) {
38+
bool isValid = false;
39+
int subGeneratorId = eventHeader->getInfo<int>(
40+
o2::mcgenid::GeneratorProperty::SUBGENERATORID, isValid);
41+
if (subGeneratorId == 0) {
42+
nEventsMB++;
43+
} else if (subGeneratorId == checkPdgQuarkOne) {
44+
nEventsInjOne++;
45+
} else if (subGeneratorId == checkPdgQuarkTwo) {
46+
nEventsInjTwo++;
47+
} else if (subGeneratorId == checkPdgQuarkThree) {
48+
nEventsInjThree++;
49+
}
50+
} // if event header
51+
52+
int nelectronsev = 0;
53+
54+
for (auto &track : *tracks) {
55+
auto pdg = track.GetPdgCode();
56+
if (std::abs(pdg) == checkPdgQuarkOne) {
57+
nQuarksOne++;
58+
continue;
59+
}
60+
if (std::abs(pdg) == checkPdgQuarkTwo) {
61+
nQuarksTwo++;
62+
continue;
63+
}
64+
if (std::abs(pdg) == checkPdgQuarkThree) {
65+
nQuarksThree++;
66+
continue;
67+
}
68+
69+
70+
auto y = track.GetRapidity();
71+
if (std::abs(pdg) == checkPdgDecayElectron) {
72+
int igmother = track.getMotherTrackId();
73+
auto gmTrack = (*tracks)[igmother];
74+
int gmpdg = gmTrack.GetPdgCode();
75+
if (int(std::abs(gmpdg) / 100.) == 1 ||
76+
int(std::abs(gmpdg) / 1000.) == 1 ||
77+
int(std::abs(gmpdg) / 100.) == 2 ||
78+
int(std::abs(gmpdg) / 1000.) == 2 ||
79+
int(std::abs(gmpdg) / 100.) == 3 ||
80+
int(std::abs(gmpdg) / 1000.) == 3) {
81+
nElectrons++;
82+
nelectronsev++;
83+
} // gmpdg
84+
} // pdgdecay
85+
} // loop track
86+
// std::cout << "#electrons per event: " << nelectronsev << "\n";
87+
}
88+
89+
std::cout << "--------------------------------\n";
90+
std::cout << "# Events: " << nEvents << "\n";
91+
std::cout << "# MB events: " << nEventsMB << "\n";
92+
std::cout << Form("# events injected with %d quark pair: ", checkPdgQuarkOne)
93+
<< nEventsInjOne << "\n";
94+
std::cout << Form("# events injected with %d quark pair: ", checkPdgQuarkTwo)
95+
<< nEventsInjTwo << "\n";
96+
std::cout << Form("# events injected with %d quark pair: ", checkPdgQuarkThree)
97+
<< nEventsInjThree << "\n";
98+
std::cout << Form("# %d (anti)quarks: ", checkPdgQuarkOne) << nQuarksOne
99+
<< "\n";
100+
std::cout << Form("# %d (anti)quarks: ", checkPdgQuarkTwo) << nQuarksTwo
101+
<< "\n";
102+
std::cout << Form("# %d (anti)quarks: ", checkPdgQuarkThree) << nQuarksThree
103+
<< "\n";
104+
105+
if (nEventsMB < nEvents * (1 - ratioTrigger) * 0.95 ||
106+
nEventsMB > nEvents * (1 - ratioTrigger) *
107+
1.05) { // we put some tolerance since the number of
108+
// generated events is small
109+
std::cerr << "Number of generated MB events different than expected\n";
110+
return 1;
111+
}
112+
if (nEventsInjOne < nEvents * ratioTrigger * 0.5 * 0.95 ||
113+
nEventsInjOne > nEvents * ratioTrigger * 0.5 * 1.05) {
114+
std::cerr << "Number of generated events injected with " << checkPdgQuarkOne
115+
<< " different than expected\n";
116+
return 1;
117+
}
118+
if (nEventsInjTwo < nEvents * ratioTrigger * 0.5 * 0.95 ||
119+
nEventsInjTwo > nEvents * ratioTrigger * 0.5 * 1.05) {
120+
std::cerr << "Number of generated events injected with " << checkPdgQuarkTwo
121+
<< " different than expected\n";
122+
return 1;
123+
}
124+
if (nEventsInjThree < nEvents * ratioTrigger * 0.5 * 0.95 ||
125+
nEventsInjThree > nEvents * ratioTrigger * 0.5 * 1.05) {
126+
std::cerr << "Number of generated events injected with " << checkPdgQuarkThree
127+
<< " different than expected\n";
128+
return 1;
129+
}
130+
if (nQuarksOne <
131+
nEvents *
132+
ratioTrigger) { // we expect anyway more because the same quark is
133+
// repeated several time, after each gluon radiation
134+
std::cerr << "Number of generated (anti)quarks " << checkPdgQuarkOne
135+
<< " lower than expected\n";
136+
return 1;
137+
}
138+
if (nQuarksTwo <
139+
nEvents *
140+
ratioTrigger) { // we expect anyway more because the same quark is
141+
// repeated several time, after each gluon radiation
142+
std::cerr << "Number of generated (anti)quarks " << checkPdgQuarkTwo
143+
<< " lower than expected\n";
144+
return 1;
145+
}
146+
if (nQuarksThree <
147+
nEvents *
148+
ratioTrigger) { // we expect anyway more because the same quark is
149+
// repeated several time, after each gluon radiation
150+
std::cerr << "Number of generated (anti)quarks " << checkPdgQuarkThree
151+
<< " lower than expected\n";
152+
return 1;
153+
}
154+
std::cout << "#electrons: " << nElectrons << "\n";
155+
156+
return 0;
157+
} // external

0 commit comments

Comments
 (0)