Skip to content

Commit 9a196d1

Browse files
fcatalan92Benedikt Volkel
authored andcommitted
Enhance fraction of D+ to KKpi in D2H MC + new configuration (#1552)
* Enhance fraction of D+ to KKpi * Add config with charm+beauty, gap3, and PYTHIA Mode2 (cherry picked from commit bb6dc1b)
1 parent 21f19da commit 9a196d1

File tree

4 files changed

+138
-2
lines changed

4 files changed

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

MC/config/PWGHF/pythia8/generator/pythia8_charmhadronic_with_decays.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ ParticleDecays:tau0Max 10.
2828
411:oneChannel = 1 0.0752 0 -321 211 211
2929
411:addChannel = 1 0.0104 0 -313 211
3030
411:addChannel = 1 0.0156 0 311 211
31-
411:addChannel = 1 0.00276 0 333 211
31+
411:addChannel = 1 0.0752 0 333 211 # to have the same amount of D+->KKpi and D+->Kpipi
3232
## add Lc decays absent in PYTHIA8 decay table and set BRs from PDG for other
3333
4122:oneChannel = 1 0.0196 100 2212 -313
3434
4122:addChannel = 1 0.0108 100 2224 -321

MC/config/PWGHF/pythia8/generator/pythia8_charmhadronic_with_decays_Mode2.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ BeamRemnants:saturation 5
4646
411:oneChannel = 1 0.0752 0 -321 211 211
4747
411:addChannel = 1 0.0104 0 -313 211
4848
411:addChannel = 1 0.0156 0 311 211
49-
411:addChannel = 1 0.00276 0 333 211
49+
411:addChannel = 1 0.0752 0 333 211 # to have the same amount of D+->KKpi and D+->Kpipi
5050
## add Lc decays absent in PYTHIA8 decay table and set BRs from PDG for other
5151
4122:oneChannel = 1 0.0196 100 2212 -313
5252
4122:addChannel = 1 0.0108 100 2224 -321

0 commit comments

Comments
 (0)