Skip to content

Commit c79c80a

Browse files
mpucciosawenzel
authored andcommitted
Add hypertriton gun on top of Pythia8 HI
1 parent 45b3e6a commit c79c80a

File tree

3 files changed

+123
-0
lines changed

3 files changed

+123
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[GeneratorExternal]
2+
fileName=${O2DPG_ROOT}/MC/config/PWGLF/pythia8/generator_pythia8_longlived.C
3+
funcName=generateLongLived(1010010030, 10)
4+
5+
[GeneratorPythia8]
6+
config=${O2_ROOT}/share/Generators/egconfig/pythia8_hi.cfg
7+
8+
[DecayerPythia8]
9+
config[0]=${O2_ROOT}/share/Generators/pythia8/decays/hypertriton.cfg
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#include "Pythia8/Pythia.h"
2+
#include "FairGenerator.h"
3+
#include "FairPrimaryGenerator.h"
4+
#include "Generators/GeneratorPythia8.h"
5+
#include "TRandom3.h"
6+
#include "TParticlePDG.h"
7+
#include "TDatabasePDG.h"
8+
#include "TMath.h"
9+
#include <cmath>
10+
11+
using namespace Pythia8;
12+
13+
class GeneratorPythia8LongLivedGun : public o2::eventgen::GeneratorPythia8
14+
{
15+
public:
16+
/// constructor
17+
GeneratorPythia8LongLivedGun(int input_pdg, int nInject = 1) : pdg{input_pdg}, nParticles{nInject}, m{getMass(input_pdg)}
18+
{
19+
}
20+
21+
/// Destructor
22+
~GeneratorPythia8LongLivedGun() = default;
23+
24+
/// randomize the PDG code sign of core particle
25+
void setRandomizePDGsign(bool val) { randomizePDGsign = val; }
26+
27+
/// get mass from TParticlePDG
28+
double getMass(int input_pdg)
29+
{
30+
double mass = 0;
31+
if (TDatabasePDG::Instance())
32+
{
33+
TParticlePDG *particle = TDatabasePDG::Instance()->GetParticle(input_pdg);
34+
if (particle)
35+
{
36+
mass = particle->Mass();
37+
}
38+
else
39+
{
40+
std::cout << "===> Unknown particle requested, mass set to 0" << std::endl;
41+
}
42+
}
43+
return mass;
44+
}
45+
46+
//__________________________________________________________________
47+
Bool_t importParticles() override
48+
{
49+
GeneratorPythia8::importParticles();
50+
static int sign{1};
51+
for (int i{0}; i < nParticles; ++i)
52+
{
53+
const double pt = gRandom->Uniform(genMinPt, genMaxPt);
54+
const double eta = gRandom->Uniform(genMinEta, genMaxEta);
55+
const double phi = gRandom->Uniform(0, TMath::TwoPi());
56+
const double px{pt * std::cos(phi)};
57+
const double py{pt * std::sin(phi)};
58+
const double pz{pt * std::sinh(eta)};
59+
const double et{std::hypot(std::hypot(pt, pz), m)};
60+
sign *= randomizePDGsign ? -1 : 1;
61+
mParticles.push_back(TParticle(sign * pdg, 1, -1, -1, -1, -1, px, py, pz, et, 0., 0., 0., 0.));
62+
}
63+
return true;
64+
}
65+
66+
private:
67+
double genMinPt = 0.5; /// minimum 3-momentum for generated particles
68+
double genMaxPt = 12.; /// maximum 3-momentum for generated particles
69+
double genMinEta = -1.; /// minimum pseudorapidity for generated particles
70+
double genMaxEta = -1.; /// maximum pseudorapidity for generated particles
71+
72+
double m = 0; /// particle mass [GeV/c^2]
73+
int pdg = 0; /// particle pdg code
74+
int nParticles = 1; /// Number of injected particles
75+
76+
bool randomizePDGsign = true; /// bool to randomize the PDG code of the core particle
77+
};
78+
79+
///___________________________________________________________
80+
FairGenerator *generateLongLived(int pdg, int nInject)
81+
{
82+
return new GeneratorPythia8LongLivedGun(pdg, nInject);
83+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
#
4+
# A example workflow MC->RECO->AOD for a simple pp min bias
5+
# production, targetting test beam conditions.
6+
7+
# make sure O2DPG + O2 is loaded
8+
[ ! "${O2DPG_ROOT}" ] && echo "Error: This needs O2DPG loaded" && exit 1
9+
[ ! "${O2_ROOT}" ] && echo "Error: This needs O2 loaded" && exit 1
10+
11+
# ----------- LOAD UTILITY FUNCTIONS --------------------------
12+
. ${O2_ROOT}/share/scripts/jobutils.sh
13+
14+
# ----------- START ACTUAL JOB -----------------------------
15+
16+
NWORKERS=${NWORKERS:-8}
17+
MODULES="--skipModules ZDC"
18+
SIMENGINE=${SIMENGINE:-TGeant3}
19+
NSIGEVENTS=${NSIGEVENTS:-1}
20+
NBKGEVENTS=${NBKGEVENTS:-1}
21+
NTIMEFRAMES=${NTIMEFRAMES:-1}
22+
INTRATE=${INTRATE:-50000}
23+
[[ ${SPLITID} != "" ]] && SEED="-seed ${SPLITID}" || SEED=""
24+
25+
# create workflow
26+
${O2DPG_ROOT}/MC/bin/o2dpg_sim_workflow.py -eCM 5500 -col PbPb -gen external -j ${NWORKERS} -ns ${NSIGEVENTS} -tf ${NTIMEFRAMES} -interactionRate ${INTRATE} -confKey "Diamond.width[2]=6." -e ${SIMENGINE} ${SEED} -mod "--skipModules ZDC" \
27+
-ini ${O2DPG_ROOT}/MC/config/PWGLF/ini/GeneratorLFHypertritonPbPb.ini
28+
29+
# run workflow
30+
# allow increased timeframe parallelism with --cpu-limit 32
31+
${O2DPG_ROOT}/MC/bin/o2_dpg_workflow_runner.py -f workflow.json -tt aod --cpu-limit 32

0 commit comments

Comments
 (0)