]> git.uio.no Git - u/mrichter/AliRoot.git/blob - test/genkine/sim/Config.C
072600ab3fcf75bf310629cc81842ec4e9afc030
[u/mrichter/AliRoot.git] / test / genkine / sim / 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/AliMagFMaps.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/AliITSvPPRasymmFMD.h"
44 #include "TPC/AliTPCv2.h"
45 #include "TOF/AliTOFv6T0.h"
46 #include "HMPID/AliHMPIDv2.h"
47 #include "ZDC/AliZDCv3.h"
48 #include "TRD/AliTRDv1.h"
49 #include "FMD/AliFMDv1.h"
50 #include "MUON/AliMUONv1.h"
51 #include "EMCAL/AliEMCALv2.h"
52 #include "PHOS/AliPHOSv1.h"
53 #include "PMD/AliPMDv1.h"
54 #include "T0/AliT0v1.h"
55 #include "EMCAL/AliEMCALv2.h"
56 #include "ACORDE/AliACORDEv0.h"
57 #include "VZERO/AliVZEROv7.h"
58 #include "EVGEN/AliGenExtFile.h"
59 #include "EVGEN/AliGenReaderTreeK.h"
60 #endif
61
62 enum PprRad_t
63 {
64     kGluonRadiation, kNoGluonRadiation
65 };
66
67 enum PprMag_t
68 {
69     k2kG, k4kG, k5kG
70 };
71
72 enum PprTrigConf_t
73 {
74     kDefaultPPTrig, kDefaultPbPbTrig
75 };
76
77 const char * pprTrigConfName[] = {
78     "p-p","Pb-Pb"
79 };
80
81 enum PprGeo_t
82   {
83     kHoles, kNoHoles
84   };
85
86 // This part for configuration    
87
88 static PprRad_t srad = kGluonRadiation;
89 static PprMag_t smag = k5kG;
90 static Int_t    sseed = 12345; //Set 0 to use the current time
91
92 static PprTrigConf_t strig = kDefaultPPTrig; // default PbPb trigger configuration
93 static PprGeo_t geo = kHoles;
94 // Comment line 
95 static TString  comment;
96
97 // Functions
98 Float_t EtaToTheta(Float_t arg);
99 AliGenerator* GeneratorFactory();
100
101 void Config()
102 {
103     // ThetaRange is (0., 180.). It was (0.28,179.72) 7/12/00 09:00
104     // Theta range given through pseudorapidity limits 22/6/2001
105
106     // Set Random Number seed
107     gRandom->SetSeed(sseed);
108     cout<<"Seed for random number generation= "<<gRandom->GetSeed()<<endl; 
109   
110
111
112    // libraries required by geant321
113 #if defined(__CINT__)
114     gSystem->Load("libgeant321");
115 #endif
116
117     new     TGeant3TGeo("C++ Interface to Geant3");
118
119     AliRunLoader* rl=0x0;
120
121     cout<<"Config.C: Creating Run Loader ..."<<endl;
122     rl = AliRunLoader::Open("galice.root",
123                             AliConfig::GetDefaultEventFolderName(),
124                             "recreate");
125     if (rl == 0x0)
126       {
127         gAlice->Fatal("Config.C","Can not instatiate the Run Loader");
128         return;
129       }
130     rl->SetCompressionLevel(2);
131     rl->SetNumberOfEventsPerFile(100);
132     gAlice->SetRunLoader(rl);
133
134   // Set the trigger configuration
135     gAlice->SetTriggerDescriptor(pprTrigConfName[strig]);
136     cout<<"Trigger configuration is set to  "<<pprTrigConfName[strig]<<endl;
137
138
139     //
140     // Set External decayer
141     AliDecayer *decayer = new AliDecayerPythia();
142     decayer->SetForceDecay(kAll);
143     decayer->Init();
144
145     //forbid some decays
146     AliPythia * py= AliPythia::Instance();
147     py->SetMDME(737,1,0); //forbid D*+->D+ + pi0
148     py->SetMDME(738,1,0);//forbid D*+->D+ + gamma
149
150     for(Int_t d=747; d<=762; d++){ 
151       py->SetMDME(d,1,0);
152     }
153
154     for(Int_t d=764; d<=807; d++){ 
155       py->SetMDME(d,1,0);
156     }
157
158
159    
160     gMC->SetExternalDecayer(decayer);
161     //
162     //
163     //=======================================================================
164     //
165     //=======================================================================
166     // ************* STEERING parameters FOR ALICE SIMULATION **************
167     // --- Specify event type to be tracked through the ALICE setup
168     // --- All positions are in cm, angles in degrees, and P and E in GeV
169
170     gMC->SetProcess("DCAY",1);
171     gMC->SetProcess("PAIR",1);
172     gMC->SetProcess("COMP",1);
173     gMC->SetProcess("PHOT",1);
174     gMC->SetProcess("PFIS",0);
175     gMC->SetProcess("DRAY",0);
176     gMC->SetProcess("ANNI",1);
177     gMC->SetProcess("BREM",1);
178     gMC->SetProcess("MUNU",1);
179     gMC->SetProcess("CKOV",1);
180     gMC->SetProcess("HADR",1);
181     gMC->SetProcess("LOSS",2);
182     gMC->SetProcess("MULS",1);
183     gMC->SetProcess("RAYL",1);
184
185     Float_t cut = 1.e-3;        // 1MeV cut by default
186     Float_t tofmax = 1.e10;
187
188     gMC->SetCut("CUTGAM", cut);
189     gMC->SetCut("CUTELE", cut);
190     gMC->SetCut("CUTNEU", cut);
191     gMC->SetCut("CUTHAD", cut);
192     gMC->SetCut("CUTMUO", cut);
193     gMC->SetCut("BCUTE",  cut); 
194     gMC->SetCut("BCUTM",  cut); 
195     gMC->SetCut("DCUTE",  cut); 
196     gMC->SetCut("DCUTM",  cut); 
197     gMC->SetCut("PPCUTM", cut);
198     gMC->SetCut("TOFMAX", tofmax); 
199
200     // Debug and log level
201     //    AliLog::SetGlobalDebugLevel(0);
202     //    AliLog::SetGlobalLogLevel(AliLog::kError);
203
204     // Generator Configuration
205     AliGenerator* gener = GeneratorFactory();
206     gener->SetOrigin(0, 0, 0);    // vertex position
207     gener->SetSigma(0, 0, 5.3);   // Sigma in (X,Y,Z) (cm) on IP position
208     gener->SetCutVertexZ(1.);     // Truncate at 1 sigma
209     gener->SetVertexSmear(kPerEvent); 
210     gener->SetTrackingFlag(1);
211     gener->Init();
212     
213     if (smag == k2kG) {
214         comment = comment.Append(" | L3 field 0.2 T");
215     } else if (smag == k4kG) {
216         comment = comment.Append(" | L3 field 0.4 T");
217     } else if (smag == k5kG) {
218         comment = comment.Append(" | L3 field 0.5 T");
219     }
220     
221     
222     if (srad == kGluonRadiation)
223     {
224         comment = comment.Append(" | Gluon Radiation On");
225         
226     } else {
227         comment = comment.Append(" | Gluon Radiation Off");
228     }
229
230
231     printf("\n \n Comment: %s \n \n", comment.Data());
232     
233     
234 // Field (L3 0.4 T)
235     AliMagFMaps* field = new AliMagFMaps("Maps","Maps", 2, 1., 10., smag);
236     field->SetL3ConstField(0); //Using const. field in the barrel
237     rl->CdGAFile();
238     gAlice->SetField(field);    
239 //
240     Int_t   iABSO   = 1;
241     Int_t   iDIPO   = 1;
242     Int_t   iFMD    = 1;
243     Int_t   iFRAME  = 1;
244     Int_t   iHALL   = 1;
245     Int_t   iITS    = 1;
246     Int_t   iMAG    = 1;
247     Int_t   iMUON   = 1;
248     Int_t   iPHOS   = 1;
249     Int_t   iPIPE   = 1;
250     Int_t   iPMD    = 1;
251     Int_t   iHMPID   = 1;
252     Int_t   iSHIL   = 1;
253     Int_t   iT0  = 1;
254     Int_t   iTOF    = 1;
255     Int_t   iTPC    = 1;
256     Int_t   iTRD    = 1;
257     Int_t   iZDC    = 1;
258     Int_t   iEMCAL  = 1;
259     Int_t   iVZERO  = 1;
260     Int_t   iACORDE    = 0;
261
262     //=================== Alice BODY parameters =============================
263     AliBODY *BODY = new AliBODY("BODY", "Alice envelop");
264
265
266     if (iMAG)
267     {
268         //=================== MAG parameters ============================
269         // --- Start with Magnet since detector layouts may be depending ---
270         // --- on the selected Magnet dimensions ---
271         AliMAG *MAG = new AliMAG("MAG", "Magnet");
272     }
273
274
275     if (iABSO)
276     {
277         //=================== ABSO parameters ============================
278         AliABSO *ABSO = new AliABSOv3("ABSO", "Muon Absorber");
279     }
280
281     if (iDIPO)
282     {
283         //=================== DIPO parameters ============================
284
285         AliDIPO *DIPO = new AliDIPOv3("DIPO", "Dipole version 3");
286     }
287
288     if (iHALL)
289     {
290         //=================== HALL parameters ============================
291
292         AliHALL *HALL = new AliHALLv3("HALL", "Alice Hall");
293     }
294
295
296     if (iFRAME)
297     {
298         //=================== FRAME parameters ============================
299
300         AliFRAMEv2 *FRAME = new AliFRAMEv2("FRAME", "Space Frame");
301         if (geo == kHoles) {
302           FRAME->SetHoles(1);
303         } else {
304           FRAME->SetHoles(0);
305         }
306     }
307
308     if (iSHIL)
309     {
310         //=================== SHIL parameters ============================
311
312         AliSHIL *SHIL = new AliSHILv3("SHIL", "Shielding Version 3");
313     }
314
315
316     if (iPIPE)
317     {
318         //=================== PIPE parameters ============================
319
320         AliPIPE *PIPE = new AliPIPEv3("PIPE", "Beam Pipe");
321     }
322  
323     if (iITS)
324     {
325         //=================== ITS parameters ============================
326
327         AliITSvPPRasymmFMD *ITS  = new AliITSvPPRasymmFMD("ITS","New ITS PPR detailed version with asymmetric services");
328     }
329
330     if (iTPC)
331     {
332       //============================ TPC parameters =====================
333         AliTPC *TPC = new AliTPCv2("TPC", "Default");
334     }
335
336
337     if (iTOF) {
338         //=================== TOF parameters ============================
339         AliTOF *TOF = new AliTOFv6T0("TOF", "normal TOF");
340     }
341
342
343     if (iHMPID)
344     {
345         //=================== HMPID parameters ===========================
346         AliHMPID *HMPID = new AliHMPIDv2("HMPID", "normal HMPID");
347
348     }
349
350
351     if (iZDC)
352     {
353         //=================== ZDC parameters ============================
354
355         AliZDC *ZDC = new AliZDCv3("ZDC", "normal ZDC");
356     }
357
358     if (iTRD)
359     {
360         //=================== TRD parameters ============================
361
362         AliTRD *TRD = new AliTRDv1("TRD", "TRD slow simulator");
363     }
364
365     if (iFMD)
366     {
367         //=================== FMD parameters ============================
368         AliFMD *FMD = new AliFMDv1("FMD", "normal FMD");
369    }
370
371     if (iMUON)
372     {
373         //=================== MUON parameters ===========================
374         // New MUONv1 version (geometry defined via builders)
375         AliMUON *MUON = new AliMUONv1("MUON", "default");
376     }
377     //=================== PHOS parameters ===========================
378
379     if (iPHOS)
380     {
381         AliPHOS *PHOS = new AliPHOSv1("PHOS", "IHEP");
382     }
383
384
385     if (iPMD)
386     {
387         //=================== PMD parameters ============================
388         AliPMD *PMD = new AliPMDv1("PMD", "normal PMD");
389     }
390
391     if (iT0)
392     {
393         //=================== T0 parameters ============================
394         AliT0 *T0 = new AliT0v1("T0", "T0 Detector");
395     }
396
397     if (iEMCAL)
398     {
399         //=================== EMCAL parameters ============================
400         AliEMCAL *EMCAL = new AliEMCALv2("EMCAL", "SHISH_77_TRD1_2X2_FINAL_110DEG");
401     }
402
403      if (iACORDE)
404     {
405         //=================== ACORDE parameters ============================
406         AliACORDE *ACORDE = new AliACORDEv0("ACORDE", "normal ACORDE");
407     }
408
409      if (iVZERO)
410     {
411         //=================== VZERO parameters ============================
412         AliVZERO *VZERO = new AliVZEROv7("VZERO", "normal VZERO");
413     }
414  
415              
416 }
417
418 Float_t EtaToTheta(Float_t arg){
419   return (180./TMath::Pi())*2.*atan(exp(-arg));
420 }
421
422
423
424 AliGenerator* GeneratorFactory() {
425
426   AliGenExtFile *gener = new AliGenExtFile(-1);
427   AliGenReaderTreeK * reader = new AliGenReaderTreeK();
428
429   reader->SetFileName("galice.root");
430   reader->AddDir("../gen");
431   gener->SetReader(reader);
432      
433   return gener;
434
435  
436 }
437