fixing SEGV in case of switched of TR
[u/mrichter/AliRoot.git] / test / gun / Config.C
CommitLineData
3928b038 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>
9bb2665f 9#include <TPDGCode.h>
3928b038 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 "EVGEN/AliGenFixed.h"
21#include "EVGEN/AliGenBox.h"
22#include "STEER/AliMagFMaps.h"
23#include "STRUCT/AliBODY.h"
24#include "STRUCT/AliMAG.h"
96fb3353 25#include "STRUCT/AliABSOv3.h"
26#include "STRUCT/AliDIPOv3.h"
27#include "STRUCT/AliHALLv3.h"
3928b038 28#include "STRUCT/AliFRAMEv2.h"
96fb3353 29#include "STRUCT/AliSHILv3.h"
30#include "STRUCT/AliPIPEv3.h"
3928b038 31#include "ITS/AliITSvPPRasymmFMD.h"
32#include "TPC/AliTPCv2.h"
0d7ef405 33#include "TOF/AliTOFv6T0.h"
55eb2b56 34#include "HMPID/AliHMPIDv2.h"
cb14d625 35#include "ZDC/AliZDCv3.h"
3928b038 36#include "TRD/AliTRDv1.h"
37#include "TRD/AliTRDgeometry.h"
38#include "FMD/AliFMDv1.h"
39#include "MUON/AliMUONv1.h"
40#include "PHOS/AliPHOSv1.h"
41#include "PMD/AliPMDv1.h"
42#include "T0/AliT0v1.h"
43#include "EMCAL/AliEMCALv2.h"
44#include "ACORDE/AliACORDEv0.h"
45#include "VZERO/AliVZEROv7.h"
46#endif
47
48enum PprTrigConf_t
49{
50 kDefaultPPTrig, kDefaultPbPbTrig
51};
52
53const char * pprTrigConfName[] = {
54 "p-p","Pb-Pb"
55};
56
3b90f080 57enum PprGeo_t
58 {
59 kHoles, kNoHoles
60 };
61
3928b038 62Float_t EtaToTheta(Float_t arg);
63
64static PprTrigConf_t strig = kDefaultPPTrig;// default PP trigger configuration
3b90f080 65static PprGeo_t geo = kHoles;
3928b038 66
67void Config()
68{
69 // ThetaRange is (0., 180.). It was (0.28,179.72) 7/12/00 09:00
70 // Theta range given through pseudorapidity limits 22/6/2001
71
72 // Set Random Number seed
73 gRandom->SetSeed(123456); // Set 0 to use the currecnt time
74
75
76 // libraries required by geant321
77#if defined(__CINT__)
78 gSystem->Load("libgeant321");
79#endif
80
81 new TGeant3TGeo("C++ Interface to Geant3");
82
83 AliRunLoader* rl=0x0;
84
85
86 rl = AliRunLoader::Open("galice.root",
87 AliConfig::GetDefaultEventFolderName(),
88 "recreate");
89 if (rl == 0x0)
90 {
91 gAlice->Fatal("Config.C","Can not instatiate the Run Loader");
92 return;
93 }
94 rl->SetCompressionLevel(2);
95 rl->SetNumberOfEventsPerFile(3);
96 gAlice->SetRunLoader(rl);
97
98 // Set the trigger configuration
99 gAlice->SetTriggerDescriptor(pprTrigConfName[strig]);
100 cout<<"Trigger configuration is set to "<<pprTrigConfName[strig]<<endl;
101
102 //
103 // Set External decayer
104 TVirtualMCDecayer *decayer = new AliDecayerPythia();
105
106 decayer->SetForceDecay(kAll);
107 decayer->Init();
108 gMC->SetExternalDecayer(decayer);
109 //=======================================================================
110 // ************* STEERING parameters FOR ALICE SIMULATION **************
111 // --- Specify event type to be tracked through the ALICE setup
112 // --- All positions are in cm, angles in degrees, and P and E in GeV
113
114
115 gMC->SetProcess("DCAY",1);
116 gMC->SetProcess("PAIR",1);
117 gMC->SetProcess("COMP",1);
118 gMC->SetProcess("PHOT",1);
119 gMC->SetProcess("PFIS",0);
120 gMC->SetProcess("DRAY",0);
121 gMC->SetProcess("ANNI",1);
122 gMC->SetProcess("BREM",1);
123 gMC->SetProcess("MUNU",1);
124 gMC->SetProcess("CKOV",1);
125 gMC->SetProcess("HADR",1);
126 gMC->SetProcess("LOSS",2);
127 gMC->SetProcess("MULS",1);
128 gMC->SetProcess("RAYL",1);
129
130 Float_t cut = 1.e-3; // 1MeV cut by default
131 Float_t tofmax = 1.e10;
132
133 gMC->SetCut("CUTGAM", cut);
134 gMC->SetCut("CUTELE", cut);
135 gMC->SetCut("CUTNEU", cut);
136 gMC->SetCut("CUTHAD", cut);
137 gMC->SetCut("CUTMUO", cut);
138 gMC->SetCut("BCUTE", cut);
139 gMC->SetCut("BCUTM", cut);
140 gMC->SetCut("DCUTE", cut);
141 gMC->SetCut("DCUTM", cut);
142 gMC->SetCut("PPCUTM", cut);
143 gMC->SetCut("TOFMAX", tofmax);
144
145 // Special generation for Valgrind tests
146 // Each detector is fired by few particles selected
147 // to cover specific cases
148
149
150 // The cocktail iitself
151
152 AliGenCocktail *gener = new AliGenCocktail();
153 gener->SetPhiRange(0, 360);
154 // Set pseudorapidity range from -8 to 8.
155 Float_t thmin = EtaToTheta(8); // theta min. <---> eta max
156 Float_t thmax = EtaToTheta(-8); // theta max. <---> eta min
157 gener->SetThetaRange(thmin,thmax);
158 gener->SetOrigin(0, 0, 0); //vertex position
159 gener->SetSigma(0, 0, 0); //Sigma in (X,Y,Z) (cm) on IP position
160
161
162 // Particle guns for the barrel part (taken from RichConfig)
163
164 AliGenFixed *pG1=new AliGenFixed(1);
9bb2665f 165 pG1->SetPart(kProton);
3928b038 166 pG1->SetMomentum(2.5);
167 pG1->SetTheta(109.5-3);
168 pG1->SetPhi(10);
169 gener->AddGenerator(pG1,"g1",1);
170
171 AliGenFixed *pG2=new AliGenFixed(1);
9bb2665f 172 pG2->SetPart(kPiPlus);
3928b038 173 pG2->SetMomentum(1.0);
174 pG2->SetTheta( 90.0-3);
175 pG2->SetPhi(10);
176 gener->AddGenerator(pG2,"g2",1);
177
178 AliGenFixed *pG3=new AliGenFixed(1);
9bb2665f 179 pG3->SetPart(kPiMinus);
3928b038 180 pG3->SetMomentum(1.5);
181 pG3->SetTheta(109.5-3);
182 pG3->SetPhi(30);
183 gener->AddGenerator(pG3,"g3",1);
184
185 AliGenFixed *pG4=new AliGenFixed(1);
9bb2665f 186 pG4->SetPart(kKPlus);
3928b038 187 pG4->SetMomentum(0.7);
188 pG4->SetTheta( 90.0-3);
189 pG4->SetPhi(30);
190 gener->AddGenerator(pG4,"g4",1);
191
192 AliGenFixed *pG5=new AliGenFixed(1);
9bb2665f 193 pG5->SetPart(kKMinus);
3928b038 194 pG5->SetMomentum(1.0);
195 pG5->SetTheta( 70.0-3);
196 pG5->SetPhi(30);
197 gener->AddGenerator(pG5,"g5",1);
198
199 AliGenFixed *pG6=new AliGenFixed(1);
9bb2665f 200 pG6->SetPart(kProtonBar);
3928b038 201 pG6->SetMomentum(2.5);
202 pG6->SetTheta( 90.0-3);
203 pG6->SetPhi(50);
204 gener->AddGenerator(pG6,"g6",1);
205
206 AliGenFixed *pG7=new AliGenFixed(1);
9bb2665f 207 pG7->SetPart(kPiMinus);
3928b038 208 pG7->SetMomentum(0.7);
209 pG7->SetTheta( 70.0-3);
210 pG7->SetPhi(50);
211 gener->AddGenerator(pG7,"g7",1);
212
213 // Electrons for TRD
214
215 AliGenFixed *pG8=new AliGenFixed(1);
9bb2665f 216 pG8->SetPart(kElectron);
3928b038 217 pG8->SetMomentum(1.2);
218 pG8->SetTheta( 95.0);
219 pG8->SetPhi(190);
220 gener->AddGenerator(pG8,"g8",1);
221
222 AliGenFixed *pG9=new AliGenFixed(1);
9bb2665f 223 pG9->SetPart(kPositron);
3928b038 224 pG9->SetMomentum(1.2);
225 pG9->SetTheta( 85.0);
226 pG9->SetPhi(190);
227 gener->AddGenerator(pG9,"g9",1);
228
229 // PHOS
230
231 AliGenBox *gphos = new AliGenBox(1);
232 gphos->SetMomentumRange(10,11.);
233 gphos->SetPhiRange(270.5,270.7);
234 gphos->SetThetaRange(90.5,90.7);
9bb2665f 235 gphos->SetPart(kGamma);
3928b038 236 gener->AddGenerator(gphos,"GENBOX GAMMA for PHOS",1);
237
238 // EMCAL
239
240 AliGenBox *gemcal = new AliGenBox(1);
241 gemcal->SetMomentumRange(10,11.);
242 gemcal->SetPhiRange(90.5,199.5);
243 gemcal->SetThetaRange(90.5,90.7);
9bb2665f 244 gemcal->SetPart(kGamma);
3928b038 245 gener->AddGenerator(gemcal,"GENBOX GAMMA for EMCAL",1);
246
247 // MUON
248 AliGenBox * gmuon1 = new AliGenBox(1);
249 gmuon1->SetMomentumRange(20.,20.1);
250 gmuon1->SetPhiRange(0., 360.);
251 gmuon1->SetThetaRange(171.000,178.001);
9bb2665f 252 gmuon1->SetPart(kMuonMinus); // Muons
3928b038 253 gener->AddGenerator(gmuon1,"GENBOX MUON1",1);
254
255 AliGenBox * gmuon2 = new AliGenBox(1);
256 gmuon2->SetMomentumRange(20.,20.1);
257 gmuon2->SetPhiRange(0., 360.);
258 gmuon2->SetThetaRange(171.000,178.001);
9bb2665f 259 gmuon2->SetPart(kMuonPlus); // Muons
3928b038 260 gener->AddGenerator(gmuon2,"GENBOX MUON1",1);
261
262 //TOF
263 AliGenFixed *gtof=new AliGenFixed(1);
9bb2665f 264 gtof->SetPart(kProton);
3928b038 265 gtof->SetMomentum(2.5);
266 gtof->SetTheta(95);
6b61de21 267 gtof->SetPhi(340);
3928b038 268 gener->AddGenerator(gtof,"Proton for TOF",1);
6b61de21 269
270 //FMD1
271 AliGenFixed *gfmd1=new AliGenFixed(1);
272 gfmd1->SetPart(kGamma);
273 gfmd1->SetMomentum(25);
274 gfmd1->SetTheta(1.8);
275 gfmd1->SetPhi(10);
276 gener->AddGenerator(gfmd1,"Gamma for FMD1",1);
277
278 //FMD2i
279 AliGenFixed *gfmd2i=new AliGenFixed(1);
280 gfmd2i->SetPart(kPiPlus);
281 gfmd2i->SetMomentum(1.5);
282 gfmd2i->SetTheta(7.3);
283 gfmd2i->SetPhi(20);
284 gener->AddGenerator(gfmd2i,"Pi+ for FMD2i",1);
285
286 //FMD2o
287 AliGenFixed *gfmd2o=new AliGenFixed(1);
288 gfmd2o->SetPart(kPiMinus);
289 gfmd2o->SetMomentum(1.5);
290 gfmd2o->SetTheta(16.1);
291 gfmd2o->SetPhi(30);
292 gener->AddGenerator(gfmd2o,"Pi- for FMD2o",1);
293
294 //FMD3o
295 AliGenFixed *gfmd3o=new AliGenFixed(1);
296 gfmd3o->SetPart(kPiPlus);
297 gfmd3o->SetMomentum(1.5);
298 gfmd3o->SetTheta(163.9);
299 gfmd3o->SetPhi(40);
300 gener->AddGenerator(gfmd3o,"Pi+ for FMD3o",1);
301
302 //FMD3i
303 AliGenFixed *gfmd3i=new AliGenFixed(1);
304 gfmd3i->SetPart(kPiMinus);
305 gfmd3i->SetMomentum(1.5);
306 gfmd3i->SetTheta(170.5);
307 gfmd3i->SetPhi(50);
308 gener->AddGenerator(gfmd3i,"Pi- for FMD3i",1);
3928b038 309
310 gener->Init();
311
312
313 //
314 // Activate this line if you want the vertex smearing to happen
315 // track by track
316 //
317 //gener->SetVertexSmear(perTrack);
318 // Field (L3 0.5 T)
319 AliMagFMaps* field = new AliMagFMaps("Maps","Maps", 2, 1., 10., 2);
320 field->SetL3ConstField(1); //Using const. field in the barrel if 0
321 gAlice->SetField(field);
322
323
324 Int_t iABSO = 1;
325 Int_t iDIPO = 1;
326 Int_t iFMD = 1;
327 Int_t iFRAME = 1;
328 Int_t iHALL = 1;
329 Int_t iITS = 1;
330 Int_t iMAG = 1;
331 Int_t iMUON = 1;
332 Int_t iPHOS = 1;
333 Int_t iPIPE = 1;
334 Int_t iPMD = 1;
335 Int_t iHMPID = 1;
336 Int_t iSHIL = 1;
337 Int_t iT0 = 1;
338 Int_t iTOF = 1;
339 Int_t iTPC = 1;
340 Int_t iTRD = 1;
341 Int_t iZDC = 1;
342 Int_t iEMCAL = 1;
343 Int_t iACORDE = 0;
344 Int_t iVZERO = 1;
345 rl->CdGAFile();
346 //=================== Alice BODY parameters =============================
347 AliBODY *BODY = new AliBODY("BODY", "Alice envelop");
348
349 if (iMAG)
350 {
351 //=================== MAG parameters ============================
352 // --- Start with Magnet since detector layouts may be depending ---
353 // --- on the selected Magnet dimensions ---
354 AliMAG *MAG = new AliMAG("MAG", "Magnet");
355 }
356
357
358 if (iABSO)
359 {
360 //=================== ABSO parameters ============================
96fb3353 361 AliABSO *ABSO = new AliABSOv3("ABSO", "Muon Absorber");
3928b038 362 }
363
364 if (iDIPO)
365 {
366 //=================== DIPO parameters ============================
367
96fb3353 368 AliDIPO *DIPO = new AliDIPOv3("DIPO", "Dipole version 3");
3928b038 369 }
370
371 if (iHALL)
372 {
373 //=================== HALL parameters ============================
374
96fb3353 375 AliHALL *HALL = new AliHALLv3("HALL", "Alice Hall");
3928b038 376 }
377
378
379 if (iFRAME)
380 {
381 //=================== FRAME parameters ============================
382
383 AliFRAMEv2 *FRAME = new AliFRAMEv2("FRAME", "Space Frame");
3b90f080 384 if (geo == kHoles) {
385 FRAME->SetHoles(1);
386 } else {
387 FRAME->SetHoles(0);
388 }
3928b038 389 }
390
391 if (iSHIL)
392 {
393 //=================== SHIL parameters ============================
394
96fb3353 395 AliSHIL *SHIL = new AliSHILv3("SHIL", "Shielding Version 3");
3928b038 396 }
397
398
399 if (iPIPE)
400 {
401 //=================== PIPE parameters ============================
402
96fb3353 403 AliPIPE *PIPE = new AliPIPEv3("PIPE", "Beam Pipe");
3928b038 404 }
405
e89fa83b 406 if (iITS)
407 {
408 //=================== ITS parameters ============================
3928b038 409
3928b038 410 AliITSvPPRasymmFMD *ITS = new AliITSvPPRasymmFMD("ITS","ITS PPR detailed version with asymmetric services");
3928b038 411 }
412
413 if (iTPC)
414 {
415 //============================ TPC parameters ===================
416 AliTPC *TPC = new AliTPCv2("TPC", "Default");
417 }
418
419
420 if (iTOF) {
421 //=================== TOF parameters ============================
0d7ef405 422 AliTOF *TOF = new AliTOFv6T0("TOF", "normal TOF");
3928b038 423 // Partial geometry: modules at 2,3,4,6,7,11,12,14,15,16
424 // starting at 6h in positive direction
425 Int_t TOFSectors[18]={-1,-1,0,0,0,-1,0,0,-1,-1,-1,0,0,-1,0,0,0,0};
426 TOF->SetTOFSectors(TOFSectors);
427 }
428
429
430 if (iHMPID)
431 {
432 //=================== HMPID parameters ===========================
55eb2b56 433 AliHMPID *HMPID = new AliHMPIDv2("HMPID", "normal HMPID");
3928b038 434
435 }
436
437
438 if (iZDC)
439 {
440 //=================== ZDC parameters ============================
441
cb14d625 442 AliZDC *ZDC = new AliZDCv3("ZDC", "normal ZDC");
3928b038 443 }
444
445 if (iTRD)
446 {
447 //=================== TRD parameters ============================
448
449 AliTRD *TRD = new AliTRDv1("TRD", "TRD slow simulator");
450 AliTRDgeometry *geoTRD = TRD->GetGeometry();
451 // Partial geometry: modules at 2,3,4,6,11,12,14,15
452 // starting at 6h in positive direction
453 geoTRD->SetSMstatus(0,0);
454 geoTRD->SetSMstatus(1,0);
455 geoTRD->SetSMstatus(5,0);
456 geoTRD->SetSMstatus(7,0);
457 geoTRD->SetSMstatus(8,0);
458 geoTRD->SetSMstatus(9,0);
459 geoTRD->SetSMstatus(10,0);
460 geoTRD->SetSMstatus(13,0);
461 geoTRD->SetSMstatus(16,0);
462 geoTRD->SetSMstatus(17,0);
463 }
464
465 if (iFMD)
466 {
467 //=================== FMD parameters ============================
468 AliFMD *FMD = new AliFMDv1("FMD", "normal FMD");
469 }
470
471 if (iMUON)
472 {
473 //=================== MUON parameters ===========================
474 // New MUONv1 version (geometry defined via builders)
475 AliMUON *MUON = new AliMUONv1("MUON","default");
476 }
477 //=================== PHOS parameters ===========================
478
479 if (iPHOS)
480 {
481 AliPHOS *PHOS = new AliPHOSv1("PHOS", "IHEP");
482 }
483
484
485 if (iPMD)
486 {
487 //=================== PMD parameters ============================
488 AliPMD *PMD = new AliPMDv1("PMD", "normal PMD");
489 }
490
491 if (iT0)
492 {
493 //=================== T0 parameters ============================
494 AliT0 *T0 = new AliT0v1("T0", "T0 Detector");
495 }
496
497 if (iEMCAL)
498 {
499 //=================== EMCAL parameters ============================
500 AliEMCAL *EMCAL = new AliEMCALv2("EMCAL", "SHISH_77_TRD1_2X2_FINAL_110DEG");
501 }
502
503 if (iACORDE)
504 {
505 //=================== ACORDE parameters ============================
506 AliACORDE *ACORDE = new AliACORDEv0("ACORDE", "normal ACORDE");
507 }
508
509 if (iVZERO)
510 {
511 //=================== VZERO parameters ============================
512 AliVZERO *VZERO = new AliVZEROv7("VZERO", "normal VZERO");
513 }
514
515
516}
517
518Float_t EtaToTheta(Float_t arg){
519 return (180./TMath::Pi())*2.*atan(exp(-arg));
520}