]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ACORDE/macros/Config.C
Filling BB flags in digit with trigger simulator
[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   AliSimulation::Instance()->SetTriggerConfig(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",-1.,-1., mag);
188   TGeoGlobalMagField::Instance()->SetField(field);
189
190   rl->CdGAFile();
191
192   Int_t iABSO  = 0;
193   Int_t iACORDE = 1;
194   Int_t iDIPO  = 0;
195   Int_t iEMCAL = 0;
196   Int_t iFMD   = 0;
197   Int_t iFRAME = 0;
198   Int_t iHALL  = 0;
199   Int_t iITS   = 0;
200   Int_t iMAG   = 0;
201   Int_t iMUON  = 0;
202   Int_t iPHOS  = 0;
203   Int_t iPIPE  = 0;
204   Int_t iPMD   = 0;
205   Int_t iHMPID  = 0;
206   Int_t iSHIL  = 0;
207   Int_t iT0 = 0;
208   Int_t iTOF   = 0;
209   Int_t iTPC   = 0;
210   Int_t iTRD   = 0;
211   Int_t iVZERO = 0;
212   Int_t iZDC   = 0;
213   
214     //=================== Alice BODY parameters =============================
215     AliBODY *BODY = new AliBODY("BODY", "Alice envelop");
216     if (iMAG)
217     {
218         //=================== MAG parameters ============================
219         // --- Start with Magnet since detector layouts may be depending ---
220         // --- on the selected Magnet dimensions ---
221         AliMAG *MAG = new AliMAG("MAG", "Magnet");
222     }
223     if (iABSO)
224     {
225         //=================== ABSO parameters ============================
226         AliABSO *ABSO = new AliABSOv0("ABSO", "Muon Absorber");
227     }
228     if (iDIPO)
229     {
230         //=================== DIPO parameters ============================
231         AliDIPO *DIPO = new AliDIPOv2("DIPO", "Dipole version 2");
232     }
233     if (iHALL)
234     {
235         //=================== HALL parameters ============================
236         AliHALL *HALL = new AliHALL("HALL", "Alice Hall");
237     }
238     if (iFRAME)
239     {
240         //=================== FRAME parameters ============================
241         AliFRAMEv2 *FRAME = new AliFRAMEv2("FRAME", "Space Frame");
242     }
243     if (iSHIL)
244     {
245         //=================== SHIL parameters ============================
246         AliSHIL *SHIL = new AliSHILv2("SHIL", "Shielding Version 2");
247     }
248     if (iPIPE)
249     {
250         //=================== PIPE parameters ============================
251         AliPIPE *PIPE = new AliPIPEv0("PIPE", "Beam Pipe");
252     }
253  
254     if(iITS) {
255     //=================== ITS parameters ============================
256     //
257     // As the innermost detector in ALICE, the Inner Tracking System "impacts" on
258     // almost all other detectors. This involves the fact that the ITS geometry
259     // still has several options to be followed in parallel in order to determine
260     // the best set-up which minimizes the induced background. All the geometries
261     // available to date are described in the following. Read carefully the comments
262     // and use the default version (the only one uncommented) unless you are making
263     // comparisons and you know what you are doing. In this case just uncomment the
264     // ITS geometry you want to use and run Aliroot.
265     //
266     // Detailed geometries:         
267     //
268     //
269     //AliITS *ITS  = new AliITSv5symm("ITS","Updated ITS TDR detailed version with symmetric services");
270     //
271     //AliITS *ITS  = new AliITSv5asymm("ITS","Updates ITS TDR detailed version with asymmetric services");
272     //
273         AliITSvPPRasymmFMD *ITS  = new AliITSvPPRasymmFMD("ITS","New ITS PPR detailed version with asymmetric services");
274         ITS->SetMinorVersion(2);  // don't touch this parameter if you're not an ITS developer
275         ITS->SetReadDet(kFALSE);          // don't touch this parameter if you're not an ITS developer
276     //    ITS->SetWriteDet("$ALICE_ROOT/ITS/ITSgeometry_vPPRasymm2.det");  // don't touch this parameter if you're not an ITS developer
277         ITS->SetThicknessDet1(200.);   // detector thickness on layer 1 must be in the range [100,300]
278         ITS->SetThicknessDet2(200.);   // detector thickness on layer 2 must be in the range [100,300]
279         ITS->SetThicknessChip1(150.);  // chip thickness on layer 1 must be in the range [150,300]
280         ITS->SetThicknessChip2(150.);  // chip thickness on layer 2 must be in the range [150,300]
281         ITS->SetRails(0);            // 1 --> rails in ; 0 --> rails out
282         ITS->SetCoolingFluid(1);   // 1 --> water ; 0 --> freon
283     // Coarse geometries (warning: no hits are produced with these coarse geometries and they unuseful 
284     // for reconstruction !):
285     //                                                     
286     //
287     //AliITSvPPRcoarseasymm *ITS  = new AliITSvPPRcoarseasymm("ITS","New ITS PPR coarse version with asymmetric services");
288     //ITS->SetRails(0);                // 1 --> rails in ; 0 --> rails out
289     //ITS->SetSupportMaterial(0);      // 0 --> Copper ; 1 --> Aluminum ; 2 --> Carbon
290     //
291     //AliITS *ITS  = new AliITSvPPRcoarsesymm("ITS","New ITS PPR coarse version with symmetric services");
292     //ITS->SetRails(0);                // 1 --> rails in ; 0 --> rails out
293     //ITS->SetSupportMaterial(0);      // 0 --> Copper ; 1 --> Aluminum ; 2 --> Carbon
294     //                      
295     //
296     //
297     // Geant3 <-> EUCLID conversion
298     // ============================
299     //
300     // SetEUCLID is a flag to output (=1) or not to output (=0) both geometry and
301     // media to two ASCII files (called by default ITSgeometry.euc and
302     // ITSgeometry.tme) in a format understandable to the CAD system EUCLID.
303     // The default (=0) means that you dont want to use this facility.
304     //
305         ITS->SetEUCLID(0);  
306     }
307     if (iTPC)
308     {
309       //============================ TPC parameters =====================
310         AliTPC *TPC = new AliTPCv2("TPC", "Default");
311     }
312     if (iTOF) {
313         //=================== TOF parameters ============================
314         AliTOF *TOF = new AliTOFv5T0("TOF", "normal TOF");
315         // Partial geometry: modules at 2,3,4,6,7,11,12,14,15,16
316         // starting at 6h in positive direction
317         //      Int_t TOFSectors[18]={-1,-1,0,0,0,-1,0,0,-1,-1,-1,0,0,-1,0,0,0,0};
318         // Partial geometry: modules at 1,2,6,7,9,10,11,12,15,16,17
319         // (ALICE numbering convention)
320         Int_t TOFSectors[18]={-1,0,0,-1,-1,-1,0,0,-1,0,0,0,0,-1,-1,0,0,0};
321         TOF->SetTOFSectors(TOFSectors);
322     }
323     if (iHMPID)
324     {
325         //=================== HMPID parameters ===========================
326         AliHMPID *HMPID = new AliHMPIDv1("HMPID", "normal HMPID");
327     }
328     if (iZDC)
329     {
330         //=================== ZDC parameters ============================
331         AliZDC *ZDC = new AliZDCv2("ZDC", "normal ZDC");
332     }
333     if (iTRD)
334     {
335         //=================== TRD parameters ============================
336         AliTRD *TRD = new AliTRDv1("TRD", "TRD slow simulator");
337         AliTRDgeometry *geoTRD = TRD->GetGeometry();
338         // Partial geometry: modules at 2,3,4,6,11,12,14,15
339         // starting at 6h in positive direction
340         geoTRD->SetSMstatus(0,0);
341         geoTRD->SetSMstatus(1,0);
342         geoTRD->SetSMstatus(5,0);
343         geoTRD->SetSMstatus(7,0);
344         geoTRD->SetSMstatus(8,0);
345         geoTRD->SetSMstatus(9,0);
346         geoTRD->SetSMstatus(10,0);
347         geoTRD->SetSMstatus(13,0);
348         geoTRD->SetSMstatus(16,0);
349         geoTRD->SetSMstatus(17,0);
350     }
351     if (iFMD)
352     {
353         //=================== FMD parameters ============================
354         AliFMD *FMD = new AliFMDv1("FMD", "normal FMD");
355    }
356     if (iMUON)
357     {
358         //=================== MUON parameters ===========================
359         // New MUONv1 version (geometry defined via builders)
360         AliMUON *MUON = new AliMUONv1("MUON", "default");
361     }
362     //=================== PHOS parameters ===========================
363     if (iPHOS)
364     {
365         AliPHOS *PHOS = new AliPHOSv1("PHOS", "IHEP");
366     }
367     if (iPMD)
368     {
369         //=================== PMD parameters ============================
370         AliPMD *PMD = new AliPMDv1("PMD", "normal PMD");
371     }
372     if (iT0)
373     {
374         //=================== T0 parameters ============================
375         AliT0 *T0 = new AliT0v1("T0", "T0 Detector");
376     }
377     if (iEMCAL)
378     {
379         //=================== EMCAL parameters ============================
380         AliEMCAL *EMCAL = new AliEMCALv2("EMCAL", "EMCAL_COMPLETEV1");
381     }
382      if (iACORDE)
383     {
384         //=================== ACORDE parameters ============================
385         AliACORDE *ACORDE = new AliACORDEv1("ACORDE", "normal ACORDE");
386         // ACORDE->SetITSGeometry(kTRUE);
387         // ACORDE->SetCreateCavern(kFALSE);
388     }
389      if (iVZERO)
390     {
391         //=================== VZERO parameters =============================
392         AliVZERO *VZERO = new AliVZEROv7("VZERO", "normal VZERO");
393     }
394 }
395 void ProcessEnvironmentVars()
396 {
397     // Run type
398     if (gSystem->Getenv("CONFIG_RUN_TYPE")) {
399       for (Int_t iRun = 0; iRun < kRunMax; iRun++) {
400         if (strcmp(gSystem->Getenv("CONFIG_RUN_TYPE"), pprRunName[iRun])==0) {
401           proc = (PDC06Proc_t)iRun;
402           cout<<"Run type set to "<<pprRunName[iRun]<<endl;
403         }
404       }
405     }
406     // Random Number seed
407     if (gSystem->Getenv("CONFIG_SEED")) {
408       seed = atoi(gSystem->Getenv("CONFIG_SEED"));
409     }
410 }