Coding conventions
[u/mrichter/AliRoot.git] / macros / Config_gener.C
CommitLineData
de78d77f 1#if !defined(__CINT__) || defined(__MAKECINT__)
2#include <Riostream.h>
3#include <TRandom.h>
4#include <TSystem.h>
5#include <TVirtualMC.h>
6#include <TGeant3.h>
7#include "STEER/AliRunLoader.h"
8#include "STEER/AliRun.h"
9#include "STEER/AliConfig.h"
10#include "PYTHIA6/AliDecayerPythia.h"
11#include "EVGEN/AliGenCocktail.h"
12#include "EVGEN/AliGenFixed.h"
13#include "EVGEN/AliGenBox.h"
14#include "EVGEN/AliGenScan.h"
15#include "EVGEN/AliGenHIJINGpara.h"
16#include "THijing/AliGenHijing.h"
17#include "PYTHIA6/AliGenPythia.h"
18#include "EVGEN/AliGenParam.h"
19#include "EVGEN/AliGenMUONlib.h"
20#include "EVGEN/AliGenPHOSlib.h"
21#include "EVGEN/AliGenGSIlib.h"
22#include "EVGEN/AliGenFLUKAsource.h"
23#include "EVGEN/AliGenExtFile.h"
24#include "EVGEN/AliGenHalo.h"
25#include "EVGEN/AliGenReaderTreeK.h"
26#include "STRUCT/AliBODY.h"
27#include "STRUCT/AliMAG.h"
28#endif
29
f4417773 30enum gentype_t {hijing, hijingParam, gun, box, pythia,
11a136ef 31 param1, param2, param3, param4,
395b2e02 32 cocktail, fluka, halo, ntuple, scan, doublescan};
916c29ab 33
b86fedbb 34gentype_t gentype = hijing;
916c29ab 35
de78d77f 36Int_t ntracks=1;
916c29ab 37
38void Config()
39{
40
de78d77f 41 // Set Random Number seed
42 gRandom->SetSeed(12345); //Set 0 to use the current time
43 cout<<"Seed for random number generation= "<<gRandom->GetSeed()<<endl;
44
45
46 // libraries required by geant321
47#if defined(__CINT__)
48 gSystem->Load("libgeant321");
49#endif
50
51 new TGeant3("C++ Interface to Geant3");
916c29ab 52
53//=======================================================================
54// Create the output file
55
de78d77f 56 AliRunLoader* rl=0x0;
57
58 cout<<"Config.C: Creating Run Loader ..."<<endl;
59 rl = AliRunLoader::Open("galice.root",
60 AliConfig::fgkDefaultEventFolderName,
61 "recreate");
62 if (rl == 0x0)
63 {
64 gAlice->Fatal("Config.C","Can not instatiate the Run Loader");
65 return;
66 }
67 rl->SetCompressionLevel(2);
68 rl->SetNumberOfEventsPerFile(3);
69 gAlice->SetRunLoader(rl);
70
11a136ef 71//
72// Set External decayer
de78d77f 73 AliDecayer* decayer = new AliDecayerPythia();
74 decayer->SetForceDecay(kAll);
75 decayer->Init();
76 gMC->SetExternalDecayer(decayer);
11a136ef 77
6a3df6c9 78
916c29ab 79//
80//=======================================================================
81// ************* STEERING parameters FOR ALICE SIMULATION **************
82// --- Specify event type to be tracked through the ALICE setup
83// --- All positions are in cm, angles in degrees, and P and E in GeV
84
6a3df6c9 85
de78d77f 86 gMC->SetProcess("DCAY",1);
87 gMC->SetProcess("PAIR",1);
88 gMC->SetProcess("COMP",1);
89 gMC->SetProcess("PHOT",1);
90 gMC->SetProcess("PFIS",0);
91 gMC->SetProcess("DRAY",0);
92 gMC->SetProcess("ANNI",1);
93 gMC->SetProcess("BREM",1);
94 gMC->SetProcess("MUNU",1);
95 gMC->SetProcess("CKOV",1);
96 gMC->SetProcess("HADR",1);
97 gMC->SetProcess("LOSS",2);
98 gMC->SetProcess("MULS",1);
99 gMC->SetProcess("RAYL",1);
100
101 Float_t cut = 1.e-3; // 1MeV cut by default
102 Float_t tofmax = 1.e10;
103
104 gMC->SetCut("CUTGAM", cut);
105 gMC->SetCut("CUTELE", cut);
106 gMC->SetCut("CUTNEU", cut);
107 gMC->SetCut("CUTHAD", cut);
108 gMC->SetCut("CUTMUO", cut);
109 gMC->SetCut("BCUTE", cut);
110 gMC->SetCut("BCUTM", cut);
111 gMC->SetCut("DCUTE", cut);
112 gMC->SetCut("DCUTM", cut);
113 gMC->SetCut("PPCUTM", cut);
114 gMC->SetCut("TOFMAX", tofmax);
115
6a3df6c9 116
de78d77f 117 AliGenerator * gGener = 0x0;
118 switch(gentype)
119 {
120 case gun:
916c29ab 121//*********************************************
122// Example for Fixed Particle Gun
123//*********************************************
de78d77f 124 {
125 AliGenFixed *gener = new AliGenFixed(ntracks);
126 gener->SetMomentum(50);
127 gener->SetPhi(180.);
128 gener->SetTheta(5.);
129 gener->SetOrigin(0,0,0); //vertex position
130 gener->SetPart(13); //GEANT particle type
131 gGener = gener;
132 }
133 break;
134 case box:
916c29ab 135//*********************************************
136// Example for Moving Particle Gun *
137//*********************************************
de78d77f 138 {
139 AliGenBox *gener = new AliGenBox(ntracks);
140 gener->SetMomentumRange(3,4);
141 gener->SetPhiRange(0,360);
142 gener->SetThetaRange(90, 180. );
143 gener->SetOrigin(0,0,0);
144 //vertex position
145 gener->SetSigma(0,0,0); //Sigma in (X,Y,Z) (cm) on IP position
146 gener->SetPart(5); //GEANT particle type
147 gGener = gener;
148 }
149 break;
150 case scan:
916c29ab 151//*********************************************
152// Scanning on a grid *
153//*********************************************
de78d77f 154 {
155 AliGenScan *gener = new AliGenScan(-1);
156 gener->SetMomentumRange(4,4);
157 gener->SetPhiRange(0,360);
158 gener->SetThetaRange(9,9);
159 //vertex position
160 gener->SetSigma(6,6,0); //Sigma in (X,Y,Z) (cm) on IP position
161 gener->SetPart(5);
162 gener->SetRange(20, -100, 100, 20, -100, 100, 1, 500, 500);
163 gGener = gener;
164 }
165 break;
916c29ab 166
de78d77f 167 case hijingParam:
168 {
169 AliGenHIJINGpara *gener = new AliGenHIJINGpara(ntracks);
170 gener->SetMomentumRange(0,999);
171 gener->SetPhiRange(0,360);
172 gener->SetThetaRange(2,10);
173 gener->SetOrigin(0,0,0); //vertex position
174 gener->SetSigma(0,0,0); //Sigma in (X,Y,Z) (cm) on IP position
175 gGener = gener;
176 }
177 break;
178 case hijing:
179 {
180 AliGenHijing *gener = new AliGenHijing(-1);
50ea53d9 181// centre of mass energy
de78d77f 182 gener->SetEnergyCMS(5500);
50ea53d9 183// reference frame
de78d77f 184 gener->SetReferenceFrame("CMS ");
50ea53d9 185// projectile
de78d77f 186 gener->SetProjectile("A ", 208, 82);
187 gener->SetTarget ("A ", 208, 82);
50ea53d9 188// impact parameter range
de78d77f 189 gener->SetImpactParameterRange(0, 3.);
50ea53d9 190// evaluate cross section before run
b86fedbb 191 gener->SetEvaluate(0);
50ea53d9 192// tell hijing to keep the full parent child chain
de78d77f 193 gener->KeepFullEvent();
50ea53d9 194// enable jet quenching
de78d77f 195 gener->SetJetQuenching(1);
50ea53d9 196// enable shadowing
de78d77f 197 gener->SetShadowing(1);
50ea53d9 198// neutral pion and heavy particle decays switched off
de78d77f 199 gener->SetDecaysOff(1);
50ea53d9 200// trigger
de78d77f 201 gener->SetTrigger(0);
50ea53d9 202// kinematic selection
de78d77f 203 gener->SetSelectAll(0);
50ea53d9 204// momentum range
de78d77f 205 gener->SetMomentumRange(0,999);
50ea53d9 206// phi range
b86fedbb 207 gener->SetPhiRange(0.,360.);
50ea53d9 208// theta range
de78d77f 209 gener->SetThetaRange(0,180.);
50ea53d9 210// select flavor (0: no, 4: charm+beauty, 5:beauty)
b86fedbb 211 gener->SetFlavor(0);
50ea53d9 212//
de78d77f 213 gener->SetOrigin(0., 0.0 ,0);
214 gener->SetSigma(0,0,5.3);
215 gener->SetVertexSmear(kPerEvent);
50ea53d9 216// no tracking
de78d77f 217 gener->SetTrackingFlag(0);
218 gGener = gener;
219 }
220 break;
d6249ec3 221
de78d77f 222 case pythia:
916c29ab 223//********************************************
224// Example for Charm Production with Pythia *
225//********************************************
de78d77f 226 {
227 AliGenPythia *gener = new AliGenPythia(-1);
e417bd32 228// final state kinematic cuts
de78d77f 229 gener->SetMomentumRange(0,999);
b86fedbb 230 gener->SetPhiRange(0. ,360.);
de78d77f 231 gener->SetThetaRange(0., 180.);
232 gener->SetYRange(-10,10);
233 gener->SetPtRange(0,100);
e417bd32 234// vertex position and smearing
de78d77f 235 gener->SetOrigin(0,0,0); // vertex position
236 gener->SetVertexSmear(kPerEvent);
237 gener->SetSigma(0,0,5.6); // Sigma in (X,Y,Z) (cm) on IP position
238// Structure function. See the list in EVGEN/AliStructFuncType.h
239 gener->SetStrucFunc(kGRVHO);
e417bd32 240// Select corection for nuclear structure functions
241// gener->SetNuclei(208,208);
242//
de78d77f 243// Process type. See the list in PYTHIA6/AliPythia.h
244 gener->SetProcess(kPyBeauty);
e417bd32 245//
246// Pt transfer of the hard scattering
de78d77f 247 gener->SetPtHard(0.,5.);
e417bd32 248// Decay type (semielectronic, semimuonic, nodecay)
de78d77f 249 gener->SetForceDecay(kSemiElectronic);
e417bd32 250// Centre of mass energy
de78d77f 251 gener->SetEnergyCMS(5500.);
e417bd32 252// No Tracking
de78d77f 253 gener->SetTrackingFlag(0);
254 gGener = gener;
255 }
256 break;
395b2e02 257
de78d77f 258 case param1:
916c29ab 259//*******************************************************
395b2e02 260// Example for J/psi Production from Parameterisation
261// using default library (AliMUONlib)
916c29ab 262//*******************************************************
de78d77f 263 {
264 AliGenParam *gener =
265 new AliGenParam(ntracks, AliGenMUONlib::kUpsilon);
266 gener->SetMomentumRange(0,999);
267 gener->SetPtRange(0,999);
b86fedbb 268 gener->SetPhiRange(0. , 360.);
de78d77f 269 gener->SetYRange(2.5,4);
270 gener->SetCutOnChild(1);
271 gener->SetChildThetaRange(2,9);
272 gener->SetOrigin(0,0,0); //vertex position
273 gener->SetSigma(0,0,5.3); //Sigma in (X,Y,Z) (cm) on IP position
274 gener->SetForceDecay(kDiMuon);
275 gener->SetTrackingFlag(0);
276 gGener = gener;
277 }
278 break;
395b2e02 279
de78d77f 280 case param2:
395b2e02 281//*******************************************************
282// Example for Omega Production from Parameterisation
283// specifying library.
284//*******************************************************
de78d77f 285 {
286 AliGenParam *gener = new AliGenParam(1000,new AliGenPHOSlib(),
287 AliGenPHOSlib::kOmega);
288 gener->SetWeighting(kNonAnalog);
289 gener->SetForceDecay(kNoDecay);
290 gener->SetPtRange(0,100);
291 gener->SetThetaRange(45,135);
292 gener->SetTrackingFlag(0);
293 gGener = gener;
294 }
295 break;
395b2e02 296
de78d77f 297 case param3:
395b2e02 298//*******************************************************
299// Example for Upsilon Production from Parameterisation
300// specifying library.
301// GSI style
302//*******************************************************
de78d77f 303 {
304 AliGenParam *gener = new AliGenParam(1000,new AliGenGSIlib(),
305 AliGenGSIlib::kUpsilon, "MUON");
306 gener->SetMomentumRange(0,999);
307 gener->SetPtRange(0,999);
b86fedbb 308 gener->SetPhiRange(0., 360.);
de78d77f 309 gener->SetYRange(2.5,4);
310 gener->SetCutOnChild(1);
311 gener->SetChildThetaRange(2,9);
312 gener->SetOrigin(0,0,0); //vertex position
313 gener->SetSigma(0,0,5.3); //Sigma in (X,Y,Z) (cm) on IP position
314 gener->SetForceDecay(kDiMuon);
315 gener->SetTrackingFlag(0);
316 gGener = gener;
317 }
318 break;
395b2e02 319
de78d77f 320 case param4:
395b2e02 321//*******************************************************
322// Example for Omega Production from Parameterisation
323// specifying library.
324// The alternative way.
325//*******************************************************
de78d77f 326 {
327 AliGenLib* Lib=new AliGenPHOSlib();
328 Int_t iOmega = AliGenPHOSlib::kOmega;
329 AliGenParam *gener = new AliGenParam(50, iOmega,
330 Lib->GetPt(iOmega, ""),
331 Lib->GetY (iOmega, ""),
332 Lib->GetIp(iOmega, ""));
333 gener->SetPtRange(0,999);
334 gener->SetWeighting(kNonAnalog);
335 gener->SetForceDecay(kNoDecay);
336 gener->SetTrackingFlag(0);
337 gGener = gener;
338 }
339 break;
340
341 case fluka:
916c29ab 342//*******************************************************
343// Example for a FLUKA Boundary Source *
344//*******************************************************
de78d77f 345 {
346 AliGenFLUKAsource *gener = new AliGenFLUKAsource(-1);
347 gener->SetFileName("$(ALICE_ROOT)/data/all32.root");
348 gener->SetPartFlag(9);
349 gener->SetAgeMax(1.e-5);
916c29ab 350// 31.7 events
de78d77f 351 gener->SetFraction(0.0315);
916c29ab 352// gener->SetFraction(0.75*0.0315);
de78d77f 353 rl->CdGAFile();
916c29ab 354// gener->SetPartFlag(10);
de78d77f 355 gener->SetMomentumRange(0,999);
b86fedbb 356 gener->SetPhiRange(0.,360.);
de78d77f 357 gener->SetThetaRange(0., 180.);
358 gener->SetAgeMax(1.e-5);
916c29ab 359
360// 31.7 events
361// gener->SetFraction(0.0315);
de78d77f 362 gGener = gener;
363 }
364 break;
916c29ab 365
de78d77f 366 case ntuple:
916c29ab 367//*******************************************************
368// Example for reading from a external file *
369//*******************************************************
de78d77f 370 {
371 AliGenExtFile *gener = new AliGenExtFile(-1);
372 gener->SetVertexSmear(kPerEvent);
373 gener->SetTrackingFlag(1);
374
375 AliGenReaderTreeK * reader = new AliGenReaderTreeK();
376 reader->SetFileName("$(ALICE_ROOT)/data/dtujet93.root");
377 gener->SetReader(reader);
378 gGener = gener;
379 }
380 break;
916c29ab 381
de78d77f 382 case halo:
916c29ab 383//*******************************************************
384// Example for Tunnel Halo Source *
385//*******************************************************
de78d77f 386 {
387 AliGenHalo *gener = new AliGenHalo(ntracks);
388 gener->SetFileName("/h1/morsch/marsip/marsip5.mu");
389 gGener = gener;
390 }
391 break;
392
393 case cocktail:
916c29ab 394//*******************************************************
395// Example for a Cocktail *
396//*******************************************************
de78d77f 397 {
398 AliGenCocktail *gener = new AliGenCocktail();
916c29ab 399
de78d77f 400 gener->SetPhiRange(0,360);
401 gener->SetYRange(2.5,4);
402 gener->SetThetaRange(2,9);
403 gener->SetPtRange(0,10);
404 gener->SetOrigin(0,0,0); //vertex position
405 gener->SetSigma(0,0,0); //Sigma in (X,Y,Z) (cm) on IP position
406 gener->SetMomentumRange(0,999);
916c29ab 407
de78d77f 408 AliGenParam *jpsi = new AliGenParam(1,AliGenMUONlib::kJpsi);
409 jpsi->SetForceDecay(kDiMuon);
410 jpsi->SetCutOnChild(1);
916c29ab 411
412
de78d77f 413 AliGenFLUKAsource *bg = new AliGenFLUKAsource(-1);
414 bg->AddFile("$(ALICE_ROOT)/data/all32.root");
415 rl->CdGAFile();
416 bg->SetPartFlag(9);
417 bg->SetAgeMax(1.e-5);
916c29ab 418// 31.7 events
419// gener->SetFraction(0.0315);
de78d77f 420 bg->SetFraction(0.01*0.0315);
916c29ab 421
de78d77f 422 gener->AddGenerator(jpsi,"J/Psi", 1);
423 gener->AddGenerator(bg,"Background",1);
916c29ab 424
de78d77f 425 gGener = gener;
426 }
427 break;
428 }
916c29ab 429
430// Activate this line if you want the vertex smearing to happen
431// track by track
432//
aee8290b 433// gener->SetVertexSmear(kPerTrack);
916c29ab 434
de78d77f 435 gGener->Init();
916c29ab 436
de78d77f 437 gAlice->SetField(-999,2); //Specify maximum magnetic field in Tesla (neg. ==> default field)
916c29ab 438
de78d77f 439 Int_t iMAG=1;
440 rl->CdGAFile();
916c29ab 441
442//=================== Alice BODY parameters =============================
de78d77f 443 AliBODY *BODY = new AliBODY("BODY","Alice envelop");
916c29ab 444
445
de78d77f 446 if(iMAG) {
916c29ab 447//=================== MAG parameters ============================
448// --- Start with Magnet since detector layouts may be depending ---
449// --- on the selected Magnet dimensions ---
de78d77f 450 AliMAG *MAG = new AliMAG("MAG","Magnet");
451 }
916c29ab 452}