Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions MC/config/PWGLF/ini/GeneratorLF_Resonances_pp_Rare.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[GeneratorExternal]
fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator_pythia8_LF_rapidity_width.C
funcName=generateLFRapidity("${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator/resonancelistgun_width_inj.json", true, 5, false, true, "${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator/pythia8_inel_136tev.cfg", "")

[GeneratorPythia8] # if triggered then this will be used as the background event
config=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator/pythia8_inel_136tev.cfg

[DecayerPythia8] # after for transport code!
config[0]=${O2DPG_MC_CONFIG_ROOT}/MC/config/common/pythia8/decayer/base.cfg
config[1]=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator/resonances_width.cfg
111 changes: 111 additions & 0 deletions MC/config/PWGLF/ini/tests/GeneratorLF_Resonances_pp_Rare_test.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@

int External()
{
const std::string path{"o2sim_Kine.root"};
const int numberOfGapEvents{4}; // generateLFRapidity(..., gap=5)
const std::vector<int> injectedPDGs = {
9010221, // f0(980)
3324, -3324, // Xi(1530)0 and anti-Xi(1530)0
123324, -123324, // Xi(1820)0 and anti-Xi(1820)0
123314, -123314, // Xi(1820)- and Xi(1820)+
123334, -123334 // Omega(2012)- and Omega(2012)+
};
const std::vector<std::vector<int>> decayDaughters = {
{211, -211},
{3312, 211}, {-3312, -211},
{3122, 310}, {-3122, 310},
{3122, -321}, {-3122, 321},
{3312, 310}, {-3312, 310}
};

TFile file(path.c_str(), "READ");
if (file.IsZombie()) {
std::cerr << "Cannot open ROOT file " << path << "\n";
return 1;
}
auto tree = (TTree*)file.Get("o2sim");
if (!tree) {
std::cerr << "Cannot find tree o2sim in file " << path << "\n";
return 1;
}
std::vector<o2::MCTrack>* tracks{};
tree->SetBranchAddress("MCTrack", &tracks);

std::vector<int> nSignal(injectedPDGs.size(), 0);
std::vector<int> nNotDecayed(injectedPDGs.size(), 0);
std::vector<std::vector<int>> nDecays;
for (const auto& daughters : decayDaughters) {
nDecays.emplace_back(daughters.size(), 0);
}

int numberOfEventsProcessed{0};
int numberOfEventsProcessedWithoutInjection{0};
for (Long64_t i = 0; i < tree->GetEntries(); ++i) {
tree->GetEntry(i);
++numberOfEventsProcessed;
bool hasInjection{false};
for (const auto& track : *tracks) {
const auto pdg = track.GetPdgCode();
const auto it = std::find(injectedPDGs.begin(), injectedPDGs.end(), pdg);
if (it == injectedPDGs.end()) {
continue;
}
const auto index = static_cast<size_t>(std::distance(injectedPDGs.begin(), it));
++nSignal[index];
if (track.getFirstDaughterTrackId() < 0) {
++nNotDecayed[index];
continue;
}
for (int j = track.getFirstDaughterTrackId(); j <= track.getLastDaughterTrackId(); ++j) {
const auto pdgDau = tracks->at(j).GetPdgCode();
bool foundDau{false};
for (size_t k = 0; k < decayDaughters[index].size(); ++k) {
if (pdgDau == decayDaughters[index][k]) {
++nDecays[index][k];
foundDau = true;
hasInjection = true;
break;
}
}
if (!foundDau) {
std::cerr << "Decay daughter not found: " << pdg << " -> " << pdgDau
<< " (mother=" << track.getMotherTrackId()
<< ", secondMother=" << track.getSecondMotherTrackId() << ")\n";
}
}
}
if (!hasInjection) {
++numberOfEventsProcessedWithoutInjection;
}
}

std::cout << "--------------------------------\n";
std::cout << "# Events: " << tree->GetEntries() << "\n";
for (size_t i = 0; i < injectedPDGs.size(); ++i) {
std::cout << "# Mother\n";
std::cout << injectedPDGs[i] << " generated: " << nSignal[i]
<< ", " << nNotDecayed[i] << " did not decay\n";
for (size_t j = 0; j < decayDaughters[i].size(); ++j) {
std::cout << "# Daughter " << decayDaughters[i][j] << ": " << nDecays[i][j] << "\n";
}
}
std::cout << "--------------------------------\n";
std::cout << "Number of events processed: " << numberOfEventsProcessed << "\n";
std::cout << "Number of input for the gap events: " << numberOfGapEvents << "\n";
std::cout << "Number of events processed without injection: "
<< numberOfEventsProcessedWithoutInjection << "\n";
const double ratioOfNormalEvents = numberOfEventsProcessed
? static_cast<double>(numberOfEventsProcessedWithoutInjection) /
numberOfEventsProcessed
: 0.0;
std::cout << "Fraction without injection: " << ratioOfNormalEvents << "\n";
const double expectedRatio = static_cast<double>(numberOfGapEvents) / (numberOfGapEvents + 1);
std::cout << "Expected fraction for 1+" << numberOfGapEvents << " pattern: " << expectedRatio << "\n";

// Same basic gap sanity check as the referenced O2DPG test.
if (ratioOfNormalEvents > 0.90 || ratioOfNormalEvents < 0.70) {
std::cerr << "The number of injected events is too low or too high\n";
return 1;
}
return 0;
}
139 changes: 9 additions & 130 deletions MC/config/PWGLF/pythia8/generator/resonancelistgun_width_inj.json
Original file line number Diff line number Diff line change
@@ -1,128 +1,7 @@
{
"f_0(980)" : {
"pdg": 9010221,
"n": 10,
"ptMin": 0.0,
"ptMax": 20,
"etaMin": -1.2,
"etaMax": 1.2,
"rapidityMin": -1.2,
"rapidityMax": 1.2,
"genDecayed": true
},
"phi(1020)" : {
"pdg": 333,
"n": 10,
"ptMin": 0.0,
"ptMax": 20,
"etaMin": -1.2,
"etaMax": 1.2,
"rapidityMin": -1.2,
"rapidityMax": 1.2,
"genDecayed": true
},
"K1(1270)+": {
"pdg": 10323,
"n": 10,
"ptMin": 0.0,
"ptMax": 20,
"etaMin": -1.2,
"etaMax": 1.2,
"rapidityMin": -1.2,
"rapidityMax": 1.2,
"genDecayed": true
},
"K1(1270)-": {
"pdg": -10323,
"n": 10,
"ptMin": 0.0,
"ptMax": 20,
"etaMin": -1.2,
"etaMax": 1.2,
"rapidityMin": -1.2,
"rapidityMax": 1.2,
"genDecayed": true
},
"K1(1270)0": {
"pdg": 10313,
"n": 10,
"ptMin": 0.0,
"ptMax": 20,
"etaMin": -1.2,
"etaMax": 1.2,
"rapidityMin": -1.2,
"rapidityMax": 1.2,
"genDecayed": true
},
"anti-K1(1270)0": {
"pdg": -10313,
"n": 10,
"ptMin": 0.0,
"ptMax": 20,
"etaMin": -1.2,
"etaMax": 1.2,
"rapidityMin": -1.2,
"rapidityMax": 1.2,
"genDecayed": true
},
"Sigma(1385)-" : {
"pdg": 3114,
"n": 10,
"ptMin": 0.0,
"ptMax": 20,
"etaMin": -1.2,
"etaMax": 1.2,
"rapidityMin": -1.2,
"rapidityMax": 1.2,
"genDecayed": true
},
"anti-Sigma(1385)+" : {
"pdg": -3114,
"n": 10,
"ptMin": 0.0,
"ptMax": 20,
"etaMin": -1.2,
"etaMax": 1.2,
"rapidityMin": -1.2,
"rapidityMax": 1.2,
"genDecayed": true
},
"Sigma(1385)+" : {
"pdg": 3224,
"n": 10,
"ptMin": 0.0,
"ptMax": 20,
"etaMin": -1.2,
"etaMax": 1.2,
"rapidityMin": -1.2,
"rapidityMax": 1.2,
"genDecayed": true
},
"anti-Sigma(1385)-" : {
"pdg": -3224,
"n": 10,
"ptMin": 0.0,
"ptMax": 20,
"etaMin": -1.2,
"etaMax": 1.2,
"rapidityMin": -1.2,
"rapidityMax": 1.2,
"genDecayed": true
},
"Lambda(1520)0" : {
"pdg": 102134,
"n": 10,
"ptMin": 0.0,
"ptMax": 20,
"etaMin": -1.2,
"etaMax": 1.2,
"rapidityMin": -1.2,
"rapidityMax": 1.2,
"genDecayed": true
},
"anti-Lambda(1520)0" : {
"pdg": -102134,
"n": 10,
"n": 1,
"ptMin": 0.0,
"ptMax": 20,
"etaMin": -1.2,
Expand All @@ -133,7 +12,7 @@
},
"Xi(1530)0" : {
"pdg": 3324,
"n": 10,
"n": 1,
"ptMin": 0.0,
"ptMax": 20,
"etaMin": -1.2,
Expand All @@ -144,7 +23,7 @@
},
"anti-Xi(1530)0" : {
"pdg": -3324,
"n": 10,
"n": 1,
"ptMin": 0.0,
"ptMax": 20,
"etaMin": -1.2,
Expand All @@ -155,7 +34,7 @@
},
"Xi(1820)0" : {
"pdg": 123324,
"n": 10,
"n": 1,
"ptMin": 0.0,
"ptMax": 20,
"etaMin": -1.2,
Expand All @@ -166,7 +45,7 @@
},
"Anti-Xi(1820)0" : {
"pdg": -123324,
"n": 10,
"n": 1,
"ptMin": 0.0,
"ptMax": 20,
"etaMin": -1.2,
Expand All @@ -177,7 +56,7 @@
},
"Xi(1820)-" : {
"pdg": 123314,
"n": 10,
"n": 1,
"ptMin": 0.0,
"ptMax": 20,
"etaMin": -1.2,
Expand All @@ -188,7 +67,7 @@
},
"Xi(1820)+" : {
"pdg": -123314,
"n": 10,
"n": 1,
"ptMin": 0.0,
"ptMax": 20,
"etaMin": -1.2,
Expand All @@ -199,7 +78,7 @@
},
"Omega(2012)-" : {
"pdg": 123334,
"n": 10,
"n": 1,
"ptMin": 0.0,
"ptMax": 20,
"etaMin": -1.2,
Expand All @@ -210,7 +89,7 @@
},
"Omega(2012)+" : {
"pdg": -123334,
"n": 10,
"n": 1,
"ptMin": 0.0,
"ptMax": 20,
"etaMin": -1.2,
Expand Down
Loading