Skip to content

Commit

Permalink
Merge branch 'AliceO2Group:master' into etatune
Browse files Browse the repository at this point in the history
  • Loading branch information
ddobrigk authored Nov 22, 2024
2 parents 026ab76 + 262c869 commit 52725ba
Show file tree
Hide file tree
Showing 50 changed files with 859 additions and 116 deletions.
118 changes: 118 additions & 0 deletions MC/bin/o2_hybrid_gen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#!/usr/bin/env python3

# This script creates a template JSON file for the configuration of the hybrid generator
# The generators to be used are passed as a list of strings via the --gen flag, while the
# output filename is set using --output. All the generators available in O2sim are supported.
# Example:
# $O2DPG_ROOT/MC/bin/o2_hybrid_gen.py --gen pythia8 boxgen external extkinO2 hepmc pythia8hf \
# --output config.json

import argparse
import json

def main():
parser = argparse.ArgumentParser(description='Create a JSON file from command line flags.')
parser.add_argument('--gen', type=str, nargs='+', required=True, help='List of generators to be used')
parser.add_argument('--output', type=str, required=True, help='Output JSON file path')

args = parser.parse_args()

# put in a list all the elementes in the gen flag
noConfGen = ["pythia8pp", "pythia8hf", "pythia8hi", "pythia8powheg"]
gens = []
for gen in args.gen:
if gen == "pythia8":
gens.append({
'name': 'pythia8',
'config': {
"config": "$O2_ROOT/share/Generators/egconfig/pythia8_inel.cfg",
"hooksFileName": "",
"hooksFuncName": "",
"includePartonEvent": False,
"particleFilter": "",
"verbose": 0
}
})
elif gen == "external":
gens.append({
'name': 'external',
'config': {
"fileName": "${O2DPG_ROOT}/MC/config/PWGDQ/external/generator/GeneratorParamPromptJpsiToElectronEvtGen_pp13TeV.C",
"funcName": "GeneratorParamPromptJpsiToElectronEvtGen_pp13TeV()"
}
})
elif gen == "extkinO2":
gens.append({
'name': 'extkinO2',
'config': {
"skipNonTrackable": True,
"continueMode": False,
"roundRobin": False,
"randomize": False,
"rngseed": 0,
"randomphi": False,
"fileName": "/path/to/filename.root"
}
})
elif gen == "hepmc":
gens.append({
"name": "hepmc",
"config": {
"configcmd": {
"fileNames": "",
"cmd": ""
},
"confighepmc": {
"version": 2,
"eventsToSkip": 0,
"fileName": "/path/to/filename.hepmc",
"prune": False
}
}
})
elif gen == "boxgen":
gens.append({
"name": "boxgen",
"config": {
"pdg": 13,
"number": 1,
"eta": [
-4,
-2.5
],
"prange": [
0.1,
5
],
"phirange": [
0,
360
]
}
})
elif gen in noConfGen:
gens.append({
"name": gen,
"config": ""
})
else:
print(f"Generator {gen} not found in the list of available generators")
exit(1)

# fill fractions with 1 for each generator
fractions = [1] * len(gens)

# Put gens and fractions in the data dictionary
data = {
"generators": gens,
"fractions": fractions
}

# Write the data dictionary to a JSON file
with open(args.output, 'w') as f:
json.dump(data, f, indent=2)

print(f"JSON file created at {args.output}")

if __name__ == "__main__":
main()
8 changes: 8 additions & 0 deletions MC/config/PWGDQ/EvtGen/DecayTablesEvtgen/PSITOJPSIPIPI.DEC
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Decay J/psi
### from DECAY.DEC
1.000 e+ e- PHOTOS VLL;
Enddecay
Decay psi(2S)
1.000 J/psi pi+ pi- VVPIPI;
Enddecay
End
10 changes: 10 additions & 0 deletions MC/config/PWGDQ/EvtGen/DecayTablesEvtgen/X3872TOJPSIPIPI.DEC
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Decay X_1(3872)
#### Breit-Wigner function for the pion distribution (S-Wave approximation)
1.000 J/psi pi+ pi- XJPSIRHO0PIPI_S;
Enddecay
Decay J/psi
### from DECAY.DEC
1.000 e+ e- PHOTOS VLL;
Enddecay

End
117 changes: 117 additions & 0 deletions MC/config/PWGDQ/external/generator/GeneratorPromptCharmonia.C
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,75 @@ class O2_GeneratorParamPsiPbPb5TeV : public GeneratorTGenerator
GeneratorParam* paramPsi = nullptr;
};


