]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TFluka/macro/FlukaConfig.C
ed73a617cd641638b0fd8060ac812583ad527e0b
[u/mrichter/AliRoot.git] / TFluka / macro / FlukaConfig.C
1 static Int_t    eventsPerRun = 100;
2 enum PprGeo_t
3 {
4     kHoles, kNoHoles
5 };
6                                                                                 
7 enum PprRad_t
8 {
9     kGluonRadiation, kNoGluonRadiation
10 };
11                                                                                 
12 // This part for configuration
13 static PprGeo_t sgeo = kHoles;
14 static PprRad_t srad = kGluonRadiation;
15 static AliMagF::BMap_t smag = AliMagF::k5kG;
16                                                                                 
17 // Comment line
18 static TString  comment;
19                                                                                 
20 // Functions
21 Float_t EtaToTheta(Float_t arg);
22
23 void Config()
24 {
25   cout << "==> Config.C..." << endl;
26   
27   // Set Random Number seed
28   gRandom->SetSeed(12345);
29   cout<<"Seed for random number generation= "<<gRandom->GetSeed()<<endl;
30
31   gSystem->Load("liblhapdf.so");      // Parton density functions
32   gSystem->Load("libEGPythia6.so");   // TGenerator interface
33   gSystem->Load("libpythia6.so");     // Pythia
34   gSystem->Load("libAliPythia6.so");  // ALICE specific implementations
35   
36   
37
38   Bool_t isFluka = kTRUE;
39   if (isFluka) {
40     gSystem->Load("libGeom");
41     cout << "\t* Loading TFluka..." << endl;  
42     gSystem->Load("libfluka");    
43     
44     cout << "\t* Instantiating TFluka..." << endl;
45     new  TFluka("C++ Interface to Fluka", 0/*verbositylevel*/);
46   }
47   else {
48     cout << "\t* Loading Geant3..." << endl;  
49     gSystem->Load("libgeant321");
50     
51     cout << "\t* Instantiating Geant3TGeo..." << endl;
52     new     TGeant3TGeo("C++ Interface to Geant3");
53   }
54   
55   if(!AliCDBManager::Instance()->IsDefaultStorageSet()){
56       AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
57       AliCDBManager::Instance()->SetRun(0);
58   }
59
60   
61   AliRunLoader* rl=0x0;
62                                                                                 
63   cout<<"Config.C: Creating Run Loader ..."<<endl;
64   rl = AliRunLoader::Open("galice.root",
65                             AliConfig::GetDefaultEventFolderName(),
66                             "recreate");
67   if (rl == 0x0)
68     {
69       gAlice->Fatal("Config.C","Can not instatiate the Run Loader");
70       return;
71     }
72   rl->SetCompressionLevel(2);
73   rl->SetNumberOfEventsPerFile(3);
74   gAlice->SetRunLoader(rl);
75                                                                                 
76   //
77   // Set External decayer
78   AliDecayer *decayer = new AliDecayerPythia();
79                                                                                
80   decayer->SetForceDecay(kAll);
81   decayer->Init();
82   gMC->SetExternalDecayer(decayer);
83
84   //
85   //
86   //
87   // Physics process control
88
89   gMC->SetProcess("DCAY",1);
90   gMC->SetProcess("PAIR",1);
91   gMC->SetProcess("COMP",1);
92   gMC->SetProcess("PHOT",1);
93   gMC->SetProcess("PFIS",0);
94   gMC->SetProcess("DRAY",1);
95   gMC->SetProcess("ANNI",1);
96   gMC->SetProcess("BREM",1);
97   gMC->SetProcess("MUNU",1);
98   gMC->SetProcess("CKOV",1); 
99   gMC->SetProcess("HADR",1);
100   gMC->SetProcess("LOSS",2);
101   gMC->SetProcess("MULS",1);
102   gMC->SetProcess("RAYL",1);
103                                                                                 
104   Float_t cut = 1.e-3;        // 1MeV cut by default
105   Float_t tofmax = 1.e10;
106                                                                                 
107   gMC->SetCut("CUTGAM", cut);
108   gMC->SetCut("CUTELE", cut);
109   gMC->SetCut("CUTNEU", cut);
110   gMC->SetCut("CUTHAD", cut);
111   gMC->SetCut("CUTMUO", cut);
112   gMC->SetCut("BCUTE",  cut);
113   gMC->SetCut("BCUTM",  cut);
114   gMC->SetCut("DCUTE",  cut);
115   gMC->SetCut("DCUTM",  cut);
116   gMC->SetCut("PPCUTM", cut);
117   gMC->SetCut("TOFMAX", tofmax);
118
119   //
120   //=======================================================================
121   // ************* STEERING parameters FOR ALICE SIMULATION **************
122   // --- Specify event type to be tracked through the ALICE setup
123   // --- All positions are in cm, angles in degrees, and P and E in GeV
124   if (gSystem->Getenv("CONFIG_NPARTICLES"))
125       int     nParticles = atoi(gSystem->Getenv("CONFIG_NPARTICLES"));
126   else
127       int     nParticles = 1000;
128   
129   cout << "\t* Creating and configuring generator for " << nParticles 
130        << " particles..." << endl;
131   
132   AliGenHIJINGpara *gener = new AliGenHIJINGpara(nParticles);
133   
134   gener->SetMomentumRange(0., 999);
135   gener->SetPhiRange(0, 360);
136   // Set pseudorapidity range from -3 to 3.
137   Float_t thmin = EtaToTheta( 3.);   // theta min. <---> eta max
138   Float_t thmax = EtaToTheta(-3.);   // theta max. <---> eta min 
139   gener->SetThetaRange(thmin,thmax);
140   gener->SetOrigin(0, 0, 0);  //vertex position
141   gener->SetSigma(0, 0, 0);   //Sigma in (X,Y,Z) (cm) on IP position
142   gener->Init();
143   // 
144   // Activate this line if you want the vertex smearing to happen
145   // track by track
146   //
147
148
149     if (smag == AliMagF::k2kG) {
150         comment = comment.Append(" | L3 field 0.2 T");
151     } else if (smag == AliMagF::k5kG) {
152         comment = comment.Append(" | L3 field 0.5 T");
153     }
154                                                                                 
155                                                                                 
156     if (srad == kGluonRadiation)
157     {
158         comment = comment.Append(" | Gluon Radiation On");
159                                                                                 
160     } else {
161         comment = comment.Append(" | Gluon Radiation Off");
162     }
163                                                                                 
164     if (sgeo == kHoles)
165     {
166         comment = comment.Append(" | Holes for PHOS/HMPID");
167                                                                                 
168     } else {
169         comment = comment.Append(" | No holes for PHOS/HMPID");
170     }
171                                                                                 
172     printf("\n \n Comment: %s \n \n", comment.Data());
173                                                                                 
174                                                                                 
175 // Field (L3 0.4 T)
176     AliMagF *field = new AliMagF("Maps","Maps", 2, 1., 1., 10., smag);
177     field->SetL3ConstField(0); //Using const. field in the barrel
178     TGeoGlobalMagField::Instance()->SetField(field);
179     rl->CdGAFile();
180  
181   Int_t   iABSO    = 0; 
182   Int_t   iACORDE  = 0; 
183   Int_t   iDIPO    = 0; 
184   Int_t   iFMD     = 0; 
185   Int_t   iFRAME   = 0; 
186   Int_t   iHALL    = 0; 
187   Int_t   iITS     = 0; 
188   Int_t   iMAG     = 0; 
189   Int_t   iMUON    = 0; 
190   Int_t   iPHOS    = 0; 
191   Int_t   iPIPE    = 0; 
192   Int_t   iPMD     = 0; 
193   Int_t   iHMPID   = 0; 
194   Int_t   iSHIL    = 0; 
195   Int_t   iT0      = 0; 
196   Int_t   iTOF     = 0; 
197   Int_t   iTPC     = 0;
198   Int_t   iTRD     = 0; 
199   Int_t   iZDC     = 0; 
200   Int_t   iEMCAL   = 0; 
201   Int_t   iVZERO   = 0;
202  
203   cout << "\t* Creating the detectors ..." << endl;
204   //=================== Alice BODY parameters =============================
205     //=================== Alice BODY parameters =============================
206     AliBODY *BODY = new AliBODY("BODY", "Alice envelop");
207                                                                                 
208
209     if (iMAG)
210     {
211         //=================== MAG parameters ============================
212         // --- Start with Magnet since detector layouts may be depending ---
213         // --- on the selected Magnet dimensions ---
214         AliMAG *MAG = new AliMAG("MAG", "Magnet");
215     }
216
217
218     if (iABSO)
219     {
220         //=================== ABSO parameters ============================
221         AliABSO *ABSO = new AliABSOv3("ABSO", "Muon Absorber");
222     }
223
224     if (iDIPO)
225     {
226         //=================== DIPO parameters ============================
227
228         AliDIPO *DIPO = new AliDIPOv3("DIPO", "Dipole version 2");
229     }
230
231     if (iHALL)
232     {
233         //=================== HALL parameters ============================
234
235         AliHALL *HALL = new AliHALLv3("HALL", "Alice Hall");
236     }
237
238
239     if (iFRAME)
240     {
241         //=================== FRAME parameters ============================
242
243         AliFRAMEv2 *FRAME = new AliFRAMEv2("FRAME", "Space Frame");
244     }
245
246     if (iSHIL)
247     {
248         //=================== SHIL parameters ============================
249
250         AliSHIL *SHIL = new AliSHILv2("SHIL", "Shielding Version 2");
251     }
252
253
254     if (iPIPE)
255     {
256         //=================== PIPE parameters ============================
257
258         AliPIPE *PIPE = new AliPIPEv3("PIPE", "Beam Pipe");
259     }
260  
261     if (iITS)
262     {
263         //=================== ITS parameters ============================
264
265         AliITS *ITS  = new AliITSv11Hybrid("ITS","ITS v11Hybrid");
266     }
267
268
269     if (iTPC)
270     {
271       //============================ TPC parameters =====================
272         AliTPC *TPC = new AliTPCv2("TPC", "Default");
273     }
274
275
276     if (iTOF) {
277         //=================== TOF parameters ============================
278         AliTOF *TOF = new AliTOFv6T0("TOF", "normal TOF");
279     }
280
281
282     if (iHMPID)
283     {
284         //=================== HMPID parameters ===========================
285         AliHMPID *HMPID = new AliHMPIDv3("HMPID", "normal HMPID");
286
287     }
288
289
290     if (iZDC)
291     {
292         //=================== ZDC parameters ============================
293
294         AliZDC *ZDC = new AliZDCv2("ZDC", "normal ZDC");
295     }
296
297     if (iTRD)
298     {
299         //=================== TRD parameters ============================
300
301         AliTRD *TRD = new AliTRDv1("TRD", "TRD slow simulator");
302         AliTRDgeometry *geoTRD = TRD->GetGeometry();
303         // Partial geometry: modules at 2,3,4,6,11,12,14,15
304         // starting at 6h in positive direction
305         geoTRD->SetSMstatus(0,0);
306         geoTRD->SetSMstatus(1,0);
307         geoTRD->SetSMstatus(5,0);
308         geoTRD->SetSMstatus(7,0);
309         geoTRD->SetSMstatus(8,0);
310         geoTRD->SetSMstatus(9,0);
311         geoTRD->SetSMstatus(10,0);
312         geoTRD->SetSMstatus(13,0);
313         geoTRD->SetSMstatus(16,0);
314         geoTRD->SetSMstatus(17,0);
315     }
316
317     if (iFMD)
318     {
319         //=================== FMD parameters ============================
320         AliFMD *FMD = new AliFMDv1("FMD", "normal FMD");
321    }
322
323     if (iMUON)
324     {
325         //=================== MUON parameters ===========================
326         // New MUONv1 version (geometry defined via builders)
327         AliMUON *MUON = new AliMUONv1("MUON", "default");
328     }
329     //=================== PHOS parameters ===========================
330
331     if (iPHOS)
332     {
333         AliPHOS *PHOS = new AliPHOSv1("PHOS", "IHEP");
334         //Set simulation parameters different from the default ones.
335         AliPHOSSimParam* simEmc = AliPHOSSimParam::GetInstance() ;
336   
337         // APD noise of warm (+20C) PHOS:
338         // a2 = a1*(Y1/Y2)*(M1/M2), where a1 = 0.012 is APD noise at -25C,
339         // Y1 = 4.3 photo-electrons/MeV, Y2 = 1.7 p.e/MeV - light yields at -25C and +20C,
340         // M1 = 50, M2 = 50 - APD gain factors chosen for t1 = -25C and t2 = +20C,
341         // Y = MeanLightYield*APDEfficiency.
342
343         Float_t apdNoise = 0.012*2.5; 
344         simEmc->SetAPDNoise(apdNoise);
345
346         //Raw Light Yield at +20C
347         simEmc->SetMeanLightYield(18800);
348
349         //ADC channel width at +18C.
350         simEmc->SetADCchannelW(0.0125);
351     }
352
353
354     if (iPMD)
355     {
356         //=================== PMD parameters ============================
357         AliPMD *PMD = new AliPMDv1("PMD", "normal PMD");
358     }
359
360     if (iT0)
361     {
362         //=================== T0 parameters ============================
363         AliT0 *T0 = new AliT0v1("T0", "T0 Detector");
364     }
365
366     if (iEMCAL)
367     {
368         AliEMCAL *EMCAL = new AliEMCALv2("EMCAL", "SHISH_77_TRD1_2X2_FINAL_110DEG");
369     }
370
371      if (iACORDE)
372     {
373         //=================== ACORDE parameters ============================
374         AliACORDE *ACORDE = new AliACORDEv1("ACORDE", "normal ACORDE");
375     }
376
377      if (iVZERO)
378     {
379         //=================== ACORDE parameters ============================
380         AliVZERO *VZERO = new AliVZEROv7("VZERO", "normal VZERO");
381     }                                                                                
382 }
383                                                                                 
384 Float_t EtaToTheta(Float_t arg){
385   return (180./TMath::Pi())*2.*atan(exp(-arg));
386 }
387