]> git.uio.no Git - u/mrichter/AliRoot.git/blob - test/generators/epos/Config.C
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / test / generators / epos / 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,"ConfigPPR.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 <TGeant3TGeo.h>
13 #include <TPDGCode.h>
14 #include <TF1.h>
15 #include "STEER/AliRunLoader.h"
16 #include "STEER/AliRun.h"
17 #include "STEER/AliConfig.h"
18 #include "STEER/AliGenerator.h"
19 #include "STEER/AliLog.h"
20 #include "PYTHIA6/AliDecayerPythia.h"
21 #include "EVGEN/AliGenHIJINGpara.h"
22 #include "THijing/AliGenHijing.h"
23 #include "EVGEN/AliGenCocktail.h"
24 #include "EVGEN/AliGenSlowNucleons.h"
25 #include "EVGEN/AliSlowNucleonModelExp.h"
26 #include "EVGEN/AliGenParam.h"
27 #include "EVGEN/AliGenMUONlib.h"
28 #include "EVGEN/AliGenSTRANGElib.h"
29 #include "EVGEN/AliGenMUONCocktail.h"
30 #include "EVGEN/AliGenCocktail.h"
31 #include "EVGEN/AliGenGeVSim.h"
32 #include "EVGEN/AliGeVSimParticle.h"
33 #include "PYTHIA6/AliGenPythia.h"
34 #include "STEER/AliMagF.h"
35 #include "STRUCT/AliBODY.h"
36 #include "STRUCT/AliMAG.h"
37 #include "STRUCT/AliABSOv3.h"
38 #include "STRUCT/AliDIPOv3.h"
39 #include "STRUCT/AliHALLv3.h"
40 #include "STRUCT/AliFRAMEv2.h"
41 #include "STRUCT/AliSHILv3.h"
42 #include "STRUCT/AliPIPEv3.h"
43 #include "ITS/AliITSv11.h"
44 #include "TPC/AliTPCv2.h"
45 #include "TOF/AliTOFv6T0.h"
46 #include "HMPID/AliHMPIDv3.h"
47 #include "ZDC/AliZDCv4.h"
48 #include "TRD/AliTRDv1.h"
49 #include "FMD/AliFMDv1.h"
50 #include "MUON/AliMUONv1.h"
51 #include "PHOS/AliPHOSv1.h"
52 #include "PMD/AliPMDv1.h"
53 #include "T0/AliT0v1.h"
54 #include "EMCAL/AliEMCALv2.h"
55 #include "ACORDE/AliACORDEv1.h"
56 #include "VZERO/AliVZEROv7.h"
57 #include "EPOS/AliGenEpos.h"
58 #endif
59
60 enum PprTrigConf_t
61 {
62     kDefaultPPTrig, kDefaultPbPbTrig
63 };
64
65 const char * pprTrigConfName[] = {
66     "p-p","Pb-Pb"
67 };
68
69 // This part for configuration    
70
71 static AliMagF::BMap_t smag = AliMagF::k5kG;
72 static Int_t    sseed = 0; //Set 0 to use the current time
73 static PprTrigConf_t strig = kDefaultPPTrig; // default pp trigger configuration
74 static Float_t energy = 900;
75
76 // Comment line 
77 static TString  comment;
78
79 // Functions
80 Float_t EtaToTheta(Float_t arg);
81 void ProcessEnvironmentVars();
82
83 void Config()
84 {
85     // ThetaRange is (0., 180.). It was (0.28,179.72) 7/12/00 09:00
86     // Theta range given through pseudorapidity limits 22/6/2001
87
88     // Get settings from environment variables
89     ProcessEnvironmentVars();
90
91     // Set Random Number seed
92     gRandom->SetSeed(sseed);
93     cout<<"Seed for random number generation= "<<gRandom->GetSeed()<<endl; 
94
95
96    // libraries required by geant321
97 #if defined(__CINT__)
98     gSystem->Load("liblhapdf");
99     gSystem->Load("libEGPythia6");
100     gSystem->Load("libpythia6");
101     gSystem->Load("libAliPythia6");
102     gSystem->Load("libgeant321");
103     gSystem->Load("libEPOS");
104 #endif
105
106     new     TGeant3TGeo("C++ Interface to Geant3");
107
108   // Output every 100 tracks
109   ((TGeant3*)gMC)->SetSWIT(4,100);
110
111     AliRunLoader* rl=0x0;
112
113     AliLog::Message(AliLog::kInfo, "Creating Run Loader", "", "", "Config()","ConfigPPR.C", __LINE__);
114
115     rl = AliRunLoader::Open("galice.root",
116                             AliConfig::GetDefaultEventFolderName(),
117                             "recreate");
118     if (rl == 0x0)
119       {
120         gAlice->Fatal("Config.C","Can not instatiate the Run Loader");
121         return;
122       }
123     rl->SetCompressionLevel(2);
124     rl->SetNumberOfEventsPerFile(100);
125     gAlice->SetRunLoader(rl);
126
127     // Set the trigger configuration
128     AliSimulation::Instance()->SetTriggerConfig(pprTrigConfName[strig]);
129     cout<<"Trigger configuration is set to  "<<pprTrigConfName[strig]<<endl;
130
131     //
132     // Set External decayer
133     AliDecayer *decayer = new AliDecayerPythia();
134     decayer->Init();
135     gMC->SetExternalDecayer(decayer);
136     //
137     //
138     //=======================================================================
139     //
140     //=======================================================================
141     // ************* STEERING parameters FOR ALICE SIMULATION **************
142     // --- Specify event type to be tracked through the ALICE setup
143     // --- All positions are in cm, angles in degrees, and P and E in GeV
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     // Generator Configuration
176
177     AliGenerator* gener = 0x0;
178
179     AliGenEpos *epos = new AliGenEpos();
180     epos->SetProjectile("p", 1, 1);
181     epos->SetTarget("p", 1, 1);
182     epos->SetEnergyCMS(energy);
183     gener = epos;
184
185     gener->SetOrigin(0, 0, 0);    // vertex position
186     gener->SetSigma(0, 0, 5.3);   // Sigma in (X,Y,Z) (cm) on IP position
187     gener->SetCutVertexZ(1.);     // Truncate at 1 sigma
188     gener->SetVertexSmear(kPerEvent); 
189     gener->SetTrackingFlag(1);
190     gener->Init();
191     
192     AliMagF* field = 0x0;
193     if (smag == AliMagF::k2kG) {
194         comment = comment.Append(" | L3 field 0.2 T");
195         field = new AliMagF("Maps","Maps", -1., -1., AliMagF::k5kG,AliMagF::kBeamTypepp, energy/2.0);
196     } else if (smag == AliMagF::k5kG) {
197         comment = comment.Append(" | L3 field 0.5 T");
198         field = new AliMagF("Maps","Maps", -1., -1., AliMagF::k5kG,AliMagF::kBeamTypepp, energy/2.0);
199     }
200     
201     printf("\n \n Comment: %s \n \n", comment.Data());
202     
203     
204 // Field
205     TGeoGlobalMagField::Instance()->SetField(field);
206
207     rl->CdGAFile();
208 //
209     Int_t   iABSO   = 1;
210     Int_t   iDIPO   = 1;
211     Int_t   iFMD    = 1;
212     Int_t   iFRAME  = 1;
213     Int_t   iHALL   = 1;
214     Int_t   iITS    = 1;
215     Int_t   iMAG    = 1;
216     Int_t   iMUON   = 1;
217     Int_t   iPHOS   = 1;
218     Int_t   iPIPE   = 1;
219     Int_t   iPMD    = 1;
220     Int_t   iHMPID  = 1;
221     Int_t   iSHIL   = 1;
222     Int_t   iT0     = 1;
223     Int_t   iTOF    = 1;
224     Int_t   iTPC    = 1;
225     Int_t   iTRD    = 1;
226     Int_t   iZDC    = 1;
227     Int_t   iEMCAL  = 1;
228     Int_t   iVZERO  = 1;
229     Int_t   iACORDE = 1;
230
231     //=================== Alice BODY parameters =============================
232     AliBODY *BODY = new AliBODY("BODY", "Alice envelop");
233
234     if (iMAG)
235     {
236         //=================== MAG parameters ============================
237         // --- Start with Magnet since detector layouts may be depending ---
238         // --- on the selected Magnet dimensions ---
239         AliMAG *MAG = new AliMAG("MAG", "Magnet");
240     }
241
242
243     if (iABSO)
244     {
245         //=================== ABSO parameters ============================
246         AliABSO *ABSO = new AliABSOv3("ABSO", "Muon Absorber");
247     }
248
249     if (iDIPO)
250     {
251         //=================== DIPO parameters ============================
252
253         AliDIPO *DIPO = new AliDIPOv3("DIPO", "Dipole version 3");
254     }
255
256     if (iHALL)
257     {
258         //=================== HALL parameters ============================
259
260         AliHALL *HALL = new AliHALLv3("HALL", "Alice Hall");
261     }
262
263
264     if (iFRAME)
265     {
266         //=================== FRAME parameters ============================
267
268         AliFRAMEv2 *FRAME = new AliFRAMEv2("FRAME", "Space Frame");
269         FRAME->SetHoles(1);
270     }
271
272     if (iSHIL)
273     {
274         //=================== SHIL parameters ============================
275
276         AliSHIL *SHIL = new AliSHILv3("SHIL", "Shielding Version 3");
277     }
278
279
280     if (iPIPE)
281     {
282         //=================== PIPE parameters ============================
283
284         AliPIPE *PIPE = new AliPIPEv3("PIPE", "Beam Pipe");
285     }
286  
287     if (iITS)
288     {
289         //=================== ITS parameters ============================
290
291         AliITS *ITS  = new AliITSv11("ITS","ITS v11");
292     }
293
294     if (iTPC)
295     {
296         //============================ TPC parameters ===================
297         AliTPC *TPC = new AliTPCv2("TPC", "Default");
298     }
299
300
301     if (iTOF) {
302         //=================== TOF parameters ============================
303         AliTOF *TOF = new AliTOFv6T0("TOF", "normal TOF");
304      }
305
306
307     if (iHMPID)
308     {
309         //=================== HMPID parameters ===========================
310         AliHMPID *HMPID = new AliHMPIDv3("HMPID", "normal HMPID");
311
312     }
313
314
315     if (iZDC)
316     {
317         //=================== ZDC parameters ============================
318
319         AliZDC *ZDC = new AliZDCv4("ZDC", "normal ZDC");
320     }
321
322     if (iTRD)
323     {
324         //=================== TRD parameters ============================
325
326         AliTRD *TRD = new AliTRDv1("TRD", "TRD slow simulator");
327         AliTRDgeometry *geoTRD = TRD->GetGeometry();
328         // Partial geometry: modules at 0,1,7,8,9,10,17
329         // starting at 3h in positive direction
330         geoTRD->SetSMstatus(2,0);
331         geoTRD->SetSMstatus(3,0);
332         geoTRD->SetSMstatus(4,0);
333         geoTRD->SetSMstatus(5,0);
334         geoTRD->SetSMstatus(6,0);
335         geoTRD->SetSMstatus(11,0);
336         geoTRD->SetSMstatus(12,0);
337         geoTRD->SetSMstatus(13,0);
338         geoTRD->SetSMstatus(14,0);
339         geoTRD->SetSMstatus(15,0);
340         geoTRD->SetSMstatus(16,0);
341     }
342
343     if (iFMD)
344     {
345         //=================== FMD parameters ============================
346         AliFMD *FMD = new AliFMDv1("FMD", "normal FMD");
347    }
348
349     if (iMUON)
350     {
351         //=================== MUON parameters ===========================
352         // New MUONv1 version (geometry defined via builders)
353         AliMUON *MUON = new AliMUONv1("MUON","default");
354     }
355     //=================== PHOS parameters ===========================
356
357     if (iPHOS)
358     {
359         AliPHOS *PHOS = new AliPHOSv1("PHOS", "IHEP");
360     }
361
362
363     if (iPMD)
364     {
365         //=================== PMD parameters ============================
366         AliPMD *PMD = new AliPMDv1("PMD", "normal PMD");
367     }
368
369     if (iT0)
370     {
371         //=================== T0 parameters ============================
372         AliT0 *T0 = new AliT0v1("T0", "T0 Detector");
373     }
374
375     if (iEMCAL)
376     {
377         //=================== EMCAL parameters ============================
378         AliEMCAL *EMCAL = new AliEMCALv2("EMCAL", "EMCAL_COMPLETEV1");
379     }
380
381      if (iACORDE)
382     {
383         //=================== ACORDE parameters ============================
384         AliACORDE *ACORDE = new AliACORDEv1("ACORDE", "normal ACORDE");
385     }
386
387      if (iVZERO)
388     {
389         //=================== VZERO parameters ============================
390         AliVZERO *VZERO = new AliVZEROv7("VZERO", "normal VZERO");
391     }
392  
393              
394 }
395
396 Float_t EtaToTheta(Float_t arg){
397   return (180./TMath::Pi())*2.*atan(exp(-arg));
398 }
399
400
401
402
403 void ProcessEnvironmentVars()
404 {
405     // Run type
406     if (gSystem->Getenv("CONFIG_RUN_TYPE")) {
407       for (Int_t iRun = 0; iRun < kRunMax; iRun++) {
408         if (strcmp(gSystem->Getenv("CONFIG_RUN_TYPE"), pprRunName[iRun])==0) {
409           srun = (PprRun_t)iRun;
410           cout<<"Run type set to "<<pprRunName[iRun]<<endl;
411         }
412       }
413     }
414
415     // Random Number seed
416     if (gSystem->Getenv("CONFIG_SEED")) {
417       sseed = atoi(gSystem->Getenv("CONFIG_SEED"));
418     }
419 }