Skip to content

Commit f5b3059

Browse files
authored
Add ini file for combined c->D->mu and b->B->D->mu (#2523)
* Add ini file for combined c->D->mu and b->B->D->mu * Retrigger CI * Fix typo * Fix issue due to limited number of generated events for test * Update number of test events to prevent tests to fail * Fix tests * Fix tests * Add checking of diquarks also and not only c quarks * Reset tests * Reset tests
1 parent e9d5f2d commit f5b3059

5 files changed

Lines changed: 149 additions & 3 deletions

‎MC/config/PWGHF/external/generator/generator_pythia8_gaptriggered_hf.C‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,22 @@ FairGenerator *GeneratorPythia8GapTriggeredCharmAndBeauty(int inputTriggerRatio,
479479
return myGen;
480480
}
481481

482+
// Charm and beauty enriched (2/3 charm 1/3 beauty)
483+
FairGenerator *GeneratorPythia8GapTriggeredCharmBeautyCharm(int inputTriggerRatio, float yQuarkMin = -1.5, float yQuarkMax = 1.5, float yHadronMin = -1.5, float yHadronMax = 1.5, std::vector<int> hadronPdgList = {}, std::vector<std::array<int, 2>> partPdgToReplaceList = {}, std::vector<float> freqReplaceList = {})
484+
{
485+
auto myGen = new GeneratorPythia8GapTriggeredHF(inputTriggerRatio, std::vector<int>{4, 5, 4}, hadronPdgList, partPdgToReplaceList, freqReplaceList);
486+
auto seed = (gRandom->TRandom::GetSeed() % 900000000);
487+
myGen->setUsedSeed(seed);
488+
myGen->readString("Random:setSeed on");
489+
myGen->readString("Random:seed " + std::to_string(seed));
490+
myGen->setQuarkRapidity(yQuarkMin, yQuarkMax);
491+
if (hadronPdgList.size() != 0)
492+
{
493+
myGen->setHadronRapidity(yHadronMin, yHadronMax);
494+
}
495+
return myGen;
496+
}
497+
482498
FairGenerator *GeneratorPythia8GapHF(int inputTriggerRatio, float yQuarkMin = -1.5, float yQuarkMax = 1.5, float yHadronMin = -1.5, float yHadronMax = 1.5, std::vector<int> quarkPdgList = {}, std::vector<int> hadronPdgList = {}, std::vector<std::array<int, 2>> partPdgToReplaceList = {}, std::vector<float> freqReplaceList = {})
483499
{
484500
if (hadronPdgList.size() == 0 && quarkPdgList.size() == 0)

‎MC/config/PWGHF/ini/GeneratorHF_D2H_ccbar_and_bbbar_gap5_Mode2_corrBkgSigmaC.ini‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#NEV_TEST> 100
1+
#NEV_TEST> 150
22
### The external generator derives from GeneratorPythia8.
33
[GeneratorExternal]
44
fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGHF/external/generator/generator_pythia8_gaptriggered_hf.C
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#NEV_TEST> 150
2+
### The external generator derives from GeneratorPythia8
3+
[GeneratorExternal]
4+
fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGHF/external/generator/generator_pythia8_gaptriggered_hf.C
5+
funcName=GeneratorPythia8GapTriggeredCharmBeautyCharm(3, -4.3, -2.2)
6+
[GeneratorPythia8]
7+
config=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGHF/pythia8/generator/pythia8_charm_with_mudecays_Mode2.cfg
8+
includePartonEvent=true

‎MC/config/PWGHF/ini/tests/GeneratorHF_D2H_ccbar_and_bbbar_gap5_Mode2_corrBkgSigmaC.C‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ int External() {
1212
float ratioTrigger = 1./5.; // one event triggered out of 5
1313
std::array<std::array<int, 2>, 2> pdgReplParticles = {std::array{413, 14122}, std::array{413, 4124}};
1414
std::array<std::array<int, 2>, 2> pdgReplPartCounters = {std::array{0, 0}, std::array{0, 0}};
15-
std::array<float, 2> freqRepl = {0.5, 0.5};
15+
std::array<float, 2> freqRepl = {0.35, 0.5};
1616
std::map<int, int> sumOrigReplacedParticles = {{413, 0}};
1717

1818
std::array<int, 3> checkPdgHadron{413, 14122, 4124};
@@ -120,7 +120,15 @@ int External() {
120120
/// check that among the mothers there is a c/cbar quark
121121
/// This means that the charm hadron comes from the c-quark hadronization, where the c/cbar quark
122122
/// comes from a c-cbar pair present in the current event, tagged with a b-bbar (e.g. double-parton scattering)
123-
if(std::find(motherPdgCodes.begin(), motherPdgCodes.end(), 4) == motherPdgCodes.end() && std::find(motherPdgCodes.begin(), motherPdgCodes.end(), -4) == motherPdgCodes.end()) {
123+
/// we check also if it comes from a charmed diquark
124+
if(std::find(motherPdgCodes.begin(), motherPdgCodes.end(), 4) == motherPdgCodes.end() && std::find(motherPdgCodes.begin(), motherPdgCodes.end(), -4) == motherPdgCodes.end()
125+
&& std::find(motherPdgCodes.begin(), motherPdgCodes.end(), 4101) == motherPdgCodes.end() && std::find(motherPdgCodes.begin(), motherPdgCodes.end(), -4101) == motherPdgCodes.end()
126+
&& std::find(motherPdgCodes.begin(), motherPdgCodes.end(), 4103) == motherPdgCodes.end() && std::find(motherPdgCodes.begin(), motherPdgCodes.end(), -4103) == motherPdgCodes.end()
127+
&& std::find(motherPdgCodes.begin(), motherPdgCodes.end(), 4201) == motherPdgCodes.end() && std::find(motherPdgCodes.begin(), motherPdgCodes.end(), -4201) == motherPdgCodes.end()
128+
&& std::find(motherPdgCodes.begin(), motherPdgCodes.end(), 4203) == motherPdgCodes.end() && std::find(motherPdgCodes.begin(), motherPdgCodes.end(), -4203) == motherPdgCodes.end()
129+
&& std::find(motherPdgCodes.begin(), motherPdgCodes.end(), 4301) == motherPdgCodes.end() && std::find(motherPdgCodes.begin(), motherPdgCodes.end(), -4301) == motherPdgCodes.end()
130+
&& std::find(motherPdgCodes.begin(), motherPdgCodes.end(), 4303) == motherPdgCodes.end() && std::find(motherPdgCodes.begin(), motherPdgCodes.end(), -4303) == motherPdgCodes.end()
131+
&& std::find(motherPdgCodes.begin(), motherPdgCodes.end(), 4403) == motherPdgCodes.end() && std::find(motherPdgCodes.begin(), motherPdgCodes.end(), -4403) == motherPdgCodes.end()){
124132
/// if we arrive here, it means that the hadron comes from the decay of a beauty hadron.
125133
/// This can happen if and only if this is not a replaced one (i.e. native from Lambdab0 decay)
126134
if (std::find(motherPdgCodes.begin(), motherPdgCodes.end(), 5122) == motherPdgCodes.end() && std::find(motherPdgCodes.begin(), motherPdgCodes.end(), -5122) == motherPdgCodes.end()) {
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
int External() {
2+
3+
int checkPdgDecayMuon = 13;
4+
int checkPdgQuarkOne{4};
5+
int checkPdgQuarkTwo{5};
6+
float ratioQuarkOneTwo{2.};
7+
8+
float ratioTrigger = 1./3; // one event triggered out of 5
9+
10+
std::string path{"o2sim_Kine.root"};
11+
12+
TFile file(path.c_str(), "READ");
13+
if (file.IsZombie()) {
14+
std::cerr << "Cannot open ROOT file" << path << "\n";
15+
return 1;
16+
}
17+
18+
auto tree = (TTree *)file.Get("o2sim");
19+
if (!tree) {
20+
std::cerr << "Cannot find tree o2sim in file" << path << "\n";
21+
return 1;
22+
}
23+
24+
std::vector<o2::MCTrack> *tracks{};
25+
tree->SetBranchAddress("MCTrack", &tracks);
26+
27+
o2::dataformats::MCEventHeader *eventHeader = nullptr;
28+
tree->SetBranchAddress("MCEventHeader.", &eventHeader);
29+
30+
int nEventsMB{0};
31+
int nEventsInjOne{0};
32+
int nEventsInjTwo{0};
33+
int nQuarks{0};
34+
int nMuons{0};
35+
36+
int nMuonsInAcceptance{};
37+
38+
auto nEvents = tree->GetEntries();
39+
40+
for (int i = 0; i < nEvents; i++) {
41+
tree->GetEntry(i);
42+
// check subgenerator information
43+
if (eventHeader->hasInfo(o2::mcgenid::GeneratorProperty::SUBGENERATORID)) {
44+
bool isValid = false;
45+
int subGeneratorId = eventHeader->getInfo<int>(o2::mcgenid::GeneratorProperty::SUBGENERATORID, isValid);
46+
if (subGeneratorId == 0) {
47+
nEventsMB++;
48+
} else if (subGeneratorId == checkPdgQuarkOne) {
49+
nEventsInjOne++;
50+
} else if (subGeneratorId == checkPdgQuarkTwo) {
51+
nEventsInjTwo++;
52+
}
53+
}
54+
55+
int nmuonsev = 0;
56+
int nmuonsevinacc = 0;
57+
58+
for (auto &track : *tracks) {
59+
auto pdg = track.GetPdgCode();
60+
if (std::abs(pdg) == checkPdgQuarkOne || std::abs(pdg) == checkPdgQuarkTwo) {
61+
nQuarks++;
62+
continue;
63+
} // pdgquark
64+
auto y = track.GetRapidity();
65+
if (std::abs(pdg) == checkPdgDecayMuon) {
66+
int igmother = track.getMotherTrackId();
67+
auto gmTrack = (*tracks)[igmother];
68+
int gmpdg = gmTrack.GetPdgCode();
69+
if (int(std::abs(gmpdg) / 100.) == 4 ||
70+
int(std::abs(gmpdg) / 1000.) == 4) {
71+
nMuons++;
72+
nmuonsev++;
73+
if (-4.3 < y && y < -2.2) {
74+
nMuonsInAcceptance++;
75+
nmuonsevinacc++;
76+
}
77+
} // gmpdg
78+
79+
} // pdgdecay
80+
81+
} // loop track
82+
// std::cout << "#muons per event: " << nmuonsev << "\n";
83+
// std::cout << "#muons in acceptance per event: " << nmuonsev << "\n";
84+
} // events
85+
86+
std::cout << "#events: " << nEvents << "\n";
87+
std::cout << "# MB events: " << nEventsMB << "\n";
88+
std::cout << Form("# events injected with %d quark pair: ", checkPdgQuarkOne)
89+
<< nEventsInjOne << "\n";
90+
std::cout << Form("# events injected with %d quark pair: ", checkPdgQuarkTwo)
91+
<< nEventsInjTwo << "\n";
92+
if (nEventsMB < nEvents * (1 - ratioTrigger) * 0.95 ||
93+
nEventsMB > nEvents * (1 - ratioTrigger) *
94+
1.05) { // we put some tolerance since the number of
95+
// generated events is small
96+
std::cerr << "Number of generated MB events different than expected\n";
97+
return 1;
98+
}
99+
if ((nEventsInjOne + nEventsInjTwo) < nEvents * ratioTrigger * 0.95 ||
100+
(nEventsInjOne + nEventsInjTwo) > nEvents * ratioTrigger * 1.05) {
101+
std::cerr << "Number of generated events injected with " << checkPdgQuarkOne << " and " << checkPdgQuarkTwo
102+
<< " different than expected\n";
103+
return 1;
104+
}
105+
if (std::abs(float(nEventsInjOne) / nEventsInjTwo - ratioQuarkOneTwo) / ratioQuarkOneTwo > 0.1) {
106+
std::cerr << "Ratio between quark " << checkPdgQuarkOne << " and quark " << checkPdgQuarkTwo
107+
<< " different than expected\n";
108+
return 1;
109+
}
110+
std::cout << "#muons: " << nMuons << "\n";
111+
std::cout << "#muons in acceptance: " << nMuonsInAcceptance << "\n";
112+
113+
return 0;
114+
} // external

0 commit comments

Comments
 (0)