Skip to content

Commit d271cfa

Browse files
ZFedericaalcaliva
authored andcommitted
PWGHF: add xic+ in ini file and rename (#1582)
* Add xic+ and rename ini * Update test * Rename test * Sort pdg codes * Re-add old files * Fix typo * Update (cherry picked from commit 6843faf)
1 parent ce29ee2 commit d271cfa

File tree

3 files changed

+133
-1
lines changed

3 files changed

+133
-1
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
### The external generator derives from GeneratorPythia8.
2+
[GeneratorExternal]
3+
fileName=${O2DPG_ROOT}/MC/config/PWGHF/external/generator/generator_pythia8_gaptriggered_hf.C
4+
funcName=GeneratorPythia8GapTriggeredCharmAndBeauty(5, -1.5, 1.5, -1.5, 1.5, {4132, 4332, 4232})
5+
6+
[GeneratorPythia8]
7+
config=${O2DPG_ROOT}/MC/config/PWGHF/pythia8/generator/pythia8_charmhadronic_with_decays_Mode2.cfg
8+
includePartonEvent=true
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
int External() {
2+
std::string path{"o2sim_Kine.root"};
3+
4+
int checkPdgQuarkOne{4};
5+
int checkPdgQuarkTwo{5};
6+
float ratioTrigger = 1./5; // one event triggered out of 5
7+
8+
std::vector<int> checkPdgHadron{4132, 4332, 4232};
9+
std::map<int, std::vector<std::vector<int>>> checkHadronDecays{ // sorted pdg of daughters
10+
{4132, {{211, 3312}}}, // Xic0
11+
{4332, {{211, 3334}, {211, 3312}}}, // Omegac0
12+
{4232, {{313, 2212}, {211, 321, 2212}, {211, 3324}, {211, 211, 3312}}} //Xic+
13+
};
14+
15+
TFile file(path.c_str(), "READ");
16+
if (file.IsZombie()) {
17+
std::cerr << "Cannot open ROOT file " << path << "\n";
18+
return 1;
19+
}
20+
21+
auto tree = (TTree *)file.Get("o2sim");
22+
std::vector<o2::MCTrack> *tracks{};
23+
tree->SetBranchAddress("MCTrack", &tracks);
24+
o2::dataformats::MCEventHeader *eventHeader = nullptr;
25+
tree->SetBranchAddress("MCEventHeader.", &eventHeader);
26+
27+
int nEventsMB{}, nEventsInjOne{}, nEventsInjTwo{};
28+
int nQuarksOne{}, nQuarksTwo{}, nSignals{}, nSignalGoodDecay{};
29+
auto nEvents = tree->GetEntries();
30+
31+
for (int i = 0; i < nEvents; i++) {
32+
tree->GetEntry(i);
33+
34+
// check subgenerator information
35+
if (eventHeader->hasInfo(o2::mcgenid::GeneratorProperty::SUBGENERATORID)) {
36+
bool isValid = false;
37+
int subGeneratorId = eventHeader->getInfo<int>(o2::mcgenid::GeneratorProperty::SUBGENERATORID, isValid);
38+
if (subGeneratorId == 0) {
39+
nEventsMB++;
40+
} else if (subGeneratorId == checkPdgQuarkOne) {
41+
nEventsInjOne++;
42+
} else if (subGeneratorId == checkPdgQuarkTwo) {
43+
nEventsInjTwo++;
44+
}
45+
}
46+
47+
for (auto &track : *tracks) {
48+
auto pdg = track.GetPdgCode();
49+
if (std::abs(pdg) == checkPdgQuarkOne) {
50+
nQuarksOne++;
51+
continue;
52+
}
53+
if (std::abs(pdg) == checkPdgQuarkTwo) {
54+
nQuarksTwo++;
55+
continue;
56+
}
57+
if (std::find(checkPdgHadron.begin(), checkPdgHadron.end(), std::abs(pdg)) != checkPdgHadron.end()) { // found signal
58+
nSignals++; // count signal PDG
59+
60+
std::vector<int> pdgsDecay{};
61+
std::vector<int> pdgsDecayAntiPart{};
62+
for (int j{track.getFirstDaughterTrackId()}; j <= track.getLastDaughterTrackId(); ++j) {
63+
auto pdgDau = tracks->at(j).GetPdgCode();
64+
pdgsDecay.push_back(pdgDau);
65+
if (pdgDau != 333) { // phi is antiparticle of itself
66+
pdgsDecayAntiPart.push_back(-pdgDau);
67+
} else {
68+
pdgsDecayAntiPart.push_back(pdgDau);
69+
}
70+
}
71+
72+
std::sort(pdgsDecay.begin(), pdgsDecay.end());
73+
std::sort(pdgsDecayAntiPart.begin(), pdgsDecayAntiPart.end());
74+
75+
for (auto &decay : checkHadronDecays[std::abs(pdg)]) {
76+
if (pdgsDecay == decay || pdgsDecayAntiPart == decay) {
77+
nSignalGoodDecay++;
78+
break;
79+
}
80+
}
81+
}
82+
}
83+
}
84+
85+
std::cout << "--------------------------------\n";
86+
std::cout << "# Events: " << nEvents << "\n";
87+
std::cout << "# MB events: " << nEventsMB << "\n";
88+
std::cout << Form("# events injected with %d quark pair: ", checkPdgQuarkOne) << nEventsInjOne << "\n";
89+
std::cout << Form("# events injected with %d quark pair: ", checkPdgQuarkTwo) << nEventsInjTwo << "\n";
90+
std::cout << Form("# %d (anti)quarks: ", checkPdgQuarkOne) << nQuarksOne << "\n";
91+
std::cout << Form("# %d (anti)quarks: ", checkPdgQuarkTwo) << nQuarksTwo << "\n";
92+
std::cout <<"# signal hadrons: " << nSignals << "\n";
93+
std::cout <<"# signal hadrons decaying in the correct channel: " << nSignalGoodDecay << "\n";
94+
95+
if (nEventsMB < nEvents * (1 - ratioTrigger) * 0.95 || nEventsMB > nEvents * (1 - ratioTrigger) * 1.05) { // we put some tolerance since the number of generated events is small
96+
std::cerr << "Number of generated MB events different than expected\n";
97+
return 1;
98+
}
99+
if (nEventsInjOne < nEvents * ratioTrigger * 0.5 * 0.95 || nEventsInjOne > nEvents * ratioTrigger * 0.5 * 1.05) {
100+
std::cerr << "Number of generated events injected with " << checkPdgQuarkOne << " different than expected\n";
101+
return 1;
102+
}
103+
if (nEventsInjTwo < nEvents * ratioTrigger * 0.5 * 0.95 || nEventsInjTwo > nEvents * ratioTrigger * 0.5 * 1.05) {
104+
std::cerr << "Number of generated events injected with " << checkPdgQuarkTwo << " different than expected\n";
105+
return 1;
106+
}
107+
108+
if (nQuarksOne < nEvents * ratioTrigger) { // we expect anyway more because the same quark is repeated several time, after each gluon radiation
109+
std::cerr << "Number of generated (anti)quarks " << checkPdgQuarkOne << " lower than expected\n";
110+
return 1;
111+
}
112+
if (nQuarksTwo < nEvents * ratioTrigger) { // we expect anyway more because the same quark is repeated several time, after each gluon radiation
113+
std::cerr << "Number of generated (anti)quarks " << checkPdgQuarkTwo << " lower than expected\n";
114+
return 1;
115+
}
116+
117+
float fracForcedDecays = float(nSignalGoodDecay) / nSignals;
118+
if (fracForcedDecays < 0.9) { // we put some tolerance (e.g. due to oscillations which might change the final state)
119+
std::cerr << "Fraction of signals decaying into the correct channel " << fracForcedDecays << " lower than expected\n";
120+
return 1;
121+
}
122+
123+
return 0;
124+
}

MC/config/PWGHF/ini/tests/GeneratorHF_D2H_ccbar_and_bbbar_gap5_Mode2_XiC_OmegaC.C

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ int External() {
88
std::vector<int> checkPdgHadron{4132, 4332};
99
std::map<int, std::vector<std::vector<int>>> checkHadronDecays{ // sorted pdg of daughters
1010
{4132, {{211, 3312}}}, // Xic0
11-
{4332, {{211, 3334}, {211, 3312}}} // Omegac+
11+
{4332, {{211, 3334}, {211, 3312}}} // Omegac0
1212
};
1313

1414
TFile file(path.c_str(), "READ");

0 commit comments

Comments
 (0)