AliPhysics  06e4d4b (06e4d4b)
Config.C
Go to the documentation of this file.
1 
19 // -------------------------------------------------------------------
31 struct Setup
32 {
33  TString runType; // Event generator chosen
34  UInt_t seed; // Random number seed - (env)
35  Float_t minB; // Least imp.param. (env)
36  Float_t maxB; // Largest imp.param. (env)
37  TString backend; // The backend to use (geant3 or geant4)
46  static Float_t Env2Float(const char* envName, Float_t def)
47  {
48  TString val(gSystem->Getenv(envName));
49  if (val.IsNull()) return def;
50  return val.Atof();
51  }
60  static UInt_t Env2UInt(const char* envName, UInt_t def)
61  {
62  TString val(gSystem->Getenv(envName));
63  if (val.IsNull()) return def;
64  return UInt_t(val.Atoll());
65  }
74  static UInt_t Env2Int(const char* envName, Int_t def)
75  {
76  TString val(gSystem->Getenv(envName));
77  if (val.IsNull()) return def;
78  return val.Atoi();
79  }
80 
85  Setup()
86  : runType(""),
87  seed(0),
88  minB(0),
89  maxB(100)
90  {
91  TDatime now;
92  runType = gSystem->Getenv("CONFIG_RUN_TYPE");
93  backend = gSystem->Getenv("CONFIG_BACKEND");
94  seed = Env2UInt("CONFIG_SEED", now.Get());
95  minB = Env2Float("CONFIG_BMIN", 0);
96  maxB = Env2Float("CONFIG_BMAX", 100);
97  if (runType[0] == 'k') runType.Remove(0,1);
98  runType.ToLower();
99 
100  // gROOT->Macro("GetGRP.C");
101 
102 
103  if (runType.IsNull() || runType == "default") DeduceRunType();
104 
105  Print();
106  }
111  void Print()
112  {
113  Printf("=======================================================\n"
114  " Set-up of the simulation\n");
115  grp->Print();
116  Printf("Run type: '%s'", runType.Data());
117  Printf("Backend: '%s'", backend.Data());
118  Printf("b range: [%4.1f,%4.1f]fm", minB, maxB);
119  Printf("Seed: %d", seed);
120  Printf("\n"
121  "=======================================================");
122  }
123  Bool_t IsGeant3() const
124  {
125  return (backend.EqualTo("geant3", TString::kIgnoreCase) ||
126  backend.EqualTo("g3", TString::kIgnoreCase));
127  }
128  Bool_t IsGeant4() const
129  {
130  return (backend.EqualTo("geant4", TString::kIgnoreCase) ||
131  backend.EqualTo("g4", TString::kIgnoreCase));
132  }
136  void MakeBackend()
137  {
138  if (!IsGeant4()) {
139  gSystem->Load("libgeant321");
140  new TGeant3TGeo("C++ Interface to Geant3");
141  }
142  else {
143  gROOT->Macro("$ALICE/geant4_vmc/examples/macro/g4libs.C");
144  // Create G4 VMC
145  TGeant4 *g4 = 0;
146 
147  TG4RunConfiguration* runConfiguration
148  = new TG4RunConfiguration("geomRoot",
149  "FTFP_BERT_EMV+optical",
150  "specialCuts+stackPopper+stepLimiter",
151  true);
152  TGeant4* g4 = new TGeant4("TGeant4",
153  "The Geant4 Monte Carlo : "
154  "FTFP_BERT_EMV+optical",
155  runConfiguration);
156  // Customization of Geant4 VMC
157  g4->ProcessGeantCommand("/mcVerbose/all 1");
158  g4->ProcessGeantCommand("/mcVerbose/geometryManager 1");
159  g4->ProcessGeantCommand("/mcVerbose/opGeometryManager 1");
160  g4->ProcessGeantCommand("/mcTracking/loopVerbose 1");
161  g4->ProcessGeantCommand("/mcPhysics/rangeCuts 0.01 mm");
162  g4->ProcessGeantCommand("/mcTracking/skipNeutrino true");
163 
164  // Activate step limit defined in low density materials
165  // (the default value is 10 cm)
166  g4->ProcessGeantCommand("/mcDet/setIsMaxStepInLowDensityMaterials true");
167  g4->ProcessGeantCommand("/mcDet/setMaxStepInLowDensityMaterials 10 m");
168 
169  // Activate step limit defined in tracking media
170  // (Note: this slows down simulation significantly)
171  // g4->ProcessGeantCommand("/mcDet/setIsUserMaxStep true");
172 
173  // for G4 <= 9.4.p03
174  // g4->ProcessGeantCommand("/mcPhysics/selectOpProcess Scintillation");
175  // g4->ProcessGeantCommand("/mcPhysics/setOpProcessActivation false");
176  // for G4 >= 9.5
177  g4->ProcessGeantCommand("/optics_engine/selectOpProcess Scintillation");
178  g4->ProcessGeantCommand("/optics_engine/setOpProcessUse false");
179  g4->ProcessGeantCommand("/optics_engine/selectOpProcess OpWLS");
180  g4->ProcessGeantCommand("/optics_engine/setOpProcessUse false");
181  g4->ProcessGeantCommand("/optics_engine/selectOpProcess OpMieHG");
182  g4->ProcessGeantCommand("/optics_engine/setOpProcessUse false");
183  g4->ProcessGeantCommand("/optics_engine/selectOpProcess Cerenkov");
184 
185  // Activate saving random engine status
186  // (the file per event will be re-written with each new event)
187  // gAlice->GetMCApp()->SetSaveRndmStatus(kTRUE);
188  // g4->ProcessGeantCommand("/mcRun/saveRandom true");
189 
190  // Activate saving random engine status for each event
191  // (a new file will be written for each event)
192  // gAlice->GetMCApp()->SetSaveRndmStatusPerEvent(kTRUE);
193  // g4->ProcessGeantCommand("/mcRun/saveRandom true");
194  // g4->ProcessGeantCommand("/mcEvent/saveRandom true");
195 
196  // Activate printing size of used memory per event
197  g4->ProcessGeantCommand("/mcEvent/printMemory true");
198 
199  // Uncomment this line to get a detail info from each step
200  // g4->ProcessGeantCommand("/tracking/verbose 1");
201 
202  // More info from the physics list
203  // the verbosity level is passed to all contained physics lists and their
204  // physics builders
205  // g4->ProcessGeantCommand("/mcVerbose/composedPhysicsList 2");
206 
207  // More info from optical processes
208  // g4->ProcessGeantCommand("/mcVerbose/opticalPhysicsList 3");
209 
210  // More info from geometry building
211  // g4->ProcessGeantCommand("/mcVerbose/geometryManager 1");
212 
213  // More info from setting geometry properties (in materials and surfaces)
214  // for optical physics
215  // g4->ProcessGeantCommand("/mcVerbose/opGeometryManager 1");
216 
217  // More info about regions construction
218  // and conversion of VMC cuts in cuts in range per regions
219  // g4->ProcessGeantCommand("/mcVerbose/regionsManager 2");
220  // g4->ProcessGeantCommand("/mcRegions/print true");
221 
222  // Suppress verbose info from tracks which reached maximum number of steps
223  // (default value is 30000)
224  // g4->ProcessGeantCommand("/mcTracking/loopVerbose 0");
225 
226  //
227  // Set apply cuts
228  // g4->ProcessGeantCommand("/process/em/applyCuts true");
229  // g4->ProcessGeantCommand("/mcVerbose/geometryManager 2");
230  /*
231  g4->ProcessGeantCommand("/mcVerbose/composedPhysicsList 2");
232  g4->ProcessGeantCommand("/mcDet/volNameSeparator !");
233  g4->ProcessGeantCommand("/mcPhysics/setStackPopperSelection "
234  "e+ e- pi+ pi- kaon+ kaon- gamma");
235  //g4->ProcessGeantCommand("/tracking/verbose 1");
236 
237  g4->ProcessGeantCommand("/mcControl/g3Defaults");
238  !!!!n Generates warnings:
239  >>> Event 0
240  G4ProcessTable::Insert : arguments are 0 pointer
241  G4ProcessTable::Insert : arguments are 0 pointer
242  G4ProcessTable::Insert : arguments are 0 pointer
243  G4ProcessTable::Insert : arguments are 0 pointer
244  G4ProcessTable::Insert : arguments are 0 pointer
245 
246  */
247  }
248  }
249 
258  {
259  if (grp->IsPP()) runType = "pythia";
260  else if (grp->IsPA() || grp->IsAP()) runType = "dpmjet";
261  else if (grp->IsAA()) runType = "hijing";
262  }
263 };
264 
269 void Config()
270 {
271  // --- Get settings from environment variables --------------------
272  Setup s;
273  gROOT->Macro("EGConfig.C");
274 
275 
276  // ---- Seed random number generator -------------------------------
277  gRandom->SetSeed(s.seed);
278  std::cerr << "Seed for random number generation= " << s.seed << std::endl;
279 
280  //------------------------------------------------------------------
281  //
282  // Geometry and tracking
283  //
284  // --- Libraries required by geant321 ------------------------------
286  s.MakeBackend();
287  // gSystem->Load("libgeant321");
288  // new TGeant3TGeo("C++ Interface to Geant3");
289 
290  // -----------------------------------------------------------------
291  // Create the output file
292  std::cout<< "Config.C: Creating Run Loader ..." << std::endl;
293  AliRunLoader* rl = AliRunLoader::Open("galice.root",
294  AliConfig::GetDefaultEventFolderName(),
295  "recreate");
296  if (!rl) Fatal("Config","Can not instatiate the Run Loader");
297 
298  rl->SetCompressionLevel(2);
299  rl->SetNumberOfEventsPerFile(1000);
300  gAlice->SetRunLoader(rl);
301 
302  //
303  //=======================================================================
304  // Steering parameters for ALICE simulation
305  //
306  // --- Specify event type to be tracked through the ALICE setup
307  // --- All positions are in cm, angles in degrees, and P and E in GeV
308 
309  // --- Process switches --------------------------------------------
310  gMC->SetProcess("DCAY",1);
311  gMC->SetProcess("PAIR",1);
312  gMC->SetProcess("COMP",1);
313  gMC->SetProcess("PHOT",1);
314  gMC->SetProcess("PFIS",0);
315  gMC->SetProcess("DRAY",0);
316  gMC->SetProcess("ANNI",1);
317  gMC->SetProcess("BREM",1);
318  gMC->SetProcess("MUNU",1);
319  gMC->SetProcess("CKOV",1);
320  gMC->SetProcess("HADR",1);
321  gMC->SetProcess("LOSS",2);
322  gMC->SetProcess("MULS",1);
323  gMC->SetProcess("RAYL",1);
324 
325 
326  // --- Tracking cuts -----------------------------------------------
327  Float_t cut = 1.e-3; // 1MeV cut by default
328  Float_t tofmax = 1.e10;
329  gMC->SetCut("CUTGAM", cut);
330  gMC->SetCut("CUTELE", cut);
331  gMC->SetCut("CUTNEU", cut);
332  gMC->SetCut("CUTHAD", cut);
333  gMC->SetCut("CUTMUO", cut);
334  gMC->SetCut("BCUTE", cut);
335  gMC->SetCut("BCUTM", cut);
336  gMC->SetCut("DCUTE", cut);
337  gMC->SetCut("DCUTM", cut);
338  gMC->SetCut("PPCUTM", cut);
339  gMC->SetCut("TOFMAX", tofmax);
340 
341  // --- Set External decayer ----------------------------------------
342  TVirtualMCDecayer* decayer = egCfg->MakeDecayer(s.runType);
343  if (decayer) gMC->SetExternalDecayer(decayer);
344 
345  //------------------------------------------------------------------
346  //
347  // Generator Configuration
348  //
349  // --- Make the generator - this loads libraries
350  AliGenerator* gener = egCfg->MakeGenerator(s.runType,
351  s.minB,
352  s.maxB);
353  if (!egCfg->IsLego()) {
354  gener->Init();
355  if (gener->IsA()->InheritsFrom("AliGenHijing")) {
356  Info("", "Setting Hijing debug");
357  // static_cast<AliGenHijing*>(gener->GetTHijing()->SetIHPR2(10,1));
358  }
359  }
360 
361 
362  // --- Go back to galice.root --------------------------------------
363  rl->CdGAFile();
364 
365  //=================== Alice BODY parameters =============================
366  AliBODY *BODY = new AliBODY("BODY", "Alice envelop");
367 
368 
369  if (detCfg->UseMAG()) new AliMAG("MAG", "Magnet");
370  if (detCfg->UseABSO()) new AliABSOv3("ABSO", "Muon Absorber");
371  if (detCfg->UseDIPO()) new AliDIPOv3("DIPO", "Dipole version 3");
372  if (detCfg->UseHALL()) new AliHALLv3("HALL", "Alice Hall");
373  if (detCfg->UseFRAME()) (new AliFRAMEv2("FRAME", "Space Frame"))->SetHoles(1);
374  if (detCfg->UseSHIL()) new AliSHILv3("SHIL", "Shielding Version 3");
375  if (detCfg->UsePIPE()) new AliPIPEv3("PIPE", "Beam Pipe");
376  if (detCfg->UseITS()) new AliITSv11("ITS","ITS v11");
377  // if (detCfg->UseITS()) new AliITSv11Hybrid("ITS","ITS v11Hybrid");
378  if (detCfg->UseTPC()) {
379  AliTPC* tpc = new AliTPCv2("TPC", "Default");
380  if (s.IsGeant4()) tpc->SetPrimaryIonisation();
381  }
382  if (detCfg->UseTOF()) new AliTOFv6T0("TOF", "normal TOF");
383  if (detCfg->UseHMPID()) new AliHMPIDv3("HMPID", "normal HMPID");
384  if (detCfg->UseZDC()) {
385  AliZDC *ZDC = 0;
386  if (grp->period.EqualTo("LHC10h")) {
387  // Need to use older ZDC for PbPb
388  ZDC = new AliZDCv3("ZDC", "normal ZDC");
389  ZDC->SetSpectatorsTrack();
390  }
391  else
392  ZDC = new AliZDCv4("ZDC", "normal ZDC");
393  if (grp->Year() < 2011) { //?
394  // What are these? Do they need to be set properly?
395  //Collimators aperture
396  ZDC->SetVCollSideCAperture(0.85);
397  ZDC->SetVCollSideCCentre(0.);
398  ZDC->SetVCollSideAAperture(0.75);
399  ZDC->SetVCollSideACentre(0.);
400  //Detector position
401  ZDC->SetYZNC(1.6);
402  ZDC->SetYZNA(1.6);
403  ZDC->SetYZPC(1.6);
404  ZDC->SetYZPA(1.6);
405  }
406  ZDC->SetLumiLength(0.);
407  if (grp->IsPA() || grp->IsAP()) {
408  ZDC->SetpAsystem();
409  ZDC->SetBeamEnergy(82.*grp->beamEnergy/208.);
410  }
411  }
412  if (detCfg->UseTRD()) {
413  AliTRD *TRD = new AliTRDv1("TRD", "TRD slow simulator");
414  AliTRDgeometry *geoTRD = TRD->GetGeometry();
415  // Total of 18 super modules. We turn them all off by default
416  for (Int_t i = 0; i < 18; i++) geoTRD->SetSMstatus(i, 0);
417 
418  // '09-'10 had 7 super modules
419  geoTRD->SetSMstatus( 0,1);
420  geoTRD->SetSMstatus( 1,1);
421  geoTRD->SetSMstatus( 7,1);
422  geoTRD->SetSMstatus( 8,1);
423  geoTRD->SetSMstatus( 9,1);
424  geoTRD->SetSMstatus(14,1);//?
425  geoTRD->SetSMstatus(17,1);
426 
427  // In jan '11 3 more were added
428  if (grp->Year() > 2010) {
429  geoTRD->SetSMstatus(11, 1);
430  geoTRD->SetSMstatus(15, 1);
431  geoTRD->SetSMstatus(16, 1);//?
432  }
433 
434  // In the 2012 shutdow 3 more were added
435  if (grp->Year() > 2012) {
436  geoTRD->SetSMstatus( 2,1);
437  geoTRD->SetSMstatus( 3,1);
438  geoTRD->SetSMstatus( 6,1);
439  }
440  if (grp->Year() > 2014) {
441  geoTRD->SetSMstatus( 4,1);
442  geoTRD->SetSMstatus( 5,1);
443  geoTRD->SetSMstatus(10,1);
444  geoTRD->SetSMstatus(12,1);
445  geoTRD->SetSMstatus(13,1);
446  }
447  }
448  if (detCfg->UseFMD()) new AliFMDv1("FMD", "normal FMD");
449  if (detCfg->UseMUON()) {
450  AliMUON *MUON = new AliMUONv1("MUON", "default");
451  MUON->SetTriggerEffCells(1); // not needed if raw masks
452  MUON->SetTriggerResponseV1(2);
453  }
454  if (detCfg->UsePHOS()) new AliPHOSv1("PHOS", "noCPV_Modules123");
455  if (detCfg->UsePMD()) new AliPMDv1("PMD", "normal PMD");
456  if (detCfg->UseT0()) new AliT0v1("T0", "T0 Detector");
457  if (detCfg->UseEMCAL()) {
458  TString var;
459  if (grp->run <= 140000) var="EMCAL_FIRSTYEARV1";
460  else if (grp->run <= 170593) var="COMPLETEV1";
461  else if (grp->run <= 197692) var="EMCAL_COMPLETE12SMV1";
462  else var="EMCAL_COMPLETE12SMV1_DCAL_8SM";
463  new AliEMCALv2("EMCAL", var.Data());
464  }
465  if (detCfg->UseACORDE()) new AliACORDEv1("ACORDE", "normal ACORDE");
466  if (detCfg->UseVZERO()) new AliVZEROv7("VZERO", "normal VZERO");
467 }
468 
469 
470 
471 
472 //
473 // EOF
474 //
virtual Bool_t UseFRAME() const
Definition: BaseConfig.C:22
UInt_t run
Definition: GRP.C:102
virtual Bool_t UseMAG() const
Definition: BaseConfig.C:25
virtual Bool_t UseSHIL() const
Definition: BaseConfig.C:31
virtual Bool_t UsePMD() const
Definition: BaseConfig.C:29
virtual Bool_t UsePIPE() const
Definition: BaseConfig.C:28
virtual Bool_t UseDIPO() const
Definition: BaseConfig.C:19
UInt_t Year() const
Definition: GRP.C:196
virtual Bool_t UseHALL() const
Definition: BaseConfig.C:23
Bool_t IsPA() const
Definition: GRP.C:147
TString backend
Definition: Config.C:37
static UInt_t Env2UInt(const char *envName, UInt_t def)
Definition: Config.C:60
AliRunLoader * rl
TSystem * gSystem
TVirtualMCDecayer * MakeDecayer(const TString &rt)
Definition: BaseConfig.C:346
virtual Bool_t IsLego() const
Definition: BaseConfig.C:193
virtual Bool_t UseFMD() const
Definition: BaseConfig.C:21
Bool_t IsGeant3() const
Definition: Config.C:123
TRandom * gRandom
virtual Bool_t UseT0() const
Definition: BaseConfig.C:32
virtual Bool_t UseABSO() const
Definition: BaseConfig.C:17
virtual Bool_t UsePHOS() const
Definition: BaseConfig.C:27
virtual Bool_t UseMUON() const
Definition: BaseConfig.C:26
Bool_t IsAA() const
Definition: GRP.C:159
int Int_t
Definition: External.C:63
virtual Bool_t UseACORDE() const
Definition: BaseConfig.C:18
unsigned int UInt_t
Definition: External.C:33
float Float_t
Definition: External.C:68
virtual Bool_t UseTPC() const
Definition: BaseConfig.C:34
static void LoadGen(const TString &runType)
Definition: BaseConfig.C:229
VirtualEGCfg * egCfg
Definition: BaseConfig.C:385
void DeduceRunType()
Definition: Config.C:257
static Float_t Env2Float(const char *envName, Float_t def)
Definition: Config.C:46
Definition: Config.C:31
UInt_t beamEnergy
Definition: GRP.C:99
void Print()
Definition: GRP.C:125
TString period
Definition: GRP.C:101
TString runType
Definition: Config.C:33
UInt_t seed
Definition: Config.C:34
virtual Bool_t UseITS() const
Definition: BaseConfig.C:24
GRPData * grp
Definition: GRP.C:361
Bool_t IsPP() const
Definition: GRP.C:141
virtual Bool_t UseTRD() const
Definition: BaseConfig.C:35
virtual Bool_t UseVZERO() const
Definition: BaseConfig.C:36
virtual Bool_t UseZDC() const
Definition: BaseConfig.C:37
VirtualDetCfg * detCfg
Definition: BaseConfig.C:139
virtual Bool_t UseEMCAL() const
Definition: BaseConfig.C:20
void Print()
Definition: Config.C:111
void Config()
Definition: Config.C:269
bool Bool_t
Definition: External.C:53
Bool_t IsGeant4() const
Definition: Config.C:128
void MakeBackend()
Definition: Config.C:136
Setup()
Definition: Config.C:85
Float_t minB
Definition: Config.C:35
Bool_t IsAP() const
Definition: GRP.C:153
static UInt_t Env2Int(const char *envName, Int_t def)
Definition: Config.C:74
virtual Bool_t UseTOF() const
Definition: BaseConfig.C:33
virtual Bool_t UseHMPID() const
Definition: BaseConfig.C:30
Float_t maxB
Definition: Config.C:36
AliGenerator * MakeGenerator(const TString &rt, Float_t b1, Float_t b2, Bool_t smear=true)
Definition: BaseConfig.C:315