]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ACORDE/macros/testMC/Config_AliGenACORDE.C
eeaffc2cfdf89d58c7d72cbeafaaac9c60b65a78
[u/mrichter/AliRoot.git] / ACORDE / macros / testMC / Config_AliGenACORDE.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
8         Config to simulate cosmic muons using the AliGenACORDE class
9
10
11         Comments to:
12
13                 Mario Rodriguez Cahuantzi <mrodrigu@mail.cern.ch>
14                 FCFM-BUAP, Puebla, Pue. Mexico
15
16         Nov. 18th. 2009 @ INFN sez. Torino, Italy
17
18
19 **********************************************************************************/
20 #if !defined(__CINT__) || defined(__MAKECINT__)
21 #include <Riostream.h>
22 #include <TRandom.h>
23 #include <TSystem.h>
24 #include <TVirtualMC.h>
25 #include <TGeant3TGeo.h>
26 #include "STEER/AliRunLoader.h"
27 #include "STEER/AliRun.h"
28 #include "STEER/AliConfig.h"
29 #include "PYTHIA6/AliDecayerPythia.h"
30 #include "EVGEN/AliGenCocktail.h"
31 #include "EVGEN/AliGenCosmicsParam.h"
32 #include "EVGEN/AliGenHIJINGpara.h"
33 #include "STEER/AliMagFMaps.h"
34 #include "STRUCT/AliBODY.h"
35 #include "STRUCT/AliMAG.h"
36 #include "STRUCT/AliABSOv0.h"
37 #include "STRUCT/AliDIPOv2.h"
38 #include "STRUCT/AliHALL.h"
39 #include "STRUCT/AliFRAMEv2.h"
40 #include "STRUCT/AliSHILv2.h"
41 #include "STRUCT/AliPIPEv0.h"
42 #include "ITS/AliITSv11Hybrid.h"
43 #include "TPC/AliTPCv2.h"
44 #include "TOF/AliTOFv5T0.h"
45 #include "HMPID/AliHMPIDv3.h"
46 #include "ZDC/AliZDCv3.h"
47 #include "TRD/AliTRDv1.h"
48 #include "FMD/AliFMDv1.h"
49 #include "MUON/AliMUONv1.h"
50 #include "PHOS/AliPHOSv1.h"
51 #include "PMD/AliPMDv1.h"
52 #include "START/AliSTARTv1.h"
53 #include "EMCAL/AliEMCALv2.h"
54 #include "ACORDE/AliACORDEv1.h"
55 #include "VZERO/AliVZEROv7.h"
56 #endif
57
58 //--- Magnetic Field ---
59 enum Mag_t
60 {
61     k2kG, k4kG, k5kG
62 };
63
64 Float_t EtaToTheta(Float_t arg);
65
66 static Mag_t         mag      = k5kG; 
67 void LoadPythia();
68 void Config()
69 {
70     // ThetaRange is (0., 180.). It was (0.28,179.72) 7/12/00 09:00
71     // Theta range given through pseudorapidity limits 22/6/2001
72
73     // Set Random Number seed
74   TDatime dt;
75   UInt_t curtime=dt.Get();
76   UInt_t procid=gSystem->GetPid();
77   UInt_t seed=curtime-procid;
78   if (gSystem->Getenv("envevno")) {
79     seed=atoi(gSystem->Getenv("envevno"));
80     seed += 1000; // 0 e' il seed dall'orologio....
81     printf("...taking seed as event number + 1000...\n");
82   }
83   printf("...setting seed as %d...\n",seed);
84   gRandom->SetSeed(seed);
85   printf("Seed for random number generation = %d \n",gRandom->GetSeed());
86
87
88   //  AliLog::Message(AliLog::kInfo, Form("Seed for random number generation = %d",gRandom->GetSeed()), "Config.C", "Config.C", "Config()","Config.C", __LINE__);
89
90 LoadPythia();
91    // libraries required by geant321
92 #if defined(__CINT__)
93     gSystem->Load("libgeant321");
94 #endif
95
96     new     TGeant3TGeo("C++ Interface to Geant3");
97
98     if(!AliCDBManager::Instance()->IsDefaultStorageSet()){
99       AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
100       AliCDBManager::Instance()->SetRun(0);
101     }
102
103     AliRunLoader* rl=0x0;
104
105     AliLog::Message(AliLog::kInfo, "Creating Run Loader", "Config.C", "Config.C", "Config()"," Config.C", __LINE__);
106
107     rl = AliRunLoader::Open("galice.root",
108                             AliConfig::GetDefaultEventFolderName(),
109                             "recreate");
110     if (rl == 0x0)
111       {
112         gAlice->Fatal("Config.C","Can not instatiate the Run Loader");
113         return;
114       }
115     rl->SetCompressionLevel(2);
116     rl->SetNumberOfEventsPerFile(100000);
117     gAlice->SetRunLoader(rl);
118
119    // to load an alternative geometry
120
121     // gAlice->SetGeometryFromFile("geometry.root");
122     // gAlice->SetGeometryFromCDB();
123
124     // Set the trigger configuration
125
126     AliSimulation::Instance()->SetTriggerConfig("ACORDE");
127     cout<<"Trigger configuration is set to  ACORDE"<<endl;
128
129     //
130     // Set External decayer
131
132     TVirtualMCDecayer *decayer = new AliDecayerPythia();
133
134     decayer->SetForceDecay(kAll);
135     decayer->Init();
136     gMC->SetExternalDecayer(decayer);
137
138
139     //=======================================================================
140     // ************* STEERING parameters FOR ALICE SIMULATION **************
141     // --- Specify event type to be tracked through the ALICE setup
142     // --- All positions are in cm, angles in degrees, and P and E in GeV
143
144
145     gMC->SetProcess("DCAY",1);
146     gMC->SetProcess("PAIR",1);
147     gMC->SetProcess("COMP",1);
148     gMC->SetProcess("PHOT",1);
149     gMC->SetProcess("PFIS",0);
150     gMC->SetProcess("DRAY",0);
151     gMC->SetProcess("ANNI",1);
152     gMC->SetProcess("BREM",1);
153     gMC->SetProcess("MUNU",1);
154     gMC->SetProcess("CKOV",1);
155     gMC->SetProcess("HADR",1);
156     gMC->SetProcess("LOSS",2);
157     gMC->SetProcess("MULS",1);
158     gMC->SetProcess("RAYL",1);
159
160     Float_t cut = 1.e-3;        // 1MeV cut by default
161     Float_t tofmax = 1.e10;
162
163     gMC->SetCut("CUTGAM", cut);
164     gMC->SetCut("CUTELE", cut);
165     gMC->SetCut("CUTNEU", cut);
166     gMC->SetCut("CUTHAD", cut);
167     gMC->SetCut("CUTMUO", cut);
168     gMC->SetCut("BCUTE",  cut); 
169     gMC->SetCut("BCUTM",  cut); 
170     gMC->SetCut("DCUTE",  cut); 
171     gMC->SetCut("DCUTM",  cut); 
172     gMC->SetCut("PPCUTM", cut);
173     gMC->SetCut("TOFMAX", tofmax); 
174
175
176
177     cout << "<<< *** Using the cosmic generator AliGenACORDE *** >>>" << endl;
178
179     AliGenACORDE *gener = new AliGenACORDE();
180     gener->SetZenithalAngleRange(0.,65.);
181     gener->SetAzimuthalAngleRange(0.,359.);
182     gener->SetMomentumResolution(1.);
183     gener->SetSigma(0,0,0);
184     gener->SetMomentumRange(10.,1000.);
185     gener->SetNumberOfParticles(100);
186     // two options
187     //  kMuonMinus
188     //  kMuinPlus
189     gener->SetPart(kMuonMinus);
190
191     // three options
192     //  kSingleMuons
193     //  kMuonBundle
194     //  kMuonFlux --> not yet
195
196     gener->SetMode(kSingleMuons);
197
198     // If you choose kMuonBundle, you should set how many particles do you
199     // want and in wich region should the muons be generated, for instance
200     // if you want to generate n^2 muons, in a square of side 300 cm
201     //gener->SetRange(4, 300., 4, 300.);
202
203     // gener->SetVertexSmear(kPerEvent); // Set the smearing per Event
204
205
206     // Starts the generation
207
208     gener->Init();
209
210
211
212     // MAGNETIC FIELD IN THE BARREL, by default set to 0.5 Teslas
213    
214     TGeoGlobalMagField::Instance()->SetField(new AliMagF("Maps","Maps", 1., 1.,  AliMagF::k5kG));
215
216
217     // Only with ACORDE and TPC detectors
218     // for cosmic analysis TOF (iFRAME) and ITS could be set to ON
219
220     Int_t   iABSO  =  0;
221     Int_t   iDIPO  =  0;
222     Int_t   iFMD   =  0;
223     Int_t   iFRAME =  0;
224     Int_t   iHALL  =  0;
225     Int_t   iITS   =  0;
226     Int_t   iMAG   =  1;
227     Int_t   iMUON  =  0;
228     Int_t   iPHOS  =  0;
229     Int_t   iPIPE  =  0;
230     Int_t   iPMD   =  0;
231     Int_t   iHMPID =  0;
232     Int_t   iSHIL  =  0;
233     Int_t   iSTART =  0;
234     Int_t   iTOF   =  0;
235     Int_t   iTPC   =  1;
236     Int_t   iTRD   =  0;
237     Int_t   iZDC   =  0;
238     Int_t   iEMCAL =  0;
239     Int_t   iACORDE   =  1;
240     Int_t   iVZERO =  0;
241     rl->CdGAFile();
242     //=================== Alice BODY parameters =============================
243     AliBODY *BODY = new AliBODY("BODY", "Alice envelop");
244
245     if (iMAG)
246     {
247         //=================== MAG parameters ============================
248         // --- Start with Magnet since detector layouts may be depending ---
249         // --- on the selected Magnet dimensions ---
250         AliMAG *MAG = new AliMAG("MAG", "Magnet");
251     }
252
253
254     if (iABSO)
255     {
256         //=================== ABSO parameters ============================
257         AliABSO *ABSO = new AliABSOv0("ABSO", "Muon Absorber");
258     }
259
260     if (iDIPO)
261     {
262         //=================== DIPO parameters ============================
263
264         AliDIPO *DIPO = new AliDIPOv2("DIPO", "Dipole version 2");
265     }
266
267     if (iHALL)
268     {
269         //=================== HALL parameters ============================
270
271         AliHALL *HALL = new AliHALL("HALL", "Alice Hall");
272     }
273
274
275     if (iFRAME)
276     {
277         //=================== FRAME parameters ============================
278
279         AliFRAMEv2 *FRAME = new AliFRAMEv2("FRAME", "Space Frame");
280         FRAME->SetHoles(1);
281     }
282
283     if (iSHIL)
284     {
285         //=================== SHIL parameters ============================
286
287         AliSHIL *SHIL = new AliSHILv2("SHIL", "Shielding Version 2");
288     }
289
290
291     if (iPIPE)
292     {
293         //=================== PIPE parameters ============================
294
295         AliPIPE *PIPE = new AliPIPEv0("PIPE", "Beam Pipe");
296     }
297  
298     if (iITS)
299     {
300         //=================== ITS parameters ============================
301
302         AliITS *ITS  = new AliITSv11Hybrid("ITS","ITS v11Hybrid");
303     }
304
305     if (iTPC)
306     {
307         //============================ TPC parameters ===================
308         AliTPC *TPC = new AliTPCv2("TPC", "Default");
309     }
310
311
312     if (iTOF) {
313         //=================== TOF parameters ============================
314         AliTOF *TOF = new AliTOFv5T0("TOF", "normal TOF");
315     }
316
317
318     if (iHMPID)
319     {
320         //=================== HMPID parameters ===========================
321         AliHMPID *HMPID = new AliHMPIDv3("HMPID", "normal HMPID");
322
323     }
324
325
326     if (iZDC)
327     {
328         //=================== ZDC parameters ============================
329
330         AliZDC *ZDC = new AliZDCv3("ZDC", "normal ZDC");
331     }
332
333     if (iTRD)
334     {
335         //=================== TRD parameters ============================
336
337         AliTRD *TRD = new AliTRDv1("TRD", "TRD slow simulator");
338     }
339
340     if (iFMD)
341     {
342         //=================== FMD parameters ============================
343         AliFMD *FMD = new AliFMDv1("FMD", "normal FMD");
344    }
345
346     if (iMUON)
347     {
348         //=================== MUON parameters ===========================
349         // New MUONv1 version (geometry defined via builders)
350         AliMUON *MUON = new AliMUONv1("MUON", "default");
351     }
352     //=================== PHOS parameters ===========================
353
354     if (iPHOS)
355     {
356         AliPHOS *PHOS = new AliPHOSv1("PHOS", "IHEP");
357     }
358
359
360     if (iPMD)
361     {
362         //=================== PMD parameters ============================
363         AliPMD *PMD = new AliPMDv1("PMD", "normal PMD");
364     }
365
366     if (iSTART)
367     {
368         //=================== START parameters ============================
369         AliSTART *START = new AliSTARTv1("START", "START Detector");
370     }
371
372     if (iEMCAL)
373     {
374         //=================== EMCAL parameters ============================
375         AliEMCAL *EMCAL = new AliEMCALv2("EMCAL", "SHISH_77_TRD1_2X2_FINAL_110DEG");
376     }
377
378      if (iACORDE)
379     {
380         //=================== ACORDE parameters ============================
381         AliACORDE *ACORDE = new AliACORDEv1("ACORDE", "normal ACORDE");
382     }
383
384      if (iVZERO)
385     {
386         //=================== ACORDE parameters ============================
387         AliVZERO *VZERO = new AliVZEROv7("VZERO", "normal VZERO");
388     }
389
390      AliLog::Message(AliLog::kInfo, "End of Config", "Config.C", "Config.C", "Config()"," Config.C", __LINE__);
391
392 }
393
394 Float_t EtaToTheta(Float_t arg){
395   return (180./TMath::Pi())*2.*atan(exp(-arg));
396 }
397 void LoadPythia()
398 {
399     // Load Pythia related libraries
400
401     gSystem->Load("liblhapdf.so");      // Parton density functions
402     gSystem->Load("libEGPythia6.so");   // TGenerator interface
403     gSystem->Load("libpythia6.so");     // Pythia
404     gSystem->Load("libAliPythia6.so");  // ALICE specific implementations
405 }
406