From fd79bae169ced32462d40c60b82409fc3ff27d26 Mon Sep 17 00:00:00 2001 From: motomioya Date: Thu, 15 Feb 2024 14:06:05 +0900 Subject: [PATCH 01/18] Add bbtomuons without forcing semileptonic decay --- .../generator/GeneratorBeautyToMu_EvtGen.C | 5 ++-- .../GeneratorHF_bbbarToDDbarToMuons_fwdy.ini | 23 ++++++++++++++++ .../PWGDQ/runBeautyToMuons_noForce_fwd_pp.sh | 27 +++++++++++++++++++ 3 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 MC/config/PWGDQ/ini/GeneratorHF_bbbarToDDbarToMuons_fwdy.ini create mode 100644 MC/run/PWGDQ/runBeautyToMuons_noForce_fwd_pp.sh diff --git a/MC/config/PWGDQ/external/generator/GeneratorBeautyToMu_EvtGen.C b/MC/config/PWGDQ/external/generator/GeneratorBeautyToMu_EvtGen.C index 98b71a00b..0c0ee1b50 100644 --- a/MC/config/PWGDQ/external/generator/GeneratorBeautyToMu_EvtGen.C +++ b/MC/config/PWGDQ/external/generator/GeneratorBeautyToMu_EvtGen.C @@ -11,7 +11,7 @@ R__ADD_INCLUDE_PATH($O2DPG_ROOT/MC/config/PWGHF/external/generator) FairGenerator* -GeneratorBeautyToMu_EvtGenFwdY(double rapidityMin = -4.3, double rapidityMax = -2.2, bool ispp = true, bool verbose = false, TString pdgs = "511;521;531;541;5112;5122;5232;5132;5332") +GeneratorBeautyToMu_EvtGenFwdY(double rapidityMin = -4.3, double rapidityMax = -2.2, bool ispp = true, bool forcedecay = true, bool verbose = false, TString pdgs = "511;521;531;541;5112;5122;5232;5132;5332") { auto gen = new o2::eventgen::GeneratorEvtGen(); gen->setRapidity(rapidityMin,rapidityMax); @@ -30,7 +30,8 @@ GeneratorBeautyToMu_EvtGenFwdY(double rapidityMin = -4.3, double rapidityMax = - gen->AddPdg(std::stoi(spdg),i); printf("PDG %d \n",std::stoi(spdg)); } - gen->SetForceDecay(kEvtSemiMuonic); + if(forcedecay) gen->SetForceDecay(kEvtSemiElectronic); + else gen->SetForceDecay(kEvtAll); // set random seed gen->readString("Random:setSeed on"); uint random_seed; diff --git a/MC/config/PWGDQ/ini/GeneratorHF_bbbarToDDbarToMuons_fwdy.ini b/MC/config/PWGDQ/ini/GeneratorHF_bbbarToDDbarToMuons_fwdy.ini new file mode 100644 index 000000000..18a7faf43 --- /dev/null +++ b/MC/config/PWGDQ/ini/GeneratorHF_bbbarToDDbarToMuons_fwdy.ini @@ -0,0 +1,23 @@ + +### The setup uses an external event generator +### This part sets the path of the file and the function call to retrieve it + +[GeneratorExternal] +fileName = ${O2DPG_ROOT}/MC/config/PWGDQ/external/generator/GeneratorBeautyToMu_EvtGen.C +funcName = GeneratorBeautyToMu_EvtGenFwdY(-4.3,-2.3,true,false) + +### The external generator derives from GeneratorPythia8. +### This part configures the bits of the interface: configuration and user hooks + +[GeneratorPythia8] +config = ${O2DPG_ROOT}/MC/config/common/pythia8/generator/pythia8_hf.cfg +hooksFileName = ${O2DPG_ROOT}/MC/config/PWGHF/pythia8/hooks/pythia8_userhooks_qqbar.C +hooksFuncName = pythia8_userhooks_bbbar(-4.3,-2.3) + +### The setup uses an external even generator trigger which is +### defined in the following file and it is retrieved and configured +### according to the specified function call + +[TriggerExternal] +fileName = ${O2DPG_ROOT}/MC/config/PWGDQ/trigger/selectDaughterFromHFwithinAcc.C +funcName = selectDaughterFromHFwithinAcc(13,kTRUE,-4.3,-2.3) diff --git a/MC/run/PWGDQ/runBeautyToMuons_noForce_fwd_pp.sh b/MC/run/PWGDQ/runBeautyToMuons_noForce_fwd_pp.sh new file mode 100644 index 000000000..ded2c646b --- /dev/null +++ b/MC/run/PWGDQ/runBeautyToMuons_noForce_fwd_pp.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +# make sure O2DPG + O2 is loaded +[ ! "${O2DPG_ROOT}" ] && echo "Error: This needs O2DPG loaded" && exit 1 +[ ! "${O2_ROOT}" ] && echo "Error: This needs O2 loaded" && exit 1 + +# ----------- SETUP LOCAL CCDB CACHE -------------------------- +export ALICEO2_CCDB_LOCALCACHE=$PWD/.ccdb + + +# ----------- LOAD UTILITY FUNCTIONS -------------------------- +. ${O2_ROOT}/share/scripts/jobutils.sh + +RNDSEED=${RNDSEED:-0} +NSIGEVENTS=${NSIGEVENTS:-1} +NBKGEVENTS=${NBKGEVENTS:-1} +NWORKERS=${NWORKERS:-8} +NTIMEFRAMES=${NTIMEFRAMES:-1} + + +${O2DPG_ROOT}/MC/bin/o2dpg_sim_workflow.py -eCM 13600 -gen external -j ${NWORKERS} -ns ${NSIGEVENTS} -tf ${NTIMEFRAMES} -e TGeant4 -mod "MCH MFT MID ITS" \ + -trigger "external" -ini $O2DPG_ROOT/MC/config/PWGDQ/ini/GeneratorHF_bbbarToDDbarToMuons_fwdy.ini \ + -genBkg pythia8 -procBkg cdiff -colBkg pp --embedding -nb ${NBKGEVENTS} \ + -confKeyBkg "Diamond.width[2]=6" -interactionRate 2000 --mft-assessment-full --fwdmatching-assessment-full + +# run workflow +${O2DPG_ROOT}/MC/bin/o2_dpg_workflow_runner.py -f workflow.json -f workflow.json -tt aod -jmax 1 From 7f4feaafdb334a174cbbf1ed1b3dd51181b78e2a Mon Sep 17 00:00:00 2001 From: motomioya Date: Fri, 16 Feb 2024 13:43:22 +0900 Subject: [PATCH 02/18] Modified bugs --- MC/config/PWGDQ/external/generator/GeneratorBeautyToMu_EvtGen.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MC/config/PWGDQ/external/generator/GeneratorBeautyToMu_EvtGen.C b/MC/config/PWGDQ/external/generator/GeneratorBeautyToMu_EvtGen.C index 0c0ee1b50..3edfb93dc 100644 --- a/MC/config/PWGDQ/external/generator/GeneratorBeautyToMu_EvtGen.C +++ b/MC/config/PWGDQ/external/generator/GeneratorBeautyToMu_EvtGen.C @@ -30,7 +30,7 @@ GeneratorBeautyToMu_EvtGenFwdY(double rapidityMin = -4.3, double rapidityMax = - gen->AddPdg(std::stoi(spdg),i); printf("PDG %d \n",std::stoi(spdg)); } - if(forcedecay) gen->SetForceDecay(kEvtSemiElectronic); + if(forcedecay) gen->SetForceDecay(kEvtSemiMuonic); else gen->SetForceDecay(kEvtAll); // set random seed gen->readString("Random:setSeed on"); From 4f471ba46f3d855c2ff23410a7bd6ffa42334ff4 Mon Sep 17 00:00:00 2001 From: motomioya Date: Fri, 8 Mar 2024 15:59:36 +0900 Subject: [PATCH 03/18] Add test file for bb->mumu with natural decay --- .../GeneratorHF_bbbarToDDbarToMuons_fwdy.C | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 MC/config/PWGDQ/ini/tests/GeneratorHF_bbbarToDDbarToMuons_fwdy.C diff --git a/MC/config/PWGDQ/ini/tests/GeneratorHF_bbbarToDDbarToMuons_fwdy.C b/MC/config/PWGDQ/ini/tests/GeneratorHF_bbbarToDDbarToMuons_fwdy.C new file mode 100644 index 000000000..53e3565c8 --- /dev/null +++ b/MC/config/PWGDQ/ini/tests/GeneratorHF_bbbarToDDbarToMuons_fwdy.C @@ -0,0 +1,89 @@ +int External() +{ + int checkPdgDecay = 13; + std::string path{"o2sim_Kine.root"}; + 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"); + std::vector* tracks{}; + tree->SetBranchAddress("MCTrack", &tracks); + + int nLeptons{}; + int nLeptonsInAcceptance{}; + int nLeptonsToBeDone{}; + int nSignalPairs{}; + int nLeptonPairs{}; + int nLeptonPairsInAcceptance{}; + int nLeptonPairsToBeDone{}; + auto nEvents = tree->GetEntries(); + + for (int i = 0; i < nEvents; i++) { + tree->GetEntry(i); + int nleptonseinacc = 0; + int nleptonse = 0; + int nleptonseToBeDone = 0; + int nopenHeavy = 0; + for (auto& track : *tracks) { + auto pdg = track.GetPdgCode(); + auto y = track.GetRapidity(); + if (std::abs(pdg) == checkPdgDecay) { + int igmother = track.getMotherTrackId(); + if (igmother > 0) { + auto gmTrack = (*tracks)[igmother]; + int gmpdg = gmTrack.GetPdgCode(); + if ( int(std::abs(gmpdg)/100.) == 4 || int(std::abs(gmpdg)/1000.) == 4 || int(std::abs(gmpdg)/100.) == 5 || int(std::abs(gmpdg)/1000.) == 5 ) { + nLeptons++; + nleptonse++; + if (-4.3 < y && y < -2.3) { + nleptonseinacc++; + nLeptonsInAcceptance++; + } + if (track.getToBeDone()) { + nLeptonsToBeDone++; + nleptonseToBeDone++; + } + } + } + } else if (std::abs(pdg) == 411 || std::abs(pdg) == 421 || std::abs(pdg) == 431 || std::abs(pdg) == 4122 || std::abs(pdg) == 4132 || std::abs(pdg) == 4232 || std::abs(pdg) == 4332 || std::abs(pdg) == 511 || std::abs(pdg) == 521 || std::abs(pdg) == 531 || std::abs(pdg) == 541 || std::abs(pdg) == 5112 || std::abs(pdg) == 5122 || std::abs(pdg) == 5232 || std::abs(pdg) == 5132 || std::abs(pdg) == 5332) { + nopenHeavy++; + } + } + if (nopenHeavy > 1) nSignalPairs++; + if (nleptonse > 1) nLeptonPairs++; + if (nleptonseToBeDone > 1) nLeptonPairsToBeDone++; + if (nleptonseinacc > 1) nLeptonPairsInAcceptance++; + } + std::cout << "#events: " << nEvents << "\n" + << "#leptons in acceptance: " << nLeptonsInAcceptance << "\n" + << "#lepton pairs in acceptance: " << nLeptonPairsInAcceptance << "\n" + << "#leptons: " << nLeptons << "\n" + << "#leptons to be done: " << nLeptonsToBeDone << "\n" + << "#signal pairs: " << nSignalPairs << "\n" + << "#lepton pairs: " << nLeptonPairs << "\n" + << "#lepton pairs to be done: " << nLeptonPairsToBeDone << "\n"; + if (nLeptons == 0) { + std::cerr << "Number of leptons should be greater than 1.\n"; + return 1; + } + if (nLeptonPairs < nSignalPairs) { + std::cerr << "Number of lepton pairs should be at least equaled to the number of open charm hadron pairs\n"; + return 1; + } + if (nLeptonPairsInAcceptance < nEvents) { + std::cerr << "Number of lepton pairs should be at least equaled to the number of events\n"; + return 1; + } + if (nLeptonPairs != nLeptonPairsToBeDone) { + std::cerr << "The number of lepton pairs should be the same as the number of lepton pairs which should be transported.\n"; + return 1; + } + if (nLeptons != nLeptonsToBeDone) { + std::cerr << "The number of leptons should be the same as the number of leptons which should be transported.\n"; + return 1; + } + + return 0; +} From 5addaa8aa2a344bc0663178d2789c2c81ab70f5b Mon Sep 17 00:00:00 2001 From: motomioya Date: Fri, 8 Mar 2024 21:43:21 +0900 Subject: [PATCH 04/18] Add test file for bb->mumu with natural decay --- .../GeneratorHF_bbbarToDDbarToMuons_fwdy.C | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/MC/config/PWGDQ/ini/tests/GeneratorHF_bbbarToDDbarToMuons_fwdy.C b/MC/config/PWGDQ/ini/tests/GeneratorHF_bbbarToDDbarToMuons_fwdy.C index 53e3565c8..fa25c4df3 100644 --- a/MC/config/PWGDQ/ini/tests/GeneratorHF_bbbarToDDbarToMuons_fwdy.C +++ b/MC/config/PWGDQ/ini/tests/GeneratorHF_bbbarToDDbarToMuons_fwdy.C @@ -57,31 +57,31 @@ int External() if (nleptonseinacc > 1) nLeptonPairsInAcceptance++; } std::cout << "#events: " << nEvents << "\n" - << "#leptons in acceptance: " << nLeptonsInAcceptance << "\n" - << "#lepton pairs in acceptance: " << nLeptonPairsInAcceptance << "\n" - << "#leptons: " << nLeptons << "\n" - << "#leptons to be done: " << nLeptonsToBeDone << "\n" + << "#muons in acceptance: " << nLeptonsInAcceptance << "\n" + << "#muon pairs in acceptance: " << nLeptonPairsInAcceptance << "\n" + << "#muons: " << nLeptons << "\n" + << "#muons to be done: " << nLeptonsToBeDone << "\n" << "#signal pairs: " << nSignalPairs << "\n" - << "#lepton pairs: " << nLeptonPairs << "\n" - << "#lepton pairs to be done: " << nLeptonPairsToBeDone << "\n"; + << "#muon pairs: " << nLeptonPairs << "\n" + << "#muon pairs to be done: " << nLeptonPairsToBeDone << "\n"; if (nLeptons == 0) { - std::cerr << "Number of leptons should be greater than 1.\n"; + std::cerr << "Number of muons should be greater than 1.\n"; return 1; } - if (nLeptonPairs < nSignalPairs) { - std::cerr << "Number of lepton pairs should be at least equaled to the number of open charm hadron pairs\n"; + if (nSignalPairs <= nLeptonPairs) { + std::cerr << "Number of muon pairs should be less than open charm hadron pairs\n"; return 1; } - if (nLeptonPairsInAcceptance < nEvents) { - std::cerr << "Number of lepton pairs should be at least equaled to the number of events\n"; + if (nSignalPairs < nEvents) { + std::cerr << "Number of signal pairs should be at least equaled to the number of oevents\n"; return 1; } if (nLeptonPairs != nLeptonPairsToBeDone) { - std::cerr << "The number of lepton pairs should be the same as the number of lepton pairs which should be transported.\n"; + std::cerr << "The number of muon pairs should be the same as the number of muon pairs which should be transported.\n"; return 1; } if (nLeptons != nLeptonsToBeDone) { - std::cerr << "The number of leptons should be the same as the number of leptons which should be transported.\n"; + std::cerr << "The number of muons should be the same as the number of muons which should be transported.\n"; return 1; } From b02a29fef6511480b00995c76dc6c2dcb01c0013 Mon Sep 17 00:00:00 2001 From: motomioya Date: Fri, 8 Mar 2024 22:01:54 +0900 Subject: [PATCH 05/18] Add test file for bb->mumu with natural decay --- .../ini/tests/GeneratorHF_bbbarToDDbarToMuons_fwdy.C | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/MC/config/PWGDQ/ini/tests/GeneratorHF_bbbarToDDbarToMuons_fwdy.C b/MC/config/PWGDQ/ini/tests/GeneratorHF_bbbarToDDbarToMuons_fwdy.C index fa25c4df3..271e0ff39 100644 --- a/MC/config/PWGDQ/ini/tests/GeneratorHF_bbbarToDDbarToMuons_fwdy.C +++ b/MC/config/PWGDQ/ini/tests/GeneratorHF_bbbarToDDbarToMuons_fwdy.C @@ -64,16 +64,12 @@ int External() << "#signal pairs: " << nSignalPairs << "\n" << "#muon pairs: " << nLeptonPairs << "\n" << "#muon pairs to be done: " << nLeptonPairsToBeDone << "\n"; - if (nLeptons == 0) { - std::cerr << "Number of muons should be greater than 1.\n"; - return 1; - } if (nSignalPairs <= nLeptonPairs) { - std::cerr << "Number of muon pairs should be less than open charm hadron pairs\n"; + std::cerr << "Number of muon pairs should be less than HF hadron pairs\n"; return 1; } if (nSignalPairs < nEvents) { - std::cerr << "Number of signal pairs should be at least equaled to the number of oevents\n"; + std::cerr << "Number of signal pairs should be at least equaled to the number of events\n"; return 1; } if (nLeptonPairs != nLeptonPairsToBeDone) { From fe81199347e1ad373c8a46c49c62b24412618383 Mon Sep 17 00:00:00 2001 From: motomioya Date: Mon, 22 Jul 2024 00:25:04 +0900 Subject: [PATCH 06/18] Add LF to mumu --- .../Generator_pythia8_GapTriggered_LFmumu.C | 286 ++++++++++++++++++ .../ini/Generator_GapTriggered_LFmumu.ini | 9 + ...or_GapTriggered_LFmumu_random_np1_gap0.ini | 9 + .../ini/tests/Generator_GapTriggered_LFmumu.C | 62 ++++ .../PWGEM/runPythia8GapTriggeredLFmumu_pp.sh | 55 ++++ 5 files changed, 421 insertions(+) create mode 100644 MC/config/PWGEM/external/generator/Generator_pythia8_GapTriggered_LFmumu.C create mode 100644 MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu.ini create mode 100644 MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu_random_np1_gap0.ini create mode 100644 MC/config/PWGEM/ini/tests/Generator_GapTriggered_LFmumu.C create mode 100644 MC/run/PWGEM/runPythia8GapTriggeredLFmumu_pp.sh diff --git a/MC/config/PWGEM/external/generator/Generator_pythia8_GapTriggered_LFmumu.C b/MC/config/PWGEM/external/generator/Generator_pythia8_GapTriggered_LFmumu.C new file mode 100644 index 000000000..a2417eae3 --- /dev/null +++ b/MC/config/PWGEM/external/generator/Generator_pythia8_GapTriggered_LFmumu.C @@ -0,0 +1,286 @@ +R__ADD_INCLUDE_PATH($O2DPG_ROOT/MC/config/PWGDQ/EvtGen) +R__ADD_INCLUDE_PATH($O2DPG_ROOT/MC/config/PWGDQ/external/generator) +R__ADD_INCLUDE_PATH($O2DPG_ROOT/MC/config/PWGEM/external/generator) +R__LOAD_LIBRARY(libpythia6) +R__LOAD_LIBRARY(libEGPythia6) +#include "GeneratorEvtGen.C" +#include "GeneratorCocktail.C" +#include "Generators/GeneratorPythia8.h" +#include "Pythia8/Pythia.h" + +using namespace std; +using namespace Pythia8; + +namespace o2 { +namespace eventgen { + +class CocktailParam : public GeneratorTGenerator { +public: + CocktailParam(GeneratorParam *thisGenerator) + : GeneratorTGenerator(thisGenerator->GetName()) { + setTGenerator(thisGenerator); + }; + + ~CocktailParam() { delete thisGenerator; }; + +private: + GeneratorParam *thisGenerator = nullptr; +}; + + +//my generator class +class GeneratorPythia8GapTriggeredLFmumu : public GeneratorPythia8 { + + public: + GeneratorPythia8GapTriggeredLFmumu() : GeneratorPythia8() { + mGeneratedEvents = 0; + mInverseTriggerRatio = 1; + fGeneratorCocktail = 0x0; + mMode = -1; + mTargetPDG = 0; + }; + + GeneratorPythia8GapTriggeredLFmumu(int lInputTriggerRatio, float yMin, float yMax, int nPart, int mode) : GeneratorPythia8() { + mGeneratedEvents = 0; + mInverseTriggerRatio = lInputTriggerRatio; + mMode = mode; + // LMee cocktail settings: + float minPt = 0; + float maxPt = 25; + float phiMin = 0.; + float phiMax = 360.; + Weighting_t weightMode = kNonAnalog; + + //create cocktail generator : eta, eta', rho, omega, phi + fGeneratorCocktail = new o2::eventgen::GeneratorEvtGen(); + + // EXODUS decayer + TString O2DPG_ROOT = TString(getenv("O2DPG_ROOT")); + auto decayer = new PythiaDecayerConfig(); + decayer->SetDecayerExodus(); + TString useLMeeDecaytable = "$O2DPG_ROOT/MC/config/PWGEM/decaytables/decaytable_LMee.dat"; + useLMeeDecaytable=useLMeeDecaytable.ReplaceAll("$O2DPG_ROOT",O2DPG_ROOT); + useLMeeDecaytable=useLMeeDecaytable.ReplaceAll("${O2DPG_ROOT}",O2DPG_ROOT); + decayer->SetDecayTableFile(useLMeeDecaytable.Data()); + decayer->ReadDecayTable(); + + //Param + GeneratorParamEMlib *emlib = new GeneratorParamEMlib(); + + // eta + auto geneta = new GeneratorParam(nPart,emlib,GeneratorParamEMlib::kEta,"eta"); // 221 + geneta->SetName("eta"); + geneta->SetMomentumRange(0., 25.); + geneta->SetPtRange(minPt, maxPt); + geneta->SetYRange(yMin, yMax); + geneta->SetPhiRange(phiMin, phiMax); + geneta->SetWeighting(weightMode); // flat pt, y and v2 zero + geneta->SetDecayer(decayer); // EXOUS; + geneta->SetForceDecay(kDiMuon); // Dielectrons + geneta->SetForceGammaConversion(kFALSE); + geneta->SetSelectAll(kTRUE); // Store also the gamma in pi0->e+e-gamma + geneta->Init(); + CocktailParam *newgeneta = new CocktailParam(geneta); + + // etaprime + auto genetaprime = new GeneratorParam(nPart,emlib,GeneratorParamEMlib::kEtaprime,"etaprime"); // 331 + genetaprime->SetName("etaprime"); + genetaprime->SetMomentumRange(0., 25.); + genetaprime->SetPtRange(minPt, maxPt); + genetaprime->SetYRange(yMin, yMax); + genetaprime->SetPhiRange(phiMin, phiMax); + genetaprime->SetWeighting(weightMode); // flat pt, y and v2 zero + genetaprime->SetDecayer(decayer); // EXOUS; + genetaprime->SetForceDecay(kDiMuon); // Dielectrons + genetaprime->SetForceGammaConversion(kFALSE); + genetaprime->SetSelectAll(kTRUE); // Store also the gamma in pi0->e+e-gamma + genetaprime->Init(); + CocktailParam *newgenetaprime = new CocktailParam(genetaprime); + + // rho + auto genrho = new GeneratorParam(nPart,emlib,GeneratorParamEMlib::kRho0,"rho"); // 113 + genrho->SetName("rho"); + genrho->SetMomentumRange(0., 25.); + genrho->SetPtRange(minPt, maxPt); + genrho->SetYRange(yMin, yMax); + genrho->SetPhiRange(phiMin, phiMax); + genrho->SetWeighting(weightMode); // flat pt, y and v2 zero + genrho->SetDecayer(decayer); // EXOUS; + genrho->SetForceDecay(kDiMuon); // Dielectrons + genrho->SetForceGammaConversion(kFALSE); + genrho->SetSelectAll(kTRUE); // Store also the gamma in pi0->e+e-gamma + genrho->Init(); + CocktailParam *newgenrho = new CocktailParam(genrho); + + // Omega + auto genomega = new GeneratorParam(nPart,emlib,GeneratorParamEMlib::kOmega,"omega"); //223 + genomega->SetName("omega"); + genomega->SetMomentumRange(0., 25.); + genomega->SetPtRange(minPt, maxPt); + genomega->SetYRange(yMin, yMax); + genomega->SetPhiRange(phiMin, phiMax); + genomega->SetWeighting(weightMode); // flat pt, y and v2 zero + genomega->SetDecayer(decayer); // EXOUS; + genomega->SetForceDecay(kDiMuon); // Dielectrons + genomega->SetForceGammaConversion(kFALSE); + genomega->SetSelectAll(kTRUE); // Store also the gamma in pi0->e+e-gamma + genomega->Init(); + CocktailParam *newgenomega = new CocktailParam(genomega); + + // phi + auto genphi = new GeneratorParam(nPart,emlib,GeneratorParamEMlib::kPhi,"phi"); //333 + genphi->SetName("phi"); + genphi->SetMomentumRange(0., 25.); + genphi->SetPtRange(minPt, maxPt); + genphi->SetYRange(yMin, yMax); + genphi->SetPhiRange(phiMin, phiMax); + genphi->SetWeighting(weightMode); // flat pt, y and v2 zero + genphi->SetDecayer(decayer); // EXOUS; + genphi->SetForceDecay(kDiMuon); // Dielectrons + genphi->SetForceGammaConversion(kFALSE); + genphi->SetSelectAll(kTRUE); // Store also the gamma in pi0->e+e-gamma + genphi->Init(); + CocktailParam *newgenphi = new CocktailParam(genphi); + + int target_pdg = 1; + + if (mMode < 0) { + target_pdg = 1; + cout << "all-particle mode is selected. all 5 mesons are injected in each event" << endl; + cout << "add eta for signal" << endl; + fGeneratorCocktail->AddGenerator(newgeneta, 1); + cout << "add etaprime for signal" << endl; + fGeneratorCocktail->AddGenerator(newgenetaprime, 1); + cout << "add rho for signal" << endl; + fGeneratorCocktail->AddGenerator(newgenrho, 1); + cout << "add omega for signal" << endl; + fGeneratorCocktail->AddGenerator(newgenomega, 1); + cout << "add phi for signal" << endl; + fGeneratorCocktail->AddGenerator(newgenphi, 1); + } else if (mMode < 100) { + cout << "1-particle Mode is selected. 1 meson selected randomly per job is injected in each event" << endl; + TRandom3 *r3 = new TRandom3(0); + double rndm = r3->Rndm(); + printf("rndm = %f\n", rndm); + + if (rndm < 1/5.) { + cout << "add eta for signal" << endl; + fGeneratorCocktail->AddGenerator(newgeneta, 1); + target_pdg = 221; + } else if (rndm < 2/5.) { + cout << "add etaprime for signal" << endl; + fGeneratorCocktail->AddGenerator(newgenetaprime, 1); + target_pdg = 331; + } else if (rndm < 3/5.) { + cout << "add rho for signal" << endl; + fGeneratorCocktail->AddGenerator(newgenrho, 1); + target_pdg = 113; + } else if (rndm < 4/5.) { + cout << "add omega for signal" << endl; + fGeneratorCocktail->AddGenerator(newgenomega, 1); + target_pdg = 223; + } else if (rndm < 5/5.) { + cout << "add phi for signal" << endl; + fGeneratorCocktail->AddGenerator(newgenphi, 1); + target_pdg = 333; + } + delete r3; + } else { //directly select meson pdg + target_pdg = mMode; + switch (mMode) { + case 221 : + cout << "add eta for signal" << endl; + fGeneratorCocktail->AddGenerator(newgeneta, 1); + break; + case 331 : + cout << "add etaprime for signal" << endl; + fGeneratorCocktail->AddGenerator(newgenetaprime, 1); + break; + case 113 : + cout << "add rho for signal" << endl; + fGeneratorCocktail->AddGenerator(newgenrho, 1); + break; + case 223 : + cout << "add omega for signal" << endl; + fGeneratorCocktail->AddGenerator(newgenomega, 1); + break; + case 333 : + cout << "add phi for signal" << endl; + fGeneratorCocktail->AddGenerator(newgenphi, 1); + break; + default: + cout << "!WARNING! default : nothing is added to cocktail generator" << endl; + target_pdg = 1; + break; + } + } + + // print debug + fGeneratorCocktail->PrintDebug(); + fGeneratorCocktail->Init(); + + cout << "target_pdg for subGeneratorId is " << target_pdg << endl; + addSubGenerator(0, "gap mb pythia"); + addSubGenerator(target_pdg, "injected cocktail"); + mTargetPDG = target_pdg; + }; + + ~GeneratorPythia8GapTriggeredLFmumu() = default; + + protected: + bool generateEvent() override + { + GeneratorPythia8::generateEvent(); + + if (mGeneratedEvents % mInverseTriggerRatio == 0){ // add injected prompt signals to the stack + fGeneratorCocktail->generateEvent(); + notifySubGenerator(mTargetPDG); + } else { // gap event + notifySubGenerator(0); + } + mGeneratedEvents++; + return true; + } + + bool importParticles() override + { + GeneratorPythia8::importParticles(); + + bool genOk = false; + if ((mGeneratedEvents-1) % mInverseTriggerRatio == 0){ // add injected prompt signals to the stack + fGeneratorCocktail->importParticles(); + int originalSize = mParticles.size(); + for(int ipart=0; ipart < fGeneratorCocktail->getParticles().size(); ipart++){ + TParticle part = TParticle(fGeneratorCocktail->getParticles().at(ipart)); + if(part.GetFirstMother() >= 0) part.SetFirstMother(part.GetFirstMother() + originalSize); + if(part.GetFirstDaughter() >= 0) part.SetFirstDaughter(part.GetFirstDaughter() + originalSize); + if(part.GetLastDaughter() >= 0) part.SetLastDaughter(part.GetLastDaughter() + originalSize); + mParticles.push_back(part); + // encodeParticleStatusAndTracking method already called in GeneratorEvtGen.C + } + fGeneratorCocktail->clearParticles(); + } + + return true; + } + + private: + GeneratorEvtGen *fGeneratorCocktail; + // Control gap-triggering + unsigned long long mGeneratedEvents; + int mInverseTriggerRatio; + int mMode; + int mTargetPDG; +}; + +} // close eventgen +} // close o2 + +// Predefined generators: // this function should be called in ini file. +FairGenerator *GeneratorPythia8GapTriggeredLFmumu_ForEM(int inputTriggerRatio = 5, float yMin=-4.3, float yMax=-2.2, int nPart = 1, int mode = -1) { + auto myGen = new GeneratorPythia8GapTriggeredLFmumu(inputTriggerRatio, yMin, yMax, nPart, mode); + auto seed = (gRandom->TRandom::GetSeed() % 900000000); + myGen->readString("Random:setSeed on"); + myGen->readString("Random:seed " + std::to_string(seed)); + return myGen; +} diff --git a/MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu.ini b/MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu.ini new file mode 100644 index 000000000..5f0c2f477 --- /dev/null +++ b/MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu.ini @@ -0,0 +1,9 @@ +### The setup uses an external event generator +### This part sets the path of the file and the function call to retrieve it + +[GeneratorExternal] +fileName = ${O2DPG_ROOT}/MC/config/PWGEM/external/generator/Generator_pythia8_GapTriggered_LFmumu.C +funcName = GeneratorPythia8GapTriggeredLFmumu_ForEM(5+1, -4.3, -2.2, 1, -1) + +[GeneratorPythia8] +config = ${O2DPG_ROOT}/MC/config/PWGEM/pythia8/generator/pythia8_MB_gapevent.cfg diff --git a/MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu_random_np1_gap0.ini b/MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu_random_np1_gap0.ini new file mode 100644 index 000000000..db1275c4f --- /dev/null +++ b/MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu_random_np1_gap0.ini @@ -0,0 +1,9 @@ +### The setup uses an external event generator +### This part sets the path of the file and the function call to retrieve it + +[GeneratorExternal] +fileName = ${O2DPG_ROOT}/MC/config/PWGEM/external/generator/Generator_pythia8_GapTriggered_LFmumu.C +funcName = GeneratorPythia8GapTriggeredLFmumu_ForEM(0+1, -4.3, -2.2, 1, 1) + +[GeneratorPythia8] +config = ${O2DPG_ROOT}/MC/config/PWGEM/pythia8/generator/pythia8_MB_gapevent.cfg diff --git a/MC/config/PWGEM/ini/tests/Generator_GapTriggered_LFmumu.C b/MC/config/PWGEM/ini/tests/Generator_GapTriggered_LFmumu.C new file mode 100644 index 000000000..9d6112a74 --- /dev/null +++ b/MC/config/PWGEM/ini/tests/Generator_GapTriggered_LFmumu.C @@ -0,0 +1,62 @@ +int External() +{ + std::string path{"o2sim_Kine.root"}; + 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"); + std::vector* tracks{}; + tree->SetBranchAddress("MCTrack", &tracks); + + int nMesons{}; + int nMesonsDiMuonDecay{}; + auto nEvents = tree->GetEntries(); + + for (int i = 0; i < nEvents; i++) { + tree->GetEntry(i); + for (auto& track : *tracks) { + auto pdg = track.GetPdgCode(); + auto y = track.GetRapidity(); + if ((pdg == 221) || (pdg == 331) || (pdg == 223) || (pdg == 113) || (pdg == 333)) { + if ((y>-4.3) && (y<-2.2)) { + nMesons++; + Int_t counterel = 0; + Int_t counterpos = 0; + int k1 = track.getFirstDaughterTrackId(); + int k2 = track.getLastDaughterTrackId(); + // k1 < k2 and no -1 for k2 + for (int d=k1; d <= k2; d++) { + if (d>0) { + auto decay = (*tracks)[d]; + int pdgdecay = decay.GetPdgCode(); + if (pdgdecay == 13) { + counterel++; + } + if (pdgdecay == -13) { + counterpos++; + } + } + } + if ((counterel>0) && (counterpos>0)) nMesonsDiMuonDecay++; + } + } + } + } + + std::cout << "#events: " << nEvents << "\n" + << "#mesons: " << nMesons << "\n"; + + if (nMesonsDiMuonDecay < (5*nEvents)) { + std::cerr << "One should have at least 5 mesons that decay into dimuons per event.\n"; + return 1; + } + //if (nMesons < nEvents) { + //std::cerr << "One meson per event should be produced.\n"; + //return 1; + //} + + return 0; +} diff --git a/MC/run/PWGEM/runPythia8GapTriggeredLFmumu_pp.sh b/MC/run/PWGEM/runPythia8GapTriggeredLFmumu_pp.sh new file mode 100644 index 000000000..3f3bf93d2 --- /dev/null +++ b/MC/run/PWGEM/runPythia8GapTriggeredLFmumu_pp.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash + +# make sure O2DPG + O2 is loaded +#[ ! "${O2DPG_ROOT}" ] && echo "Error: This needs O2DPG loaded" && exit 1 +#[ ! "${O2_ROOT}" ] && echo "Error: This needs O2 loaded" && exit 1 + +# ----------- SETUP LOCAL CCDB CACHE -------------------------- +#export ALICEO2_CCDB_LOCALCACHE=$PWD/.ccdb + + +# ----------- LOAD UTILITY FUNCTIONS -------------------------- +#. ${O2_ROOT}/share/scripts/jobutils.sh + +#NSIGEVENTS=${NSIGEVENTS:-10} +#NWORKERS=${NWORKERS:-8} +#NTIMEFRAMES=${NTIMEFRAMES:-1} +#INTRATE=${INTRATE:-500000} + +#CONFIGNAME="Generator_GapTriggered_LFmumu_np1_gap5.ini" + +#${O2DPG_ROOT}/MC/bin/o2dpg_sim_workflow.py -eCM 13600 -col pp -gen external -j ${NWORKERS} -ns ${NSIGEVENTS} -tf ${NTIMEFRAMES} -e TGeant4 -mod "--skipModules ZDC" \ + #-ini $O2DPG_ROOT/MC/config/PWGEM/ini/$CONFIGNAME \ + #-confKeyBkg "Diamond.width[2]=6" -interactionRate ${INTRATE} + +# run workflow +#${O2DPG_ROOT}/MC/bin/o2_dpg_workflow_runner.py -f workflow.json -tt aod --cpu-limit 32 + +#!/usr/bin/env bash + +# make sure O2DPG + O2 is loaded +[ ! "${O2DPG_ROOT}" ] && echo "Error: This needs O2DPG loaded" && exit 1 +[ ! "${O2_ROOT}" ] && echo "Error: This needs O2 loaded" && exit 1 + +# ----------- SETUP LOCAL CCDB CACHE -------------------------- +export ALICEO2_CCDB_LOCALCACHE=$PWD/.ccdb + + +# ----------- LOAD UTILITY FUNCTIONS -------------------------- +. ${O2_ROOT}/share/scripts/jobutils.sh + +NSIGEVENTS=${NSIGEVENTS:-10} +NWORKERS=${NWORKERS:-8} +NTIMEFRAMES=${NTIMEFRAMES:-1} +INTRATE=${INTRATE:-500000} +GAP=${GAP:-0} +NP=${NP:-1} + +CONFIGNAME="Generator_GapTriggered_LFmumu_random_np${NP}_gap${GAP}.ini" + +${O2DPG_ROOT}/MC/bin/o2dpg_sim_workflow.py -eCM 13600 -col pp -gen external -j ${NWORKERS} -ns ${NSIGEVENTS} -tf ${NTIMEFRAMES} -e TGeant4 -mod "--skipModules ZDC" \ + -ini $O2DPG_ROOT/MC/config/PWGEM/ini/$CONFIGNAME \ + -confKeyBkg "Diamond.width[2]=6" -interactionRate ${INTRATE} + +# run workflow +${O2DPG_ROOT}/MC/bin/o2_dpg_workflow_runner.py -f workflow.json -tt aod --cpu-limit 32 From 1bad5ba1c1e336d3621c150e536dfba7e63d55bb Mon Sep 17 00:00:00 2001 From: motomioya Date: Mon, 22 Jul 2024 00:43:00 +0900 Subject: [PATCH 07/18] Change gap --- MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu.ini b/MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu.ini index 5f0c2f477..9e17f7f72 100644 --- a/MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu.ini +++ b/MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu.ini @@ -3,7 +3,7 @@ [GeneratorExternal] fileName = ${O2DPG_ROOT}/MC/config/PWGEM/external/generator/Generator_pythia8_GapTriggered_LFmumu.C -funcName = GeneratorPythia8GapTriggeredLFmumu_ForEM(5+1, -4.3, -2.2, 1, -1) +funcName = GeneratorPythia8GapTriggeredLFmumu_ForEM(0+1, -4.3, -2.2, 1, -1) [GeneratorPythia8] config = ${O2DPG_ROOT}/MC/config/PWGEM/pythia8/generator/pythia8_MB_gapevent.cfg From 608e463c087a469029dd93991f7e57368ac86db7 Mon Sep 17 00:00:00 2001 From: motomioya Date: Mon, 22 Jul 2024 00:59:16 +0900 Subject: [PATCH 08/18] Clean files for LF to mumu --- MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu.ini | 2 +- .../Generator_GapTriggered_LFmumu_random_np1_gap0.ini | 9 --------- .../PWGEM/ini/tests/Generator_GapTriggered_LFmumu.C | 4 ++-- MC/run/PWGEM/runPythia8GapTriggeredLFmumu_pp.sh | 4 +--- 4 files changed, 4 insertions(+), 15 deletions(-) delete mode 100644 MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu_random_np1_gap0.ini diff --git a/MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu.ini b/MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu.ini index 9e17f7f72..db1275c4f 100644 --- a/MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu.ini +++ b/MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu.ini @@ -3,7 +3,7 @@ [GeneratorExternal] fileName = ${O2DPG_ROOT}/MC/config/PWGEM/external/generator/Generator_pythia8_GapTriggered_LFmumu.C -funcName = GeneratorPythia8GapTriggeredLFmumu_ForEM(0+1, -4.3, -2.2, 1, -1) +funcName = GeneratorPythia8GapTriggeredLFmumu_ForEM(0+1, -4.3, -2.2, 1, 1) [GeneratorPythia8] config = ${O2DPG_ROOT}/MC/config/PWGEM/pythia8/generator/pythia8_MB_gapevent.cfg diff --git a/MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu_random_np1_gap0.ini b/MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu_random_np1_gap0.ini deleted file mode 100644 index db1275c4f..000000000 --- a/MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu_random_np1_gap0.ini +++ /dev/null @@ -1,9 +0,0 @@ -### The setup uses an external event generator -### This part sets the path of the file and the function call to retrieve it - -[GeneratorExternal] -fileName = ${O2DPG_ROOT}/MC/config/PWGEM/external/generator/Generator_pythia8_GapTriggered_LFmumu.C -funcName = GeneratorPythia8GapTriggeredLFmumu_ForEM(0+1, -4.3, -2.2, 1, 1) - -[GeneratorPythia8] -config = ${O2DPG_ROOT}/MC/config/PWGEM/pythia8/generator/pythia8_MB_gapevent.cfg diff --git a/MC/config/PWGEM/ini/tests/Generator_GapTriggered_LFmumu.C b/MC/config/PWGEM/ini/tests/Generator_GapTriggered_LFmumu.C index 9d6112a74..f66f5db7a 100644 --- a/MC/config/PWGEM/ini/tests/Generator_GapTriggered_LFmumu.C +++ b/MC/config/PWGEM/ini/tests/Generator_GapTriggered_LFmumu.C @@ -49,8 +49,8 @@ int External() std::cout << "#events: " << nEvents << "\n" << "#mesons: " << nMesons << "\n"; - if (nMesonsDiMuonDecay < (5*nEvents)) { - std::cerr << "One should have at least 5 mesons that decay into dimuons per event.\n"; + if (nMesonsDiMuonDecay < (nEvents)) { + std::cerr << "One should have at least 1 mesons that decay into dimuons per event.\n"; return 1; } //if (nMesons < nEvents) { diff --git a/MC/run/PWGEM/runPythia8GapTriggeredLFmumu_pp.sh b/MC/run/PWGEM/runPythia8GapTriggeredLFmumu_pp.sh index 3f3bf93d2..4cfb459a8 100644 --- a/MC/run/PWGEM/runPythia8GapTriggeredLFmumu_pp.sh +++ b/MC/run/PWGEM/runPythia8GapTriggeredLFmumu_pp.sh @@ -42,10 +42,8 @@ NSIGEVENTS=${NSIGEVENTS:-10} NWORKERS=${NWORKERS:-8} NTIMEFRAMES=${NTIMEFRAMES:-1} INTRATE=${INTRATE:-500000} -GAP=${GAP:-0} -NP=${NP:-1} -CONFIGNAME="Generator_GapTriggered_LFmumu_random_np${NP}_gap${GAP}.ini" +CONFIGNAME="Generator_GapTriggered_LFmumu.ini" ${O2DPG_ROOT}/MC/bin/o2dpg_sim_workflow.py -eCM 13600 -col pp -gen external -j ${NWORKERS} -ns ${NSIGEVENTS} -tf ${NTIMEFRAMES} -e TGeant4 -mod "--skipModules ZDC" \ -ini $O2DPG_ROOT/MC/config/PWGEM/ini/$CONFIGNAME \ From a45c993b81ec3f0cbe68918923ef195d31387119 Mon Sep 17 00:00:00 2001 From: motomioya Date: Mon, 22 Jul 2024 01:09:01 +0900 Subject: [PATCH 09/18] Mofity test script --- MC/config/PWGEM/ini/tests/Generator_GapTriggered_LFmumu.C | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MC/config/PWGEM/ini/tests/Generator_GapTriggered_LFmumu.C b/MC/config/PWGEM/ini/tests/Generator_GapTriggered_LFmumu.C index f66f5db7a..272a6e407 100644 --- a/MC/config/PWGEM/ini/tests/Generator_GapTriggered_LFmumu.C +++ b/MC/config/PWGEM/ini/tests/Generator_GapTriggered_LFmumu.C @@ -47,7 +47,8 @@ int External() } std::cout << "#events: " << nEvents << "\n" - << "#mesons: " << nMesons << "\n"; + << "#mesons: " << nMesons << "\n" + << "#mesons to dimuon: " << nMesonsDiMuonDecay << "\n"; if (nMesonsDiMuonDecay < (nEvents)) { std::cerr << "One should have at least 1 mesons that decay into dimuons per event.\n"; From 025c743fb306fa378c300eba7298a1efbe1df609 Mon Sep 17 00:00:00 2001 From: motomioya Date: Mon, 22 Jul 2024 01:18:23 +0900 Subject: [PATCH 10/18] modify to test test script --- MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu.ini b/MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu.ini index db1275c4f..726887ec2 100644 --- a/MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu.ini +++ b/MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu.ini @@ -3,7 +3,7 @@ [GeneratorExternal] fileName = ${O2DPG_ROOT}/MC/config/PWGEM/external/generator/Generator_pythia8_GapTriggered_LFmumu.C -funcName = GeneratorPythia8GapTriggeredLFmumu_ForEM(0+1, -4.3, -2.2, 1, 1) +funcName = GeneratorPythia8GapTriggeredLFmumu_ForEM(3+1, -4.3, -2.2, 1, 1) [GeneratorPythia8] config = ${O2DPG_ROOT}/MC/config/PWGEM/pythia8/generator/pythia8_MB_gapevent.cfg From c3cb72230ddcccaf4bad0eb7c7cf6ea0f96845a7 Mon Sep 17 00:00:00 2001 From: motomioya Date: Mon, 22 Jul 2024 01:20:33 +0900 Subject: [PATCH 11/18] modify to test test script --- MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu.ini b/MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu.ini index 726887ec2..f4708703e 100644 --- a/MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu.ini +++ b/MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu.ini @@ -3,7 +3,7 @@ [GeneratorExternal] fileName = ${O2DPG_ROOT}/MC/config/PWGEM/external/generator/Generator_pythia8_GapTriggered_LFmumu.C -funcName = GeneratorPythia8GapTriggeredLFmumu_ForEM(3+1, -4.3, -2.2, 1, 1) +funcName = GeneratorPythia8GapTriggeredLFmumu_ForEM(0, -4.3, -2.2, 1, 1) [GeneratorPythia8] config = ${O2DPG_ROOT}/MC/config/PWGEM/pythia8/generator/pythia8_MB_gapevent.cfg From 5632f6a9c517ffc114295042032fc4bd9306da78 Mon Sep 17 00:00:00 2001 From: motomioya Date: Mon, 22 Jul 2024 01:33:45 +0900 Subject: [PATCH 12/18] modify to test test script --- MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu.ini b/MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu.ini index f4708703e..db1275c4f 100644 --- a/MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu.ini +++ b/MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu.ini @@ -3,7 +3,7 @@ [GeneratorExternal] fileName = ${O2DPG_ROOT}/MC/config/PWGEM/external/generator/Generator_pythia8_GapTriggered_LFmumu.C -funcName = GeneratorPythia8GapTriggeredLFmumu_ForEM(0, -4.3, -2.2, 1, 1) +funcName = GeneratorPythia8GapTriggeredLFmumu_ForEM(0+1, -4.3, -2.2, 1, 1) [GeneratorPythia8] config = ${O2DPG_ROOT}/MC/config/PWGEM/pythia8/generator/pythia8_MB_gapevent.cfg From 513c3495fa9728bd9cd5b23ebea222545a5d7f91 Mon Sep 17 00:00:00 2001 From: motomioya Date: Mon, 22 Jul 2024 02:51:21 +0900 Subject: [PATCH 13/18] modify to test test script --- .../PWGEM/ini/tests/Generator_GapTriggered_LFmumu.C | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/MC/config/PWGEM/ini/tests/Generator_GapTriggered_LFmumu.C b/MC/config/PWGEM/ini/tests/Generator_GapTriggered_LFmumu.C index 272a6e407..f7f4d33a5 100644 --- a/MC/config/PWGEM/ini/tests/Generator_GapTriggered_LFmumu.C +++ b/MC/config/PWGEM/ini/tests/Generator_GapTriggered_LFmumu.C @@ -48,14 +48,13 @@ int External() std::cout << "#events: " << nEvents << "\n" << "#mesons: " << nMesons << "\n" - << "#mesons to dimuon: " << nMesonsDiMuonDecay << "\n"; - if (nMesonsDiMuonDecay < (nEvents)) { - std::cerr << "One should have at least 1 mesons that decay into dimuons per event.\n"; + if (nMesons < (nEvents)) { + std::cerr << "One should have at least one mesons in forward region per event.\n"; return 1; } - //if (nMesons < nEvents) { - //std::cerr << "One meson per event should be produced.\n"; + //if (nMesonsDiMuonDecay < nEvents) { + //std::cerr << "One meson to dimuon decay per event should be produced.\n"; //return 1; //} From f4b628b0746aeba022426d68de9a202914ab4745 Mon Sep 17 00:00:00 2001 From: motomioya Date: Mon, 22 Jul 2024 02:54:51 +0900 Subject: [PATCH 14/18] bug fixing --- MC/config/PWGEM/ini/tests/Generator_GapTriggered_LFmumu.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MC/config/PWGEM/ini/tests/Generator_GapTriggered_LFmumu.C b/MC/config/PWGEM/ini/tests/Generator_GapTriggered_LFmumu.C index f7f4d33a5..d5c824d55 100644 --- a/MC/config/PWGEM/ini/tests/Generator_GapTriggered_LFmumu.C +++ b/MC/config/PWGEM/ini/tests/Generator_GapTriggered_LFmumu.C @@ -47,7 +47,7 @@ int External() } std::cout << "#events: " << nEvents << "\n" - << "#mesons: " << nMesons << "\n" + << "#mesons: " << nMesons << "\n"; if (nMesons < (nEvents)) { std::cerr << "One should have at least one mesons in forward region per event.\n"; From 338c79da0f185bb68f810aeae381433be51dcb28 Mon Sep 17 00:00:00 2001 From: motomioya Date: Tue, 30 Jul 2024 08:31:26 +0900 Subject: [PATCH 15/18] Modify gap number --- MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu.ini | 2 +- MC/config/PWGEM/ini/tests/Generator_GapTriggered_LFmumu.C | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu.ini b/MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu.ini index db1275c4f..659e30805 100644 --- a/MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu.ini +++ b/MC/config/PWGEM/ini/Generator_GapTriggered_LFmumu.ini @@ -3,7 +3,7 @@ [GeneratorExternal] fileName = ${O2DPG_ROOT}/MC/config/PWGEM/external/generator/Generator_pythia8_GapTriggered_LFmumu.C -funcName = GeneratorPythia8GapTriggeredLFmumu_ForEM(0+1, -4.3, -2.2, 1, 1) +funcName = GeneratorPythia8GapTriggeredLFmumu_ForEM(5+1, -4.3, -2.2, 1, 1) [GeneratorPythia8] config = ${O2DPG_ROOT}/MC/config/PWGEM/pythia8/generator/pythia8_MB_gapevent.cfg diff --git a/MC/config/PWGEM/ini/tests/Generator_GapTriggered_LFmumu.C b/MC/config/PWGEM/ini/tests/Generator_GapTriggered_LFmumu.C index d5c824d55..f79058e59 100644 --- a/MC/config/PWGEM/ini/tests/Generator_GapTriggered_LFmumu.C +++ b/MC/config/PWGEM/ini/tests/Generator_GapTriggered_LFmumu.C @@ -49,8 +49,8 @@ int External() std::cout << "#events: " << nEvents << "\n" << "#mesons: " << nMesons << "\n"; - if (nMesons < (nEvents)) { - std::cerr << "One should have at least one mesons in forward region per event.\n"; + if (nMesons < (nEvents*5)) { + std::cerr << "One should have at least one mesons in forward region per 5 events.\n"; return 1; } //if (nMesonsDiMuonDecay < nEvents) { From 357980148bb336c077b50db96767e7fddc05571d Mon Sep 17 00:00:00 2001 From: motomioya Date: Tue, 30 Jul 2024 15:22:50 +0900 Subject: [PATCH 16/18] Fixed bugs --- MC/config/PWGEM/ini/tests/Generator_GapTriggered_LFmumu.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MC/config/PWGEM/ini/tests/Generator_GapTriggered_LFmumu.C b/MC/config/PWGEM/ini/tests/Generator_GapTriggered_LFmumu.C index f79058e59..16f2d9118 100644 --- a/MC/config/PWGEM/ini/tests/Generator_GapTriggered_LFmumu.C +++ b/MC/config/PWGEM/ini/tests/Generator_GapTriggered_LFmumu.C @@ -49,7 +49,7 @@ int External() std::cout << "#events: " << nEvents << "\n" << "#mesons: " << nMesons << "\n"; - if (nMesons < (nEvents*5)) { + if (nMesons < (nEvents/5)) { std::cerr << "One should have at least one mesons in forward region per 5 events.\n"; return 1; } From 1ce979fd6056958da49203b592421ed8d741fa8a Mon Sep 17 00:00:00 2001 From: motomioya Date: Wed, 14 Aug 2024 18:06:22 +0900 Subject: [PATCH 17/18] Add scripts for cc to mumu by inel --- ...rHF_ccbarToMuonsSemileptonic_fwdy_inel.ini | 22 +++++ ...ccbarToMuonsSemileptonic_fwdy_inel_cr2.ini | 22 +++++ ...torHF_ccbarToMuonsSemileptonic_fwdy_inel.C | 81 +++++++++++++++++++ ...F_ccbarToMuonsSemileptonic_fwdy_inel_cr2.C | 81 +++++++++++++++++++ 4 files changed, 206 insertions(+) create mode 100644 MC/config/PWGDQ/ini/GeneratorHF_ccbarToMuonsSemileptonic_fwdy_inel.ini create mode 100644 MC/config/PWGDQ/ini/GeneratorHF_ccbarToMuonsSemileptonic_fwdy_inel_cr2.ini create mode 100644 MC/config/PWGDQ/ini/tests/GeneratorHF_ccbarToMuonsSemileptonic_fwdy_inel.C create mode 100644 MC/config/PWGDQ/ini/tests/GeneratorHF_ccbarToMuonsSemileptonic_fwdy_inel_cr2.C diff --git a/MC/config/PWGDQ/ini/GeneratorHF_ccbarToMuonsSemileptonic_fwdy_inel.ini b/MC/config/PWGDQ/ini/GeneratorHF_ccbarToMuonsSemileptonic_fwdy_inel.ini new file mode 100644 index 000000000..86f9d3e1a --- /dev/null +++ b/MC/config/PWGDQ/ini/GeneratorHF_ccbarToMuonsSemileptonic_fwdy_inel.ini @@ -0,0 +1,22 @@ +### The setup uses an external event generator +### This part sets the path of the file and the function call to retrieve it + +[GeneratorExternal] +fileName = ${O2DPG_ROOT}/MC/config/PWGDQ/external/generator/GeneratorCharmToMu_EvtGen.C +funcName = GeneratorCharmToMu_EvtGenFwdY() + +### The external generator derives from GeneratorPythia8. +### This part configures the bits of the interface: configuration and user hooks + +[GeneratorPythia8] +config = ${O2DPG_ROOT}/MC/config/common/pythia8/generator/pythia8_inel.cfg +hooksFileName = ${O2DPG_ROOT}/MC/config/PWGHF/pythia8/hooks/pythia8_userhooks_qqbar.C +hooksFuncName = pythia8_userhooks_ccbar(-4.3,-2.3) + +### The setup uses an external even generator trigger which is +### defined in the following file and it is retrieved and configured +### according to the specified function call + +[TriggerExternal] +fileName = ${O2DPG_ROOT}/MC/config/PWGDQ/trigger/selectDaughterFromHFwithinAcc.C +funcName = selectDaughterFromHFwithinAcc(13,kTRUE,-4.3,-2.3) diff --git a/MC/config/PWGDQ/ini/GeneratorHF_ccbarToMuonsSemileptonic_fwdy_inel_cr2.ini b/MC/config/PWGDQ/ini/GeneratorHF_ccbarToMuonsSemileptonic_fwdy_inel_cr2.ini new file mode 100644 index 000000000..a379d3f0f --- /dev/null +++ b/MC/config/PWGDQ/ini/GeneratorHF_ccbarToMuonsSemileptonic_fwdy_inel_cr2.ini @@ -0,0 +1,22 @@ +### The setup uses an external event generator +### This part sets the path of the file and the function call to retrieve it + +[GeneratorExternal] +fileName = ${O2DPG_ROOT}/MC/config/PWGDQ/external/generator/GeneratorCharmToMu_EvtGen.C +funcName = GeneratorCharmToMu_EvtGenFwdY() + +### The external generator derives from GeneratorPythia8. +### This part configures the bits of the interface: configuration and user hooks + +[GeneratorPythia8] +config = ${O2DPG_ROOT}/MC/config/common/pythia8/generator/pythia8_pp_cr2.cfg +hooksFileName = ${O2DPG_ROOT}/MC/config/PWGHF/pythia8/hooks/pythia8_userhooks_qqbar.C +hooksFuncName = pythia8_userhooks_ccbar(-4.3,-2.3) + +### The setup uses an external even generator trigger which is +### defined in the following file and it is retrieved and configured +### according to the specified function call + +[TriggerExternal] +fileName = ${O2DPG_ROOT}/MC/config/PWGDQ/trigger/selectDaughterFromHFwithinAcc.C +funcName = selectDaughterFromHFwithinAcc(13,kTRUE,-4.3,-2.3) diff --git a/MC/config/PWGDQ/ini/tests/GeneratorHF_ccbarToMuonsSemileptonic_fwdy_inel.C b/MC/config/PWGDQ/ini/tests/GeneratorHF_ccbarToMuonsSemileptonic_fwdy_inel.C new file mode 100644 index 000000000..abba3a50b --- /dev/null +++ b/MC/config/PWGDQ/ini/tests/GeneratorHF_ccbarToMuonsSemileptonic_fwdy_inel.C @@ -0,0 +1,81 @@ +int External() +{ + int checkPdgDecay = 13; + std::string path{"o2sim_Kine.root"}; + 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"); + std::vector* tracks{}; + tree->SetBranchAddress("MCTrack", &tracks); + + int nLeptons{}; + int nLeptonsInAcceptance{}; + int nLeptonsToBeDone{}; + int nSignalPairs{}; + int nLeptonPairs{}; + int nLeptonPairsInAcceptance{}; + int nLeptonPairsToBeDone{}; + auto nEvents = tree->GetEntries(); + + for (int i = 0; i < nEvents; i++) { + tree->GetEntry(i); + int nleptonseinacc = 0; + int nleptonse = 0; + int nleptonseToBeDone = 0; + int nopenHeavy = 0; + for (auto& track : *tracks) { + auto pdg = track.GetPdgCode(); + auto y = track.GetRapidity(); + if (std::abs(pdg) == checkPdgDecay) { + int igmother = track.getMotherTrackId(); + if (igmother > 0) { + auto gmTrack = (*tracks)[igmother]; + int gmpdg = gmTrack.GetPdgCode(); + if ( int(std::abs(gmpdg)/100.) == 4 || int(std::abs(gmpdg)/1000.) == 4 || int(std::abs(gmpdg)/100.) == 5 || int(std::abs(gmpdg)/1000.) == 5 ) { + nLeptons++; + nleptonse++; + if (-4.3 < y && y < -2.3) { + nleptonseinacc++; + nLeptonsInAcceptance++; + } + if (track.getToBeDone()) { + nLeptonsToBeDone++; + nleptonseToBeDone++; + } + } + } + } else if (std::abs(pdg) == 411 || std::abs(pdg) == 421 || std::abs(pdg) == 431 || std::abs(pdg) == 4122 || std::abs(pdg) == 4132 || std::abs(pdg) == 4232 || std::abs(pdg) == 4332) { + nopenHeavy++; + } + } + if (nopenHeavy > 1) nSignalPairs++; + if (nleptonse > 1) nLeptonPairs++; + if (nleptonseToBeDone > 1) nLeptonPairsToBeDone++; + if (nleptonseinacc > 1) nLeptonPairsInAcceptance++; + } + std::cout << "#events: " << nEvents << "\n" + << "#muons in acceptance: " << nLeptonsInAcceptance << "\n" + << "#muon pairs in acceptance: " << nLeptonPairsInAcceptance << "\n" + << "#muons: " << nLeptons << "\n" + << "#muons to be done: " << nLeptonsToBeDone << "\n" + << "#signal pairs: " << nSignalPairs << "\n" + << "#muon pairs: " << nLeptonPairs << "\n" + << "#muon pairs to be done: " << nLeptonPairsToBeDone << "\n"; + if (nSignalPairs < nEvents) { + std::cerr << "Number of signal pairs should be at least equaled to the number of events\n"; + return 1; + } + if (nLeptonPairs != nLeptonPairsToBeDone) { + std::cerr << "The number of muon pairs should be the same as the number of muon pairs which should be transported.\n"; + return 1; + } + if (nLeptons != nLeptonsToBeDone) { + std::cerr << "The number of muons should be the same as the number of muons which should be transported.\n"; + return 1; + } + + return 0; +} diff --git a/MC/config/PWGDQ/ini/tests/GeneratorHF_ccbarToMuonsSemileptonic_fwdy_inel_cr2.C b/MC/config/PWGDQ/ini/tests/GeneratorHF_ccbarToMuonsSemileptonic_fwdy_inel_cr2.C new file mode 100644 index 000000000..abba3a50b --- /dev/null +++ b/MC/config/PWGDQ/ini/tests/GeneratorHF_ccbarToMuonsSemileptonic_fwdy_inel_cr2.C @@ -0,0 +1,81 @@ +int External() +{ + int checkPdgDecay = 13; + std::string path{"o2sim_Kine.root"}; + 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"); + std::vector* tracks{}; + tree->SetBranchAddress("MCTrack", &tracks); + + int nLeptons{}; + int nLeptonsInAcceptance{}; + int nLeptonsToBeDone{}; + int nSignalPairs{}; + int nLeptonPairs{}; + int nLeptonPairsInAcceptance{}; + int nLeptonPairsToBeDone{}; + auto nEvents = tree->GetEntries(); + + for (int i = 0; i < nEvents; i++) { + tree->GetEntry(i); + int nleptonseinacc = 0; + int nleptonse = 0; + int nleptonseToBeDone = 0; + int nopenHeavy = 0; + for (auto& track : *tracks) { + auto pdg = track.GetPdgCode(); + auto y = track.GetRapidity(); + if (std::abs(pdg) == checkPdgDecay) { + int igmother = track.getMotherTrackId(); + if (igmother > 0) { + auto gmTrack = (*tracks)[igmother]; + int gmpdg = gmTrack.GetPdgCode(); + if ( int(std::abs(gmpdg)/100.) == 4 || int(std::abs(gmpdg)/1000.) == 4 || int(std::abs(gmpdg)/100.) == 5 || int(std::abs(gmpdg)/1000.) == 5 ) { + nLeptons++; + nleptonse++; + if (-4.3 < y && y < -2.3) { + nleptonseinacc++; + nLeptonsInAcceptance++; + } + if (track.getToBeDone()) { + nLeptonsToBeDone++; + nleptonseToBeDone++; + } + } + } + } else if (std::abs(pdg) == 411 || std::abs(pdg) == 421 || std::abs(pdg) == 431 || std::abs(pdg) == 4122 || std::abs(pdg) == 4132 || std::abs(pdg) == 4232 || std::abs(pdg) == 4332) { + nopenHeavy++; + } + } + if (nopenHeavy > 1) nSignalPairs++; + if (nleptonse > 1) nLeptonPairs++; + if (nleptonseToBeDone > 1) nLeptonPairsToBeDone++; + if (nleptonseinacc > 1) nLeptonPairsInAcceptance++; + } + std::cout << "#events: " << nEvents << "\n" + << "#muons in acceptance: " << nLeptonsInAcceptance << "\n" + << "#muon pairs in acceptance: " << nLeptonPairsInAcceptance << "\n" + << "#muons: " << nLeptons << "\n" + << "#muons to be done: " << nLeptonsToBeDone << "\n" + << "#signal pairs: " << nSignalPairs << "\n" + << "#muon pairs: " << nLeptonPairs << "\n" + << "#muon pairs to be done: " << nLeptonPairsToBeDone << "\n"; + if (nSignalPairs < nEvents) { + std::cerr << "Number of signal pairs should be at least equaled to the number of events\n"; + return 1; + } + if (nLeptonPairs != nLeptonPairsToBeDone) { + std::cerr << "The number of muon pairs should be the same as the number of muon pairs which should be transported.\n"; + return 1; + } + if (nLeptons != nLeptonsToBeDone) { + std::cerr << "The number of muons should be the same as the number of muons which should be transported.\n"; + return 1; + } + + return 0; +} From 2d0ce0346d1e2116ee66ff8903fe247f99024e6b Mon Sep 17 00:00:00 2001 From: motomioya Date: Wed, 14 Aug 2024 20:49:04 +0900 Subject: [PATCH 18/18] Modify rapidity range for test --- .../ini/tests/GeneratorHF_ccbarToMuonsSemileptonic_fwdy_inel.C | 2 +- .../tests/GeneratorHF_ccbarToMuonsSemileptonic_fwdy_inel_cr2.C | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MC/config/PWGDQ/ini/tests/GeneratorHF_ccbarToMuonsSemileptonic_fwdy_inel.C b/MC/config/PWGDQ/ini/tests/GeneratorHF_ccbarToMuonsSemileptonic_fwdy_inel.C index abba3a50b..012e45b90 100644 --- a/MC/config/PWGDQ/ini/tests/GeneratorHF_ccbarToMuonsSemileptonic_fwdy_inel.C +++ b/MC/config/PWGDQ/ini/tests/GeneratorHF_ccbarToMuonsSemileptonic_fwdy_inel.C @@ -37,7 +37,7 @@ int External() if ( int(std::abs(gmpdg)/100.) == 4 || int(std::abs(gmpdg)/1000.) == 4 || int(std::abs(gmpdg)/100.) == 5 || int(std::abs(gmpdg)/1000.) == 5 ) { nLeptons++; nleptonse++; - if (-4.3 < y && y < -2.3) { + if (-4.3 < y && y < -2.2) { nleptonseinacc++; nLeptonsInAcceptance++; } diff --git a/MC/config/PWGDQ/ini/tests/GeneratorHF_ccbarToMuonsSemileptonic_fwdy_inel_cr2.C b/MC/config/PWGDQ/ini/tests/GeneratorHF_ccbarToMuonsSemileptonic_fwdy_inel_cr2.C index abba3a50b..012e45b90 100644 --- a/MC/config/PWGDQ/ini/tests/GeneratorHF_ccbarToMuonsSemileptonic_fwdy_inel_cr2.C +++ b/MC/config/PWGDQ/ini/tests/GeneratorHF_ccbarToMuonsSemileptonic_fwdy_inel_cr2.C @@ -37,7 +37,7 @@ int External() if ( int(std::abs(gmpdg)/100.) == 4 || int(std::abs(gmpdg)/1000.) == 4 || int(std::abs(gmpdg)/100.) == 5 || int(std::abs(gmpdg)/1000.) == 5 ) { nLeptons++; nleptonse++; - if (-4.3 < y && y < -2.3) { + if (-4.3 < y && y < -2.2) { nleptonseinacc++; nLeptonsInAcceptance++; }