diff --git a/MC/config/PWGDQ/external/generator/generator_pythia8Onia_PromptSignals_gaptriggered.C b/MC/config/PWGDQ/external/generator/generator_pythia8Onia_PromptSignals_gaptriggered.C index f37e207f4..74d71bda6 100644 --- a/MC/config/PWGDQ/external/generator/generator_pythia8Onia_PromptSignals_gaptriggered.C +++ b/MC/config/PWGDQ/external/generator/generator_pythia8Onia_PromptSignals_gaptriggered.C @@ -173,4 +173,37 @@ FairGenerator* // gen->PrintDebug(); return gen; -} \ No newline at end of file +} + +FairGenerator* + GeneratorPromptJpsi_EvtGenFwdy(int triggerGap, double rapidityMin = -4.3, double rapidityMax = -2.3, bool verbose = false) +{ + auto gen = new o2::eventgen::GeneratorEvtGen(); + gen->setTriggerGap(triggerGap); + gen->setRapidityRange(rapidityMin, rapidityMax); + gen->addHadronPDGs(443); + gen->setVerbose(verbose); + + TString pathO2table = gSystem->ExpandPathName("${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGDQ/pythia8/decayer/switchOffJpsi.cfg"); + gen->readFile(pathO2table.Data()); + gen->setConfigMBdecays(pathO2table); + gen->PrintDebug(true); + + gen->SetSizePdg(1); + gen->AddPdg(443, 0); + + gen->SetForceDecay(kEvtDiMuon); + + // set random seed + gen->readString("Random:setSeed on"); + uint random_seed; + unsigned long long int random_value = 0; + ifstream urandom("/dev/urandom", ios::in|ios::binary); + urandom.read(reinterpret_cast(&random_value), sizeof(random_seed)); + gen->readString(Form("Random:seed = %llu", random_value % 900000001)); + + // print debug + // gen->PrintDebug(); + + return gen; +} diff --git a/MC/config/PWGDQ/ini/Generator_InjectedPromptJpsiFwdy_PythiaOnia_TriggerGap.ini b/MC/config/PWGDQ/ini/Generator_InjectedPromptJpsiFwdy_PythiaOnia_TriggerGap.ini new file mode 100644 index 000000000..e6f0d7316 --- /dev/null +++ b/MC/config/PWGDQ/ini/Generator_InjectedPromptJpsiFwdy_PythiaOnia_TriggerGap.ini @@ -0,0 +1,7 @@ +### The external generator derives from GeneratorPythia8. +[GeneratorExternal] +fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGDQ/external/generator/generator_pythia8Onia_PromptSignals_gaptriggered.C +funcName=GeneratorPromptJpsi_EvtGenFwdy(5,-4.3,-2.3) + +[GeneratorPythia8] +config=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGDQ/pythia8/generator/pythia8_onia_triggerGap.cfg diff --git a/MC/config/PWGDQ/ini/tests/Generator_InjectedPromptJpsiFwdy_PythiaOnia_TriggerGap.C b/MC/config/PWGDQ/ini/tests/Generator_InjectedPromptJpsiFwdy_PythiaOnia_TriggerGap.C new file mode 100644 index 000000000..2b75fcdbd --- /dev/null +++ b/MC/config/PWGDQ/ini/tests/Generator_InjectedPromptJpsiFwdy_PythiaOnia_TriggerGap.C @@ -0,0 +1,82 @@ +int External() +{ + int checkPdgSignal[] = {443}; + int checkPdgDecay = 13; + double rapiditymin = -4.3; double rapiditymax = -2.3; + std::string path{"o2sim_Kine.root"}; + std::cout << "Check for\nsignal PDG " << checkPdgSignal[0] << "\n decay PDG " << checkPdgDecay << "\n"; + 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 nAntileptons{}; + int nLeptonPairs{}; + int nLeptonPairsToBeDone{}; + int nSignalJpsi{}; + int nSignalJpsiWithinAcc{}; + auto nEvents = tree->GetEntries(); + o2::steer::MCKinematicsReader mcreader("o2sim", o2::steer::MCKinematicsReader::Mode::kMCKine); + Bool_t isInjected = kFALSE; + + for (int i = 0; i < nEvents; i++) { + tree->GetEntry(i); + for (auto& track : *tracks) { + auto pdg = track.GetPdgCode(); + auto rapidity = track.GetRapidity(); + auto idMoth = track.getMotherTrackId(); + if (pdg == checkPdgDecay) { + // count leptons + nLeptons++; + } else if(pdg == -checkPdgDecay) { + // count anti-leptons + nAntileptons++; + } else if (pdg == checkPdgSignal[0]) { + if(idMoth < 0){ + // count signal PDG + nSignalJpsi++; + // count signal PDG within acceptance + if(rapidity > rapiditymin && rapidity < rapiditymax) nSignalJpsiWithinAcc++; + } + auto child0 = o2::mcutils::MCTrackNavigator::getDaughter0(track, *tracks); + auto child1 = o2::mcutils::MCTrackNavigator::getDaughter1(track, *tracks); + if (child0 != nullptr && child1 != nullptr) { + // check for parent-child relations + auto pdg0 = child0->GetPdgCode(); + auto pdg1 = child1->GetPdgCode(); + std::cout << "First and last children of parent " << checkPdgSignal << " are PDG0: " << pdg0 << " PDG1: " << pdg1 << "\n"; + if (std::abs(pdg0) == checkPdgDecay && std::abs(pdg1) == checkPdgDecay && pdg0 == -pdg1) { + nLeptonPairs++; + if (child0->getToBeDone() && child1->getToBeDone()) { + nLeptonPairsToBeDone++; + } + } + } + } + } + } + std::cout << "#events: " << nEvents << "\n" + << "#leptons: " << nLeptons << "\n" + << "#antileptons: " << nAntileptons << "\n" + << "#signal (prompt Jpsi): " << nSignalJpsi << "; within acceptance " << rapiditymin << " < y < " << rapiditymax << " : " << nSignalJpsiWithinAcc << "\n" + << "#lepton pairs: " << nLeptonPairs << "\n" + << "#lepton pairs to be done: " << nLeptonPairs << "\n"; + + + if (nLeptonPairs == 0 || nLeptons == 0 || nAntileptons == 0) { + std::cerr << "Number of leptons, number of anti-leptons as well as number of lepton pairs should all be greater than 1.\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; + } + + return 0; +} diff --git a/MC/config/common/pythia8/generator/pythia8_hf.cfg b/MC/config/common/pythia8/generator/pythia8_hf.cfg index 273751f09..899e96b31 100644 --- a/MC/config/common/pythia8/generator/pythia8_hf.cfg +++ b/MC/config/common/pythia8/generator/pythia8_hf.cfg @@ -1,7 +1,7 @@ ### beams Beams:idA 2212 # proton Beams:idB 2212 # proton -Beams:eCM 14000. # GeV +Beams:eCM 13600. # GeV ### processes HardQCD:hardccbar on # scatterings g-g / q-qbar -> c-cbar