Skip to content

Commit df8e47c

Browse files
author
mattia
committed
Fix test macro for Sc bkg, checking for D*+.
1 parent 22da986 commit df8e47c

File tree

1 file changed

+36
-13
lines changed

1 file changed

+36
-13
lines changed

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

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ int External() {
1515
std::array<float, 2> freqRepl = {0.5, 0.5};
1616
std::map<int, int> sumOrigReplacedParticles = {{413, 0}};
1717

18-
std::array<int, 2> checkPdgHadron{14122, 4124};
18+
std::array<int, 3> checkPdgHadron{413, 14122, 4124};
1919
std::map<int, std::vector<std::vector<int>>> checkHadronDecays{ // sorted (!) pdg of daughters
2020
//{14122, {{4222, -211}, {4112, 211}, {4122, 211, -211}}}, // Lc(2595)+
2121
//{4124, {{4222, -211}, {4112, 211}, {4122, 211, -211}}} // Lc(2625)+
2222
{14122, {{-211, 4222}, {211, 4112}, {-211, 211, 4122}}}, // Lc(2595)+
23-
{4124, {{-211, 4222}, {211, 4112}, {-211, 211, 4122}}} // Lc(2625)+
23+
{4124, {{-211, 4222}, {211, 4112}, {-211, 211, 4122}}}, // Lc(2625)+
24+
{413, {{22, 411}, {111, 411}, {211, 421}}} // D*+ as in PYTHIA
2425
};
2526

2627
TFile file(path.c_str(), "READ");
@@ -64,7 +65,7 @@ int External() {
6465
auto absPdg = std::abs(pdg);
6566
if (std::find(checkPdgHadron.begin(), checkPdgHadron.end(), absPdg) != checkPdgHadron.end()) { // found signal
6667
nSignals++; // count signal PDG
67-
std::cout << "==> signal " << absPdg << " found!" << std::endl;
68+
std::cout << std::endl << "==> signal " << absPdg << " found!" << std::endl;
6869

6970
if (subGeneratorId == checkPdgQuarkOne) { // replacement only for prompt ---> BUT ALSO NON-PROMPT D* SEEM TO BE REPLACED
7071
for (int iRepl{0}; iRepl<2; ++iRepl) {
@@ -76,8 +77,9 @@ int External() {
7677
sumOrigReplacedParticles[pdgReplParticles[iRepl][0]]++;
7778
}
7879
}
79-
} else if (subGeneratorId == checkPdgQuarkTwo) {
80-
std::cout << " NB: we have a " << absPdg << " also in event with quark " << checkPdgQuarkTwo << std::endl;
80+
}
81+
else if (subGeneratorId == checkPdgQuarkTwo && (absPdg == pdgReplParticles[0][1] || absPdg == pdgReplParticles[1][1])) {
82+
std::cout << " NB: we have a " << absPdg << " also in event with quark " << checkPdgQuarkTwo << ", i.e in an event with c-cbar pair present, tagged with a b-bbar (e.g. double-parton scattering)" << std::endl;
8183
std::cout << " ### mother indices: ";
8284
int idFirstMother = track.getMotherTrackId();
8385
int idSecondMother = track.getSecondMotherTrackId();
@@ -86,13 +88,29 @@ int External() {
8688
std::cout << i << " ";
8789
motherIds.push_back(i);
8890
}
91+
std::cout << std::endl;
92+
93+
/// To establish if the partonic event is switched on or not, check if the motherIds are all -1 for the current hadron
94+
/// This is ok for Lc excited states deriving from the replacement of a prompt D*+
95+
/// Instead, Lc excited states coming from Lb decays (i.e. not coming from a D*+ replacement))have at least one mother that has idx !=-1 (*)
8996
bool partonicEventOn = false;
90-
if(motherIds != std::vector<int>{-1, -1}) {
97+
bool motherIdsAllMinus1 = true;
98+
for(int idx : motherIds) {
99+
if(idx != -1) {
100+
/// one mother id different from
101+
motherIdsAllMinus1 = false;
102+
break;
103+
}
104+
}
105+
//if(motherIds != std::vector<int>{-1, -1}) {
106+
if(!motherIdsAllMinus1) {
91107
std::cout << "The " << absPdg << " particle has mothers. This should mean that it comes directly from parton hadronization, and that the partonic event was kept in the MC production " << std::endl;
92108
partonicEventOn = true;
93109
}
110+
94111
std::cout << " ### mother PDG codes: ";
95112
std::vector<int> motherPdgCodes = {};
113+
bool updateCounters = true;
96114
if(partonicEventOn) {
97115
for(int i=idFirstMother; i<=idSecondMother; i++) {
98116
motherPdgCodes.push_back(tracks->at(i).GetPdgCode());
@@ -103,16 +121,21 @@ int External() {
103121
/// This means that the charm hadron comes from the c-quark hadronization, where the c/cbar quark
104122
/// comes from a c-cbar pair present in the current event, tagged with a b-bbar (e.g. double-parton scattering)
105123
if(std::find(motherPdgCodes.begin(), motherPdgCodes.end(), 4) == motherPdgCodes.end() && std::find(motherPdgCodes.begin(), motherPdgCodes.end(), -4) == motherPdgCodes.end()) {
106-
/// if the partinc event is not really saved and we arrive here, it means that motherIds != {-1, -1} because
107-
/// the hadron comes from the decay of a beauty hadron. This can happen if and only if this is not a replaced one (i.e. native from Lambdab0 decay)
124+
/// if we arrive here, it means that the hadron comes from the decay of a beauty hadron.
125+
/// This can happen if and only if this is not a replaced one (i.e. native from Lambdab0 decay)
108126
if (std::find(motherPdgCodes.begin(), motherPdgCodes.end(), 5122) == motherPdgCodes.end() && std::find(motherPdgCodes.begin(), motherPdgCodes.end(), -5122) == motherPdgCodes.end()) {
109127
std::cerr << "The particle " << absPdg << " does not originate neither from a c/c-bar quark (replaced) nor from a Lambda_b0 decay. There is something wrong, aborting..." << std::endl;
110128
return 1;
111129
}
130+
/// since this is a native Lc excited state from Lb0 decay, we must not update the replacement counters
131+
updateCounters = false;
112132
}
113133
}
114134
std::cout << std::endl;
115135

136+
/// update the counters only if the Lc excited state comes from a replaced prompt D*+, i.e. not from a Lb0 decay
137+
if (!updateCounters) continue;
138+
116139
/// only if we arrive here it means that everything is ok, and we can safely update the counters for the final statistics
117140
for (int iRepl{0}; iRepl<2; ++iRepl) {
118141
if (absPdg == pdgReplParticles[iRepl][0]) {
@@ -133,7 +156,7 @@ int External() {
133156
auto pdgDau = tracks->at(j).GetPdgCode();
134157
pdgsDecay.push_back(pdgDau);
135158
std::cout << " -- daughter " << j << ": " << pdgDau << std::endl;
136-
if (pdgDau != 333) { // phi is antiparticle of itself
159+
if (pdgDau != 333 && pdgDau != 111) { // phi and pi0 are antiparticles of themselves
137160
pdgsDecayAntiPart.push_back(-pdgDau);
138161
} else {
139162
pdgsDecayAntiPart.push_back(pdgDau);
@@ -163,15 +186,15 @@ int External() {
163186
std::cout <<"# signal hadrons: " << nSignals << "\n";
164187
std::cout <<"# signal hadrons decaying in the correct channel: " << nSignalGoodDecay << "\n";
165188

166-
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
189+
if (nEventsMB < nEvents * (1 - ratioTrigger) * 0.90 || nEventsMB > nEvents * (1 - ratioTrigger) * 1.10) { // we put some tolerance since the number of generated events is small
167190
std::cerr << "Number of generated MB events different than expected\n";
168191
return 1;
169192
}
170-
if (nEventsInjOne < nEvents * ratioTrigger * 0.5 * 0.95 || nEventsInjOne > nEvents * ratioTrigger * 0.5 * 1.05) {
193+
if (nEventsInjOne < nEvents * ratioTrigger * 0.5 * 0.90 || nEventsInjOne > nEvents * ratioTrigger * 0.5 * 1.10) {
171194
std::cerr << "Number of generated events injected with " << checkPdgQuarkOne << " different than expected\n";
172195
return 1;
173196
}
174-
if (nEventsInjTwo < nEvents * ratioTrigger * 0.5 * 0.95 || nEventsInjTwo > nEvents * ratioTrigger * 0.5 * 1.05) {
197+
if (nEventsInjTwo < nEvents * ratioTrigger * 0.5 * 0.90 || nEventsInjTwo > nEvents * ratioTrigger * 0.5 * 1.10) {
175198
std::cerr << "Number of generated events injected with " << checkPdgQuarkTwo << " different than expected\n";
176199
return 1;
177200
}
@@ -184,7 +207,7 @@ int External() {
184207

185208
for (int iRepl{0}; iRepl<2; ++iRepl) {
186209

187-
std::cout << " --- pdgReplPartCounters[" << iRepl << "][1] = " << pdgReplPartCounters[iRepl][1] << ", freqRepl[" << iRepl <<"] = " << freqRepl[iRepl] << ", sumOrigReplacedParticles[pdgReplParticles[" << iRepl << "][0]] =" << sumOrigReplacedParticles[pdgReplParticles[iRepl][0]] << std::endl;
210+
std::cout << " --- pdgReplPartCounters[" << iRepl << "][1] = " << pdgReplPartCounters[iRepl][1] << ", freqRepl[" << iRepl <<"] = " << freqRepl[iRepl] << ", sumOrigReplacedParticles[pdgReplParticles[" << iRepl << "][0]] = " << sumOrigReplacedParticles[pdgReplParticles[iRepl][0]] << std::endl;
188211

189212
if (std::abs(pdgReplPartCounters[iRepl][1] - freqRepl[iRepl] * sumOrigReplacedParticles[pdgReplParticles[iRepl][0]]) > 2 * std::sqrt(freqRepl[iRepl] * sumOrigReplacedParticles[pdgReplParticles[iRepl][0]])) { // 2 sigma compatibility
190213
float fracMeas = 0.;

0 commit comments

Comments
 (0)