]> git.uio.no Git - u/mrichter/AliRoot.git/blob - macros/g4ConfigCommon.C
Using getter instead of global constant
[u/mrichter/AliRoot.git] / macros / g4ConfigCommon.C
1 // $Id$
2 //
3 // AliRoot Configuration for running aliroot with Monte Carlo.
4 // Called from g4Config.C
5
6 Float_t EtaToTheta(Float_t arg);
7 static Int_t    eventsPerRun = 100;
8 enum PprGeo_t 
9 {
10     kHoles, kNoHoles
11 };
12 static PprGeo_t geo = kHoles;
13
14 void ConfigCommon(Bool_t interactiveSetup)
15 {
16   // ============================= 
17   // Root file
18   // ============================= 
19
20   // Create the output file
21   AliRunLoader* rl = 0;
22   rl = AliRunLoader::Open("galice.root",
23                            AliConfig::GetDefaultEventFolderName(),
24                            "recreate");
25   if (!rl) {
26     gAlice->Fatal("Config.C","Can not instatiate the Run Loader");
27     return;
28   }
29   rl->SetCompressionLevel(2);
30   rl->SetNumberOfEventsPerFile(3);
31   gAlice->SetRunLoader(rl);
32
33   // Set External decayer
34   AliDecayer* decayer = new AliDecayerPythia();
35   decayer->SetForceDecay(kAll);
36   decayer->Init();
37   gMC->SetExternalDecayer(decayer);
38
39   // Physics process control
40   gMC ->SetProcess("DCAY",1);
41   gMC ->SetProcess("PAIR",1);
42   gMC ->SetProcess("COMP",1);
43   gMC ->SetProcess("PHOT",1);
44   gMC ->SetProcess("PFIS",0);
45   gMC ->SetProcess("DRAY",0);
46   gMC ->SetProcess("ANNI",1);
47   gMC ->SetProcess("BREM",1);
48   gMC ->SetProcess("MUNU",1);
49   //xx gMC ->SetProcess("CKOV",1);
50   gMC ->SetProcess("HADR",1); //Select pure GEANH (HADR 1) or GEANH/NUCRIN (HADR 3)
51   gMC ->SetProcess("LOSS",2);
52   gMC ->SetProcess("MULS",1);
53   //xx gMC ->SetProcess("RAYL",1);
54
55   // Energy cuts
56   // (in development)
57   Float_t cut    = 1.e-3; // 1MeV cut by default
58   Float_t tofmax = 1.e10; 
59
60   gMC ->SetCut("CUTGAM",cut);
61   gMC ->SetCut("CUTELE",cut);
62   gMC ->SetCut("CUTNEU",cut);
63   gMC ->SetCut("CUTHAD",cut);
64   gMC ->SetCut("CUTMUO",cut);
65   gMC ->SetCut("BCUTE",cut);
66   gMC ->SetCut("BCUTM",cut);
67   gMC ->SetCut("DCUTE",cut);
68   gMC ->SetCut("DCUTM",cut);
69   gMC ->SetCut("PPCUTM",cut);
70   gMC ->SetCut("TOFMAX",tofmax);
71
72   // ============================= 
73   // Event generator
74   // ============================= 
75
76   // --- Specify event type to be tracked through the ALICE setup
77   // --- All positions are in cm, angles in degrees, and P and E in GeV
78
79   Int_t nParticles = 100;
80   if (gSystem->Getenv("CONFIG_NPARTICLES")) 
81     nParticles = atoi(gSystem->Getenv("CONFIG_NPARTICLES"));
82
83   AliGenCocktail *gener = new AliGenCocktail();
84   gener->SetPhiRange(0, 360);
85   // Set pseudorapidity range from -8 to 8.
86   Float_t thmin = EtaToTheta(8);   // theta min. <---> eta max
87   Float_t thmax = EtaToTheta(-8);  // theta max. <---> eta min 
88   gener->SetThetaRange(thmin,thmax);
89   gener->SetOrigin(0, 0, 0);  //vertex position
90   gener->SetSigma(0, 0, 0);   //Sigma in (X,Y,Z) (cm) on IP position
91
92   AliGenHIJINGpara *hijingparam = new AliGenHIJINGpara(nParticles);
93   hijingparam->SetMomentumRange(0.2, 999);
94   gener->AddGenerator(hijingparam,"HIJING PARAM",1);
95
96   //    AliGenBox *genbox = new AliGenBox(nParticles);
97   //    genbox->SetPart(22);
98   //    genbox->SetPtRange(0.3, 10.00);
99   //    gener->AddGenerator(genbox,"GENBOX GAMMA for PHOS",1);
100   gener->Init();
101
102   // Activate this line if you want the vertex smearing to happen
103   // track by track
104
105   //gener->SetVertexSmear(perTrack); 
106
107   // ============================= 
108   // Magnetic field
109   // ============================= 
110
111   // Field (L3 0.4 T)
112   AliMagFMaps* field = new AliMagFMaps("Maps","Maps", 2, 1., 10., 1);
113   gAlice->SetField(field);    
114   
115   // Old magnetic field
116   //gAlice->SetField(-999,2);    //Specify maximum magnetic field in Tesla (neg. ==> default field)
117
118   // ============================= 
119   // Alice modules
120   // ============================= 
121
122   if (!interactiveSetup) {
123
124     // Select modules 
125   Int_t iABSO  = 1;
126   Int_t iDIPO  = 1;
127   Int_t iFMD   = 1;
128   Int_t iFRAME = 1;
129   Int_t iHALL  = 1;
130   Int_t iITS   = 1;
131   Int_t iMAG   = 1;
132   Int_t iMUON  = 1;
133   Int_t iPHOS  = 1;
134   Int_t iPIPE  = 1;
135   Int_t iPMD   = 1;
136   Int_t iRICH  = 1;
137   Int_t iSHIL  = 1;
138   Int_t iSTART = 1;
139   Int_t iTOF   = 1;
140   Int_t iTPC   = 1;
141   Int_t iTRD   = 1;
142   Int_t iZDC   = 1;
143   Int_t iEMCAL = 1;
144   Int_t iCRT   = 0;  
145   Int_t iVZERO = 1;
146
147   // ONLY FOR GEANT4
148
149   // Exclude detectors with temporary problem
150   iCRT = 0;
151   iEMCAL = 0;
152   iFMD = 0;
153  
154   // END OF ONLY FOR GEANT4
155
156
157     //=================== Alice BODY parameters =============================
158     AliBODY *BODY = new AliBODY("BODY", "Alice envelop");
159
160
161     if (iMAG)
162     {
163         //=================== MAG parameters ============================
164         // --- Start with Magnet since detector layouts may be depending ---
165         // --- on the selected Magnet dimensions ---
166         AliMAG *MAG = new AliMAG("MAG", "Magnet");
167     }
168
169
170     if (iABSO)
171     {
172         //=================== ABSO parameters ============================
173         AliABSO *ABSO = new AliABSOv0("ABSO", "Muon Absorber");
174     }
175
176     if (iDIPO)
177     {
178         //=================== DIPO parameters ============================
179
180         AliDIPO *DIPO = new AliDIPOv2("DIPO", "Dipole version 2");
181     }
182
183     if (iHALL)
184     {
185         //=================== HALL parameters ============================
186
187         AliHALL *HALL = new AliHALL("HALL", "Alice Hall");
188     }
189
190
191     if (iFRAME)
192     {
193         //=================== FRAME parameters ============================
194
195         AliFRAMEv2 *FRAME = new AliFRAMEv2("FRAME", "Space Frame");
196         if (geo == kHoles) {
197             FRAME->SetHoles(1);
198         } else {
199             FRAME->SetHoles(0);
200         }
201     }
202
203     if (iSHIL)
204     {
205         //=================== SHIL parameters ============================
206
207         AliSHIL *SHIL = new AliSHILv2("SHIL", "Shielding");
208     }
209
210
211     if (iPIPE)
212     {
213         //=================== PIPE parameters ============================
214
215         AliPIPE *PIPE = new AliPIPEv0("PIPE", "Beam Pipe");
216     }
217  
218     if(iITS) 
219     {
220       //=================== ITS parameters ============================
221       //
222       // As the innermost detector in ALICE, the Inner Tracking System "impacts" on
223       // almost all other detectors. This involves the fact that the ITS geometry
224       // still has several options to be followed in parallel in order to determine
225       // the best set-up which minimizes the induced background. All the geometries
226       // available to date are described in the following. Read carefully the comments
227       // and use the default version (the only one uncommented) unless you are making
228       // comparisons and you know what you are doing. In this case just uncomment the
229       // ITS geometry you want to use and run Aliroot.
230       //
231       // Detailed geometries:         
232       //
233       //
234       //
235 /*
236         AliITSvPPRasymmFMD *ITS  = new AliITSvPPRasymmFMD("ITS","ITS PPR detailed version with asymmetric services");
237         ITS->SetMinorVersion(2);  // don't touch this parameter if you're not an ITS developer
238         ITS->SetReadDet(kTRUE);   // don't touch this parameter if you're not an ITS developer
239         //    ITS->SetWriteDet("$ALICE_ROOT/ITS/ITSgeometry_vPPRasymm2.det");  // don't touch this parameter if you're not an ITS developer
240         ITS->SetThicknessDet1(200.);   // detector thickness on layer 1 must be in the range [100,300]
241         ITS->SetThicknessDet2(200.);   // detector thickness on layer 2 must be in the range [100,300]
242         ITS->SetThicknessChip1(200.);  // chip thickness on layer 1 must be in the range [150,300]
243         ITS->SetThicknessChip2(200.);  // chip thickness on layer 2 must be in the range [150,300]
244         ITS->SetRails(0);              // 1 --> rails in ; 0 --> rails out
245         ITS->SetCoolingFluid(1);       // 1 --> water ; 0 --> freon
246 */
247       //
248       // Coarse geometries (warning: no hits are produced with these coarse geometries and they unuseful 
249       // for reconstruction !):
250       //                                                       
251       //
252       AliITSvPPRcoarseasymm *ITS  = new AliITSvPPRcoarseasymm("ITS","New ITS PPR coarse version with asymmetric services");
253       ITS->SetRails(0);                // 1 --> rails in ; 0 --> rails out
254       ITS->SetSupportMaterial(0);      // 0 --> Copper ; 1 --> Aluminum ; 2 --> Carbon
255       //
256       //AliITS *ITS  = new AliITSvPPRcoarsesymm("ITS","New ITS PPR coarse version with symmetric services");
257       //ITS->SetRails(0);                // 1 --> rails in ; 0 --> rails out
258       //ITS->SetSupportMaterial(0);      // 0 --> Copper ; 1 --> Aluminum ; 2 --> Carbon
259       //                      
260       //
261       //
262       // Geant3 <-> EUCLID conversion
263       // ============================
264       //
265       // SetEUCLID is a flag to output (=1) or not to output (=0) both geometry and
266       // media to two ASCII files (called by default ITSgeometry.euc and
267       // ITSgeometry.tme) in a format understandable to the CAD system EUCLID.
268       // The default (=0) means that you dont want to use this facility.
269       //
270       ITS->SetEUCLID(0);  
271     }  
272
273     if (iTPC)
274     {
275         //============================ TPC parameters ================================
276         // --- This allows the user to specify sectors for the SLOW (TPC geometry 2)
277         // --- Simulator. SecAL (SecAU) <0 means that ALL lower (upper)
278         // --- sectors are specified, any value other than that requires at least one 
279         // --- sector (lower or upper)to be specified!
280         // --- Reminder: sectors 1-24 are lower sectors (1-12 -> z>0, 13-24 -> z<0)
281         // ---           sectors 25-72 are the upper ones (25-48 -> z>0, 49-72 -> z<0)
282         // --- SecLows - number of lower sectors specified (up to 6)
283         // --- SecUps - number of upper sectors specified (up to 12)
284         // --- Sens - sensitive strips for the Slow Simulator !!!
285         // --- This does NOT work if all S or L-sectors are specified, i.e.
286         // --- if SecAL or SecAU < 0
287         //
288         //
289         //-----------------------------------------------------------------------------
290
291         //  gROOT->LoadMacro("SetTPCParam.C");
292         //  AliTPCParam *param = SetTPCParam();
293         AliTPC *TPC = new AliTPCv2("TPC", "Default");
294
295         // All sectors included 
296         TPC->SetSecAL(-1);
297         TPC->SetSecAU(-1);
298
299     }
300
301     if (iTOF)
302     {
303         //=================== TOF parameters ============================
304         AliTOF *TOF = new AliTOFv4T0("TOF", "normal TOF");
305     }
306
307     if (iRICH)
308     {
309         //=================== RICH parameters ===========================
310         AliRICH *RICH = new AliRICHv3("RICH", "normal RICH");
311     }
312
313
314     if (iZDC)
315     {
316         //=================== ZDC parameters ============================
317
318         AliZDC *ZDC = new AliZDCv2("ZDC", "normal ZDC");
319     }
320
321     if (iTRD)
322     {
323         //=================== TRD parameters ============================
324
325         AliTRD *TRD = new AliTRDv1("TRD", "TRD slow simulator");
326
327         // Select the gas mixture (0: 97% Xe + 3% isobutane, 1: 90% Xe + 10% CO2)
328         TRD->SetGasMix(1);
329         if (geo == kHoles) {
330             // With hole in front of PHOS
331             TRD->SetPHOShole();
332             // With hole in front of RICH
333             TRD->SetRICHhole();
334         }
335         // Switch on TR
336         AliTRDsim *TRDsim = TRD->CreateTR();
337     }
338
339     if (iFMD)
340     {
341         //=================== FMD parameters ============================
342
343         AliFMD *FMD = new AliFMDv1("FMD", "normal FMD");
344     }
345
346     if (iMUON)
347     {
348         //=================== MUON parameters ===========================
349
350         AliMUON *MUON = new AliMUONv1("MUON", "default");
351         MUON->AddGeometryBuilder(new AliMUONSt1GeometryBuilder(MUON));
352         MUON->AddGeometryBuilder(new AliMUONSt2GeometryBuilder(MUON));
353         MUON->AddGeometryBuilder(new AliMUONSlatGeometryBuilder(MUON));
354         MUON->AddGeometryBuilder(new AliMUONTriggerGeometryBuilder(MUON));
355     }
356     //=================== PHOS parameters ===========================
357
358     if (iPHOS)
359     {
360         AliPHOS *PHOS = new AliPHOSv1("PHOS", "IHEP");
361     }
362
363
364     if (iPMD)
365     {
366         //=================== PMD parameters ============================
367         AliPMD *PMD = new AliPMDv1("PMD", "normal PMD");
368     }
369
370     if (iSTART)
371     {
372         //=================== START parameters ============================
373         AliSTART *START = new AliSTARTv1("START", "START Detector");
374     }
375
376     if (iEMCAL)
377     {
378         //=================== EMCAL parameters ============================
379         AliEMCAL *EMCAL = new AliEMCALv1("EMCAL", "EMCAL_55_25");
380     }
381
382     if (iCRT)
383     {
384         //=================== CRT parameters ============================
385
386         AliCRT *CRT = new AliCRTv0("CRT", "normal ACORDE");
387     }
388
389     if (iVZERO)
390     {
391         //=================== CRT parameters ============================
392         AliVZERO *VZERO = new AliVZEROv3("VZERO", "normal VZERO");
393     }
394
395   } // end (!isSetInteractively)
396   else {
397   
398     if (geo == kHoles) 
399       AliRunConfiguration::SwitchHoles(kTRUE);
400     else  
401       AliRunConfiguration::SwitchHoles(kFALSE);
402   }    
403 }
404
405 Float_t EtaToTheta(Float_t arg){
406   return (180./TMath::Pi())*2.*atan(exp(-arg));
407 }