Skip to content

Commit 5245357

Browse files
HF Jet MC - fix weighting, using new HF jet generator (#1319)
1 parent e82a624 commit 5245357

4 files changed

Lines changed: 258 additions & 29 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
### The external generator derives from GeneratorPythia8.
2+
[GeneratorExternal]
3+
fileName=${O2DPG_ROOT}/MC/config/PWGHF/external/generator/generator_pythia8_gaptriggered_hf.C
4+
funcName=GeneratorPythia8GapTriggeredCharm(3, -5, 5)
5+
6+
[GeneratorPythia8]
7+
config=${O2DPG_ROOT}/MC/config/PWGGAJE/pythia8/generator/pythia8_jet_charmtriggers_with_decays.cfg
8+
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
int External() {
2+
std::string path{"o2sim_Kine.root"};
3+
int checkPdgQuark{4};
4+
float ratioTrigger = 1. / 3; // one event triggered out of 3
5+
std::vector<int> checkPdgHadron{411, 421, 431, 443, 4122, 4132, 4232, 4332};
6+
std::map<int, std::vector<std::vector<int>>> checkHadronDecays{
7+
// sorted pdg of daughters
8+
{411, {{-321, 211, 211}, {-313, 211}, {211, 311}, {211, 333}}}, // D+
9+
{421, {{-321, 211}, {-321, 111, 211}}}, // D0
10+
{431, {{211, 333}}}, // Ds+
11+
{443, {{-11, 11}}}, // Jpsi
12+
{4122,
13+
{{-313, 2212}, {-321, 2224}, {211, 3124}, {-321, 211, 2212}}}, // Lc+
14+
{4132, {{211, 3312}}}, // Xic0
15+
{4232,
16+
{{-313, 2212},
17+
{-321, 3324},
18+
{211, 211, 3312},
19+
{-321, 211, 2212}}}, // Xic+
20+
{4332, {{211, 3334}}} // Omegac+
21+
};
22+
23+
TFile file(path.c_str(), "READ");
24+
if (file.IsZombie()) {
25+
std::cerr << "Cannot open ROOT file " << path << "\n";
26+
return 1;
27+
}
28+
29+
auto tree = (TTree *)file.Get("o2sim");
30+
std::vector<o2::MCTrack> *tracks{};
31+
tree->SetBranchAddress("MCTrack", &tracks);
32+
33+
int nQuarks{}, nSignals{}, nSignalGoodDecay{};
34+
auto nEvents = tree->GetEntries();
35+
36+
// Setting up event header to access event weight info
37+
o2::dataformats::MCEventHeader *eventHeader = nullptr;
38+
;
39+
tree->SetBranchAddress("MCEventHeader.", &eventHeader);
40+
int weight1Counter = 0;
41+
bool isvalid;
42+
43+
for (int i = 0; i < nEvents; i++) {
44+
tree->GetEntry(i);
45+
46+
float eventWeight = eventHeader->getInfo<float>("weight", isvalid);
47+
if (!isvalid) {
48+
std::cerr << "Could not retrieve event weight from MCEventHeader\n";
49+
return 1;
50+
}
51+
if (abs(eventWeight - 1) <
52+
1E-5) { // checks that the event weights are not unitary
53+
weight1Counter++;
54+
}
55+
56+
for (auto &track : *tracks) {
57+
auto pdg = track.GetPdgCode();
58+
if (std::abs(pdg) == checkPdgQuark) {
59+
nQuarks++;
60+
continue;
61+
}
62+
if (std::find(checkPdgHadron.begin(), checkPdgHadron.end(),
63+
std::abs(pdg)) != checkPdgHadron.end()) // found signal
64+
{
65+
// count signal PDG
66+
nSignals++;
67+
68+
std::vector<int> pdgsDecay{};
69+
std::vector<int> pdgsDecayAntiPart{};
70+
for (int j{track.getFirstDaughterTrackId()};
71+
j <= track.getLastDaughterTrackId(); ++j) {
72+
auto pdgDau = tracks->at(j).GetPdgCode();
73+
pdgsDecay.push_back(pdgDau);
74+
if (pdgDau != 333) { // phi is antiparticle of itself
75+
pdgsDecayAntiPart.push_back(-pdgDau);
76+
} else {
77+
pdgsDecayAntiPart.push_back(pdgDau);
78+
}
79+
}
80+
81+
std::sort(pdgsDecay.begin(), pdgsDecay.end());
82+
std::sort(pdgsDecayAntiPart.begin(), pdgsDecayAntiPart.end());
83+
84+
for (auto &decay : checkHadronDecays[std::abs(pdg)]) {
85+
if (pdgsDecay == decay || pdgsDecayAntiPart == decay) {
86+
nSignalGoodDecay++;
87+
break;
88+
}
89+
}
90+
}
91+
}
92+
}
93+
std::cout << "--------------------------------\n";
94+
std::cout << "# Events: " << nEvents << "\n";
95+
std::cout << Form("# %d (anti)quarks: ", checkPdgQuark) << nQuarks << "\n";
96+
std::cout << "# signal hadrons: " << nSignals << "\n";
97+
std::cout << "# signal hadrons decaying in the correct channel: "
98+
<< nSignalGoodDecay << "\n";
99+
100+
if (nQuarks <
101+
2 * nEvents *
102+
ratioTrigger) // we expect anyway more because the same quark is
103+
// repeated several time, after each gluon radiation
104+
{
105+
std::cerr << "Number of generated (anti)quarks " << checkPdgQuark
106+
<< " lower than expected\n";
107+
return 1;
108+
}
109+
110+
float fracForcedDecays = float(nSignalGoodDecay) / nSignals;
111+
if (fracForcedDecays < 0.9) // we put some tolerance (e.g. due to oscillations
112+
// which might change the final state)
113+
{
114+
std::cerr << "Fraction of signals decaying into the correct channel "
115+
<< fracForcedDecays << " lower than expected\n";
116+
return 1;
117+
}
118+
119+
if (weight1Counter == nEvents) {
120+
std::cerr << "All events have a unitary weight\n";
121+
return 1;
122+
}
123+
124+
return 0;
125+
}
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
### author: Aimeric Landou (aimeric.landou@cern.ch)
2+
### based on Fabrizio Grosa's HF template (fabrizio.grosa@cern.ch)
3+
### since: January 2023
4+
5+
### beams
6+
Beams:idA 2212 # proton
7+
Beams:idB 2212 # proton
8+
Beams:eCM 13600. # GeV
9+
10+
# ### processes
11+
# SoftQCD:inelastic on # all inelastic processes
12+
13+
### decays
14+
ParticleDecays:limitTau0 on
15+
ParticleDecays:tau0Max 10.
16+
17+
### Force golden charm hadrons decay modes for trigger studies
18+
19+
### add D+ decays absent in PYTHIA8 decay table and set BRs from PDG for other
20+
411:oneChannel = 1 0.0752 0 -321 211 211
21+
411:addChannel = 1 0.0104 0 -313 211
22+
411:addChannel = 1 0.0156 0 311 211
23+
411:addChannel = 1 0.00276 0 333 211
24+
## add Lc decays absent in PYTHIA8 decay table and set BRs from PDG for other
25+
4122:oneChannel = 1 0.0196 100 2212 -313
26+
4122:addChannel = 1 0.0108 100 2224 -321
27+
4122:addChannel = 1 0.022 100 3124 211
28+
4122:addChannel = 1 0.035 0 2212 -321 211
29+
### add Xic+ decays absent in PYTHIA8 decay table
30+
4232:addChannel = 1 0.2 0 2212 -313
31+
4232:addChannel = 1 0.2 0 2212 -321 211
32+
4232:addChannel = 1 0.2 0 3324 211
33+
4232:addChannel = 1 0.2 0 3312 211 211
34+
### add Xic0 decays absent in PYTHIA8 decay table
35+
4132:addChannel = 1 0.2 0 3312 211
36+
37+
### K* -> K pi
38+
313:onMode = off
39+
313:onIfAll = 321 211
40+
### for Ds -> Phi pi+
41+
333:onMode = off
42+
333:onIfAll = 321 321
43+
### for D0 -> rho0 pi+ k-
44+
113:onMode = off
45+
113:onIfAll = 211 211
46+
### for Lambda_c -> Delta++ K-
47+
2224:onMode = off
48+
2224:onIfAll = 2212 211
49+
### for Lambda_c -> Lambda(1520) K-
50+
102134:onMode = off
51+
102134:onIfAll = 2212 321
52+
53+
### switch off all decay channels
54+
411:onMode = off
55+
421:onMode = off
56+
431:onMode = off
57+
4112:onMode = off
58+
4122:onMode = off
59+
4232:onMode = off
60+
4132:onMode = off
61+
443:onMode = off
62+
4332:onMode = off
63+
64+
### D0 -> K pi
65+
421:onIfMatch = 321 211
66+
67+
### D+/- -> K pi pi
68+
411:onIfMatch = 321 211 211
69+
### D+/- -> K* pi
70+
411:onIfMatch = 313 211
71+
### D+/- -> phi pi
72+
411:onIfMatch = 333 211
73+
74+
### D_s -> Phi pi
75+
431:onIfMatch = 333 211
76+
77+
### Lambda_c -> p K*
78+
4122:onIfMatch = 2212 313
79+
### Lambda_c -> Delta K
80+
4122:onIfMatch = 2224 321
81+
### Lambda_c -> Lambda(1520) pi
82+
4122:onIfMatch = 3124 211
83+
### Lambda_c -> p K pi
84+
4122:onIfMatch = 2212 321 211
85+
86+
### Xic+ -> pK*0
87+
4232:onIfMatch = 2212 313
88+
### Xic+ -> p K- pi+
89+
4232:onIfMatch = 2212 321 211
90+
### Xic+ -> Xi*0 pi+, Xi*->Xi- pi+
91+
4232:onIfMatch = 3324 211
92+
### Xic+ -> Xi- pi+ pi+
93+
4232:onIfMatch = 3312 211 211
94+
95+
### Xic0 -> Xi- pi+
96+
4132:onIfMatch = 3312 211
97+
98+
### Omega_c -> Omega pi
99+
4332:onIfMatch = 3334 211
100+
101+
### Jpsi -> ee
102+
443:onIfMatch = 11 11
103+
104+
# Correct Lb decay length (wrong in PYTHIA8 decay table)
105+
5122:tau0 = 4.41000e-01
106+
107+
# Correct OmegaC decay length (wrong in PYTHIA8 decay table)
108+
4332:tau0 = 0.08000000000
109+
110+
111+
### Jets options
112+
PhaseSpace:pTHatMin = 5.0
113+
PhaseSpace:pTHatMax = 300.0
114+
PhaseSpace:bias2Selection = on
115+
PhaseSpace:bias2SelectionPow = 6.0
116+
SoftQCD:inelastic off # all inelastic processes
117+
HardQCD:all on

MC/run/PWGGAJE/run_jets_HF_ccbar.sh

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,42 +15,21 @@
1515

1616
RNDSEED=${RNDSEED:-0} # [default = 0] time-based random seed
1717

18-
NSIGEVENTS=${NSIGEVENTS:-10}
18+
NSIGEVENTS=${NSIGEVENTS:-5}
1919
NTIMEFRAMES=${NTIMEFRAMES:-1}
2020
NWORKERS=${NWORKERS:-8}
2121
MODULES="--skipModules ZDC" #"PIPE ITS TPC EMCAL"
2222
CONFIG_ENERGY=${CONFIG_ENERGY:-13600.0}
2323
SIMENGINE=${SIMENGINE:-TGeant4}
24-
WEIGHTPOW=${WEIGHTPOW:-6.0}
2524
[[ ${SPLITID} != "" ]] && SEED="-seed ${SPLITID}" || SEED=""
2625

27-
# Default for weighted productions
28-
PTHATMIN=${PTHATMIN:-5.0}
29-
PTHATMAX=${PTHATMAX:-300.0}
30-
31-
# Define the pt hat bin arrays
32-
pthatbin_loweredges=(0 5 7 9 12 16 21 28 36 45 57 70 85 99 115 132 150 169 190 212 235)
33-
pthatbin_higheredges=( 5 7 9 12 16 21 28 36 45 57 70 85 99 115 132 150 169 190 212 235 -1)
34-
35-
# Recover environmental vars for pt binning
36-
#PTHATBIN=${PTHATBIN:-1}
37-
38-
if [ -z "$PTHATBIN" ]; then
39-
echo "Open Pt-hat range set"
40-
else
41-
PTHATMIN=${pthatbin_loweredges[$PTHATBIN]}
42-
PTHATMAX=${pthatbin_higheredges[$PTHATBIN]}
43-
fi
44-
45-
46-
#ccbar filter
47-
${O2DPG_ROOT}/MC/bin/o2dpg_sim_workflow.py -eCM ${CONFIG_ENERGY} -col pp -gen external -proc "jets" \
48-
-ptHatMin ${PTHATMIN} -ptHatMax ${PTHATMAX} \
49-
-tf ${NTIMEFRAMES} -ns ${NSIGEVENTS} -e ${SIMENGINE} \
50-
-j ${NWORKERS} -mod "--skipModules ZDC" \
51-
-interactionRate 500000 -confKey "Diamond.width[2]=6." ${SEED} \
52-
-ini $O2DPG_ROOT/MC/config/PWGHF/ini/GeneratorHFTrigger_ccbar.ini \
53-
-weightPow ${WEIGHTPOW}
26+
#ccbar filter and bias2SelectionPow and PtHat settings are in the ini file given below
27+
${O2DPG_ROOT}/MC/bin/o2dpg_sim_workflow.py -eCM ${CONFIG_ENERGY} -col pp -gen external -proc "jets" \
28+
-tf ${NTIMEFRAMES} -ns ${NSIGEVENTS} -e ${SIMENGINE} \
29+
-j ${NWORKERS} -mod "--skipModules ZDC" \
30+
-interactionRate 500000 -confKey "Diamond.width[2]=6." ${SEED} \
31+
-ini $O2DPG_ROOT/MC/config/PWGGAJE/ini/GeneratorHFJETrigger_ccbar.ini
32+
5433

5534
# run workflow
5635
# allow increased timeframe parallelism with --cpu-limit 32

0 commit comments

Comments
 (0)