]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ACORDE/macros/Config.C
Only one Check method needs to be implemented by detectors that will be valid fo...
[u/mrichter/AliRoot.git] / ACORDE / macros / Config.C
1 //
2 // Configuration for the Physics Data Challenge 2006
3 //
4 // One can use the configuration macro in compiled mode by
5 // root [0] gSystem->Load("libgeant321");
6 // root [0] gSystem->SetIncludePath("-I$ROOTSYS/include -I$ALICE_ROOT/include\
7 //                   -I$ALICE_ROOT -I$ALICE/geant3/TGeant3");
8 // root [0] .x grun.C(1,"Config_PDC06.C++")
9 #if !defined(__CINT__) || defined(__MAKECINT__)
10 #include <Riostream.h>
11 #include <TRandom.h>
12 #include <TDatime.h>
13 #include <TSystem.h>
14 #include <TVirtualMC.h>
15 #include <TGeant3TGeo.h>
16 #include "EVGEN/AliGenCocktail.h"
17 #include "EVGEN/AliGenParam.h"
18 #include "EVGEN/AliGenMUONlib.h"
19 #include "STEER/AliRunLoader.h"
20 #include "STEER/AliRun.h"
21 #include "STEER/AliConfig.h"
22 #include "PYTHIA6/AliDecayerPythia.h"
23 #include "PYTHIA6/AliGenPythia.h"
24 #include "STEER/AliMagF.h"
25 #include "STRUCT/AliBODY.h"
26 #include "STRUCT/AliMAG.h"
27 #include "STRUCT/AliABSOv0.h"
28 #include "STRUCT/AliDIPOv2.h"
29 #include "STRUCT/AliHALL.h"
30 #include "STRUCT/AliFRAMEv2.h"
31 #include "STRUCT/AliSHILv2.h"
32 #include "STRUCT/AliPIPEv0.h"
33 #include "ITS/AliITSgeom.h"
34 #include "ITS/AliITSvPPRasymmFMD.h"
35 #include "TPC/AliTPCv2.h"
36 #include "TOF/AliTOFv5T0.h"
37 #include "HMPID/AliHMPIDv1.h"
38 #include "ZDC/AliZDCv2.h"
39 #include "TRD/AliTRDv1.h"
40 #include "FMD/AliFMDv1.h"
41 #include "MUON/AliMUONv1.h"
42 #include "PHOS/AliPHOSv1.h"
43 #include "PMD/AliPMDv1.h"
44 #include "T0/AliT0v1.h"
45 #include "EMCAL/AliEMCALv2.h"
46 #include "CRT/AliCRTv0.h"
47 #include "VZERO/AliVZEROv7.h"
48 #endif
49 //--- Trigger config ---
50 enum TrigConf_t
51 {
52     kDefaultPPTrig, kDefaultPbPbTrig
53 };
54 const char * TrigConfName[] = {
55     "p-p","Pb-Pb"
56 };
57 //--- Decay Mode ---
58 enum DecayHvFl_t 
59 {
60   kNature,  kHadr, kSemiEl, kSemiMu
61 };
62 //--- Rapidity Cut ---
63 enum YCut_t
64 {
65   kFull, kBarrel, kMuonArm
66 };
67 void ProcessEnvironmentVars();
68 // This part for configuration
69 static DecayHvFl_t   decHvFl  = kNature; 
70 static YCut_t        ycut     = kFull;
71 static AliMagF::BMap_t mag    = AliMagF::k5kG; 
72 static TrigConf_t    trig     = kDefaultPPTrig; 
73 //========================//
74 // Set Random Number seed //
75 //========================//
76 TDatime dt;
77 static UInt_t seed    = dt.Get();
78 // Comment line
79 static TString comment;
80 void Config()
81 {
82  
83   // Get settings from environment variables
84   ProcessEnvironmentVars();
85   gRandom->SetSeed(seed);
86   //  gRandom->SetSeed(12345);
87   cerr<<"Seed for random number generation= "<<seed<<endl; 
88   // libraries required by geant321
89 #if defined(__CINT__)
90   gSystem->Load("libgeant321");
91 #endif
92   new TGeant3TGeo("C++ Interface to Geant3");
93   //=======================================================================
94   //  Create the output file
95    
96   AliRunLoader* rl=0x0;
97   cout<<"Config.C: Creating Run Loader ..."<<endl;
98   rl = AliRunLoader::Open("galice.root",
99                           AliConfig::GetDefaultEventFolderName(),
100                           "recreate");
101   if (rl == 0x0)
102     {
103       gAlice->Fatal("Config.C","Can not instatiate the Run Loader");
104       return;
105     }
106   rl->SetCompressionLevel(2);
107   rl->SetNumberOfEventsPerFile(1000);
108   gAlice->SetRunLoader(rl);
109   
110   // Set the trigger configuration
111   gAlice->SetTriggerDescriptor(TrigConfName[trig]);
112   cout<<"Trigger configuration is set to  "<<TrigConfName[trig]<<endl;
113   //
114   //=======================================================================
115   // ************* STEERING parameters FOR ALICE SIMULATION **************
116   // --- Specify event type to be tracked through the ALICE setup
117   // --- All positions are in cm, angles in degrees, and P and E in GeV
118     gMC->SetProcess("DCAY",1);
119     gMC->SetProcess("PAIR",1);
120     gMC->SetProcess("COMP",1);
121     gMC->SetProcess("PHOT",1);
122     gMC->SetProcess("PFIS",0);
123     gMC->SetProcess("DRAY",0);
124     gMC->SetProcess("ANNI",1);
125     gMC->SetProcess("BREM",1);
126     gMC->SetProcess("MUNU",1);
127     gMC->SetProcess("CKOV",1);
128     gMC->SetProcess("HADR",1);
129     gMC->SetProcess("LOSS",2);
130     gMC->SetProcess("MULS",1);
131     gMC->SetProcess("RAYL",1);
132     Float_t cut = 1.e-3;        // 1MeV cut by default
133     Float_t tofmax = 1.e10;
134     gMC->SetCut("CUTGAM", cut);
135     gMC->SetCut("CUTELE", cut);
136     gMC->SetCut("CUTNEU", cut);
137     gMC->SetCut("CUTHAD", cut);
138     gMC->SetCut("CUTMUO", cut);
139     gMC->SetCut("BCUTE",  cut); 
140     gMC->SetCut("BCUTM",  cut); 
141     gMC->SetCut("DCUTE",  cut); 
142     gMC->SetCut("DCUTM",  cut); 
143     gMC->SetCut("PPCUTM", cut);
144     gMC->SetCut("TOFMAX", tofmax); 
145     //    ((TGeant3 *) gMC)->SetSWIT(2,2); 
146     //    ((TGeant3 *) gMC)->SetDEBU(1,999,1); 
147   // Set External decayer //
148   //======================//
149   TVirtualMCDecayer* decayer = new AliDecayerPythia();
150   // DECAYS
151   //
152   switch(decHvFl) {
153   case kNature:
154     decayer->SetForceDecay(kAll);
155     break;
156   case kHadr:
157     decayer->SetForceDecay(kHadronicD);
158     break;
159   case kSemiEl:
160     decayer->SetForceDecay(kSemiElectronic);
161     break;
162   case kSemiMu:
163     decayer->SetForceDecay(kSemiMuonic);
164     break;
165   }
166   decayer->Init();
167   gMC->SetExternalDecayer(decayer);
168   //=========================//
169   // Generator Configuration //
170   //=========================//
171   AliGenBox* gener = new AliGenBox();
172   gener->SetThetaRange(45,135);
173   gener->SetPhiRange(30,150);
174   gener->SetMomentumRange(9.8,10.2);
175   gener->SetPart(kMuonMinus);
176   gener->SetNumberParticles(20);
177   gener->Init();
178   // FIELD
179   //    
180   if (mag == AliMagF::k2kG) {
181     comment = comment.Append(" | L3 field 0.2 T");
182   } else if (mag == AliMagF::k5kG) {
183     comment = comment.Append(" | L3 field 0.5 T");
184   }
185   printf("\n \n Comment: %s \n \n", comment.Data());
186     
187   AliMagF* field = new AliMagF("Maps","Maps",2,1.,1., 10.,mag);
188   field->SetL3ConstField(0); //Using const. field in the barrel
189   TGeoGlobalMagField::Instance()->SetField(field);
190
191   rl->CdGAFile();
192
193   Int_t iABSO  = 0;
194   Int_t iACORDE = 1;
195   Int_t iDIPO  = 0;
196   Int_t iEMCAL = 0;
197   Int_t iFMD   = 0;
198   Int_t iFRAME = 0;
199   Int_t iHALL  = 0;
200   Int_t iITS   = 0;
201   Int_t iMAG   = 0;
202   Int_t iMUON  = 0;
203   Int_t iPHOS  = 0;
204   Int_t iPIPE  = 0;
205   Int_t iPMD   = 0;
206   Int_t iHMPID  = 0;
207   Int_t iSHIL  = 0;
208   Int_t iT0 = 0;
209   Int_t iTOF   = 0;
210   Int_t iTPC   = 0;
211   Int_t iTRD   = 0;
212   Int_t iVZERO = 0;
213   Int_t iZDC   = 0;
214   
215     //=================== Alice BODY parameters =============================
216     AliBODY *BODY = new AliBODY("BODY", "Alice envelop");
217     if (iMAG)
218     {
219         //=================== MAG parameters ============================
220         // --- Start with Magnet since detector layouts may be depending ---
221         // --- on the selected Magnet dimensions ---
222         AliMAG *MAG = new AliMAG("MAG", "Magnet");
223     }
224     if (iABSO)
225     {
226         //=================== ABSO parameters ============================
227         AliABSO *ABSO = new AliABSOv0("ABSO", "Muon Absorber");
228     }
229     if (iDIPO)
230     {
231         //=================== DIPO parameters ============================
232         AliDIPO *DIPO = new AliDIPOv2("DIPO", "Dipole version 2");
233     }
234     if (iHALL)
235     {
236         //=================== HALL parameters ============================
237         AliHALL *HALL = new AliHALL("HALL", "Alice Hall");
238     }
239     if (iFRAME)
240     {
241         //=================== FRAME parameters ============================
242         AliFRAMEv2 *FRAME = new AliFRAMEv2("FRAME", "Space Frame");
243     }
244     if (iSHIL)
245     {
246         //=================== SHIL parameters ============================
247         AliSHIL *SHIL = new AliSHILv2("SHIL", "Shielding Version 2");
248     }
249     if (iPIPE)
250     {
251         //=================== PIPE parameters ============================
252         AliPIPE *PIPE = new AliPIPEv0("PIPE", "Beam Pipe");
253     }
254  
255     if(iITS) {
256     //=================== ITS parameters ============================
257     //
258     // As the innermost detector in ALICE, the Inner Tracking System "impacts" on
259     // almost all other detectors. This involves the fact that the ITS geometry
260     // still has several options to be followed in parallel in order to determine
261     // the best set-up which minimizes the induced background. All the geometries
262     // available to date are described in the following. Read carefully the comments
263     // and use the default version (the only one uncommented) unless you are making
264     // comparisons and you know what you are doing. In this case just uncomment the
265     // ITS geometry you want to use and run Aliroot.
266     //
267     // Detailed geometries:         
268     //
269     //
270     //AliITS *ITS  = new AliITSv5symm("ITS","Updated ITS TDR detailed version with symmetric services");
271     //
272     //AliITS *ITS  = new AliITSv5asymm("ITS","Updates ITS TDR detailed version with asymmetric services");
273     //
274         AliITSvPPRasymmFMD *ITS  = new AliITSvPPRasymmFMD("ITS","New ITS PPR detailed version with asymmetric services");
275         ITS->SetMinorVersion(2);  // don't touch this parameter if you're not an ITS developer
276         ITS->SetReadDet(kFALSE);          // don't touch this parameter if you're not an ITS developer
277     //    ITS->SetWriteDet("$ALICE_ROOT/ITS/ITSgeometry_vPPRasymm2.det");  // don't touch this parameter if you're not an ITS developer
278         ITS->SetThicknessDet1(200.);   // detector thickness on layer 1 must be in the range [100,300]
279         ITS->SetThicknessDet2(200.);   // detector thickness on layer 2 must be in the range [100,300]
280         ITS->SetThicknessChip1(150.);  // chip thickness on layer 1 must be in the range [150,300]
281         ITS->SetThicknessChip2(150.);  // chip thickness on layer 2 must be in the range [150,300]
282         ITS->SetRails(0);            // 1 --> rails in ; 0 --> rails out
283         ITS->SetCoolingFluid(1);   // 1 --> water ; 0 --> freon
284     // Coarse geometries (warning: no hits are produced with these coarse geometries and they unuseful 
285     // for reconstruction !):
286     //                                                     
287     //
288     //AliITSvPPRcoarseasymm *ITS  = new AliITSvPPRcoarseasymm("ITS","New ITS PPR coarse version with asymmetric services");
289     //ITS->SetRails(0);                // 1 --> rails in ; 0 --> rails out
290     //ITS->SetSupportMaterial(0);      // 0 --> Copper ; 1 --> Aluminum ; 2 --> Carbon
291     //
292     //AliITS *ITS  = new AliITSvPPRcoarsesymm("ITS","New ITS PPR coarse version with symmetric services");
293     //ITS->SetRails(0);                // 1 --> rails in ; 0 --> rails out
294     //ITS->SetSupportMaterial(0);      // 0 --> Copper ; 1 --> Aluminum ; 2 --> Carbon
295     //                      
296     //
297     //
298     // Geant3 <-> EUCLID conversion
299     // ============================
300     //
301     // SetEUCLID is a flag to output (=1) or not to output (=0) both geometry and
302     // media to two ASCII files (called by default ITSgeometry.euc and
303     // ITSgeometry.tme) in a format understandable to the CAD system EUCLID.
304     // The default (=0) means that you dont want to use this facility.
305     //
306         ITS->SetEUCLID(0);  
307     }
308     if (iTPC)
309     {
310       //============================ TPC parameters =====================
311         AliTPC *TPC = new AliTPCv2("TPC", "Default");
312     }
313     if (iTOF) {
314         //=================== TOF parameters ============================
315         AliTOF *TOF = new AliTOFv5T0("TOF", "normal TOF");
316         // Partial geometry: modules at 2,3,4,6,7,11,12,14,15,16
317         // starting at 6h in positive direction
318         //      Int_t TOFSectors[18]={-1,-1,0,0,0,-1,0,0,-1,-1,-1,0,0,-1,0,0,0,0};
319         // Partial geometry: modules at 1,2,6,7,9,10,11,12,15,16,17
320         // (ALICE numbering convention)
321         Int_t TOFSectors[18]={-1,0,0,-1,-1,-1,0,0,-1,0,0,0,0,-1,-1,0,0,0};
322         TOF->SetTOFSectors(TOFSectors);
323     }
324     if (iHMPID)
325     {
326         //=================== HMPID parameters ===========================
327         AliHMPID *HMPID = new AliHMPIDv1("HMPID", "normal HMPID");
328     }
329     if (iZDC)
330     {
331         //=================== ZDC parameters ============================
332         AliZDC *ZDC = new AliZDCv2("ZDC", "normal ZDC");
333     }
334     if (iTRD)
335     {
336         //=================== TRD parameters ============================
337         AliTRD *TRD = new AliTRDv1("TRD", "TRD slow simulator");
338         AliTRDgeometry *geoTRD = TRD->GetGeometry();
339         // Partial geometry: modules at 2,3,4,6,11,12,14,15
340         // starting at 6h in positive direction
341         geoTRD->SetSMstatus(0,0);
342         geoTRD->SetSMstatus(1,0);
343         geoTRD->SetSMstatus(5,0);
344         geoTRD->SetSMstatus(7,0);
345         geoTRD->SetSMstatus(8,0);
346         geoTRD->SetSMstatus(9,0);
347         geoTRD->SetSMstatus(10,0);
348         geoTRD->SetSMstatus(13,0);
349         geoTRD->SetSMstatus(16,0);
350         geoTRD->SetSMstatus(17,0);
351     }
352     if (iFMD)
353     {
354         //=================== FMD parameters ============================
355         AliFMD *FMD = new AliFMDv1("FMD", "normal FMD");
356    }
357     if (iMUON)
358     {
359         //=================== MUON parameters ===========================
360         // New MUONv1 version (geometry defined via builders)
361         AliMUON *MUON = new AliMUONv1("MUON", "default");
362     }
363     //=================== PHOS parameters ===========================
364     if (iPHOS)
365     {
366         AliPHOS *PHOS = new AliPHOSv1("PHOS", "IHEP");
367     }
368     if (iPMD)
369     {
370         //=================== PMD parameters ============================
371         AliPMD *PMD = new AliPMDv1("PMD", "normal PMD");
372     }
373     if (iT0)
374     {
375         //=================== T0 parameters ============================
376         AliT0 *T0 = new AliT0v1("T0", "T0 Detector");
377     }
378     if (iEMCAL)
379     {
380         //=================== EMCAL parameters ============================
381         AliEMCAL *EMCAL = new AliEMCALv2("EMCAL", "EMCAL_COMPLETE");
382     }
383      if (iACORDE)
384     {
385         //=================== ACORDE parameters ============================
386         AliACORDE *ACORDE = new AliACORDEv1("ACORDE", "normal ACORDE");
387         // ACORDE->SetITSGeometry(kTRUE);
388         // ACORDE->SetCreateCavern(kFALSE);
389     }
390      if (iVZERO)
391     {
392         //=================== VZERO parameters =============================
393         AliVZERO *VZERO = new AliVZEROv7("VZERO", "normal VZERO");
394     }
395 }
396 void ProcessEnvironmentVars()
397 {
398     // Run type
399     if (gSystem->Getenv("CONFIG_RUN_TYPE")) {
400       for (Int_t iRun = 0; iRun < kRunMax; iRun++) {
401         if (strcmp(gSystem->Getenv("CONFIG_RUN_TYPE"), pprRunName[iRun])==0) {
402           proc = (PDC06Proc_t)iRun;
403           cout<<"Run type set to "<<pprRunName[iRun]<<endl;
404         }
405       }
406     }
407     // Random Number seed
408     if (gSystem->Getenv("CONFIG_SEED")) {
409       seed = atoi(gSystem->Getenv("CONFIG_SEED"));
410     }
411 }