]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/macros/Config.C
DA->pedestal macro for SRU readout
[u/mrichter/AliRoot.git] / EMCAL / 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 <TPDGCode.h>
10 #include <TRandom.h>
11 #include <TSystem.h>
12 #include <TVirtualMC.h>
13 #include <TGeant3TGeo.h>
14 #include "STEER/AliRunLoader.h"
15 #include "STEER/AliRun.h"
16 #include "STEER/AliConfig.h"
17 #include "PYTHIA6/AliDecayerPythia.h"
18 #include "EVGEN/AliGenCocktail.h"
19 #include "EVGEN/AliGenHIJINGpara.h"
20 #include "STEER/AliMagF.h"
21 #include "STRUCT/AliBODY.h"
22 #include "STRUCT/AliMAG.h"
23 #include "STRUCT/AliABSOv3.h"
24 #include "STRUCT/AliDIPOv3.h"
25 #include "STRUCT/AliHALLv3.h"
26 #include "STRUCT/AliFRAMEv2.h"
27 #include "STRUCT/AliSHILv3.h"
28 #include "STRUCT/AliPIPEv3.h"
29 #include "ITS/AliITSv11.h"
30 #include "TPC/AliTPCv2.h"
31 #include "TOF/AliTOFv6T0.h"
32 #include "HMPID/AliHMPIDv2.h"
33 #include "ZDC/AliZDCv3.h"
34 #include "TRD/AliTRDv1.h"
35 #include "FMD/AliFMDv1.h"
36 #include "MUON/AliMUONv1.h"
37 #include "PHOS/AliPHOSv1.h"
38 #include "PMD/AliPMDv1.h"
39 #include "T0/AliT0v1.h"
40 #include "EMCAL/AliEMCALv2.h"
41 #include "ACORDE/AliACORDEv1.h"
42 #include "VZERO/AliVZEROv7.h"
43 #endif
44
45 Float_t EtaToTheta(Float_t arg);
46 void    LoadPythia();
47 AliGenerator *GenParamCalo(Int_t nPart, Int_t type, TString calo);
48
49 Int_t  year = 2012;
50 Bool_t checkGeoAndRun = kFALSE;
51
52 void Config()
53 {
54   //AliLog::SetGlobalDebugLevel(2);
55   
56   // ThetaRange is (0., 180.). It was (0.28,179.72) 7/12/00 09:00
57   // Theta range given through pseudorapidity limits 22/6/2001
58   
59   // Set Random Number seed
60   //gRandom->SetSeed(123456); // Set 0 to use the currecnt time
61   AliLog::Message(AliLog::kInfo, Form("Seed for random number generation = %d",gRandom->GetSeed()), "Config.C", "Config.C", "Config()","Config.C", __LINE__);
62   
63   // Load Pythia libraries                                        
64   LoadPythia();
65   
66   // libraries required by geant321
67 #if defined(__CINT__)
68   gSystem->Load("libgeant321");
69 #endif
70   
71   new     TGeant3TGeo("C++ Interface to Geant3");
72   
73   AliRunLoader* rl=0x0;
74   
75   AliLog::Message(AliLog::kInfo, "Creating Run Loader", "Config.C", "Config.C", "Config()"," Config.C", __LINE__);
76   
77   rl = AliRunLoader::Open("galice.root",
78                           AliConfig::GetDefaultEventFolderName(),
79                           "recreate");
80   if (rl == 0x0)
81   {
82     gAlice->Fatal("Config.C","Can not instatiate the Run Loader");
83     return;
84   }
85   rl->SetCompressionLevel(2);
86   rl->SetNumberOfEventsPerFile(10000);
87   gAlice->SetRunLoader(rl);
88   
89   // Set the trigger configuration
90   AliSimulation::Instance()->SetTriggerConfig("Pb-Pb");
91   cout<<"Trigger configuration is set to  Pb-Pb"<<endl;
92   
93   //
94   // Set External decayer
95   TVirtualMCDecayer *decayer = new AliDecayerPythia();
96   
97   decayer->SetForceDecay(kAll);
98   decayer->Init();
99   gMC->SetExternalDecayer(decayer);
100   //=======================================================================
101   // ************* STEERING parameters FOR ALICE SIMULATION **************
102   // --- Specify event type to be tracked through the ALICE setup
103   // --- All positions are in cm, angles in degrees, and P and E in GeV
104   
105   
106   gMC->SetProcess("DCAY",1);
107   gMC->SetProcess("PAIR",1);
108   gMC->SetProcess("COMP",1);
109   gMC->SetProcess("PHOT",1);
110   gMC->SetProcess("PFIS",0);
111   gMC->SetProcess("DRAY",0);
112   gMC->SetProcess("ANNI",1);
113   gMC->SetProcess("BREM",1);
114   gMC->SetProcess("MUNU",1);
115   gMC->SetProcess("CKOV",1);
116   gMC->SetProcess("HADR",1);
117   gMC->SetProcess("LOSS",2);
118   gMC->SetProcess("MULS",1);
119   gMC->SetProcess("RAYL",1);
120   
121   Float_t cut    = 1.e-3;  // 1MeV cut by default
122   Float_t tofmax = 1.e10;
123   
124   gMC->SetCut("CUTGAM", cut);
125   gMC->SetCut("CUTELE", cut);
126   gMC->SetCut("CUTNEU", cut);
127   gMC->SetCut("CUTHAD", cut);
128   gMC->SetCut("CUTMUO", cut);
129   gMC->SetCut("BCUTE",  cut); 
130   gMC->SetCut("BCUTM",  cut); 
131   gMC->SetCut("DCUTE",  cut); 
132   gMC->SetCut("DCUTM",  cut); 
133   gMC->SetCut("PPCUTM", cut);
134   gMC->SetCut("TOFMAX", tofmax); 
135   
136   
137   int     nParticles = 1;
138   if (gSystem->Getenv("CONFIG_NPARTICLES"))
139   {
140     nParticles = atoi(gSystem->Getenv("CONFIG_NPARTICLES"));
141   }
142   
143   if (gSystem->Getenv("CONFIG_YEAR"))
144   {
145     year = atoi(gSystem->Getenv("CONFIG_YEAR"));
146   }
147   
148   AliGenBox *gener = new AliGenBox(nParticles);
149   gener->SetMomentumRange(1.,10.);
150   
151   if     (year == 2010)
152     gener->SetPhiRange(80.0,120.0);
153   else if(year == 2011)
154     gener->SetPhiRange(80.0,180.0);
155   else
156     gener->SetPhiRange(80.0,190.0);
157   
158   gener->SetThetaRange(EtaToTheta(0.7), EtaToTheta(-0.7));
159   
160 //  AliGenLib* lib   = new AliGenPHOSlib();
161 //  Int_t      type  = AliGenPHOSlib::kEtaFlat;
162 //  AliGenParam *gener = new AliGenParam(1,lib,type,"");
163 //      gener->SetMomentumRange(0,999);
164 //      gener->SetPtRange(1,30);
165 //      gener->SetPhiRange(80, 200.);
166 //      gener->SetYRange(-2,2);
167 //      gener->SetThetaRange(EtaToTheta(0.7),EtaToTheta(-0.7));
168 //      gener->SetCutOnChild(1);
169 //  gener->SetChildPtRange(0.1,30);
170 //      gener->SetChildThetaRange(EtaToTheta(0.7),EtaToTheta(-0.7));
171 //  gener->SetChildPhiRange(80, 180.);
172 //      gener->SetOrigin(0,0,0);        //vertex position
173 //      gener->SetSigma(0,0,5.3);       //Sigma in (X,Y,Z) (cm) on IP position
174 //      gener->SetForceDecay(kGammaEM);
175 //
176 //  //gener->SetTrackingFlag(0);
177   
178 //  AliGenCocktail *gener = new AliGenCocktail();
179 //  gener->SetProjectile("A", 208, 82);
180 //  gener->SetTarget    ("A", 208, 82);
181 //  
182 //  // 1 Pi0 in EMCAL, 2010 configuration, 4 SM
183 //  AliGenParam *gEMCPi0 = GenParamCalo(1, AliGenPHOSlib::kPi0Flat, "EMCAL");
184 //  gener->AddGenerator(gEMCPi0,"pi0EMC", 1);
185 //  
186 //  // 1 Eta in EMCAL, 2010 configuration, 4 SM
187 //  AliGenParam *gEMCEta = GenParamCalo(1, AliGenPHOSlib::kEtaFlat, "EMCAL");
188 //  gener->AddGenerator(gEMCEta,"etaEMC", 1);
189 //  
190  
191   gener->Init();
192   
193   // 
194   // Activate this line if you want the vertex smearing to happen
195   // track by track
196   //
197   //gener->SetVertexSmear(perTrack); 
198   // Field (L3 0.5 T)
199   TGeoGlobalMagField::Instance()->SetField(new AliMagF("Maps","Maps", -1., -1., AliMagF::k5kG));
200   
201   Int_t   iABSO  =  0;
202   Int_t   iDIPO  =  0;
203   Int_t   iFMD   =  0;
204   Int_t   iFRAME =  0;
205   Int_t   iHALL  =  0;
206   Int_t   iITS   =  0;
207   Int_t   iMAG   =  0;
208   Int_t   iMUON  =  0;
209   Int_t   iPHOS  =  0;
210   Int_t   iPIPE  =  0;
211   Int_t   iPMD   =  0;
212   Int_t   iHMPID =  0;
213   Int_t   iSHIL  =  0;
214   Int_t   iT0    =  0;
215   Int_t   iTOF   =  0;
216   Int_t   iTPC   =  0;
217   Int_t   iTRD   =  0;
218   Int_t   iZDC   =  0;
219   Int_t   iEMCAL =  1;
220   Int_t   iACORDE=  0;
221   Int_t   iVZERO =  0;
222   rl->CdGAFile();
223   //=================== Alice BODY parameters =============================
224   AliBODY *BODY = new AliBODY("BODY", "Alice envelop");
225   
226   if (iMAG)
227   {
228     //=================== MAG parameters ============================
229     // --- Start with Magnet since detector layouts may be depending ---
230     // --- on the selected Magnet dimensions ---
231     AliMAG *MAG = new AliMAG("MAG", "Magnet");
232   }
233   
234   
235   if (iABSO)
236   {
237     //=================== ABSO parameters ============================
238     AliABSO *ABSO = new AliABSOv3("ABSO", "Muon Absorber");
239   }
240   
241   if (iDIPO)
242   {
243     //=================== DIPO parameters ============================
244     
245     AliDIPO *DIPO = new AliDIPOv3("DIPO", "Dipole version 3");
246   }
247   
248   if (iHALL)
249   {
250     //=================== HALL parameters ============================
251     
252     AliHALL *HALL = new AliHALLv3("HALL", "Alice Hall");
253   }
254   
255   
256   if (iFRAME)
257   {
258     //=================== FRAME parameters ============================
259     
260     AliFRAMEv2 *FRAME = new AliFRAMEv2("FRAME", "Space Frame");
261   }
262   
263   if (iSHIL)
264   {
265     //=================== SHIL parameters ============================
266     
267     AliSHIL *SHIL = new AliSHILv3("SHIL", "Shielding Version 3");
268   }
269   
270   
271   if (iPIPE)
272   {
273     //=================== PIPE parameters ============================
274     
275     AliPIPE *PIPE = new AliPIPEv3("PIPE", "Beam Pipe");
276   }
277   
278   if(iITS) {
279     
280     //=================== ITS parameters ============================
281     
282     AliITS *ITS  = new AliITSv11("ITS","ITS v11");
283   }
284   
285   if (iTPC)
286   {
287     //============================ TPC parameters ===================
288     AliTPC *TPC = new AliTPCv2("TPC", "Default");
289   }
290   
291   
292   if (iTOF) {
293     //=================== TOF parameters ============================
294     AliTOF *TOF = new AliTOFv6T0("TOF", "normal TOF");
295   }
296   
297   
298   if (iHMPID)
299   {
300     //=================== HMPID parameters ===========================
301     AliHMPID *HMPID = new AliHMPIDv3("HMPID", "normal HMPID");
302     
303   }
304   
305   
306   if (iZDC)
307   {
308     //=================== ZDC parameters ============================
309     
310     AliZDC *ZDC = new AliZDCv3("ZDC", "normal ZDC");
311   }
312   
313   if (iTRD)
314   {
315     //=================== TRD parameters ============================
316     
317     AliTRD *TRD = new AliTRDv1("TRD", "TRD slow simulator");
318     AliTRDgeometry *geoTRD = TRD->GetGeometry();
319     // starting at 3h in positive direction
320     if(year==2011 || year == 2010)
321     { // not sure if good for 2010
322       // Partial geometry: modules at 0,1,7,8,9,10,11,15,16,17
323       printf("*** TRD configuration for 2011\n");
324       geoTRD->SetSMstatus(2,0);
325       geoTRD->SetSMstatus(3,0);
326       geoTRD->SetSMstatus(4,0);
327       geoTRD->SetSMstatus(5,0);
328       geoTRD->SetSMstatus(6,0);
329       geoTRD->SetSMstatus(12,0);
330       geoTRD->SetSMstatus(13,0);
331       geoTRD->SetSMstatus(14,0);
332     }
333     else if(year==2012)
334     {
335       printf("*** TRD configuration for 2012\n");
336       geoTRD->SetSMstatus(4,0);
337       geoTRD->SetSMstatus(5,0);
338       geoTRD->SetSMstatus(12,0);
339       geoTRD->SetSMstatus(13,0);
340       geoTRD->SetSMstatus(14,0); 
341     }
342   }
343   
344   if (iFMD)
345   {
346     //=================== FMD parameters ============================
347     AliFMD *FMD = new AliFMDv1("FMD", "normal FMD");
348   }
349   
350   if (iMUON)
351   {
352     //=================== MUON parameters ===========================
353     // New MUONv1 version (geometry defined via builders)
354     AliMUON *MUON = new AliMUONv1("MUON", "default");
355   }
356   //=================== PHOS parameters ===========================
357   
358   if (iPHOS)
359   {
360     AliPHOS *PHOS = new AliPHOSv1("PHOS", "noCPV_Modules123");
361   }
362   
363   
364   if (iPMD)
365   {
366     //=================== PMD parameters ============================
367     AliPMD *PMD = new AliPMDv1("PMD", "normal PMD");
368   }
369   
370   if (iT0)
371   {
372     //=================== T0 parameters ============================
373     AliT0 *T0 = new AliT0v1("T0", "T0 Detector");
374   }
375   
376   if (iEMCAL)
377   {
378     //=================== EMCAL parameters ============================
379     if      (year == 2010)  // d phi = 40 degrees
380       AliEMCAL *EMCAL = new AliEMCALv2("EMCAL", "EMCAL_FIRSTYEARV1",    checkGeoAndRun);
381     else if (year == 2011)  // d phi = 100 degrees
382       AliEMCAL *EMCAL = new AliEMCALv2("EMCAL", "EMCAL_COMPLETEV1",     checkGeoAndRun);
383     else if (year > 2011)   // d phi = 110 degrees
384       AliEMCAL *EMCAL = new AliEMCALv2("EMCAL", "EMCAL_COMPLETE12SMV1", checkGeoAndRun);
385     else // Old configuration with 110 degrees but not perfect geometry
386       AliEMCAL *EMCAL = new AliEMCALv2("EMCAL", "EMCAL_COMPLETE",       checkGeoAndRun);
387   }
388   
389   if (iACORDE)
390   {
391     //=================== ACORDE parameters ============================
392     AliACORDE *ACORDE = new AliACORDEv1("ACORDE", "normal ACORDE");
393   }
394   
395   if (iVZERO)
396   {
397     //=================== ACORDE parameters ============================
398     AliVZERO *VZERO = new AliVZEROv7("VZERO", "normal VZERO");
399   }
400   
401   AliLog::Message(AliLog::kInfo, "End of Config", "Config.C", "Config.C", "Config()"," Config.C", __LINE__);
402   
403 }
404
405 Float_t EtaToTheta(Float_t arg){
406   return (180./TMath::Pi())*2.*atan(exp(-arg));
407 }
408
409 void LoadPythia()
410 {
411   // Load Pythia related libraries                                                                
412   gSystem->Load("liblhapdf.so");      // Parton density functions                                 
413   gSystem->Load("libEGPythia6.so");   // TGenerator interface                                     
414   gSystem->Load("libpythia6.so");     // Pythia                                                   
415   gSystem->Load("libAliPythia6.so");  // ALICE specific
416   // implementations                           
417 }
418
419
420 AliGenerator * GenParamCalo(Int_t nPart, Int_t type, TString calo)
421 {
422   // nPart of type (Pi0, Eta, Pi0Flat, EtaFlat, ...) in EMCAL or PHOS
423   // CAREFUL EMCAL year 2010 configuration
424   AliGenParam *gener = new AliGenParam(nPart,new AliGenPHOSlib(),type,"");
425   
426   // meson cuts
427   gener->SetMomentumRange(0,999);
428   gener->SetYRange(-2,2);
429   gener->SetPtRange(1,30);
430   // photon cuts
431   gener->SetForceDecay(kGammaEM); // Ensure the decays are photons
432   gener->SetCutOnChild(1);
433   gener->SetChildPtRange(0.,30);
434   
435   if(calo=="EMCAL")
436   {
437     //meson acceptance
438     gener->SetPhiRange(80., 100.); // year 2010
439     //gener->SetPhiRange(80., 180.); // year 2011
440     gener->SetThetaRange(EtaToTheta(0.7),EtaToTheta(-0.7));
441     //decay acceptance
442     gener->SetChildThetaRange(EtaToTheta(0.7),EtaToTheta(-0.7));
443     gener->SetChildPhiRange(80., 100.); // year 2010
444     //gener->SetChildPhiRange(80., 180.); // year 2011
445   }
446   else if(calo=="PHOS")
447   {
448     //meson acceptance
449     gener->SetPhiRange(260., 320.);
450     gener->SetThetaRange(EtaToTheta(0.13),EtaToTheta(-0.13));
451     //decay acceptance
452     gener->SetChildThetaRange(EtaToTheta(0.13),EtaToTheta(-0.13));
453     gener->SetChildPhiRange(260., 320.);
454   }
455   
456   return gener;
457   
458 }
459