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