From 1cde53e752a8e9af7a9c8337e1ff497c8a154e74 Mon Sep 17 00:00:00 2001 From: motomioya <95481703+motomioya@users.noreply.github.com> Date: Sat, 9 Mar 2024 00:57:04 +0900 Subject: [PATCH] Add files to simulate bbtomuons without forcing semileptonic decay (#1504) --- .../generator/GeneratorBeautyToMu_EvtGen.C | 5 +- .../GeneratorHF_bbbarToDDbarToMuons_fwdy.ini | 23 +++++ .../GeneratorHF_bbbarToDDbarToMuons_fwdy.C | 85 +++++++++++++++++++ .../PWGDQ/runBeautyToMuons_noForce_fwd_pp.sh | 27 ++++++ 4 files changed, 138 insertions(+), 2 deletions(-) create mode 100644 MC/config/PWGDQ/ini/GeneratorHF_bbbarToDDbarToMuons_fwdy.ini create mode 100644 MC/config/PWGDQ/ini/tests/GeneratorHF_bbbarToDDbarToMuons_fwdy.C 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..3edfb93dc 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(kEvtSemiMuonic); + 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/config/PWGDQ/ini/tests/GeneratorHF_bbbarToDDbarToMuons_fwdy.C b/MC/config/PWGDQ/ini/tests/GeneratorHF_bbbarToDDbarToMuons_fwdy.C new file mode 100644 index 000000000..271e0ff39 --- /dev/null +++ b/MC/config/PWGDQ/ini/tests/GeneratorHF_bbbarToDDbarToMuons_fwdy.C @@ -0,0 +1,85 @@ +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" + << "#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 <= nLeptonPairs) { + 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 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/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