Skip to content

Commit acc8c67

Browse files
ffiondagconesab
authored andcommitted
update of scripts+macros for non-prompt J/psi simulations
1 parent c108ba9 commit acc8c67

File tree

6 files changed

+148
-10
lines changed

6 files changed

+148
-10
lines changed

MC/config/PWGDQ/external/generator/GeneratorBeautyToJpsi_EvtGen.C

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// usage (fwdy) :
2-
//o2-sim -j 4 -n 10 -g external -m "PIPE ITS TPC" -o sgn --configKeyValues "GeneratorExternal.fileName=GeneratorBeautyToJpsi_EvtGen.C;GeneratorExternal.funcName=GeneratorBeautyToJpsi_EvtGenFwdY()" --configFile GeneratorHF_bbbar_fwdy.ini
2+
//o2-sim -j 4 -n 10 -g external -t external -m "PIPE ITS TPC" -o sgn --configFile GeneratorHF_bbbar_fwdy.ini
33
// usage (midy) :
4-
//o2-sim -j 4 -n 10 -g external -m "PIPE ITS TPC" -o sgn --configKeyValues "GeneratorExternal.fileName=GeneratorBeautyToJpsi_EvtGen.C;GeneratorExternal.funcName=GeneratorBeautyToJpsi_EvtGenMidY()" --configFile GeneratorHF_bbbar_midy.ini
4+
//o2-sim -j 4 -n 10 -g external -t external -m "PIPE ITS TPC" -o sgn --configFile GeneratorHF_bbbar_midy.ini
55
//
66
//
77
R__ADD_INCLUDE_PATH($O2DPG_ROOT/MC/config/PWGDQ/EvtGen)
@@ -10,14 +10,15 @@ R__ADD_INCLUDE_PATH($O2DPG_ROOT/MC/config/PWGHF/external/generator)
1010
#include "GeneratorHF.C"
1111

