From 9c2eec3ffeb47267311fc9680f3c36cc0023bb12 Mon Sep 17 00:00:00 2001 From: sawankumawat Date: Thu, 2 Apr 2026 21:54:11 +0530 Subject: [PATCH 1/3] added different injection configurations for the MC --- .../ini/GeneratorLF_Resonances_gap2_flaty.ini | 10 + .../ini/GeneratorLF_Resonances_gap4_flaty.ini | 10 + .../GeneratorLF_Resonances_pp_Glue_gap2.ini | 10 + ...eratorLF_Resonances_pp_Glue_gap2_flaty.ini | 10 + ...> GeneratorLF_Resonances_pp_Glue_gap4.ini} | 0 ...eratorLF_Resonances_pp_Glue_gap4_flaty.ini | 10 + ...neratorLF_Resonances_pp_exoticAll_gap4.ini | 10 + .../pythia8/generator/exoticresonancegun.json | 72 ++-- .../PWGLF/pythia8/generator/gluelistgun.json | 48 +-- .../pythia8/generator_pythia8_LF_rapidity.C | 322 +++++++++++------- 10 files changed, 327 insertions(+), 175 deletions(-) create mode 100644 MC/config/PWGLF/ini/GeneratorLF_Resonances_gap2_flaty.ini create mode 100644 MC/config/PWGLF/ini/GeneratorLF_Resonances_gap4_flaty.ini create mode 100644 MC/config/PWGLF/ini/GeneratorLF_Resonances_pp_Glue_gap2.ini create mode 100644 MC/config/PWGLF/ini/GeneratorLF_Resonances_pp_Glue_gap2_flaty.ini rename MC/config/PWGLF/ini/{GeneratorLF_Resonances_pp_exotic.ini => GeneratorLF_Resonances_pp_Glue_gap4.ini} (100%) create mode 100644 MC/config/PWGLF/ini/GeneratorLF_Resonances_pp_Glue_gap4_flaty.ini create mode 100644 MC/config/PWGLF/ini/GeneratorLF_Resonances_pp_exoticAll_gap4.ini diff --git a/MC/config/PWGLF/ini/GeneratorLF_Resonances_gap2_flaty.ini b/MC/config/PWGLF/ini/GeneratorLF_Resonances_gap2_flaty.ini new file mode 100644 index 000000000..e55c3195c --- /dev/null +++ b/MC/config/PWGLF/ini/GeneratorLF_Resonances_gap2_flaty.ini @@ -0,0 +1,10 @@ +[GeneratorExternal] +fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator_pythia8_LF_rapidity.C +funcName=generateLFRapidity("${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator/resonancelistgun_exoticAll.json", true, 2, false, true, "${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator/pythia8_inel_136tev.cfg", "") + +[GeneratorPythia8] # 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.cfg diff --git a/MC/config/PWGLF/ini/GeneratorLF_Resonances_gap4_flaty.ini b/MC/config/PWGLF/ini/GeneratorLF_Resonances_gap4_flaty.ini new file mode 100644 index 000000000..ecc82efee --- /dev/null +++ b/MC/config/PWGLF/ini/GeneratorLF_Resonances_gap4_flaty.ini @@ -0,0 +1,10 @@ +[GeneratorExternal] +fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator_pythia8_LF_rapidity.C +funcName=generateLFRapidity("${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator/resonancelistgun_exoticAll.json", true, 4, false, true, "${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator/pythia8_inel_136tev.cfg", "") + +[GeneratorPythia8] # 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.cfg diff --git a/MC/config/PWGLF/ini/GeneratorLF_Resonances_pp_Glue_gap2.ini b/MC/config/PWGLF/ini/GeneratorLF_Resonances_pp_Glue_gap2.ini new file mode 100644 index 000000000..5082416ec --- /dev/null +++ b/MC/config/PWGLF/ini/GeneratorLF_Resonances_pp_Glue_gap2.ini @@ -0,0 +1,10 @@ +[GeneratorExternal] +fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator_pythia8_LF_rapidity.C +funcName=generateLFRapidity("${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator/gluelistgun.json", true, 2, false, false, "${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.cfg diff --git a/MC/config/PWGLF/ini/GeneratorLF_Resonances_pp_Glue_gap2_flaty.ini b/MC/config/PWGLF/ini/GeneratorLF_Resonances_pp_Glue_gap2_flaty.ini new file mode 100644 index 000000000..e520191e7 --- /dev/null +++ b/MC/config/PWGLF/ini/GeneratorLF_Resonances_pp_Glue_gap2_flaty.ini @@ -0,0 +1,10 @@ +[GeneratorExternal] +fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator_pythia8_LF_rapidity.C +funcName=generateLFRapidity("${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator/gluelistgun.json", true, 2, 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.cfg diff --git a/MC/config/PWGLF/ini/GeneratorLF_Resonances_pp_exotic.ini b/MC/config/PWGLF/ini/GeneratorLF_Resonances_pp_Glue_gap4.ini similarity index 100% rename from MC/config/PWGLF/ini/GeneratorLF_Resonances_pp_exotic.ini rename to MC/config/PWGLF/ini/GeneratorLF_Resonances_pp_Glue_gap4.ini diff --git a/MC/config/PWGLF/ini/GeneratorLF_Resonances_pp_Glue_gap4_flaty.ini b/MC/config/PWGLF/ini/GeneratorLF_Resonances_pp_Glue_gap4_flaty.ini new file mode 100644 index 000000000..614e9e2fa --- /dev/null +++ b/MC/config/PWGLF/ini/GeneratorLF_Resonances_pp_Glue_gap4_flaty.ini @@ -0,0 +1,10 @@ +[GeneratorExternal] +fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator_pythia8_LF_rapidity.C +funcName=generateLFRapidity("${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator/gluelistgun.json", true, 4, 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.cfg diff --git a/MC/config/PWGLF/ini/GeneratorLF_Resonances_pp_exoticAll_gap4.ini b/MC/config/PWGLF/ini/GeneratorLF_Resonances_pp_exoticAll_gap4.ini new file mode 100644 index 000000000..5c9b58945 --- /dev/null +++ b/MC/config/PWGLF/ini/GeneratorLF_Resonances_pp_exoticAll_gap4.ini @@ -0,0 +1,10 @@ +[GeneratorExternal] +fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator_pythia8_LF_rapidity.C +funcName=generateLFRapidity("${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator/resonancelistgun_exoticAll.json", true, 4, false, false, "${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator/pythia8_inel_136tev.cfg", "") + +[GeneratorPythia8] # 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.cfg diff --git a/MC/config/PWGLF/pythia8/generator/exoticresonancegun.json b/MC/config/PWGLF/pythia8/generator/exoticresonancegun.json index 7043cd6d8..b35ee49ab 100644 --- a/MC/config/PWGLF/pythia8/generator/exoticresonancegun.json +++ b/MC/config/PWGLF/pythia8/generator/exoticresonancegun.json @@ -1,68 +1,68 @@ { "f_1(1285)" : { "pdg": 20223, - "n": 1, + "n": 3, "ptMin": 0.0, - "ptMax": 20, - "etaMin": -1.2, - "etaMax": 1.2, - "rapidityMin": -1.2, - "rapidityMax": 1.2, + "ptMax": 30, + "etaMin": -1.0, + "etaMax": 1.0, + "rapidityMin": -1.0, + "rapidityMax": 1.0, "genDecayed": true }, "f_1(1420)" : { "pdg": 20333, - "n": 1, + "n": 3, "ptMin": 0.0, - "ptMax": 20, - "etaMin": -1.2, - "etaMax": 1.2, - "rapidityMin": -1.2, - "rapidityMax": 1.2, + "ptMax": 30, + "etaMin": -1.0, + "etaMax": 1.0, + "rapidityMin": -1.0, + "rapidityMax": 1.0, "genDecayed": true }, "f_0(1500)" : { "pdg": 9030221, - "n": 1, + "n": 3, "ptMin": 0.0, - "ptMax": 20, - "etaMin": -1.2, - "etaMax": 1.2, - "rapidityMin": -1.2, - "rapidityMax": 1.2, + "ptMax": 30, + "etaMin": -1.0, + "etaMax": 1.0, + "rapidityMin": -1.0, + "rapidityMax": 1.0, "genDecayed": true }, "f_0(1710)" : { "pdg": 10331, - "n": 1, + "n": 3, "ptMin": 0.0, - "ptMax": 20, - "etaMin": -1.2, - "etaMax": 1.2, - "rapidityMin": -1.2, - "rapidityMax": 1.2, + "ptMax": 30, + "etaMin": -1.0, + "etaMax": 1.0, + "rapidityMin": -1.0, + "rapidityMax": 1.0, "genDecayed": true }, "f_2(1525)" : { "pdg": 335, - "n": 1, + "n": 3, "ptMin": 0.0, - "ptMax": 20, - "etaMin": -1.2, - "etaMax": 1.2, - "rapidityMin": -1.2, - "rapidityMax": 1.2, + "ptMax": 30, + "etaMin": -1.0, + "etaMax": 1.0, + "rapidityMin": -1.0, + "rapidityMax": 1.0, "genDecayed": true }, "f_0(1370)" : { "pdg": 10221, - "n": 1, + "n": 3, "ptMin": 0.0, - "ptMax": 20, - "etaMin": -1.2, - "etaMax": 1.2, - "rapidityMin": -1.2, - "rapidityMax": 1.2, + "ptMax": 30, + "etaMin": -1.0, + "etaMax": 1.0, + "rapidityMin": -1.0, + "rapidityMax": 1.0, "genDecayed": true } } diff --git a/MC/config/PWGLF/pythia8/generator/gluelistgun.json b/MC/config/PWGLF/pythia8/generator/gluelistgun.json index c261c5608..7fc4bc690 100644 --- a/MC/config/PWGLF/pythia8/generator/gluelistgun.json +++ b/MC/config/PWGLF/pythia8/generator/gluelistgun.json @@ -1,46 +1,46 @@ { "f_2(1270)": { "pdg": 225, - "n": 1, + "n": 3, "ptMin": 0.0, - "ptMax": 20, - "etaMin": -1.2, - "etaMax": 1.2, - "rapidityMin": -1.2, - "rapidityMax": 1.2, + "ptMax": 30, + "etaMin": -1.0, + "etaMax": 1.0, + "rapidityMin": -1.0, + "rapidityMax": 1.0, "genDecayed": true }, "f_0(1710)": { "pdg": 10331, - "n": 1, + "n": 3, "ptMin": 0.0, - "ptMax": 20, - "etaMin": -1.2, - "etaMax": 1.2, - "rapidityMin": -1.2, - "rapidityMax": 1.2, + "ptMax": 30, + "etaMin": -1.0, + "etaMax": 1.0, + "rapidityMin": -1.0, + "rapidityMax": 1.0, "genDecayed": true }, "f_2(1525)": { "pdg": 335, - "n": 1, + "n": 3, "ptMin": 0.0, - "ptMax": 20, - "etaMin": -1.2, - "etaMax": 1.2, - "rapidityMin": -1.2, - "rapidityMax": 1.2, + "ptMax": 30, + "etaMin": -1.0, + "etaMax": 1.0, + "rapidityMin": -1.0, + "rapidityMax": 1.0, "genDecayed": true }, "a_2(1230)": { "pdg": 115, - "n": 1, + "n": 3, "ptMin": 0.0, - "ptMax": 20, - "etaMin": -1.2, - "etaMax": 1.2, - "rapidityMin": -1.2, - "rapidityMax": 1.2, + "ptMax": 30, + "etaMin": -1.0, + "etaMax": 1.0, + "rapidityMin": -1.0, + "rapidityMax": 1.0, "genDecayed": true } } \ No newline at end of file diff --git a/MC/config/PWGLF/pythia8/generator_pythia8_LF_rapidity.C b/MC/config/PWGLF/pythia8/generator_pythia8_LF_rapidity.C index b88a9a7a6..9c6e73e5c 100644 --- a/MC/config/PWGLF/pythia8/generator_pythia8_LF_rapidity.C +++ b/MC/config/PWGLF/pythia8/generator_pythia8_LF_rapidity.C @@ -66,7 +66,7 @@ using namespace o2::mcgenstatus; class GeneratorPythia8LFRapidity : public o2::eventgen::GeneratorPythia8 { - public: +public: /// Parametric constructor GeneratorPythia8LFRapidity(bool injOnePerEvent = true, int gapBetweenInjection = 0, @@ -74,10 +74,10 @@ class GeneratorPythia8LFRapidity : public o2::eventgen::GeneratorPythia8 bool useRapidity = false, std::string pythiaCfgMb = "${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator/pythia8_inel_136tev.cfg", std::string pythiaCfgSignal = "${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator/pythia8_inel_136tev.cfg") : GeneratorPythia8{}, - mOneInjectionPerEvent{injOnePerEvent}, - mGapBetweenInjection{gapBetweenInjection}, - mUseTriggering{useTrigger}, - mUseRapidity{useRapidity} + mOneInjectionPerEvent{injOnePerEvent}, + mGapBetweenInjection{gapBetweenInjection}, + mUseTriggering{useTrigger}, + mUseRapidity{useRapidity} { LOG(info) << "GeneratorPythia8LFRapidity constructor"; LOG(info) << "++ mOneInjectionPerEvent: " << mOneInjectionPerEvent; @@ -87,16 +87,19 @@ class GeneratorPythia8LFRapidity : public o2::eventgen::GeneratorPythia8 LOG(info) << "++ pythiaCfgMb: " << pythiaCfgMb; LOG(info) << "++ pythiaCfgSignal: " << pythiaCfgSignal; gRandom->SetSeed(0); - if (useTrigger) { + if (useTrigger) + { mPythia.readString("ProcessLevel:all off"); - if (pythiaCfgMb == "") { // If no configuration file is provided, use the one from the Pythia8Param - auto& param = o2::eventgen::GeneratorPythia8Param::Instance(); + if (pythiaCfgMb == "") + { // If no configuration file is provided, use the one from the Pythia8Param + auto ¶m = o2::eventgen::GeneratorPythia8Param::Instance(); LOG(info) << "Instance LFRapidity \'Pythia8\' generator with following parameters for MB event"; LOG(info) << param; pythiaCfgMb = param.config; } - if (pythiaCfgSignal == "") { // If no configuration file is provided, use the one from the Pythia8Param - auto& param = o2::eventgen::GeneratorPythia8Param::Instance(); + if (pythiaCfgSignal == "") + { // If no configuration file is provided, use the one from the Pythia8Param + auto ¶m = o2::eventgen::GeneratorPythia8Param::Instance(); LOG(info) << "Instance LFRapidity \'Pythia8\' generator with following parameters for signal event"; LOG(info) << param; pythiaCfgSignal = param.config; @@ -104,60 +107,73 @@ class GeneratorPythia8LFRapidity : public o2::eventgen::GeneratorPythia8 pythiaCfgMb = gSystem->ExpandPathName(pythiaCfgMb.c_str()); pythiaCfgSignal = gSystem->ExpandPathName(pythiaCfgSignal.c_str()); LOG(info) << " ++ Using trigger, initializing Pythia8 for trigger"; - if (!pythiaObjectMinimumBias.readFile(pythiaCfgMb)) { + if (!pythiaObjectMinimumBias.readFile(pythiaCfgMb)) + { LOG(fatal) << "Could not pythiaObjectMinimumBias.readFile(\"" << pythiaCfgMb << "\")"; } pythiaObjectMinimumBias.readString("Random:setSeed = on"); pythiaObjectMinimumBias.readString("Random:seed =" + std::to_string(gRandom->Integer(900000000 - 2) + 1)); // FIX: Init signal pythia object - if (!pythiaObjectSignal.readFile(pythiaCfgSignal)) { + if (!pythiaObjectSignal.readFile(pythiaCfgSignal)) + { LOG(fatal) << "Could not pythiaObjectSignal.readFile(\"" << pythiaCfgSignal << "\")"; } pythiaObjectSignal.readString("Random:setSeed = on"); pythiaObjectSignal.readString("Random:seed =" + std::to_string(gRandom->Integer(900000000 - 2) + 1)); - if (!pythiaObjectMinimumBias.init()) { + if (!pythiaObjectMinimumBias.init()) + { LOG(fatal) << "Could not pythiaObjectMinimumBias.init() from " << pythiaCfgMb; } - if (!pythiaObjectSignal.init()) { + if (!pythiaObjectSignal.init()) + { LOG(fatal) << "Could not pythiaObjectSignal.init() from " << pythiaCfgSignal; } - } else { // Using simple injection with internal decay (if needed). Fetching the parameters from the configuration file of the PythiaDecayer + } + else + { // Using simple injection with internal decay (if needed). Fetching the parameters from the configuration file of the PythiaDecayer - if (pythiaCfgMb == "") { // If no configuration file is provided, use the one from the Pythia8Param - auto& param = o2::eventgen::GeneratorPythia8Param::Instance(); + if (pythiaCfgMb == "") + { // If no configuration file is provided, use the one from the Pythia8Param + auto ¶m = o2::eventgen::GeneratorPythia8Param::Instance(); LOG(info) << "Instance LFRapidity \'Pythia8\' generator with following parameters for MB event"; LOG(info) << param; pythiaCfgMb = param.config; } // FIX: Fallback if still empty to default minbias - if (pythiaCfgMb == "") { + if (pythiaCfgMb == "") + { pythiaCfgMb = "${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator/pythia8_inel_136tev.cfg"; } pythiaCfgMb = gSystem->ExpandPathName(pythiaCfgMb.c_str()); - if (!pythiaObjectMinimumBias.readFile(pythiaCfgMb)) { + if (!pythiaObjectMinimumBias.readFile(pythiaCfgMb)) + { LOG(fatal) << "Could not pythiaObjectMinimumBias.readFile(\"" << pythiaCfgMb << "\")"; } pythiaObjectMinimumBias.readString("Random:setSeed = on"); pythiaObjectMinimumBias.readString("Random:seed =" + std::to_string(gRandom->Integer(900000000 - 2) + 1)); - if (!pythiaObjectMinimumBias.init()) { + if (!pythiaObjectMinimumBias.init()) + { LOG(fatal) << "Could not pythiaObjectMinimumBias.init() from " << pythiaCfgMb; } /** switch off process level **/ mPythiaGun.readString("ProcessLevel:all off"); - auto& param = o2::eventgen::DecayerPythia8Param::Instance(); + auto ¶m = o2::eventgen::DecayerPythia8Param::Instance(); LOG(info) << "Init \'GeneratorPythia8LFRapidity\' with following parameters"; LOG(info) << param; - for (int i = 0; i < 8; ++i) { - if (param.config[i].empty()) { + for (int i = 0; i < 8; ++i) + { + if (param.config[i].empty()) + { continue; } std::string config = gSystem->ExpandPathName(param.config[i].c_str()); LOG(info) << "GeneratorPythia8LFRapidity Reading configuration from file: " << config; - if (!mPythiaGun.readFile(config, true)) { + if (!mPythiaGun.readFile(config, true)) + { LOG(fatal) << "Failed to init \'DecayerPythia8\': problems with configuration file " << config; return; @@ -165,18 +181,23 @@ class GeneratorPythia8LFRapidity : public o2::eventgen::GeneratorPythia8 } /** show changed particle data **/ - if (param.showChanged) { + if (param.showChanged) + { mPythiaGun.readString(std::string("Init:showChangedParticleData on")); - } else { + } + else + { mPythiaGun.readString(std::string("Init:showChangedParticleData off")); } /** initialise **/ - if (!mPythiaGun.init()) { + if (!mPythiaGun.init()) + { LOG(fatal) << "Failed to init \'DecayerPythia8\': init returned with error"; return; } - if (pythiaCfgSignal != "") { + if (pythiaCfgSignal != "") + { LOG(fatal) << "Cannot use simple injection and have a configuration file. pythiaCfgSignal= `" << pythiaCfgSignal << "` must be empty"; } } @@ -188,27 +209,34 @@ class GeneratorPythia8LFRapidity : public o2::eventgen::GeneratorPythia8 //__________________________________________________________________ Bool_t generateEvent() override { - if (!mUseTriggering) { // Injected mode: Embedding into MB + if (!mUseTriggering) + { // Injected mode: Embedding into MB // 1. Generate Background (MB) // LOG(info) << "Generating background event " << mEventCounter; bool lGenerationOK = false; - while (!lGenerationOK) { + while (!lGenerationOK) + { lGenerationOK = pythiaObjectMinimumBias.next(); } mPythia.event = pythiaObjectMinimumBias.event; // 2. Determine if we inject specific particles (Gap logic) bool doInjection = true; - if (mGapBetweenInjection > 0) { - if (mGapBetweenInjection == 1 && mEventCounter % 2 == 0) { + if (mGapBetweenInjection > 0) + { + if (mGapBetweenInjection == 1 && mEventCounter % 2 == 0) + { doInjection = false; - } else if (mEventCounter % mGapBetweenInjection != 0) { + } + else if (mEventCounter % mGapBetweenInjection != 0) + { doInjection = false; } } - if (!doInjection) { + if (!doInjection) + { LOG(info) << "Skipping injection for event " << mEventCounter; return true; } @@ -217,7 +245,8 @@ class GeneratorPythia8LFRapidity : public o2::eventgen::GeneratorPythia8 LOG(info) << "generateEvent (Injection) " << mEventCounter; // For Triggered mode, we start clean. For Injected mode, we have MB in mPythia.event - if (mUseTriggering) { + if (mUseTriggering) + { mPythia.event.reset(); } @@ -226,31 +255,39 @@ class GeneratorPythia8LFRapidity : public o2::eventgen::GeneratorPythia8 bool injectedForThisEvent = false; int nConfig = mGunConfigs.size(); // We start counting from the configurations of the transport decayed particles - for (const ConfigContainer& cfg : mGunConfigsGenDecayed) { + for (const ConfigContainer &cfg : mGunConfigsGenDecayed) + { nConfig++; - if (mConfigToUse >= 0 && (nConfig - 1) != mConfigToUse) { + if (mConfigToUse >= 0 && (nConfig - 1) != mConfigToUse) + { continue; } LOG(info) << "Using config container "; cfg.print(); - if (mUseTriggering) { // Do the triggering + if (mUseTriggering) + { // Do the triggering bool doSignal{mEventCounter % (mGapBetweenInjection + 1) == 0}; // Do signal or gap - if (doSignal) { + if (doSignal) + { LOG(info) << "Generating triggered signal event for particle"; cfg.print(); bool satisfiesTrigger = false; int nTries = 0; - while (!satisfiesTrigger) { - if (!pythiaObjectSignal.next()) { + while (!satisfiesTrigger) + { + if (!pythiaObjectSignal.next()) + { continue; } // Check if triggered condition satisfied - for (int j = 0; j < pythiaObjectSignal.event.size(); j++) { - const int& pypid = pythiaObjectSignal.event[j].id(); - const float& pyeta = mUseRapidity ? pythiaObjectSignal.event[j].y() : pythiaObjectSignal.event[j].eta(); - const float& pypt = pythiaObjectSignal.event[j].pT(); - if (pypid == cfg.mPdg && cfg.mMin < pyeta && pyeta < cfg.mMax && pypt > cfg.mPtMin && pypt < cfg.mPtMax) { + for (int j = 0; j < pythiaObjectSignal.event.size(); j++) + { + const int &pypid = pythiaObjectSignal.event[j].id(); + const float &pyeta = mUseRapidity ? pythiaObjectSignal.event[j].y() : pythiaObjectSignal.event[j].eta(); + const float &pypt = pythiaObjectSignal.event[j].pT(); + if (pypid == cfg.mPdg && cfg.mMin < pyeta && pyeta < cfg.mMax && pypt > cfg.mPtMin && pypt < cfg.mPtMax) + { LOG(info) << "Found particle " << j << " " << pypid << " with " << (mUseRapidity ? "rapidity" : "eta") << " " << pyeta << " and pT " << pypt << " in event " << mEventCounter << " after " << nTries << " tries"; satisfiesTrigger = true; break; @@ -259,11 +296,14 @@ class GeneratorPythia8LFRapidity : public o2::eventgen::GeneratorPythia8 nTries++; } mPythia.event = pythiaObjectSignal.event; - } else { + } + else + { LOG(info) << "Generating background event " << mEventCounter; // Generate minimum-bias event bool lGenerationOK = false; - while (!lGenerationOK) { + while (!lGenerationOK) + { lGenerationOK = pythiaObjectMinimumBias.next(); } mPythia.event = pythiaObjectMinimumBias.event; @@ -274,7 +314,8 @@ class GeneratorPythia8LFRapidity : public o2::eventgen::GeneratorPythia8 // Do the injection // Use mPythiaGun for separate generation and decay mPythiaGun.event.reset(); - for (int i{0}; i < cfg.mNInject; ++i) { + for (int i{0}; i < cfg.mNInject; ++i) + { const double pt = gRandom->Uniform(cfg.mPtMin, cfg.mPtMax); const double eta = gRandom->Uniform(cfg.mMin, cfg.mMax); const double phi = gRandom->Uniform(0, TMath::TwoPi()); @@ -284,12 +325,15 @@ class GeneratorPythia8LFRapidity : public o2::eventgen::GeneratorPythia8 double pz = 0; double et = 0; - if (mUseRapidity) { + if (mUseRapidity) + { // Rapidty Case const double mT = std::sqrt(cfg.mMass * cfg.mMass + pt * pt); pz = mT * std::sinh(eta); et = mT * std::cosh(eta); - } else { + } + else + { // Eta Case pz = pt * std::sinh(eta); const double p = pt * std::cosh(eta); @@ -318,8 +362,9 @@ class GeneratorPythia8LFRapidity : public o2::eventgen::GeneratorPythia8 int offset = mPythia.event.size(); LOG(info) << "Merging " << mPythiaGun.event.size() - 1 << " injected particles into MB event of size " << offset; - for (int i = 1; i < mPythiaGun.event.size(); ++i) { // Skip system particle 0 - Particle& p = mPythiaGun.event[i]; + for (int i = 1; i < mPythiaGun.event.size(); ++i) + { // Skip system particle 0 + Particle &p = mPythiaGun.event[i]; // Adjust history indices int mother1 = p.mother1(); int mother2 = p.mother2(); @@ -351,7 +396,8 @@ class GeneratorPythia8LFRapidity : public o2::eventgen::GeneratorPythia8 // But if we are in embedding mode, we just need to ensure the MB event is there. // The mGunConfigs are handled in importParticles. - if (mVerbose) { + if (mVerbose) + { LOG(info) << "Eventlisting"; mPythia.event.list(1); mPythia.stat(); @@ -362,12 +408,17 @@ class GeneratorPythia8LFRapidity : public o2::eventgen::GeneratorPythia8 //__________________________________________________________________ Bool_t importParticles() override { - if (!mUseTriggering) { // If the triggering is used we handle the the gap when generating the signal - if (mGapBetweenInjection > 0) { - if (mGapBetweenInjection == 1 && mEventCounter % 2 == 0) { + if (!mUseTriggering) + { // If the triggering is used we handle the the gap when generating the signal + if (mGapBetweenInjection > 0) + { + if (mGapBetweenInjection == 1 && mEventCounter % 2 == 0) + { LOG(info) << "Skipping importParticles event " << mEventCounter++; return true; - } else if (mEventCounter % mGapBetweenInjection != 0) { + } + else if (mEventCounter % mGapBetweenInjection != 0) + { LOG(info) << "Skipping importParticles event " << mEventCounter++; return true; } @@ -376,14 +427,17 @@ class GeneratorPythia8LFRapidity : public o2::eventgen::GeneratorPythia8 LOG(info) << "importParticles " << mEventCounter++; GeneratorPythia8::importParticles(); int nConfig = 0; - for (const ConfigContainer& cfg : mGunConfigs) { + for (const ConfigContainer &cfg : mGunConfigs) + { nConfig++; - if (mConfigToUse >= 0 && (nConfig - 1) != mConfigToUse) { + if (mConfigToUse >= 0 && (nConfig - 1) != mConfigToUse) + { continue; } LOGF(info, "Injecting %i particles with PDG %i, pT in [%f, %f], %s in [%f, %f]", cfg.mNInject, cfg.mPdg, cfg.mPtMin, cfg.mPtMax, (mUseRapidity ? "rapidity" : "eta"), cfg.mMin, cfg.mMax); - for (int i{0}; i < cfg.mNInject; ++i) { + for (int i{0}; i < cfg.mNInject; ++i) + { const double pt = gRandom->Uniform(cfg.mPtMin, cfg.mPtMax); const double eta = gRandom->Uniform(cfg.mMin, cfg.mMax); const double phi = gRandom->Uniform(0, TMath::TwoPi()); @@ -392,11 +446,14 @@ class GeneratorPythia8LFRapidity : public o2::eventgen::GeneratorPythia8 double pz = 0; double et = 0; - if (mUseRapidity) { + if (mUseRapidity) + { const double mT = std::sqrt(cfg.mMass * cfg.mMass + pt * pt); pz = mT * std::sinh(eta); et = mT * std::cosh(eta); - } else { + } + else + { pz = pt * std::sinh(eta); const double p = pt * std::cosh(eta); et = std::sqrt(p * p + cfg.mMass * cfg.mMass); @@ -421,17 +478,20 @@ class GeneratorPythia8LFRapidity : public o2::eventgen::GeneratorPythia8 } nConfig++; } - if (mVerbose) { + if (mVerbose) + { LOG(info) << "Printing particles that are appended"; int n = 0; - for (const auto& p : mParticles) { + for (const auto &p : mParticles) + { LOG(info) << "Particle " << n++ << " is a " << p.GetPdgCode() << " with status " << p.GetStatusCode() << " and px = " << p.Py() << " py = " << p.Py() << " pz = " << p.Pz(); } } return true; } - struct ConfigContainer { + struct ConfigContainer + { ConfigContainer(int input_pdg = 0, int n = 1, float ptMin = 1, float ptMax = 10, float min = -1, float max = 1) : mPdg{input_pdg}, @@ -443,14 +503,15 @@ class GeneratorPythia8LFRapidity : public o2::eventgen::GeneratorPythia8 { // mMass = getMassFromPDG(mPdg); mMass = GeneratorPythia8LongLivedGun::getMass(mPdg); - if (mMass <= 0) { + if (mMass <= 0) + { LOG(fatal) << "Could not find mass for mPdg " << mPdg; } LOGF(info, "ConfigContainer: mPdg = %i, mNInject = %i, mPtMin = %f, mPtMax = %f, mMin = %f, mMax = %f, mMass = %f", mPdg, mNInject, mPtMin, mPtMax, mMin, mMax, mMass); }; - ConfigContainer(TObjArray* arr) : ConfigContainer(atoi(arr->At(0)->GetName()), + ConfigContainer(TObjArray *arr) : ConfigContainer(atoi(arr->At(0)->GetName()), atoi(arr->At(1)->GetName()), atof(arr->At(2)->GetName()), atof(arr->At(3)->GetName()), @@ -458,31 +519,38 @@ class GeneratorPythia8LFRapidity : public o2::eventgen::GeneratorPythia8 atof(arr->At(5)->GetName())) { bool hasGenDecayed = false; - for (int i = 0; i < arr->GetEntries(); i++) { + for (int i = 0; i < arr->GetEntries(); i++) + { const TString n = arr->At(i)->GetName(); std::cout << n << std::endl; - if (n == "genDecayed") { + if (n == "genDecayed") + { hasGenDecayed = true; break; } } - if (hasGenDecayed) { - if (arr->GetEntries() != 7) { + if (hasGenDecayed) + { + if (arr->GetEntries() != 7) + { LOG(fatal) << "Wrong number of entries in the configuration array, should be 7, is " << arr->GetEntries(); } - } else { - if (arr->GetEntries() != 6) { + } + else + { + if (arr->GetEntries() != 6) + { LOG(fatal) << "Wrong number of entries in the configuration array, should be 6, is " << arr->GetEntries(); } } }; ConfigContainer(TString line) : ConfigContainer(line.Tokenize(" ")) {}; - ConfigContainer(const nlohmann::json& jsonParams, bool useRapidity = false) : ConfigContainer(jsonParams["pdg"], - jsonParams["n"], - jsonParams["ptMin"], - jsonParams["ptMax"], - (useRapidity && jsonParams.contains("rapidityMin")) ? jsonParams["rapidityMin"] : (jsonParams.contains("min") ? jsonParams["min"] : jsonParams["etaMin"]), - (useRapidity && jsonParams.contains("rapidityMax")) ? jsonParams["rapidityMax"] : (jsonParams.contains("max") ? jsonParams["max"] : jsonParams["etaMax"])) {}; + ConfigContainer(const nlohmann::json &jsonParams, bool useRapidity = false) : ConfigContainer(jsonParams["pdg"], + jsonParam["n"], + jsonParam["ptMin"], + jsonParam["ptMax"], + (useRapidty &&jsonParam.contain("rapiditMin")) ?jsonParam["rapiditMin"] :(jsonParams.contains("min") ? jsonParams["min"] : jsonParams["etaMin"]), + (useRapidty &&jsonParam.contain("rapiditMax")) ?jsonParam["rapiditMax"] :(jsonParas.contain("max") ?jsonParam["max"] :jsonParam["etaMax")) {}; // Data Members const int mPdg = 0; @@ -508,7 +576,8 @@ class GeneratorPythia8LFRapidity : public o2::eventgen::GeneratorPythia8 //__________________________________________________________________ ConfigContainer addGun(int input_pdg, int nInject = 1, float ptMin = 1, float ptMax = 10, float min = 1, float max = 10) { - if (mUseTriggering) { // If in trigger mode, every particle needs to be generated from pythia + if (mUseTriggering) + { // If in trigger mode, every particle needs to be generated from pythia return addGunGenDecayed(input_pdg, nInject, ptMin, ptMax, min, max); } ConfigContainer cfg{input_pdg, nInject, ptMin, ptMax, min, max}; @@ -539,13 +608,15 @@ class GeneratorPythia8LFRapidity : public o2::eventgen::GeneratorPythia8 LOG(info) << "GeneratorPythia8LFRapidity configuration with " << getNGuns() << " guns:"; LOG(info) << "Particles decayed by the transport:"; int n = 0; - for (const auto& cfg : mGunConfigs) { + for (const auto &cfg : mGunConfigs) + { LOG(info) << n++ << "/" << mGunConfigs.size() << ":"; cfg.print(); } n = 0; LOG(info) << "Particles decayed by the generator:"; - for (const auto& cfg : mGunConfigsGenDecayed) { + for (const auto &cfg : mGunConfigsGenDecayed) + { LOG(info) << n++ << "/" << mGunConfigs.size() << ":"; cfg.print(); } @@ -553,7 +624,7 @@ class GeneratorPythia8LFRapidity : public o2::eventgen::GeneratorPythia8 void setVerbose(bool verbose = true) { mVerbose = verbose; } - private: +private: // Configuration const bool mOneInjectionPerEvent = true; // if true, only one injection per event is performed, i.e. if multiple PDG (including antiparticles) are requested to be injected only one will be done per event const bool mUseTriggering = false; // if true, use triggering instead of injection @@ -574,15 +645,17 @@ class GeneratorPythia8LFRapidity : public o2::eventgen::GeneratorPythia8 ///___________________________________________________________ /// Create generator via arrays of entries. By default injecting in every event and all particles -FairGenerator* generateLFRapidity(std::vector PDGs, std::vector nInject, std::vector ptMin, std::vector ptMax, std::vector min, std::vector max, bool useRapidity = false) +FairGenerator *generateLFRapidity(std::vector PDGs, std::vector nInject, std::vector ptMin, std::vector ptMax, std::vector min, std::vector max, bool useRapidity = false) { const std::vector entries = {PDGs.size(), nInject.size(), ptMin.size(), ptMax.size(), min.size(), max.size()}; - if (!std::equal(entries.begin() + 1, entries.end(), entries.begin())) { + if (!std::equal(entries.begin() + 1, entries.end(), entries.begin())) + { LOGF(fatal, "Not equal number of entries, check configuration"); return nullptr; } - GeneratorPythia8LFRapidity* multiGun = new GeneratorPythia8LFRapidity(false, 0, false, useRapidity, "", ""); - for (unsigned long i = 0; i < entries[0]; i++) { + GeneratorPythia8LFRapidity *multiGun = new GeneratorPythia8LFRapidity(false, 0, false, useRapidity, "", ""); + for (unsigned long i = 0; i < entries[0]; i++) + { multiGun->addGun(PDGs[i], nInject[i], ptMin[i], ptMax[i], min[i], max[i]); } return multiGun; @@ -590,7 +663,7 @@ FairGenerator* generateLFRapidity(std::vector PDGs, std::vector nInjec ///___________________________________________________________ /// Create generator via an array of configurations -FairGenerator* generateLFRapidity(std::vector cfg, +FairGenerator *generateLFRapidity(std::vector cfg, std::vector cfgGenDecayed, bool injectOnePDGPerEvent = true, int gapBetweenInjection = 0, @@ -599,13 +672,15 @@ FairGenerator* generateLFRapidity(std::vectorgetNGuns()); c.print(); multiGun->addGun(c); } - for (const auto& c : cfgGenDecayed) { + for (const auto &c : cfgGenDecayed) + { LOGF(info, "Adding gun %i, particle will be decayed by the generator", multiGun->getNGuns()); c.print(); multiGun->addGunGenDecayed(c); @@ -616,7 +691,7 @@ FairGenerator* generateLFRapidity(std::vector(), param}); - if (param["genDecayed"]) { + if (param["genDecayed"]) + { cfgVecGenDecayed.push_back(GeneratorPythia8LFRapidity::ConfigContainer{param, useRapidity}); - } else { + } + else + { cfgVec.push_back(GeneratorPythia8LFRapidity::ConfigContainer{param, useRapidity}); } } - } else { + } + else + { std::string l; int n = 0; - while (getline(inputFile, l)) { + while (getline(inputFile, l)) + { TString line = l; line.Strip(TString::kBoth, ' '); std::cout << n++ << " '" << line << "'" << endl; - if (line.IsNull() || line.IsWhitespace()) { + if (line.IsNull() || line.IsWhitespace()) + { continue; } - if (line.BeginsWith("#")) { + if (line.BeginsWith("#")) + { std::cout << "Skipping\n"; continue; } - if (line.Contains("genDecayed")) { + if (line.Contains("genDecayed")) + { cfgVecGenDecayed.push_back(GeneratorPythia8LFRapidity::ConfigContainer{line}); - } else { + } + else + { cfgVec.push_back(GeneratorPythia8LFRapidity::ConfigContainer{line}); } } @@ -671,7 +760,7 @@ FairGenerator* generateLFRapidity(std::string configuration = "${O2DPG_MC_CONFIG ///___________________________________________________________ /// Create generator via input file for the triggered mode -FairGenerator* generateLFRapidityTriggered(std::string configuration = "${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator/exotic_nuclei_pp.gun", +FairGenerator *generateLFRapidityTriggered(std::string configuration = "${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator/exotic_nuclei_pp.gun", int gapBetweenInjection = 0, bool useRapidity = false, std::string pythiaCfgMb = "", @@ -681,16 +770,18 @@ FairGenerator* generateLFRapidityTriggered(std::string configuration = "${O2DPG_ } ///___________________________________________________________ -void generator_pythia8_LF_rapidity(bool testInj = true, bool testTrg = false, bool useRapidity = false, const char* particleListFile = "cfg_rapidity.json") +void generator_pythia8_LF_rapidity(bool testInj = true, bool testTrg = false, bool useRapidity = false, const char *particleListFile = "cfg_rapidity.json") { LOG(info) << "Compiled correctly!"; - if (!testInj && !testTrg) { + if (!testInj && !testTrg) + { return; } // Injected mode - if (testInj) { + if (testInj) + { LOG(info) << "Testing the injected mode"; - auto* gen = static_cast(generateLFRapidity(particleListFile, true, 0, false, useRapidity)); + auto *gen = static_cast(generateLFRapidity(particleListFile, true, 0, false, useRapidity)); gen->setVerbose(); gen->Print(); gen->print(); @@ -700,13 +791,14 @@ void generator_pythia8_LF_rapidity(bool testInj = true, bool testTrg = false, bo } // Triggered mode - if (testTrg) { + if (testTrg) + { LOG(info) << "Testing the triggered mode"; - GeneratorPythia8LFRapidity* gen = static_cast(generateLFRapidityTriggered(particleListFile, - /*gapBetweenInjection=*/0, - useRapidity, - /*pythiaCfgMb=*/"inel136tev.cfg", - /*pythiaCfgSignal=*/"inel136tev.cfg")); + GeneratorPythia8LFRapidity *gen = static_cast(generateLFRapidityTriggered(particleListFile, + /*gapBetweenInjection=*/0, + useRapidity, + /*pythiaCfgMb=*/"inel136tev.cfg", + /*pythiaCfgSignal=*/"inel136tev.cfg")); gen->setVerbose(); gen->Print(); gen->print(); From 8b349c1d21dd2a10240bccfc3754160951b00095 Mon Sep 17 00:00:00 2001 From: sawankumawat Date: Thu, 2 Apr 2026 22:04:23 +0530 Subject: [PATCH 2/3] recovered the generator code --- .../pythia8/generator_pythia8_LF_rapidity.C | 324 +++++++----------- 1 file changed, 116 insertions(+), 208 deletions(-) diff --git a/MC/config/PWGLF/pythia8/generator_pythia8_LF_rapidity.C b/MC/config/PWGLF/pythia8/generator_pythia8_LF_rapidity.C index 9c6e73e5c..7a4a3b090 100644 --- a/MC/config/PWGLF/pythia8/generator_pythia8_LF_rapidity.C +++ b/MC/config/PWGLF/pythia8/generator_pythia8_LF_rapidity.C @@ -66,7 +66,7 @@ using namespace o2::mcgenstatus; class GeneratorPythia8LFRapidity : public o2::eventgen::GeneratorPythia8 { -public: + public: /// Parametric constructor GeneratorPythia8LFRapidity(bool injOnePerEvent = true, int gapBetweenInjection = 0, @@ -74,10 +74,10 @@ public: bool useRapidity = false, std::string pythiaCfgMb = "${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator/pythia8_inel_136tev.cfg", std::string pythiaCfgSignal = "${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator/pythia8_inel_136tev.cfg") : GeneratorPythia8{}, - mOneInjectionPerEvent{injOnePerEvent}, - mGapBetweenInjection{gapBetweenInjection}, - mUseTriggering{useTrigger}, - mUseRapidity{useRapidity} + mOneInjectionPerEvent{injOnePerEvent}, + mGapBetweenInjection{gapBetweenInjection}, + mUseTriggering{useTrigger}, + mUseRapidity{useRapidity} { LOG(info) << "GeneratorPythia8LFRapidity constructor"; LOG(info) << "++ mOneInjectionPerEvent: " << mOneInjectionPerEvent; @@ -87,19 +87,16 @@ public: LOG(info) << "++ pythiaCfgMb: " << pythiaCfgMb; LOG(info) << "++ pythiaCfgSignal: " << pythiaCfgSignal; gRandom->SetSeed(0); - if (useTrigger) - { + if (useTrigger) { mPythia.readString("ProcessLevel:all off"); - if (pythiaCfgMb == "") - { // If no configuration file is provided, use the one from the Pythia8Param - auto ¶m = o2::eventgen::GeneratorPythia8Param::Instance(); + if (pythiaCfgMb == "") { // If no configuration file is provided, use the one from the Pythia8Param + auto& param = o2::eventgen::GeneratorPythia8Param::Instance(); LOG(info) << "Instance LFRapidity \'Pythia8\' generator with following parameters for MB event"; LOG(info) << param; pythiaCfgMb = param.config; } - if (pythiaCfgSignal == "") - { // If no configuration file is provided, use the one from the Pythia8Param - auto ¶m = o2::eventgen::GeneratorPythia8Param::Instance(); + if (pythiaCfgSignal == "") { // If no configuration file is provided, use the one from the Pythia8Param + auto& param = o2::eventgen::GeneratorPythia8Param::Instance(); LOG(info) << "Instance LFRapidity \'Pythia8\' generator with following parameters for signal event"; LOG(info) << param; pythiaCfgSignal = param.config; @@ -107,73 +104,60 @@ public: pythiaCfgMb = gSystem->ExpandPathName(pythiaCfgMb.c_str()); pythiaCfgSignal = gSystem->ExpandPathName(pythiaCfgSignal.c_str()); LOG(info) << " ++ Using trigger, initializing Pythia8 for trigger"; - if (!pythiaObjectMinimumBias.readFile(pythiaCfgMb)) - { + if (!pythiaObjectMinimumBias.readFile(pythiaCfgMb)) { LOG(fatal) << "Could not pythiaObjectMinimumBias.readFile(\"" << pythiaCfgMb << "\")"; } pythiaObjectMinimumBias.readString("Random:setSeed = on"); pythiaObjectMinimumBias.readString("Random:seed =" + std::to_string(gRandom->Integer(900000000 - 2) + 1)); // FIX: Init signal pythia object - if (!pythiaObjectSignal.readFile(pythiaCfgSignal)) - { + if (!pythiaObjectSignal.readFile(pythiaCfgSignal)) { LOG(fatal) << "Could not pythiaObjectSignal.readFile(\"" << pythiaCfgSignal << "\")"; } pythiaObjectSignal.readString("Random:setSeed = on"); pythiaObjectSignal.readString("Random:seed =" + std::to_string(gRandom->Integer(900000000 - 2) + 1)); - if (!pythiaObjectMinimumBias.init()) - { + if (!pythiaObjectMinimumBias.init()) { LOG(fatal) << "Could not pythiaObjectMinimumBias.init() from " << pythiaCfgMb; } - if (!pythiaObjectSignal.init()) - { + if (!pythiaObjectSignal.init()) { LOG(fatal) << "Could not pythiaObjectSignal.init() from " << pythiaCfgSignal; } - } - else - { // Using simple injection with internal decay (if needed). Fetching the parameters from the configuration file of the PythiaDecayer + } else { // Using simple injection with internal decay (if needed). Fetching the parameters from the configuration file of the PythiaDecayer - if (pythiaCfgMb == "") - { // If no configuration file is provided, use the one from the Pythia8Param - auto ¶m = o2::eventgen::GeneratorPythia8Param::Instance(); + if (pythiaCfgMb == "") { // If no configuration file is provided, use the one from the Pythia8Param + auto& param = o2::eventgen::GeneratorPythia8Param::Instance(); LOG(info) << "Instance LFRapidity \'Pythia8\' generator with following parameters for MB event"; LOG(info) << param; pythiaCfgMb = param.config; } // FIX: Fallback if still empty to default minbias - if (pythiaCfgMb == "") - { + if (pythiaCfgMb == "") { pythiaCfgMb = "${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator/pythia8_inel_136tev.cfg"; } pythiaCfgMb = gSystem->ExpandPathName(pythiaCfgMb.c_str()); - if (!pythiaObjectMinimumBias.readFile(pythiaCfgMb)) - { + if (!pythiaObjectMinimumBias.readFile(pythiaCfgMb)) { LOG(fatal) << "Could not pythiaObjectMinimumBias.readFile(\"" << pythiaCfgMb << "\")"; } pythiaObjectMinimumBias.readString("Random:setSeed = on"); pythiaObjectMinimumBias.readString("Random:seed =" + std::to_string(gRandom->Integer(900000000 - 2) + 1)); - if (!pythiaObjectMinimumBias.init()) - { + if (!pythiaObjectMinimumBias.init()) { LOG(fatal) << "Could not pythiaObjectMinimumBias.init() from " << pythiaCfgMb; } /** switch off process level **/ mPythiaGun.readString("ProcessLevel:all off"); - auto ¶m = o2::eventgen::DecayerPythia8Param::Instance(); + auto& param = o2::eventgen::DecayerPythia8Param::Instance(); LOG(info) << "Init \'GeneratorPythia8LFRapidity\' with following parameters"; LOG(info) << param; - for (int i = 0; i < 8; ++i) - { - if (param.config[i].empty()) - { + for (int i = 0; i < 8; ++i) { + if (param.config[i].empty()) { continue; } std::string config = gSystem->ExpandPathName(param.config[i].c_str()); LOG(info) << "GeneratorPythia8LFRapidity Reading configuration from file: " << config; - if (!mPythiaGun.readFile(config, true)) - { + if (!mPythiaGun.readFile(config, true)) { LOG(fatal) << "Failed to init \'DecayerPythia8\': problems with configuration file " << config; return; @@ -181,23 +165,18 @@ public: } /** show changed particle data **/ - if (param.showChanged) - { + if (param.showChanged) { mPythiaGun.readString(std::string("Init:showChangedParticleData on")); - } - else - { + } else { mPythiaGun.readString(std::string("Init:showChangedParticleData off")); } /** initialise **/ - if (!mPythiaGun.init()) - { + if (!mPythiaGun.init()) { LOG(fatal) << "Failed to init \'DecayerPythia8\': init returned with error"; return; } - if (pythiaCfgSignal != "") - { + if (pythiaCfgSignal != "") { LOG(fatal) << "Cannot use simple injection and have a configuration file. pythiaCfgSignal= `" << pythiaCfgSignal << "` must be empty"; } } @@ -209,34 +188,27 @@ public: //__________________________________________________________________ Bool_t generateEvent() override { - if (!mUseTriggering) - { // Injected mode: Embedding into MB + if (!mUseTriggering) { // Injected mode: Embedding into MB // 1. Generate Background (MB) // LOG(info) << "Generating background event " << mEventCounter; bool lGenerationOK = false; - while (!lGenerationOK) - { + while (!lGenerationOK) { lGenerationOK = pythiaObjectMinimumBias.next(); } mPythia.event = pythiaObjectMinimumBias.event; // 2. Determine if we inject specific particles (Gap logic) bool doInjection = true; - if (mGapBetweenInjection > 0) - { - if (mGapBetweenInjection == 1 && mEventCounter % 2 == 0) - { + if (mGapBetweenInjection > 0) { + if (mGapBetweenInjection == 1 && mEventCounter % 2 == 0) { doInjection = false; - } - else if (mEventCounter % mGapBetweenInjection != 0) - { + } else if (mEventCounter % mGapBetweenInjection != 0) { doInjection = false; } } - if (!doInjection) - { + if (!doInjection) { LOG(info) << "Skipping injection for event " << mEventCounter; return true; } @@ -245,8 +217,7 @@ public: LOG(info) << "generateEvent (Injection) " << mEventCounter; // For Triggered mode, we start clean. For Injected mode, we have MB in mPythia.event - if (mUseTriggering) - { + if (mUseTriggering) { mPythia.event.reset(); } @@ -255,39 +226,31 @@ public: bool injectedForThisEvent = false; int nConfig = mGunConfigs.size(); // We start counting from the configurations of the transport decayed particles - for (const ConfigContainer &cfg : mGunConfigsGenDecayed) - { + for (const ConfigContainer& cfg : mGunConfigsGenDecayed) { nConfig++; - if (mConfigToUse >= 0 && (nConfig - 1) != mConfigToUse) - { + if (mConfigToUse >= 0 && (nConfig - 1) != mConfigToUse) { continue; } LOG(info) << "Using config container "; cfg.print(); - if (mUseTriggering) - { // Do the triggering + if (mUseTriggering) { // Do the triggering bool doSignal{mEventCounter % (mGapBetweenInjection + 1) == 0}; // Do signal or gap - if (doSignal) - { + if (doSignal) { LOG(info) << "Generating triggered signal event for particle"; cfg.print(); bool satisfiesTrigger = false; int nTries = 0; - while (!satisfiesTrigger) - { - if (!pythiaObjectSignal.next()) - { + while (!satisfiesTrigger) { + if (!pythiaObjectSignal.next()) { continue; } // Check if triggered condition satisfied - for (int j = 0; j < pythiaObjectSignal.event.size(); j++) - { - const int &pypid = pythiaObjectSignal.event[j].id(); - const float &pyeta = mUseRapidity ? pythiaObjectSignal.event[j].y() : pythiaObjectSignal.event[j].eta(); - const float &pypt = pythiaObjectSignal.event[j].pT(); - if (pypid == cfg.mPdg && cfg.mMin < pyeta && pyeta < cfg.mMax && pypt > cfg.mPtMin && pypt < cfg.mPtMax) - { + for (int j = 0; j < pythiaObjectSignal.event.size(); j++) { + const int& pypid = pythiaObjectSignal.event[j].id(); + const float& pyeta = mUseRapidity ? pythiaObjectSignal.event[j].y() : pythiaObjectSignal.event[j].eta(); + const float& pypt = pythiaObjectSignal.event[j].pT(); + if (pypid == cfg.mPdg && cfg.mMin < pyeta && pyeta < cfg.mMax && pypt > cfg.mPtMin && pypt < cfg.mPtMax) { LOG(info) << "Found particle " << j << " " << pypid << " with " << (mUseRapidity ? "rapidity" : "eta") << " " << pyeta << " and pT " << pypt << " in event " << mEventCounter << " after " << nTries << " tries"; satisfiesTrigger = true; break; @@ -296,14 +259,11 @@ public: nTries++; } mPythia.event = pythiaObjectSignal.event; - } - else - { + } else { LOG(info) << "Generating background event " << mEventCounter; // Generate minimum-bias event bool lGenerationOK = false; - while (!lGenerationOK) - { + while (!lGenerationOK) { lGenerationOK = pythiaObjectMinimumBias.next(); } mPythia.event = pythiaObjectMinimumBias.event; @@ -314,8 +274,7 @@ public: // Do the injection // Use mPythiaGun for separate generation and decay mPythiaGun.event.reset(); - for (int i{0}; i < cfg.mNInject; ++i) - { + for (int i{0}; i < cfg.mNInject; ++i) { const double pt = gRandom->Uniform(cfg.mPtMin, cfg.mPtMax); const double eta = gRandom->Uniform(cfg.mMin, cfg.mMax); const double phi = gRandom->Uniform(0, TMath::TwoPi()); @@ -325,15 +284,12 @@ public: double pz = 0; double et = 0; - if (mUseRapidity) - { + if (mUseRapidity) { // Rapidty Case const double mT = std::sqrt(cfg.mMass * cfg.mMass + pt * pt); pz = mT * std::sinh(eta); et = mT * std::cosh(eta); - } - else - { + } else { // Eta Case pz = pt * std::sinh(eta); const double p = pt * std::cosh(eta); @@ -362,9 +318,8 @@ public: int offset = mPythia.event.size(); LOG(info) << "Merging " << mPythiaGun.event.size() - 1 << " injected particles into MB event of size " << offset; - for (int i = 1; i < mPythiaGun.event.size(); ++i) - { // Skip system particle 0 - Particle &p = mPythiaGun.event[i]; + for (int i = 1; i < mPythiaGun.event.size(); ++i) { // Skip system particle 0 + Particle& p = mPythiaGun.event[i]; // Adjust history indices int mother1 = p.mother1(); int mother2 = p.mother2(); @@ -396,8 +351,7 @@ public: // But if we are in embedding mode, we just need to ensure the MB event is there. // The mGunConfigs are handled in importParticles. - if (mVerbose) - { + if (mVerbose) { LOG(info) << "Eventlisting"; mPythia.event.list(1); mPythia.stat(); @@ -408,17 +362,12 @@ public: //__________________________________________________________________ Bool_t importParticles() override { - if (!mUseTriggering) - { // If the triggering is used we handle the the gap when generating the signal - if (mGapBetweenInjection > 0) - { - if (mGapBetweenInjection == 1 && mEventCounter % 2 == 0) - { + if (!mUseTriggering) { // If the triggering is used we handle the the gap when generating the signal + if (mGapBetweenInjection > 0) { + if (mGapBetweenInjection == 1 && mEventCounter % 2 == 0) { LOG(info) << "Skipping importParticles event " << mEventCounter++; return true; - } - else if (mEventCounter % mGapBetweenInjection != 0) - { + } else if (mEventCounter % mGapBetweenInjection != 0) { LOG(info) << "Skipping importParticles event " << mEventCounter++; return true; } @@ -427,17 +376,14 @@ public: LOG(info) << "importParticles " << mEventCounter++; GeneratorPythia8::importParticles(); int nConfig = 0; - for (const ConfigContainer &cfg : mGunConfigs) - { + for (const ConfigContainer& cfg : mGunConfigs) { nConfig++; - if (mConfigToUse >= 0 && (nConfig - 1) != mConfigToUse) - { + if (mConfigToUse >= 0 && (nConfig - 1) != mConfigToUse) { continue; } LOGF(info, "Injecting %i particles with PDG %i, pT in [%f, %f], %s in [%f, %f]", cfg.mNInject, cfg.mPdg, cfg.mPtMin, cfg.mPtMax, (mUseRapidity ? "rapidity" : "eta"), cfg.mMin, cfg.mMax); - for (int i{0}; i < cfg.mNInject; ++i) - { + for (int i{0}; i < cfg.mNInject; ++i) { const double pt = gRandom->Uniform(cfg.mPtMin, cfg.mPtMax); const double eta = gRandom->Uniform(cfg.mMin, cfg.mMax); const double phi = gRandom->Uniform(0, TMath::TwoPi()); @@ -446,14 +392,11 @@ public: double pz = 0; double et = 0; - if (mUseRapidity) - { + if (mUseRapidity) { const double mT = std::sqrt(cfg.mMass * cfg.mMass + pt * pt); pz = mT * std::sinh(eta); et = mT * std::cosh(eta); - } - else - { + } else { pz = pt * std::sinh(eta); const double p = pt * std::cosh(eta); et = std::sqrt(p * p + cfg.mMass * cfg.mMass); @@ -478,20 +421,17 @@ public: } nConfig++; } - if (mVerbose) - { + if (mVerbose) { LOG(info) << "Printing particles that are appended"; int n = 0; - for (const auto &p : mParticles) - { + for (const auto& p : mParticles) { LOG(info) << "Particle " << n++ << " is a " << p.GetPdgCode() << " with status " << p.GetStatusCode() << " and px = " << p.Py() << " py = " << p.Py() << " pz = " << p.Pz(); } } return true; } - struct ConfigContainer - { + struct ConfigContainer { ConfigContainer(int input_pdg = 0, int n = 1, float ptMin = 1, float ptMax = 10, float min = -1, float max = 1) : mPdg{input_pdg}, @@ -503,15 +443,14 @@ public: { // mMass = getMassFromPDG(mPdg); mMass = GeneratorPythia8LongLivedGun::getMass(mPdg); - if (mMass <= 0) - { + if (mMass <= 0) { LOG(fatal) << "Could not find mass for mPdg " << mPdg; } LOGF(info, "ConfigContainer: mPdg = %i, mNInject = %i, mPtMin = %f, mPtMax = %f, mMin = %f, mMax = %f, mMass = %f", mPdg, mNInject, mPtMin, mPtMax, mMin, mMax, mMass); }; - ConfigContainer(TObjArray *arr) : ConfigContainer(atoi(arr->At(0)->GetName()), + ConfigContainer(TObjArray* arr) : ConfigContainer(atoi(arr->At(0)->GetName()), atoi(arr->At(1)->GetName()), atof(arr->At(2)->GetName()), atof(arr->At(3)->GetName()), @@ -519,38 +458,31 @@ public: atof(arr->At(5)->GetName())) { bool hasGenDecayed = false; - for (int i = 0; i < arr->GetEntries(); i++) - { + for (int i = 0; i < arr->GetEntries(); i++) { const TString n = arr->At(i)->GetName(); std::cout << n << std::endl; - if (n == "genDecayed") - { + if (n == "genDecayed") { hasGenDecayed = true; break; } } - if (hasGenDecayed) - { - if (arr->GetEntries() != 7) - { + if (hasGenDecayed) { + if (arr->GetEntries() != 7) { LOG(fatal) << "Wrong number of entries in the configuration array, should be 7, is " << arr->GetEntries(); } - } - else - { - if (arr->GetEntries() != 6) - { + } else { + if (arr->GetEntries() != 6) { LOG(fatal) << "Wrong number of entries in the configuration array, should be 6, is " << arr->GetEntries(); } } }; ConfigContainer(TString line) : ConfigContainer(line.Tokenize(" ")) {}; - ConfigContainer(const nlohmann::json &jsonParams, bool useRapidity = false) : ConfigContainer(jsonParams["pdg"], - jsonParam["n"], - jsonParam["ptMin"], - jsonParam["ptMax"], - (useRapidty &&jsonParam.contain("rapiditMin")) ?jsonParam["rapiditMin"] :(jsonParams.contains("min") ? jsonParams["min"] : jsonParams["etaMin"]), - (useRapidty &&jsonParam.contain("rapiditMax")) ?jsonParam["rapiditMax"] :(jsonParas.contain("max") ?jsonParam["max"] :jsonParam["etaMax")) {}; + ConfigContainer(const nlohmann::json& jsonParams, bool useRapidity = false) : ConfigContainer(jsonParams["pdg"], + jsonParams["n"], + jsonParams["ptMin"], + jsonParams["ptMax"], + (useRapidity && jsonParams.contains("rapidityMin")) ? jsonParams["rapidityMin"] : (jsonParams.contains("min") ? jsonParams["min"] : jsonParams["etaMin"]), + (useRapidity && jsonParams.contains("rapidityMax")) ? jsonParams["rapidityMax"] : (jsonParams.contains("max") ? jsonParams["max"] : jsonParams["etaMax"])) {}; // Data Members const int mPdg = 0; @@ -576,8 +508,7 @@ public: //__________________________________________________________________ ConfigContainer addGun(int input_pdg, int nInject = 1, float ptMin = 1, float ptMax = 10, float min = 1, float max = 10) { - if (mUseTriggering) - { // If in trigger mode, every particle needs to be generated from pythia + if (mUseTriggering) { // If in trigger mode, every particle needs to be generated from pythia return addGunGenDecayed(input_pdg, nInject, ptMin, ptMax, min, max); } ConfigContainer cfg{input_pdg, nInject, ptMin, ptMax, min, max}; @@ -608,15 +539,13 @@ public: LOG(info) << "GeneratorPythia8LFRapidity configuration with " << getNGuns() << " guns:"; LOG(info) << "Particles decayed by the transport:"; int n = 0; - for (const auto &cfg : mGunConfigs) - { + for (const auto& cfg : mGunConfigs) { LOG(info) << n++ << "/" << mGunConfigs.size() << ":"; cfg.print(); } n = 0; LOG(info) << "Particles decayed by the generator:"; - for (const auto &cfg : mGunConfigsGenDecayed) - { + for (const auto& cfg : mGunConfigsGenDecayed) { LOG(info) << n++ << "/" << mGunConfigs.size() << ":"; cfg.print(); } @@ -624,7 +553,7 @@ public: void setVerbose(bool verbose = true) { mVerbose = verbose; } -private: + private: // Configuration const bool mOneInjectionPerEvent = true; // if true, only one injection per event is performed, i.e. if multiple PDG (including antiparticles) are requested to be injected only one will be done per event const bool mUseTriggering = false; // if true, use triggering instead of injection @@ -645,17 +574,15 @@ private: ///___________________________________________________________ /// Create generator via arrays of entries. By default injecting in every event and all particles -FairGenerator *generateLFRapidity(std::vector PDGs, std::vector nInject, std::vector ptMin, std::vector ptMax, std::vector min, std::vector max, bool useRapidity = false) +FairGenerator* generateLFRapidity(std::vector PDGs, std::vector nInject, std::vector ptMin, std::vector ptMax, std::vector min, std::vector max, bool useRapidity = false) { const std::vector entries = {PDGs.size(), nInject.size(), ptMin.size(), ptMax.size(), min.size(), max.size()}; - if (!std::equal(entries.begin() + 1, entries.end(), entries.begin())) - { + if (!std::equal(entries.begin() + 1, entries.end(), entries.begin())) { LOGF(fatal, "Not equal number of entries, check configuration"); return nullptr; } - GeneratorPythia8LFRapidity *multiGun = new GeneratorPythia8LFRapidity(false, 0, false, useRapidity, "", ""); - for (unsigned long i = 0; i < entries[0]; i++) - { + GeneratorPythia8LFRapidity* multiGun = new GeneratorPythia8LFRapidity(false, 0, false, useRapidity, "", ""); + for (unsigned long i = 0; i < entries[0]; i++) { multiGun->addGun(PDGs[i], nInject[i], ptMin[i], ptMax[i], min[i], max[i]); } return multiGun; @@ -663,7 +590,7 @@ FairGenerator *generateLFRapidity(std::vector PDGs, std::vector nInjec ///___________________________________________________________ /// Create generator via an array of configurations -FairGenerator *generateLFRapidity(std::vector cfg, +FairGenerator* generateLFRapidity(std::vector cfg, std::vector cfgGenDecayed, bool injectOnePDGPerEvent = true, int gapBetweenInjection = 0, @@ -672,15 +599,13 @@ FairGenerator *generateLFRapidity(std::vectorgetNGuns()); c.print(); multiGun->addGun(c); } - for (const auto &c : cfgGenDecayed) - { + for (const auto& c : cfgGenDecayed) { LOGF(info, "Adding gun %i, particle will be decayed by the generator", multiGun->getNGuns()); c.print(); multiGun->addGunGenDecayed(c); @@ -691,7 +616,7 @@ FairGenerator *generateLFRapidity(std::vector(), param}); - if (param["genDecayed"]) - { + if (param["genDecayed"]) { cfgVecGenDecayed.push_back(GeneratorPythia8LFRapidity::ConfigContainer{param, useRapidity}); - } - else - { + } else { cfgVec.push_back(GeneratorPythia8LFRapidity::ConfigContainer{param, useRapidity}); } } - } - else - { + } else { std::string l; int n = 0; - while (getline(inputFile, l)) - { + while (getline(inputFile, l)) { TString line = l; line.Strip(TString::kBoth, ' '); std::cout << n++ << " '" << line << "'" << endl; - if (line.IsNull() || line.IsWhitespace()) - { + if (line.IsNull() || line.IsWhitespace()) { continue; } - if (line.BeginsWith("#")) - { + if (line.BeginsWith("#")) { std::cout << "Skipping\n"; continue; } - if (line.Contains("genDecayed")) - { + if (line.Contains("genDecayed")) { cfgVecGenDecayed.push_back(GeneratorPythia8LFRapidity::ConfigContainer{line}); - } - else - { + } else { cfgVec.push_back(GeneratorPythia8LFRapidity::ConfigContainer{line}); } } @@ -760,7 +671,7 @@ FairGenerator *generateLFRapidity(std::string configuration = "${O2DPG_MC_CONFIG ///___________________________________________________________ /// Create generator via input file for the triggered mode -FairGenerator *generateLFRapidityTriggered(std::string configuration = "${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator/exotic_nuclei_pp.gun", +FairGenerator* generateLFRapidityTriggered(std::string configuration = "${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator/exotic_nuclei_pp.gun", int gapBetweenInjection = 0, bool useRapidity = false, std::string pythiaCfgMb = "", @@ -770,18 +681,16 @@ FairGenerator *generateLFRapidityTriggered(std::string configuration = "${O2DPG_ } ///___________________________________________________________ -void generator_pythia8_LF_rapidity(bool testInj = true, bool testTrg = false, bool useRapidity = false, const char *particleListFile = "cfg_rapidity.json") +void generator_pythia8_LF_rapidity(bool testInj = true, bool testTrg = false, bool useRapidity = false, const char* particleListFile = "cfg_rapidity.json") { LOG(info) << "Compiled correctly!"; - if (!testInj && !testTrg) - { + if (!testInj && !testTrg) { return; } // Injected mode - if (testInj) - { + if (testInj) { LOG(info) << "Testing the injected mode"; - auto *gen = static_cast(generateLFRapidity(particleListFile, true, 0, false, useRapidity)); + auto* gen = static_cast(generateLFRapidity(particleListFile, true, 0, false, useRapidity)); gen->setVerbose(); gen->Print(); gen->print(); @@ -791,14 +700,13 @@ void generator_pythia8_LF_rapidity(bool testInj = true, bool testTrg = false, bo } // Triggered mode - if (testTrg) - { + if (testTrg) { LOG(info) << "Testing the triggered mode"; - GeneratorPythia8LFRapidity *gen = static_cast(generateLFRapidityTriggered(particleListFile, - /*gapBetweenInjection=*/0, - useRapidity, - /*pythiaCfgMb=*/"inel136tev.cfg", - /*pythiaCfgSignal=*/"inel136tev.cfg")); + GeneratorPythia8LFRapidity* gen = static_cast(generateLFRapidityTriggered(particleListFile, + /*gapBetweenInjection=*/0, + useRapidity, + /*pythiaCfgMb=*/"inel136tev.cfg", + /*pythiaCfgSignal=*/"inel136tev.cfg")); gen->setVerbose(); gen->Print(); gen->print(); @@ -806,4 +714,4 @@ void generator_pythia8_LF_rapidity(bool testInj = true, bool testTrg = false, bo gen->generateEvent(); gen->importParticles(); } -} +} \ No newline at end of file From 9625369fc7b7ef8a2dffd2481a41dab9373a0e1b Mon Sep 17 00:00:00 2001 From: sawankumawat Date: Fri, 3 Apr 2026 11:15:49 +0530 Subject: [PATCH 3/3] added test scripts for the ini files and added f0(2200) resonance in the exotic list --- .../tests/GeneratorLF_Resonances_gap2_flaty.C | 156 ++++++++++++++++ .../tests/GeneratorLF_Resonances_gap4_flaty.C | 156 ++++++++++++++++ .../GeneratorLF_Resonances_pp_Glue_gap2.C | 150 ++++++++++++++++ ...eneratorLF_Resonances_pp_Glue_gap2_flaty.C | 150 ++++++++++++++++ .../GeneratorLF_Resonances_pp_Glue_gap4.C | 150 ++++++++++++++++ ...eneratorLF_Resonances_pp_Glue_gap4_flaty.C | 150 ++++++++++++++++ ...GeneratorLF_Resonances_pp_exoticAll_gap2.C | 2 + ...GeneratorLF_Resonances_pp_exoticAll_gap4.C | 167 ++++++++++++++++++ .../PWGLF/pythia8/generator/gluelistgun.json | 33 ++++ .../PWGLF/pythia8/generator/gluelistgun2.json | 90 ++++++++++ .../PWGLF/pythia8/generator/resonances.cfg | 10 ++ 11 files changed, 1214 insertions(+) create mode 100644 MC/config/PWGLF/ini/tests/GeneratorLF_Resonances_gap2_flaty.C create mode 100644 MC/config/PWGLF/ini/tests/GeneratorLF_Resonances_gap4_flaty.C create mode 100644 MC/config/PWGLF/ini/tests/GeneratorLF_Resonances_pp_Glue_gap2.C create mode 100644 MC/config/PWGLF/ini/tests/GeneratorLF_Resonances_pp_Glue_gap2_flaty.C create mode 100644 MC/config/PWGLF/ini/tests/GeneratorLF_Resonances_pp_Glue_gap4.C create mode 100644 MC/config/PWGLF/ini/tests/GeneratorLF_Resonances_pp_Glue_gap4_flaty.C create mode 100644 MC/config/PWGLF/ini/tests/GeneratorLF_Resonances_pp_exoticAll_gap4.C create mode 100644 MC/config/PWGLF/pythia8/generator/gluelistgun2.json diff --git a/MC/config/PWGLF/ini/tests/GeneratorLF_Resonances_gap2_flaty.C b/MC/config/PWGLF/ini/tests/GeneratorLF_Resonances_gap2_flaty.C new file mode 100644 index 000000000..da107bb43 --- /dev/null +++ b/MC/config/PWGLF/ini/tests/GeneratorLF_Resonances_gap2_flaty.C @@ -0,0 +1,156 @@ +int External() +{ + std::string path{"o2sim_Kine.root"}; + int numberOfInjectedSignalsPerEvent{1}; + int numberOfGapEvents{4}; + int numberOfEventsProcessed{0}; + int numberOfEventsProcessedWithoutInjection{0}; + std::vector injectedPDGs = { + 225, // f_2(1270) + 10221, // f_0(1370) + 9030221, // f_0(1500) + 10331, // f_0(1710) + 20223, // f_1(1285) + 20333, // f_1(1420) + 335, // f_2(1525) + 115, // a_2(1320) + 9070221, // f_0(2200) + 102134, // Lambda(1520)0 + -102134 // Lambda(1520)0bar + }; + std::vector> decayDaughters = { + {310, 310}, // f_2(1270) + {310, 310}, // f_0(1370) + {310, 310}, // f_0(1500) + {310, 310}, // f_0(1710) + {310, -321, 211}, // f_1(1285) + {310, -321, 211}, // f_1(1420) + {310, 310}, // f_2(1525) + {310, 310}, // a_2(1320) + {310, 310}, // f_0(2200) + {2212, -321}, // Lambda(1520)0 + {-2212, 321} // Lambda(1520)0bar + }; + + auto nInjection = injectedPDGs.size(); + + 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 *tracks{}; + tree->SetBranchAddress("MCTrack", &tracks); + + std::vector nSignal; + for (int i = 0; i < nInjection; i++) + { + nSignal.push_back(0); + } + std::vector> nDecays; + std::vector nNotDecayed; + for (int i = 0; i < nInjection; i++) + { + std::vector nDecay; + for (int j = 0; j < decayDaughters[i].size(); j++) + { + nDecay.push_back(0); + } + nDecays.push_back(nDecay); + nNotDecayed.push_back(0); + } + auto nEvents = tree->GetEntries(); + bool hasInjection = false; + for (int i = 0; i < nEvents; i++) + { + hasInjection = false; + numberOfEventsProcessed++; + auto check = tree->GetEntry(i); + for (int idxMCTrack = 0; idxMCTrack < tracks->size(); ++idxMCTrack) + { + auto track = tracks->at(idxMCTrack); + auto pdg = track.GetPdgCode(); + auto it = std::find(injectedPDGs.begin(), injectedPDGs.end(), pdg); + int index = std::distance(injectedPDGs.begin(), it); // index of injected PDG + if (it != injectedPDGs.end()) // found + { + // count signal PDG + nSignal[index]++; + if (track.getFirstDaughterTrackId() < 0) + { + nNotDecayed[index]++; + continue; + } + for (int j{track.getFirstDaughterTrackId()}; j <= track.getLastDaughterTrackId(); ++j) + { + auto pdgDau = tracks->at(j).GetPdgCode(); + bool foundDau = false; + // count decay PDGs + for (int idxDaughter = 0; idxDaughter < decayDaughters[index].size(); ++idxDaughter) + { + if (pdgDau == decayDaughters[index][idxDaughter]) + { + nDecays[index][idxDaughter]++; + foundDau = true; + hasInjection = true; + break; + } + } + if (!foundDau) + { + std::cerr << "Decay daughter not found: " << pdg << " -> " << pdgDau << "\n"; + } + } + } + } + if (!hasInjection) + { + numberOfEventsProcessedWithoutInjection++; + } + } + std::cout << "--------------------------------\n"; + std::cout << "# Events: " << nEvents << "\n"; + for (int i = 0; i < nInjection; i++) + { + std::cout << "# Mother \n"; + std::cout << injectedPDGs[i] << " generated: " << nSignal[i] << ", " << nNotDecayed[i] << " did not decay\n"; + if (nSignal[i] == 0) + { + std::cerr << "No generated: " << injectedPDGs[i] << "\n"; + // return 1; // At least one of the injected particles should be generated + } + for (int j = 0; j < decayDaughters[i].size(); j++) + { + std::cout << "# Daughter " << decayDaughters[i][j] << ": " << nDecays[i][j] << "\n"; + } + // if (nSignal[i] != nEvents * numberOfInjectedSignalsPerEvent) + // { + // std::cerr << "Number of generated: " << injectedPDGs[i] << ", lower than expected\n"; + // // return 1; // Don't need to return 1, since the number of generated particles is not the same for each event + // } + } + 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"; + // injected event + numberOfGapEvents*gap events + injected event + numberOfGapEvents*gap events + ... + // total fraction of the gap event: numberOfEventsProcessedWithoutInjection/numberOfEventsProcessed + float ratioOfNormalEvents = numberOfEventsProcessedWithoutInjection / numberOfEventsProcessed; + if (ratioOfNormalEvents > 0.75) + { + std::cout << "The number of injected event is loo low!!" << std::endl; + return 1; + } + + return 0; +} + +void GeneratorLF_Resonances_pp1360_injection() { External(); } diff --git a/MC/config/PWGLF/ini/tests/GeneratorLF_Resonances_gap4_flaty.C b/MC/config/PWGLF/ini/tests/GeneratorLF_Resonances_gap4_flaty.C new file mode 100644 index 000000000..da107bb43 --- /dev/null +++ b/MC/config/PWGLF/ini/tests/GeneratorLF_Resonances_gap4_flaty.C @@ -0,0 +1,156 @@ +int External() +{ + std::string path{"o2sim_Kine.root"}; + int numberOfInjectedSignalsPerEvent{1}; + int numberOfGapEvents{4}; + int numberOfEventsProcessed{0}; + int numberOfEventsProcessedWithoutInjection{0}; + std::vector injectedPDGs = { + 225, // f_2(1270) + 10221, // f_0(1370) + 9030221, // f_0(1500) + 10331, // f_0(1710) + 20223, // f_1(1285) + 20333, // f_1(1420) + 335, // f_2(1525) + 115, // a_2(1320) + 9070221, // f_0(2200) + 102134, // Lambda(1520)0 + -102134 // Lambda(1520)0bar + }; + std::vector> decayDaughters = { + {310, 310}, // f_2(1270) + {310, 310}, // f_0(1370) + {310, 310}, // f_0(1500) + {310, 310}, // f_0(1710) + {310, -321, 211}, // f_1(1285) + {310, -321, 211}, // f_1(1420) + {310, 310}, // f_2(1525) + {310, 310}, // a_2(1320) + {310, 310}, // f_0(2200) + {2212, -321}, // Lambda(1520)0 + {-2212, 321} // Lambda(1520)0bar + }; + + auto nInjection = injectedPDGs.size(); + + 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 *tracks{}; + tree->SetBranchAddress("MCTrack", &tracks); + + std::vector nSignal; + for (int i = 0; i < nInjection; i++) + { + nSignal.push_back(0); + } + std::vector> nDecays; + std::vector nNotDecayed; + for (int i = 0; i < nInjection; i++) + { + std::vector nDecay; + for (int j = 0; j < decayDaughters[i].size(); j++) + { + nDecay.push_back(0); + } + nDecays.push_back(nDecay); + nNotDecayed.push_back(0); + } + auto nEvents = tree->GetEntries(); + bool hasInjection = false; + for (int i = 0; i < nEvents; i++) + { + hasInjection = false; + numberOfEventsProcessed++; + auto check = tree->GetEntry(i); + for (int idxMCTrack = 0; idxMCTrack < tracks->size(); ++idxMCTrack) + { + auto track = tracks->at(idxMCTrack); + auto pdg = track.GetPdgCode(); + auto it = std::find(injectedPDGs.begin(), injectedPDGs.end(), pdg); + int index = std::distance(injectedPDGs.begin(), it); // index of injected PDG + if (it != injectedPDGs.end()) // found + { + // count signal PDG + nSignal[index]++; + if (track.getFirstDaughterTrackId() < 0) + { + nNotDecayed[index]++; + continue; + } + for (int j{track.getFirstDaughterTrackId()}; j <= track.getLastDaughterTrackId(); ++j) + { + auto pdgDau = tracks->at(j).GetPdgCode(); + bool foundDau = false; + // count decay PDGs + for (int idxDaughter = 0; idxDaughter < decayDaughters[index].size(); ++idxDaughter) + { + if (pdgDau == decayDaughters[index][idxDaughter]) + { + nDecays[index][idxDaughter]++; + foundDau = true; + hasInjection = true; + break; + } + } + if (!foundDau) + { + std::cerr << "Decay daughter not found: " << pdg << " -> " << pdgDau << "\n"; + } + } + } + } + if (!hasInjection) + { + numberOfEventsProcessedWithoutInjection++; + } + } + std::cout << "--------------------------------\n"; + std::cout << "# Events: " << nEvents << "\n"; + for (int i = 0; i < nInjection; i++) + { + std::cout << "# Mother \n"; + std::cout << injectedPDGs[i] << " generated: " << nSignal[i] << ", " << nNotDecayed[i] << " did not decay\n"; + if (nSignal[i] == 0) + { + std::cerr << "No generated: " << injectedPDGs[i] << "\n"; + // return 1; // At least one of the injected particles should be generated + } + for (int j = 0; j < decayDaughters[i].size(); j++) + { + std::cout << "# Daughter " << decayDaughters[i][j] << ": " << nDecays[i][j] << "\n"; + } + // if (nSignal[i] != nEvents * numberOfInjectedSignalsPerEvent) + // { + // std::cerr << "Number of generated: " << injectedPDGs[i] << ", lower than expected\n"; + // // return 1; // Don't need to return 1, since the number of generated particles is not the same for each event + // } + } + 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"; + // injected event + numberOfGapEvents*gap events + injected event + numberOfGapEvents*gap events + ... + // total fraction of the gap event: numberOfEventsProcessedWithoutInjection/numberOfEventsProcessed + float ratioOfNormalEvents = numberOfEventsProcessedWithoutInjection / numberOfEventsProcessed; + if (ratioOfNormalEvents > 0.75) + { + std::cout << "The number of injected event is loo low!!" << std::endl; + return 1; + } + + return 0; +} + +void GeneratorLF_Resonances_pp1360_injection() { External(); } diff --git a/MC/config/PWGLF/ini/tests/GeneratorLF_Resonances_pp_Glue_gap2.C b/MC/config/PWGLF/ini/tests/GeneratorLF_Resonances_pp_Glue_gap2.C new file mode 100644 index 000000000..c183e2c82 --- /dev/null +++ b/MC/config/PWGLF/ini/tests/GeneratorLF_Resonances_pp_Glue_gap2.C @@ -0,0 +1,150 @@ +int External() +{ + std::string path{"o2sim_Kine.root"}; + int numberOfInjectedSignalsPerEvent{1}; + int numberOfGapEvents{4}; + int numberOfEventsProcessed{0}; + int numberOfEventsProcessedWithoutInjection{0}; + std::vector injectedPDGs = { + 9010221, // f_0(980) + 225, // f_2(1270) + 115, // a_2(1320) + 10221, // f_0(1370) + 9030221, // f_0(1500) + 335, // f_2(1525) + 10331, // f_0(1710) + 9070221 // f_0(2200) + }; + std::vector> decayDaughters = { + {211, -211}, // f_0(980) + {310, 310}, // f_2(1270) + {310, 310}, // a_2(1320) + {310, 310}, // f_0(1370) + {310, 310}, // f_0(1500) + {310, 310}, // f_2(1525) + {310, 310}, // f_0(1710) + {310, 310}, // f_0(2200) + }; + + auto nInjection = injectedPDGs.size(); + + 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 *tracks{}; + tree->SetBranchAddress("MCTrack", &tracks); + + std::vector nSignal; + for (int i = 0; i < nInjection; i++) + { + nSignal.push_back(0); + } + std::vector> nDecays; + std::vector nNotDecayed; + for (int i = 0; i < nInjection; i++) + { + std::vector nDecay; + for (int j = 0; j < decayDaughters[i].size(); j++) + { + nDecay.push_back(0); + } + nDecays.push_back(nDecay); + nNotDecayed.push_back(0); + } + auto nEvents = tree->GetEntries(); + bool hasInjection = false; + for (int i = 0; i < nEvents; i++) + { + hasInjection = false; + numberOfEventsProcessed++; + auto check = tree->GetEntry(i); + for (int idxMCTrack = 0; idxMCTrack < tracks->size(); ++idxMCTrack) + { + auto track = tracks->at(idxMCTrack); + auto pdg = track.GetPdgCode(); + auto it = std::find(injectedPDGs.begin(), injectedPDGs.end(), pdg); + int index = std::distance(injectedPDGs.begin(), it); // index of injected PDG + if (it != injectedPDGs.end()) // found + { + // count signal PDG + nSignal[index]++; + if (track.getFirstDaughterTrackId() < 0) + { + nNotDecayed[index]++; + continue; + } + for (int j{track.getFirstDaughterTrackId()}; j <= track.getLastDaughterTrackId(); ++j) + { + auto pdgDau = tracks->at(j).GetPdgCode(); + bool foundDau = false; + // count decay PDGs + for (int idxDaughter = 0; idxDaughter < decayDaughters[index].size(); ++idxDaughter) + { + if (pdgDau == decayDaughters[index][idxDaughter]) + { + nDecays[index][idxDaughter]++; + foundDau = true; + hasInjection = true; + break; + } + } + if (!foundDau) + { + std::cerr << "Decay daughter not found: " << pdg << " -> " << pdgDau << "\n"; + } + } + } + } + if (!hasInjection) + { + numberOfEventsProcessedWithoutInjection++; + } + } + std::cout << "--------------------------------\n"; + std::cout << "# Events: " << nEvents << "\n"; + for (int i = 0; i < nInjection; i++) + { + std::cout << "# Mother \n"; + std::cout << injectedPDGs[i] << " generated: " << nSignal[i] << ", " << nNotDecayed[i] << " did not decay\n"; + if (nSignal[i] == 0) + { + std::cerr << "No generated: " << injectedPDGs[i] << "\n"; + // return 1; // At least one of the injected particles should be generated + } + for (int j = 0; j < decayDaughters[i].size(); j++) + { + std::cout << "# Daughter " << decayDaughters[i][j] << ": " << nDecays[i][j] << "\n"; + } + // if (nSignal[i] != nEvents * numberOfInjectedSignalsPerEvent) + // { + // std::cerr << "Number of generated: " << injectedPDGs[i] << ", lower than expected\n"; + // // return 1; // Don't need to return 1, since the number of generated particles is not the same for each event + // } + } + 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"; + // injected event + numberOfGapEvents*gap events + injected event + numberOfGapEvents*gap events + ... + // total fraction of the gap event: numberOfEventsProcessedWithoutInjection/numberOfEventsProcessed + float ratioOfNormalEvents = numberOfEventsProcessedWithoutInjection / numberOfEventsProcessed; + if (ratioOfNormalEvents > 0.75) + { + std::cout << "The number of injected event is loo low!!" << std::endl; + return 1; + } + + return 0; +} + +void GeneratorLF_Resonances_pp1360_injection() { External(); } diff --git a/MC/config/PWGLF/ini/tests/GeneratorLF_Resonances_pp_Glue_gap2_flaty.C b/MC/config/PWGLF/ini/tests/GeneratorLF_Resonances_pp_Glue_gap2_flaty.C new file mode 100644 index 000000000..c183e2c82 --- /dev/null +++ b/MC/config/PWGLF/ini/tests/GeneratorLF_Resonances_pp_Glue_gap2_flaty.C @@ -0,0 +1,150 @@ +int External() +{ + std::string path{"o2sim_Kine.root"}; + int numberOfInjectedSignalsPerEvent{1}; + int numberOfGapEvents{4}; + int numberOfEventsProcessed{0}; + int numberOfEventsProcessedWithoutInjection{0}; + std::vector injectedPDGs = { + 9010221, // f_0(980) + 225, // f_2(1270) + 115, // a_2(1320) + 10221, // f_0(1370) + 9030221, // f_0(1500) + 335, // f_2(1525) + 10331, // f_0(1710) + 9070221 // f_0(2200) + }; + std::vector> decayDaughters = { + {211, -211}, // f_0(980) + {310, 310}, // f_2(1270) + {310, 310}, // a_2(1320) + {310, 310}, // f_0(1370) + {310, 310}, // f_0(1500) + {310, 310}, // f_2(1525) + {310, 310}, // f_0(1710) + {310, 310}, // f_0(2200) + }; + + auto nInjection = injectedPDGs.size(); + + 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 *tracks{}; + tree->SetBranchAddress("MCTrack", &tracks); + + std::vector nSignal; + for (int i = 0; i < nInjection; i++) + { + nSignal.push_back(0); + } + std::vector> nDecays; + std::vector nNotDecayed; + for (int i = 0; i < nInjection; i++) + { + std::vector nDecay; + for (int j = 0; j < decayDaughters[i].size(); j++) + { + nDecay.push_back(0); + } + nDecays.push_back(nDecay); + nNotDecayed.push_back(0); + } + auto nEvents = tree->GetEntries(); + bool hasInjection = false; + for (int i = 0; i < nEvents; i++) + { + hasInjection = false; + numberOfEventsProcessed++; + auto check = tree->GetEntry(i); + for (int idxMCTrack = 0; idxMCTrack < tracks->size(); ++idxMCTrack) + { + auto track = tracks->at(idxMCTrack); + auto pdg = track.GetPdgCode(); + auto it = std::find(injectedPDGs.begin(), injectedPDGs.end(), pdg); + int index = std::distance(injectedPDGs.begin(), it); // index of injected PDG + if (it != injectedPDGs.end()) // found + { + // count signal PDG + nSignal[index]++; + if (track.getFirstDaughterTrackId() < 0) + { + nNotDecayed[index]++; + continue; + } + for (int j{track.getFirstDaughterTrackId()}; j <= track.getLastDaughterTrackId(); ++j) + { + auto pdgDau = tracks->at(j).GetPdgCode(); + bool foundDau = false; + // count decay PDGs + for (int idxDaughter = 0; idxDaughter < decayDaughters[index].size(); ++idxDaughter) + { + if (pdgDau == decayDaughters[index][idxDaughter]) + { + nDecays[index][idxDaughter]++; + foundDau = true; + hasInjection = true; + break; + } + } + if (!foundDau) + { + std::cerr << "Decay daughter not found: " << pdg << " -> " << pdgDau << "\n"; + } + } + } + } + if (!hasInjection) + { + numberOfEventsProcessedWithoutInjection++; + } + } + std::cout << "--------------------------------\n"; + std::cout << "# Events: " << nEvents << "\n"; + for (int i = 0; i < nInjection; i++) + { + std::cout << "# Mother \n"; + std::cout << injectedPDGs[i] << " generated: " << nSignal[i] << ", " << nNotDecayed[i] << " did not decay\n"; + if (nSignal[i] == 0) + { + std::cerr << "No generated: " << injectedPDGs[i] << "\n"; + // return 1; // At least one of the injected particles should be generated + } + for (int j = 0; j < decayDaughters[i].size(); j++) + { + std::cout << "# Daughter " << decayDaughters[i][j] << ": " << nDecays[i][j] << "\n"; + } + // if (nSignal[i] != nEvents * numberOfInjectedSignalsPerEvent) + // { + // std::cerr << "Number of generated: " << injectedPDGs[i] << ", lower than expected\n"; + // // return 1; // Don't need to return 1, since the number of generated particles is not the same for each event + // } + } + 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"; + // injected event + numberOfGapEvents*gap events + injected event + numberOfGapEvents*gap events + ... + // total fraction of the gap event: numberOfEventsProcessedWithoutInjection/numberOfEventsProcessed + float ratioOfNormalEvents = numberOfEventsProcessedWithoutInjection / numberOfEventsProcessed; + if (ratioOfNormalEvents > 0.75) + { + std::cout << "The number of injected event is loo low!!" << std::endl; + return 1; + } + + return 0; +} + +void GeneratorLF_Resonances_pp1360_injection() { External(); } diff --git a/MC/config/PWGLF/ini/tests/GeneratorLF_Resonances_pp_Glue_gap4.C b/MC/config/PWGLF/ini/tests/GeneratorLF_Resonances_pp_Glue_gap4.C new file mode 100644 index 000000000..c183e2c82 --- /dev/null +++ b/MC/config/PWGLF/ini/tests/GeneratorLF_Resonances_pp_Glue_gap4.C @@ -0,0 +1,150 @@ +int External() +{ + std::string path{"o2sim_Kine.root"}; + int numberOfInjectedSignalsPerEvent{1}; + int numberOfGapEvents{4}; + int numberOfEventsProcessed{0}; + int numberOfEventsProcessedWithoutInjection{0}; + std::vector injectedPDGs = { + 9010221, // f_0(980) + 225, // f_2(1270) + 115, // a_2(1320) + 10221, // f_0(1370) + 9030221, // f_0(1500) + 335, // f_2(1525) + 10331, // f_0(1710) + 9070221 // f_0(2200) + }; + std::vector> decayDaughters = { + {211, -211}, // f_0(980) + {310, 310}, // f_2(1270) + {310, 310}, // a_2(1320) + {310, 310}, // f_0(1370) + {310, 310}, // f_0(1500) + {310, 310}, // f_2(1525) + {310, 310}, // f_0(1710) + {310, 310}, // f_0(2200) + }; + + auto nInjection = injectedPDGs.size(); + + 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 *tracks{}; + tree->SetBranchAddress("MCTrack", &tracks); + + std::vector nSignal; + for (int i = 0; i < nInjection; i++) + { + nSignal.push_back(0); + } + std::vector> nDecays; + std::vector nNotDecayed; + for (int i = 0; i < nInjection; i++) + { + std::vector nDecay; + for (int j = 0; j < decayDaughters[i].size(); j++) + { + nDecay.push_back(0); + } + nDecays.push_back(nDecay); + nNotDecayed.push_back(0); + } + auto nEvents = tree->GetEntries(); + bool hasInjection = false; + for (int i = 0; i < nEvents; i++) + { + hasInjection = false; + numberOfEventsProcessed++; + auto check = tree->GetEntry(i); + for (int idxMCTrack = 0; idxMCTrack < tracks->size(); ++idxMCTrack) + { + auto track = tracks->at(idxMCTrack); + auto pdg = track.GetPdgCode(); + auto it = std::find(injectedPDGs.begin(), injectedPDGs.end(), pdg); + int index = std::distance(injectedPDGs.begin(), it); // index of injected PDG + if (it != injectedPDGs.end()) // found + { + // count signal PDG + nSignal[index]++; + if (track.getFirstDaughterTrackId() < 0) + { + nNotDecayed[index]++; + continue; + } + for (int j{track.getFirstDaughterTrackId()}; j <= track.getLastDaughterTrackId(); ++j) + { + auto pdgDau = tracks->at(j).GetPdgCode(); + bool foundDau = false; + // count decay PDGs + for (int idxDaughter = 0; idxDaughter < decayDaughters[index].size(); ++idxDaughter) + { + if (pdgDau == decayDaughters[index][idxDaughter]) + { + nDecays[index][idxDaughter]++; + foundDau = true; + hasInjection = true; + break; + } + } + if (!foundDau) + { + std::cerr << "Decay daughter not found: " << pdg << " -> " << pdgDau << "\n"; + } + } + } + } + if (!hasInjection) + { + numberOfEventsProcessedWithoutInjection++; + } + } + std::cout << "--------------------------------\n"; + std::cout << "# Events: " << nEvents << "\n"; + for (int i = 0; i < nInjection; i++) + { + std::cout << "# Mother \n"; + std::cout << injectedPDGs[i] << " generated: " << nSignal[i] << ", " << nNotDecayed[i] << " did not decay\n"; + if (nSignal[i] == 0) + { + std::cerr << "No generated: " << injectedPDGs[i] << "\n"; + // return 1; // At least one of the injected particles should be generated + } + for (int j = 0; j < decayDaughters[i].size(); j++) + { + std::cout << "# Daughter " << decayDaughters[i][j] << ": " << nDecays[i][j] << "\n"; + } + // if (nSignal[i] != nEvents * numberOfInjectedSignalsPerEvent) + // { + // std::cerr << "Number of generated: " << injectedPDGs[i] << ", lower than expected\n"; + // // return 1; // Don't need to return 1, since the number of generated particles is not the same for each event + // } + } + 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"; + // injected event + numberOfGapEvents*gap events + injected event + numberOfGapEvents*gap events + ... + // total fraction of the gap event: numberOfEventsProcessedWithoutInjection/numberOfEventsProcessed + float ratioOfNormalEvents = numberOfEventsProcessedWithoutInjection / numberOfEventsProcessed; + if (ratioOfNormalEvents > 0.75) + { + std::cout << "The number of injected event is loo low!!" << std::endl; + return 1; + } + + return 0; +} + +void GeneratorLF_Resonances_pp1360_injection() { External(); } diff --git a/MC/config/PWGLF/ini/tests/GeneratorLF_Resonances_pp_Glue_gap4_flaty.C b/MC/config/PWGLF/ini/tests/GeneratorLF_Resonances_pp_Glue_gap4_flaty.C new file mode 100644 index 000000000..c183e2c82 --- /dev/null +++ b/MC/config/PWGLF/ini/tests/GeneratorLF_Resonances_pp_Glue_gap4_flaty.C @@ -0,0 +1,150 @@ +int External() +{ + std::string path{"o2sim_Kine.root"}; + int numberOfInjectedSignalsPerEvent{1}; + int numberOfGapEvents{4}; + int numberOfEventsProcessed{0}; + int numberOfEventsProcessedWithoutInjection{0}; + std::vector injectedPDGs = { + 9010221, // f_0(980) + 225, // f_2(1270) + 115, // a_2(1320) + 10221, // f_0(1370) + 9030221, // f_0(1500) + 335, // f_2(1525) + 10331, // f_0(1710) + 9070221 // f_0(2200) + }; + std::vector> decayDaughters = { + {211, -211}, // f_0(980) + {310, 310}, // f_2(1270) + {310, 310}, // a_2(1320) + {310, 310}, // f_0(1370) + {310, 310}, // f_0(1500) + {310, 310}, // f_2(1525) + {310, 310}, // f_0(1710) + {310, 310}, // f_0(2200) + }; + + auto nInjection = injectedPDGs.size(); + + 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 *tracks{}; + tree->SetBranchAddress("MCTrack", &tracks); + + std::vector nSignal; + for (int i = 0; i < nInjection; i++) + { + nSignal.push_back(0); + } + std::vector> nDecays; + std::vector nNotDecayed; + for (int i = 0; i < nInjection; i++) + { + std::vector nDecay; + for (int j = 0; j < decayDaughters[i].size(); j++) + { + nDecay.push_back(0); + } + nDecays.push_back(nDecay); + nNotDecayed.push_back(0); + } + auto nEvents = tree->GetEntries(); + bool hasInjection = false; + for (int i = 0; i < nEvents; i++) + { + hasInjection = false; + numberOfEventsProcessed++; + auto check = tree->GetEntry(i); + for (int idxMCTrack = 0; idxMCTrack < tracks->size(); ++idxMCTrack) + { + auto track = tracks->at(idxMCTrack); + auto pdg = track.GetPdgCode(); + auto it = std::find(injectedPDGs.begin(), injectedPDGs.end(), pdg); + int index = std::distance(injectedPDGs.begin(), it); // index of injected PDG + if (it != injectedPDGs.end()) // found + { + // count signal PDG + nSignal[index]++; + if (track.getFirstDaughterTrackId() < 0) + { + nNotDecayed[index]++; + continue; + } + for (int j{track.getFirstDaughterTrackId()}; j <= track.getLastDaughterTrackId(); ++j) + { + auto pdgDau = tracks->at(j).GetPdgCode(); + bool foundDau = false; + // count decay PDGs + for (int idxDaughter = 0; idxDaughter < decayDaughters[index].size(); ++idxDaughter) + { + if (pdgDau == decayDaughters[index][idxDaughter]) + { + nDecays[index][idxDaughter]++; + foundDau = true; + hasInjection = true; + break; + } + } + if (!foundDau) + { + std::cerr << "Decay daughter not found: " << pdg << " -> " << pdgDau << "\n"; + } + } + } + } + if (!hasInjection) + { + numberOfEventsProcessedWithoutInjection++; + } + } + std::cout << "--------------------------------\n"; + std::cout << "# Events: " << nEvents << "\n"; + for (int i = 0; i < nInjection; i++) + { + std::cout << "# Mother \n"; + std::cout << injectedPDGs[i] << " generated: " << nSignal[i] << ", " << nNotDecayed[i] << " did not decay\n"; + if (nSignal[i] == 0) + { + std::cerr << "No generated: " << injectedPDGs[i] << "\n"; + // return 1; // At least one of the injected particles should be generated + } + for (int j = 0; j < decayDaughters[i].size(); j++) + { + std::cout << "# Daughter " << decayDaughters[i][j] << ": " << nDecays[i][j] << "\n"; + } + // if (nSignal[i] != nEvents * numberOfInjectedSignalsPerEvent) + // { + // std::cerr << "Number of generated: " << injectedPDGs[i] << ", lower than expected\n"; + // // return 1; // Don't need to return 1, since the number of generated particles is not the same for each event + // } + } + 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"; + // injected event + numberOfGapEvents*gap events + injected event + numberOfGapEvents*gap events + ... + // total fraction of the gap event: numberOfEventsProcessedWithoutInjection/numberOfEventsProcessed + float ratioOfNormalEvents = numberOfEventsProcessedWithoutInjection / numberOfEventsProcessed; + if (ratioOfNormalEvents > 0.75) + { + std::cout << "The number of injected event is loo low!!" << std::endl; + return 1; + } + + return 0; +} + +void GeneratorLF_Resonances_pp1360_injection() { External(); } diff --git a/MC/config/PWGLF/ini/tests/GeneratorLF_Resonances_pp_exoticAll_gap2.C b/MC/config/PWGLF/ini/tests/GeneratorLF_Resonances_pp_exoticAll_gap2.C index 74076d41c..de5440853 100644 --- a/MC/config/PWGLF/ini/tests/GeneratorLF_Resonances_pp_exoticAll_gap2.C +++ b/MC/config/PWGLF/ini/tests/GeneratorLF_Resonances_pp_exoticAll_gap2.C @@ -14,6 +14,7 @@ int External() 20333, // f_1(1420) 335, // f_2(1525) 115, // a_2(1320) + 9070221, // f_0(2200) 102134, // Lambda(1520)0 -102134 // Lambda(1520)0bar }; @@ -26,6 +27,7 @@ int External() {310, -321, 211}, // f_1(1420) {310, 310}, // f_2(1525) {310, 310}, // a_2(1320) + {310, 310}, // f_0(2200) {2212, -321}, // Lambda(1520)0 {-2212, 321} // Lambda(1520)0bar }; diff --git a/MC/config/PWGLF/ini/tests/GeneratorLF_Resonances_pp_exoticAll_gap4.C b/MC/config/PWGLF/ini/tests/GeneratorLF_Resonances_pp_exoticAll_gap4.C new file mode 100644 index 000000000..736d6040e --- /dev/null +++ b/MC/config/PWGLF/ini/tests/GeneratorLF_Resonances_pp_exoticAll_gap4.C @@ -0,0 +1,167 @@ +int External() +{ + std::string path{"o2sim_Kine.root"}; + int numberOfInjectedSignalsPerEvent{1}; + int numberOfGapEvents{4}; + int numberOfEventsProcessed{0}; + int numberOfEventsProcessedWithoutInjection{0}; + std::vector injectedPDGs = { + 9010221, // f_0(980) + 225, // f_2(1270) + 115, // a_2(1320) + 10221, // f_0(1370) + 9030221, // f_0(1500) + 335, // f_2(1525) + 10331, // f_0(1710) + 20223, // f_1(1285) + 20333, // f_1(1420) + 9070221, // f_0(2200) + 10323, // K1(1270)+ + -10323, // K1(1270)-bar + 123314, // Xi(1820)- + -123314, // Xi(1820)+ + 123324, // Xi(1820)0 + -123324 // Xi(1820)0bar + }; + std::vector> decayDaughters = { + {211, -211}, // f_0(980) + {310, 310}, // f_2(1270) + {310, 310}, // a_2(1320) + {310, 310}, // f_0(1370) + {310, 310}, // f_0(1500) + {310, 310}, // f_2(1525) + {310, 310}, // f_0(1710) + {310, -321, 211}, // f_1(1285) + {310, -321, 211}, // f_1(1420) + {310, 310}, // f_0(2200) + {321, 211}, // K1(1270)+ + {-321, -211}, // K1(1270)-bar + {2212, 211}, // Delta(1232)+ + {3122, -311}, // Xi(1820)- + {3122, 311}, // Xi(1820)+ + {3122, 310}, // Xi(1820)0 + {-3122, 310} // Xi(1820)0bar + }; + + auto nInjection = injectedPDGs.size(); + + 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 *tracks{}; + tree->SetBranchAddress("MCTrack", &tracks); + + std::vector nSignal; + for (int i = 0; i < nInjection; i++) + { + nSignal.push_back(0); + } + std::vector> nDecays; + std::vector nNotDecayed; + for (int i = 0; i < nInjection; i++) + { + std::vector nDecay; + for (int j = 0; j < decayDaughters[i].size(); j++) + { + nDecay.push_back(0); + } + nDecays.push_back(nDecay); + nNotDecayed.push_back(0); + } + auto nEvents = tree->GetEntries(); + bool hasInjection = false; + for (int i = 0; i < nEvents; i++) + { + hasInjection = false; + numberOfEventsProcessed++; + auto check = tree->GetEntry(i); + for (int idxMCTrack = 0; idxMCTrack < tracks->size(); ++idxMCTrack) + { + auto track = tracks->at(idxMCTrack); + auto pdg = track.GetPdgCode(); + auto it = std::find(injectedPDGs.begin(), injectedPDGs.end(), pdg); + int index = std::distance(injectedPDGs.begin(), it); // index of injected PDG + if (it != injectedPDGs.end()) // found + { + // count signal PDG + nSignal[index]++; + if (track.getFirstDaughterTrackId() < 0) + { + nNotDecayed[index]++; + continue; + } + for (int j{track.getFirstDaughterTrackId()}; j <= track.getLastDaughterTrackId(); ++j) + { + auto pdgDau = tracks->at(j).GetPdgCode(); + bool foundDau = false; + // count decay PDGs + for (int idxDaughter = 0; idxDaughter < decayDaughters[index].size(); ++idxDaughter) + { + if (pdgDau == decayDaughters[index][idxDaughter]) + { + nDecays[index][idxDaughter]++; + foundDau = true; + hasInjection = true; + break; + } + } + if (!foundDau) + { + std::cerr << "Decay daughter not found: " << pdg << " -> " << pdgDau << "\n"; + } + } + } + } + if (!hasInjection) + { + numberOfEventsProcessedWithoutInjection++; + } + } + std::cout << "--------------------------------\n"; + std::cout << "# Events: " << nEvents << "\n"; + for (int i = 0; i < nInjection; i++) + { + std::cout << "# Mother \n"; + std::cout << injectedPDGs[i] << " generated: " << nSignal[i] << ", " << nNotDecayed[i] << " did not decay\n"; + if (nSignal[i] == 0) + { + std::cerr << "No generated: " << injectedPDGs[i] << "\n"; + // return 1; // At least one of the injected particles should be generated + } + for (int j = 0; j < decayDaughters[i].size(); j++) + { + std::cout << "# Daughter " << decayDaughters[i][j] << ": " << nDecays[i][j] << "\n"; + } + // if (nSignal[i] != nEvents * numberOfInjectedSignalsPerEvent) + // { + // std::cerr << "Number of generated: " << injectedPDGs[i] << ", lower than expected\n"; + // // return 1; // Don't need to return 1, since the number of generated particles is not the same for each event + // } + } + 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"; + // injected event + numberOfGapEvents*gap events + injected event + numberOfGapEvents*gap events + ... + // total fraction of the gap event: numberOfEventsProcessedWithoutInjection/numberOfEventsProcessed + float ratioOfNormalEvents = numberOfEventsProcessedWithoutInjection / numberOfEventsProcessed; + if (ratioOfNormalEvents > 0.75) + { + std::cout << "The number of injected event is loo low!!" << std::endl; + return 1; + } + + return 0; +} + +void GeneratorLF_Resonances_pp1360_injection() { External(); } diff --git a/MC/config/PWGLF/pythia8/generator/gluelistgun.json b/MC/config/PWGLF/pythia8/generator/gluelistgun.json index 7fc4bc690..f19963707 100644 --- a/MC/config/PWGLF/pythia8/generator/gluelistgun.json +++ b/MC/config/PWGLF/pythia8/generator/gluelistgun.json @@ -10,6 +10,28 @@ "rapidityMax": 1.0, "genDecayed": true }, + "f_0(1370)": { + "pdg": 10221, + "n": 3, + "ptMin": 0.0, + "ptMax": 30, + "etaMin": -1.0, + "etaMax": 1.0, + "rapidityMin": -1.0, + "rapidityMax": 1.0, + "genDecayed": true + }, + "f_0(1500)": { + "pdg": 9030221, + "n": 3, + "ptMin": 0.0, + "ptMax": 30, + "etaMin": -1.0, + "etaMax": 1.0, + "rapidityMin": -1.0, + "rapidityMax": 1.0, + "genDecayed": true + }, "f_0(1710)": { "pdg": 10331, "n": 3, @@ -21,6 +43,17 @@ "rapidityMax": 1.0, "genDecayed": true }, + "f_0(2200)": { + "pdg": 9070221, + "n": 3, + "ptMin": 0.0, + "ptMax": 30, + "etaMin": -1.0, + "etaMax": 1.0, + "rapidityMin": -1.0, + "rapidityMax": 1.0, + "genDecayed": true + }, "f_2(1525)": { "pdg": 335, "n": 3, diff --git a/MC/config/PWGLF/pythia8/generator/gluelistgun2.json b/MC/config/PWGLF/pythia8/generator/gluelistgun2.json new file mode 100644 index 000000000..15b8c0080 --- /dev/null +++ b/MC/config/PWGLF/pythia8/generator/gluelistgun2.json @@ -0,0 +1,90 @@ +{ + "K_1(1270)": { + "pdg": 10313, + "n": 3, + "ptMin": 0.0, + "ptMax": 30, + "etaMin": -1.0, + "etaMax": 1.0, + "rapidityMin": -1.0, + "rapidityMax": 1.0, + "genDecayed": true + }, + "f_0(1370)": { + "pdg": 10221, + "n": 3, + "ptMin": 0.0, + "ptMax": 30, + "etaMin": -1.0, + "etaMax": 1.0, + "rapidityMin": -1.0, + "rapidityMax": 1.0, + "genDecayed": true + }, + "f_0(1500)": { + "pdg": 9030221, + "n": 3, + "ptMin": 0.0, + "ptMax": 30, + "etaMin": -1.0, + "etaMax": 1.0, + "rapidityMin": -1.0, + "rapidityMax": 1.0, + "genDecayed": true + }, + "f_0(1710)": { + "pdg": 10331, + "n": 3, + "ptMin": 0.0, + "ptMax": 30, + "etaMin": -1.0, + "etaMax": 1.0, + "rapidityMin": -1.0, + "rapidityMax": 1.0, + "genDecayed": true + }, + "f_0(2200)": { + "pdg": 9070221, + "n": 3, + "ptMin": 0.0, + "ptMax": 30, + "etaMin": -1.0, + "etaMax": 1.0, + "rapidityMin": -1.0, + "rapidityMax": 1.0, + "genDecayed": true + }, + "f_2(1270)": { + "pdg": 225, + "n": 3, + "ptMin": 0.0, + "ptMax": 30, + "etaMin": -1.0, + "etaMax": 1.0, + "rapidityMin": -1.0, + "rapidityMax": 1.0, + "genDecayed": true + }, + "f_2(1525)": { + "pdg": 335, + "n": 3, + "ptMin": 0.0, + "ptMax": 30, + "etaMin": -1.0, + "etaMax": 1.0, + "rapidityMin": -1.0, + "rapidityMax": 1.0, + "genDecayed": true + }, + "a_2(1230)": { + "pdg": 115, + "n": 3, + "ptMin": 0.0, + "ptMax": 30, + "etaMin": -1.0, + "etaMax": 1.0, + "rapidityMin": -1.0, + "rapidityMax": 1.0, + "genDecayed": true + } +} \ No newline at end of file diff --git a/MC/config/PWGLF/pythia8/generator/resonances.cfg b/MC/config/PWGLF/pythia8/generator/resonances.cfg index d35eaba2e..2f305d17e 100644 --- a/MC/config/PWGLF/pythia8/generator/resonances.cfg +++ b/MC/config/PWGLF/pythia8/generator/resonances.cfg @@ -45,6 +45,16 @@ ProcessLevel:all = off # will not look for the 'process' 9030221:onMode = off 9030221:onIfMatch = 310 310 +10313:all = K_1(1270) K_1(1270) 3 1 0 1.27200 0.09000 1.20000 1.50000 0 +10313:oneChannel = 1 1.000 0 310 310 +10313:onMode = off +10313:onIfMatch = 310 310 + +9070221:all = f_0(2200) f_0(2200) 0 0 0 2.20000 0.00000 2.00000 2.40000 0 +9070221:oneChannel = 1 1.000 0 310 310 +9070221:onMode = off +9070221:onIfMatch = 310 310 + 10331:all = f_0(1710) f_0(1710) 0 0 0 1.71000 0.15000 1.10000 2.40000 0 10331:oneChannel = 1 1.000 0 310 310 10331:onMode = off