Skip to content

Commit

Permalink
Merge pull request #521 from iarsene/master
Browse files Browse the repository at this point in the history
Few changes, needed for FOCAL simulations
  • Loading branch information
gconesab authored Oct 24, 2022
2 parents 429609c + e74d01a commit a7d2745
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 11 deletions.
101 changes: 94 additions & 7 deletions MC/CustomGenerators/Upgrade/FOCAL_Generators.C
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ Double_t EtaToTheta(Double_t eta)
enum GenTypes {
gun=0,
gunJpsi,
box,
box,
boxWithDecay,
pythia,
pythia_MBtrig,
pythia_dirgamma_trig,
Expand All @@ -25,6 +26,7 @@ TString gGenTypeNames[kNGenTypes] = {
"gun",
"gunJpsi",
"box",
"boxWithDecay",
"pythia",
"pythia_MBtrig",
"pythia_dirgamma_trig",
Expand Down Expand Up @@ -183,6 +185,82 @@ AliGenerator* GeneratorCustom(TString opt = "") {
generator = gener;
}
break;

case boxWithDecay:
// Example for Moving Particle Gun (with decays enabled)
{
float ptmin = 0.0;
if (gSystem->Getenv("CONFIG_PTMIN")) {
ptmin = atof(gSystem->Getenv("CONFIG_PTMIN"));
}
float ptmax = 10.0;
if (gSystem->Getenv("CONFIG_PTMAX")) {
ptmax = atof(gSystem->Getenv("CONFIG_PTMAX"));
}
float ymin = 3.0;
if (gSystem->Getenv("CONFIG_YMIN")) {
ymin = atof(gSystem->Getenv("CONFIG_YMIN"));
}
float ymax = 6.0;
if (gSystem->Getenv("CONFIG_YMAX")) {
ymax = atof(gSystem->Getenv("CONFIG_YMAX"));
}
float phimin = 0.0;
if (gSystem->Getenv("CONFIG_PHIMIN")) {
phimin = atof(gSystem->Getenv("CONFIG_PHIMIN"));
}
float phimax = 360.0;
if (gSystem->Getenv("CONFIG_PHIMAX")) {
phimax = atof(gSystem->Getenv("CONFIG_PHIMAX"));
}
int pdg = 23; // default: Z0
if (gSystem->Getenv("CONFIG_PDG")) {
pdg = atoi(gSystem->Getenv("CONFIG_PDG"));
}

// set external decayer
TVirtualMCDecayer* decayer = new AliDecayerPythia();
decayer->SetForceDecay(kAll);
decayer->Init();
gMC->SetExternalDecayer(decayer);

AliGenCocktail *gener = new AliGenCocktail();
gener->UsePerEventRates();

AliGenBox *genBox = new AliGenBox(1);
genBox->SetPtRange(ptmin, ptmax);
genBox->SetPhiRange(phimin, phimax); // full polar angle around beam axis
genBox->SetYRange(ymin, ymax);
genBox->SetOrigin(0,0,0);
//vertex position
genBox->SetSigma(0,0,0); //Sigma in (X,Y,Z) (cm) on IP position
genBox->SetPart(pdg);
gener->AddGenerator(genBox, "box", 1.);

AliGenEvtGen *gene = new AliGenEvtGen();
// NOTE: the original decay table is in AliRoot/TEvtGen/EvtGen/DecayTable/DIELECTRON.DEC
// If the decay you are after is there, then you can comment out the following line.
// Alternatively, make sure the decay file you use below is in the working directory (or copied to
// the grid working note if you run on the grid)
gene->SetUserDecayTable("DIELECTRON.DEC");
if (pdg==23) {
gene->SetForceDecay(kZDiElectron);
gene->SetParticleSwitchedOff(AliGenEvtGen::kAllPart);
}
if (pdg==443) {
gene->SetForceDecay(kDiElectron);
gene->SetParticleSwitchedOff(AliGenEvtGen::kCharmPart);
}
if (pdg==553) {
gene->SetForceDecay(kDiElectron);
gene->SetParticleSwitchedOff(AliGenEvtGen::kCharmPart);
}
gene->Init();
gener->AddGenerator(gene, "EvtGen", 1.);

generator = gener;
}
break;

case pythia:
// Example for Pythia
Expand Down Expand Up @@ -240,7 +318,11 @@ AliGenerator* GeneratorCustom(TString opt = "") {
}
gener->SetCheckFOCAL(kTRUE);
gener->SetFOCALEta(3.5, 6.2);
gener->SetTriggerParticleMinPt(4.0);
float ptmin = 4.0;
if (gSystem->Getenv("CONFIG_PTMIN")) {
ptmin = atof(gSystem->Getenv("CONFIG_PTMIN"));
}
gener->SetTriggerParticleMinPt(ptmin);
generator = gener;
}
break;
Expand Down Expand Up @@ -304,7 +386,7 @@ AliGenerator* GeneratorCustom(TString opt = "") {
gener->SetSpectators(0); // Don't track spectators
gener->SetSelectAll(0); // kinematic selection
gener->SetImpactParameterRange(0., 8.); // Impact parameter range (fm)
//gener->UnsetDataDrivenSpectators();
gener->UnsetDataDrivenSpectators();

gener->SetTrigger(2); // 2: direct photons; 3: decay photons
gener->SetPtJet(4.);
Expand Down Expand Up @@ -392,18 +474,23 @@ AliGenerator* GeneratorCustom(TString opt = "") {

/*TString fifoname("$TMPDIR/myfifo");
AliGenExtExec* eposExt = new AliGenExtExec();
eposExt->SetPathScript(Form("./gen_eposlhc.sh %s",fifoname.Data()));
//eposExt->SetPathScript(Form("./gen_eposlhc.sh %s",fifoname.Data()));
eposExt->SetPathScript(Form("crmc -o hepmc -f %s -n %d -m 0 -i %d -p %f -I %d -P %f",
fifoname.Data(),nEvents,projectileId,projectileEnergy,targetId,targetEnergy));
eposExt->SetPathFIFO(fifoname);
cocktail->AddGenerator(eposExt,"EPOS",1.);*/

TString fifoname("myfifo");
gROOT->ProcessLine(Form(".! rm -rf %s", fifoname.Data()));
gROOT->ProcessLine(Form(".! mkfifo %s", fifoname.Data()));
gROOT->ProcessLine(Form(".! bash $ALIDPG_ROOT/MC/EXTRA/gen_eposlhc.sh %s %d %d %f %d %f &> gen_eposlhc%d.log &",
/*gROOT->ProcessLine(Form(".! bash $ALIDPG_ROOT/MC/EXTRA/gen_eposlhc.sh %s %d %d %f %d %f &> gen_eposlhc%d.log &",
fifoname.Data(), nEvents,
projectileId, projectileEnergy,
targetId, targetEnergy, pileup));

targetId, targetEnergy, pileup));*/
gROOT->ProcessLine(Form(".! crmc -o hepmc -f %s -n %d -m 0 -i %d -p %f -I %d -P %f &> gen_eposlhc.log &",
fifoname.Data(), nEvents,
projectileId, projectileEnergy,
targetId, targetEnergy));
// connect HepMC reader
AliGenReaderHepMC *reader = new AliGenReaderHepMC();
reader->SetFileName(fifoname.Data());
Expand Down
4 changes: 3 additions & 1 deletion MC/DetectorConfig.C
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ enum EDetector_t {
kDetectorCentralBarrelTracking,
kDetectorRun3,
kDetectorFOCAL,
kDetectorFOCALnoFIT,
kDetectorCustom,
kNDetectors
};
Expand All @@ -28,6 +29,7 @@ const Char_t *DetectorName[kNDetectors] = {
"CentralBarrelTracking",
"Run3",
"FOCAL",
"FOCALnoFIT",
"Custom"
};

Expand Down Expand Up @@ -157,7 +159,7 @@ DetectorConfig(Int_t tag)

if( tag == kDetectorRun3 )
DetectorInitRun3(tag);
else if (tag == kDetectorFOCAL) {
else if (tag == kDetectorFOCAL || tag == kDetectorFOCALnoFIT) {
gROOT->ProcessLine(".x $ALIDPG_ROOT/MC/DetectorInitFOCAL.C");
}
else
Expand Down
6 changes: 5 additions & 1 deletion MC/DetectorInitFOCAL.C
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ Special FOCAL simulations detector init
Int_t iFIT = 1;
Int_t iFOCAL = 1;

if (strcmp(gSystem->Getenv("CONFIG_DETECTOR"), "FOCALnoFIT") == 0) {
iFIT = 0;
}

Int_t year = atoi(gSystem->Getenv("CONFIG_YEAR"));

//=================== Alice BODY parameters =============================
Expand Down Expand Up @@ -258,6 +262,6 @@ Special FOCAL simulations detector init
}

if (iFIT) {
AliFIT *fit = new AliFITv8("FIT","FIT");
AliFIT *fit = new AliFITv9("FIT","FIT");
}
}
2 changes: 1 addition & 1 deletion MC/dpgsim.sh
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ while [ ! -z "$1" ]; do
elif [ "$option" = "--detector" ]; then
CONFIG_DETECTOR="$1"
# check that FOCAL env is set in case we run a FOCAL simulation
if [ "$CONFIG_DETECTOR" = "FOCAL" ]; then
if [ "$CONFIG_DETECTOR" = "FOCAL" ] || [ "$CONFIG_DETECTOR" = "FOCALnoFIT" ]; then
if [ -z "$FOCAL" ]; then
echo "FOCAL simulation requested but FOCAL environment not set."
exit 1
Expand Down
3 changes: 2 additions & 1 deletion MC/sim.C
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ void sim()
AliSimulation sim(config_macro.Data());

if (gSystem->Getenv("CONFIG_DETECTOR")) {
if (strcmp(gSystem->Getenv("CONFIG_DETECTOR"), "FOCAL") == 0) {
if ((strcmp(gSystem->Getenv("CONFIG_DETECTOR"), "FOCAL") == 0) ||
(strcmp(gSystem->Getenv("CONFIG_DETECTOR"), "FOCALnoFIT") == 0)) {
printf(">>>>> sim.C: No align data from CDB when running FOCAL !!!!!!!!!!!!!!! \n");
sim.SetLoadAlignFromCDB(kFALSE);
sim.SetUseDetectorsFromGRP(kFALSE);
Expand Down

0 comments on commit a7d2745

Please sign in to comment.