class O2_GeneratorParamX3872MidY : public GeneratorTGenerator
{

public:
O2_GeneratorParamX3872MidY() : GeneratorTGenerator("ParamX3872MidY")
{
paramX3872 = new GeneratorParam(1, -1, PtX3872pp13TeV, YX3872pp13TeV, V2X3872pp13TeV, IpX3872pp13TeV);
paramX3872->SetMomentumRange(0., 1.e6);
paramX3872->SetPtRange(0., 1000.);
paramX3872->SetYRange(-1.0, 1.0);
paramX3872->SetPhiRange(0., 360.);
paramX3872->SetDecayer(new TPythia6Decayer()); // Pythia
paramX3872->SetForceDecay(kNoDecay); // particle left undecayed
setTGenerator(paramX3872);
};

~O2_GeneratorParamX3872MidY()
{
delete paramX3872;
};

Bool_t Init() override
{
GeneratorTGenerator::Init();
paramX3872->Init();
return true;
}

void SetNSignalPerEvent(Int_t nsig) { paramX3872->SetNumberParticles(nsig); }

//-------------------------------------------------------------------------//
static Double_t PtX3872pp13TeV(const Double_t* px, const Double_t* /*dummy*/)
{
// prompt X3872 pT
// pp, 13TeV (tuned LHCb pp 13 TeV)
//
const Double_t kC = 7.64519e+00 ;
const Double_t kpt0 = 5.30628e+00;
const Double_t kn = 3.30887e+00;
Double_t pt = px[0];
return kC * pt / TMath::Power((1. + (pt / kpt0) * (pt / kpt0)), kn);
}

//-------------------------------------------------------------------------//
static Double_t YX3872pp13TeV(const Double_t* py, const Double_t* /*dummy*/)
{
// flat rapidity distribution assumed at midrapidity
return 1.;
}

//-------------------------------------------------------------------------//
static Double_t V2X3872pp13TeV(const Double_t* /*dummy*/, const Double_t* /*dummy*/)
{
// X3872 v2
return 0.;
}

//-------------------------------------------------------------------------//
static Int_t IpX3872pp13TeV(TRandom*)
{
return 9920443;
}

private:
GeneratorParam* paramX3872 = nullptr;
};


} // namespace eventgen
} // namespace o2

Expand Down Expand Up @@ -741,6 +810,31 @@ FairGenerator* GeneratorCocktailPromptCharmoniaToMuonEvtGen_pp13TeV()
return genCocktailEvtGen;
}


FairGenerator*
GeneratorParamPromptPsiToJpsiPiPiEvtGen_pp13TeV(TString pdgs = "100443")
{
auto gen = new o2::eventgen::GeneratorEvtGen<o2::eventgen::O2_GeneratorParamPsiMidY>();
gen->SetNSignalPerEvent(1); // number of jpsis per event

std::string spdg;
TObjArray* obj = pdgs.Tokenize(";");
gen->SetSizePdg(obj->GetEntriesFast());
for (int i = 0; i < obj->GetEntriesFast(); i++) {
spdg = obj->At(i)->GetName();
gen->AddPdg(std::stoi(spdg), i);
printf("PDG %d \n", std::stoi(spdg));
}
TString pathO2 = gSystem->ExpandPathName("$O2DPG_ROOT/MC/config/PWGDQ/EvtGen/DecayTablesEvtgen");
gen->SetDecayTable(Form("%s/PSITOJPSIPIPI.DEC", pathO2.Data()));

// print debug
gen->PrintDebug();

return gen;
}


FairGenerator*
GeneratorParamPromptJpsiToMuonEvtGen_pp13TeV(TString pdgs = "443")
{
Expand Down Expand Up @@ -844,6 +938,29 @@ FairGenerator*
}


FairGenerator*
GeneratorParamX3872ToJpsiEvtGen_pp13TeV(TString pdgs = "9920443")
{
auto gen = new o2::eventgen::GeneratorEvtGen<o2::eventgen::O2_GeneratorParamX3872MidY>();
gen->SetNSignalPerEvent(1); // number of jpsis per event

std::string spdg;
TObjArray* obj = pdgs.Tokenize(";");
gen->SetSizePdg(obj->GetEntriesFast());
for (int i = 0; i < obj->GetEntriesFast(); i++) {
spdg = obj->At(i)->GetName();
gen->AddPdg(std::stoi(spdg), i);
printf("PDG %d \n", std::stoi(spdg));
}
TString pathO2 = gSystem->ExpandPathName("$O2DPG_ROOT/MC/config/PWGDQ/EvtGen/DecayTablesEvtgen");
gen->SetDecayTable(Form("%s/X3872TOJPSIPIPI.DEC", pathO2.Data()));

// print debug
gen->PrintDebug();

return gen;
}




Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ public:
case 7: // generate prompt charmonia cocktail at forward rapidity at 5TeV
mGeneratorParam = (Generator*)GeneratorCocktailPromptCharmoniaToMuonEvtGen_PbPb5TeV();
break;

case 8: // generate prompt X_1(3872) to Jpsi pi pi at midrapidity
mGeneratorParam = (Generator*)GeneratorParamX3872ToJpsiEvtGen_pp13TeV("9920443");
break;
case 9: // generate prompt psi2S to Jpsi pi pi at midrapidity
mGeneratorParam = (Generator*)GeneratorParamPromptPsiToJpsiPiPiEvtGen_pp13TeV("100443");
break;
}
mGeneratorParam->Init();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
### The external generator derives from GeneratorPythia8.
[GeneratorExternal]
fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGDQ/external/generator/generator_pythia8_withInjectedPromptSignals_gaptriggered_dq.C
funcName=GeneratorPythia8InjectedPromptCharmoniaGapTriggered(5,9)
[GeneratorPythia8]
config=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGDQ/pythia8/generator/pythia8_inel_triggerGap.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
### The external generator derives from GeneratorPythia8.
[GeneratorExternal]
fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGDQ/external/generator/generator_pythia8_withInjectedPromptSignals_gaptriggered_dq.C
funcName=GeneratorPythia8InjectedPromptCharmoniaGapTriggered(5,8)
[GeneratorPythia8]
config=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGDQ/pythia8/generator/pythia8_inel_triggerGap.cfg
Loading

0 comments on commit 52725ba

Please sign in to comment.