1212
FairGenerator*
13-
GeneratorBeautyToJpsi_EvtGenMidY(double rapidityMin = -1.5, double rapidityMax = 1.5, bool verbose = false, TString pdgs = "511;521;531;5112;5122;5232;5132")
13+
GeneratorBeautyToJpsi_EvtGenMidY(double rapidityMin = -1.5, double rapidityMax = 1.5, bool ispp = true, bool verbose = false, TString pdgs = "511;521;531;5112;5122;5232;5132")
1414
{
1515
auto gen = new o2::eventgen::GeneratorEvtGen<o2::eventgen::GeneratorHF>();
1616
gen->setRapidity(rapidityMin,rapidityMax);
1717
gen->setPDG(5);
1818

1919
gen->setVerbose(verbose);
20-
gen->setFormula("max(1.,120.*(x<5.)+80.*(1.-x/20.)*(x>5.)*(x<11.)+240.*(1.-x/13.)*(x>11.))");
20+
if(ispp) gen->setFormula("1");
21+
else gen->setFormula("max(1.,120.*(x<5.)+80.*(1.-x/20.)*(x>5.)*(x<11.)+240.*(1.-x/13.)*(x>11.))");
2122
std::string spdg;
2223
TObjArray *obj = pdgs.Tokenize(";");
2324
gen->SetSizePdg(obj->GetEntriesFast());
@@ -34,14 +35,15 @@ GeneratorBeautyToJpsi_EvtGenMidY(double rapidityMin = -1.5, double rapidityMax =
3435
}
3536

3637
FairGenerator*
37-
GeneratorBeautyToJpsi_EvtGenFwdY(double rapidityMin = -4.3, double rapidityMax = -2.2, bool verbose = false, TString pdgs = "511;521;531;5112;5122;5232;5132")
38+
GeneratorBeautyToJpsi_EvtGenFwdY(double rapidityMin = -4.3, double rapidityMax = -2.2, bool ispp = true, bool verbose = false, TString pdgs = "511;521;531;5112;5122;5232;5132")
3839
{
3940
auto gen = new o2::eventgen::GeneratorEvtGen<o2::eventgen::GeneratorHF>();
4041
gen->setRapidity(rapidityMin,rapidityMax);
4142
gen->setPDG(5);
4243

4344
gen->setVerbose(verbose);
44-
gen->setFormula("max(1.,120.*(x<5.)+80.*(1.-x/20.)*(x>5.)*(x<11.)+240.*(1.-x/13.)*(x>11.))");
45+
if(ispp) gen->setFormula("1");
46+
else gen->setFormula("max(1.,120.*(x<5.)+80.*(1.-x/20.)*(x>5.)*(x<11.)+240.*(1.-x/13.)*(x>11.))");
4547
std::string spdg;
4648
TObjArray *obj = pdgs.Tokenize(";");
4749
gen->SetSizePdg(obj->GetEntriesFast());

MC/config/PWGDQ/ini/GeneratorHF_bbbar_fwdy.ini

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
### This part sets the path of the file and the function call to retrieve it
33

44
[GeneratorExternal]
5-
fileName = ${O2DPG_ROOT}/MC/config/PWGHF/external/generator/GeneratorHF.C
6-
funcName = GeneratorHF_bbbar()
5+
fileName = ${O2DPG_ROOT}/MC/config/PWGDQ/external/generator/GeneratorBeautyToJpsi_EvtGen.C
6+
funcName = GeneratorBeautyToJpsi_EvtGenFwdY()
77

88
### The external generator derives from GeneratorPythia8.
99
### This part configures the bits of the interface: configuration and user hooks
@@ -13,6 +13,14 @@ config = ${O2DPG_ROOT}/MC/config/common/pythia8/generator/pythia8_hf.cfg
1313
hooksFileName = ${O2DPG_ROOT}/MC/config/PWGHF/pythia8/hooks/pythia8_userhooks_qqbar.C
1414
hooksFuncName = pythia8_userhooks_bbbar(-4.3,-2.3)
1515

16+
### The setup uses an external even generator trigger which is
17+
### defined in the following file and it is retrieved and configured
18+
### according to the specified function call
19+
20+
[TriggerExternal]
21+
fileName = ${O2DPG_ROOT}/MC/config/PWGDQ/trigger/selectDaughterFromHFwithinAcc.C
22+
funcName = selectDaughterFromHFwithinAcc(443,kTRUE,-4.3,-2.3)
23+
1624
### The setup inhibits transport of primary particles which are produce at forward rapidity.
1725
### The settings below only transports particles in the barrel, which is currently defined as |eta| < 2
1826

MC/config/PWGDQ/ini/GeneratorHF_bbbar_midy.ini

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
### This part sets the path of the file and the function call to retrieve it
33

44
[GeneratorExternal]
5-
fileName = ${O2DPG_ROOT}/MC/config/PWGHF/external/generator/GeneratorHF.C
6-
funcName = GeneratorHF_bbbar()
5+
fileName = ${O2DPG_ROOT}/MC/config/PWGDQ/external/generator/GeneratorBeautyToJpsi_EvtGen.C
6+
funcName = GeneratorBeautyToJpsi_EvtGenMidY()
77

88
### The external generator derives from GeneratorPythia8.
99
### This part configures the bits of the interface: configuration and user hooks
@@ -13,6 +13,14 @@ config = ${O2DPG_ROOT}/MC/config/common/pythia8/generator/pythia8_hf.cfg
1313
hooksFileName = ${O2DPG_ROOT}/MC/config/PWGHF/pythia8/hooks/pythia8_userhooks_qqbar.C
1414
hooksFuncName = pythia8_userhooks_bbbar(-1.5,1.5)
1515

16+
### The setup uses an external even generator trigger which is
17+
### defined in the following file and it is retrieved and configured
18+
### according to the specified function call
19+
20+
[TriggerExternal]
21+
fileName = ${O2DPG_ROOT}/MC/config/PWGDQ/trigger/selectDaughterFromHFwithinAcc.C
22+
funcName = selectDaughterFromHFwithinAcc(443,kTRUE,-1.5,1.5)
23+
1624
### The setup inhibits transport of primary particles which are produce at forward rapidity.
1725
### The settings below only transports particles in the barrel, which is currently defined as |eta| < 2
1826

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
R__ADD_INCLUDE_PATH($O2DPG_ROOT)
2+
#include <TParticle.h>
3+
#include "Generators/Trigger.h"
4+
5+
/// =================================================================================================================================
6+
/// Select daughters from HF particles produced in a given rapidity window
7+
/// pdgPartForAccCut: pdg of the particle (coming from c / b) requested within the rapidity window [rapidityMin, rapidityMax]
8+
/// cutOnSingleChild: if true the condition on the rapidity is required for only one of the child particles (e.g. bb -> J/psi J/psi, bb -> ee,...)
9+
/// Tested for:
10+
/// - non-prompt J/psi / Psi(2S)
11+
/// - dielectron / dimuon pairs from cc and bb
12+
/// - single electrons / muons from b and b -> c -> e
13+
/// =================================================================================================================================
14+
Int_t GetFlavour(Int_t pdgCode);
15+
16+
o2::eventgen::Trigger selectDaughterFromHFwithinAcc(Int_t pdgPartForAccCut=443, Bool_t cutOnSingleChild = kTRUE, double rapidityMin = -1., double rapidityMax = -1.)
17+
{
18+
return [pdgPartForAccCut,cutOnSingleChild,rapidityMin,rapidityMax](const std::vector<TParticle>& particles) -> bool {
19+
20+
int nsig = 0; int mpdg = -1; int mpdgUpperFamily = -1; double rapidity = -999.;
21+
Bool_t isSelectedY = kFALSE; if(!cutOnSingleChild) isSelectedY = kTRUE;
22+
Bool_t isHF = kFALSE;
23+
for (const auto& particle : particles) {
24+
if(cutOnSingleChild && TMath::Abs(particle.GetPdgCode()) == pdgPartForAccCut){
25+
Int_t mi = particle.GetMother(0);
26+
if(mi<0) continue;
27+
TParticle mother = particles.at(mi);
28+
mpdg=TMath::Abs(mother.GetPdgCode());
29+
mpdgUpperFamily=(mpdg>1000 ? mpdg+1000 : mpdg+100);
30+
if(GetFlavour(mpdg) == 5 || GetFlavour(mpdgUpperFamily) == 5){ // keep particles from (b->) c
31+
rapidity = particle.Y();
32+
if( (rapidity > rapidityMin) && (rapidity < rapidityMax) ) isSelectedY = kTRUE;
33+
}
34+
}
35+
///////
36+
if(!cutOnSingleChild && TMath::Abs(particle.GetPdgCode()) == pdgPartForAccCut){
37+
Int_t mi = particle.GetMother(0);
38+
if(mi<0) continue;
39+
TParticle mother = particles.at(mi);
40+
mpdg=TMath::Abs(mother.GetPdgCode());
41+
if( (GetFlavour(mpdg) == 5) || (GetFlavour(mpdg) == 4)){
42+
isHF = kTRUE;
43+
rapidity = particle.Y();
44+
if( (rapidity < rapidityMin) || (rapidity > rapidityMax) ) isSelectedY = kFALSE;
45+
}
46+
}
47+
}
48+
//
49+
if(cutOnSingleChild && !isSelectedY) return kFALSE;
50+
if(!cutOnSingleChild && !(isHF && isSelectedY)) return kFALSE;
51+
return kTRUE;
52+
};
53+
54+
}
55+
56+
Int_t GetFlavour(Int_t pdgCode)
57+
{
58+
//
59+
// return the flavour of a particle
60+
// input: pdg code of the particle
61+
// output: Int_t
62+
// 3 in case of strange (open and hidden)
63+
// 4 in case of charm (")
64+
// 5 in case of beauty (")
65+
//
66+
Int_t pdg = TMath::Abs(pdgCode);
67+
//Resonance
68+
if (pdg > 100000) pdg %= 100000;
69+
if(pdg > 10000) pdg %= 10000;
70+
// meson ?
71+
if(pdg > 10) pdg/=100;
72+
// baryon ?
73+
if(pdg > 10) pdg/=10;
74+
return pdg;
75+
}
76+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
3+
# make sure O2DPG + O2 is loaded
4+
[ ! "${O2DPG_ROOT}" ] && echo "Error: This needs O2DPG loaded" && exit 1
5+
[ ! "${O2_ROOT}" ] && echo "Error: This needs O2 loaded" && exit 1
6+
7+
8+
# ----------- LOAD UTILITY FUNCTIONS --------------------------
9+
. ${O2_ROOT}/share/scripts/jobutils.sh
10+
11+
RNDSEED=${RNDSEED:-0}
12+
NSIGEVENTS=${NSIGEVENTS:-1}
13+
NBKGEVENTS=${NBKGEVENTS:-1}
14+
NWORKERS=${NWORKERS:-8}
15+
NTIMEFRAMES=${NTIMEFRAMES:-1}
16+
17+
${O2DPG_ROOT}/MC/bin/o2dpg_sim_workflow.py -eCM 900 -gen external -j ${NWORKERS} -ns ${NSIGEVENTS} -tf ${NTIMEFRAMES} -e TGeant4 -mod "--skipModules ZDC" \
18+
-trigger "external" -ini $O2DPG_ROOT/MC/config/PWGDQ/ini/GeneratorHF_bbbar_fwdy.ini \
19+
-genBkg pythia8 -procBkg inel -colBkg pp --embedding -nb ${NBKGEVENTS}
20+
21+
# run workflow
22+
${O2DPG_ROOT}/MC/bin/o2_dpg_workflow_runner.py -f workflow.json
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
3+
# make sure O2DPG + O2 is loaded
4+
[ ! "${O2DPG_ROOT}" ] && echo "Error: This needs O2DPG loaded" && exit 1
5+
[ ! "${O2_ROOT}" ] && echo "Error: This needs O2 loaded" && exit 1
6+
7+
8+
# ----------- LOAD UTILITY FUNCTIONS --------------------------
9+
. ${O2_ROOT}/share/scripts/jobutils.sh
10+
11+
RNDSEED=${RNDSEED:-0}
12+
NSIGEVENTS=${NSIGEVENTS:-1}
13+
NBKGEVENTS=${NBKGEVENTS:-1}
14+
NWORKERS=${NWORKERS:-8}
15+
NTIMEFRAMES=${NTIMEFRAMES:-1}
16+
17+
${O2DPG_ROOT}/MC/bin/o2dpg_sim_workflow.py -eCM 900 -gen external -j ${NWORKERS} -ns ${NSIGEVENTS} -tf ${NTIMEFRAMES} -e TGeant4 -mod "--skipModules ZDC" \
18+
-trigger "external" -ini $O2DPG_ROOT/MC/config/PWGDQ/ini/GeneratorHF_bbbar_midy.ini \
19+
-genBkg pythia8 -procBkg inel -colBkg pp --embedding -nb ${NBKGEVENTS}
20+
21+
# run workflow
22+
${O2DPG_ROOT}/MC/bin/o2_dpg_workflow_runner.py -f workflow.json

0 commit comments

Comments
 (0)