]>
Commit | Line | Data |
---|---|---|
4c039060 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* | |
17 | $Log$ | |
8b31bfac | 18 | Revision 1.48 2001/12/20 11:44:28 morsch |
19 | Add kinematic bias for direct gamma production. | |
20 | ||
b2bb450d | 21 | Revision 1.47 2001/12/19 14:45:00 morsch |
22 | Store number of trials in header. | |
23 | ||
fd8fb861 | 24 | Revision 1.46 2001/12/19 10:36:19 morsch |
25 | Add possibility if jet kinematic biasing. | |
26 | ||
988b118b | 27 | Revision 1.45 2001/11/28 08:06:52 morsch |
28 | Use fMaxLifeTime parameter. | |
29 | ||
8cdfd303 | 30 | Revision 1.44 2001/11/27 13:13:07 morsch |
31 | Maximum lifetime for long-lived particles to be put on the stack is parameter. | |
32 | It can be set via SetMaximumLifetime(..). | |
33 | ||
47fc6bd5 | 34 | Revision 1.43 2001/10/21 18:35:56 hristov |
35 | Several pointers were set to zero in the default constructors to avoid memory management problems | |
36 | ||
2685bf00 | 37 | Revision 1.42 2001/10/15 08:21:55 morsch |
38 | Vertex truncation settings moved to AliGenMC. | |
39 | ||
4c07486d | 40 | Revision 1.41 2001/10/08 08:45:42 morsch |
41 | Possibility of vertex cut added. | |
42 | ||
a0b2b296 | 43 | Revision 1.40 2001/09/25 11:30:23 morsch |
44 | Pass event vertex to header. | |
45 | ||
c5d36e84 | 46 | Revision 1.39 2001/07/27 17:09:36 morsch |
47 | Use local SetTrack, KeepTrack and SetHighWaterMark methods | |
48 | to delegate either to local stack or to stack owned by AliRun. | |
49 | (Piotr Skowronski, A.M.) | |
50 | ||
a99cf51f | 51 | Revision 1.38 2001/07/13 10:58:54 morsch |
52 | - Some coded moved to AliGenMC | |
53 | - Improved handling of secondary vertices. | |
54 | ||
fff02fee | 55 | Revision 1.37 2001/06/28 11:17:28 morsch |
56 | SetEventListRange setter added. Events in specified range are listed for | |
57 | debugging. (Yuri Kharlov) | |
58 | ||
11dfaf8d | 59 | Revision 1.36 2001/03/30 07:05:49 morsch |
60 | Final print-out in finish run. | |
61 | Write parton system for jet-production (preliminary solution). | |
62 | ||
9be6226f | 63 | Revision 1.35 2001/03/09 13:03:40 morsch |
64 | Process_t and Struc_Func_t moved to AliPythia.h | |
65 | ||
f1a48a38 | 66 | Revision 1.34 2001/02/14 15:50:40 hristov |
67 | The last particle in event marked using SetHighWaterMark | |
68 | ||
28adac24 | 69 | Revision 1.33 2001/01/30 09:23:12 hristov |
70 | Streamers removed (R.Brun) | |
71 | ||
a8a6107b | 72 | Revision 1.32 2001/01/26 19:55:51 hristov |
73 | Major upgrade of AliRoot code | |
74 | ||
2ab0c725 | 75 | Revision 1.31 2001/01/17 10:54:31 hristov |
76 | Better protection against FPE | |
77 | ||
0f9e52a3 | 78 | Revision 1.30 2000/12/18 08:55:35 morsch |
79 | Make AliPythia dependent generartors work with new scheme of random number generation | |
80 | ||
3356c022 | 81 | Revision 1.29 2000/12/04 11:22:03 morsch |
82 | Init of sRandom as in 1.15 | |
83 | ||
097ec7c1 | 84 | Revision 1.28 2000/12/02 11:41:39 morsch |
85 | Use SetRandom() to initialize random number generator in constructor. | |
86 | ||
1ed25e11 | 87 | Revision 1.27 2000/11/30 20:29:02 morsch |
88 | Initialise static variable sRandom in constructor: sRandom = fRandom; | |
89 | ||
ad1df918 | 90 | Revision 1.26 2000/11/30 07:12:50 alibrary |
91 | Introducing new Rndm and QA classes | |
92 | ||
65fb704d | 93 | Revision 1.25 2000/10/18 19:11:27 hristov |
94 | Division by zero fixed | |
95 | ||
919c2096 | 96 | Revision 1.24 2000/09/18 10:41:35 morsch |
97 | Add possibility to use nuclear structure functions from PDF library V8. | |
98 | ||
811826d8 | 99 | Revision 1.23 2000/09/14 14:05:40 morsch |
100 | dito | |
101 | ||
819f84ad | 102 | Revision 1.22 2000/09/14 14:02:22 morsch |
103 | - Correct conversion from mm to cm when passing particle vertex to MC. | |
104 | - Correct handling of fForceDecay == all. | |
105 | ||
4451ef92 | 106 | Revision 1.21 2000/09/12 14:14:55 morsch |
107 | Call fDecayer->ForceDecay() at the beginning of Generate(). | |
108 | ||
00d6ce7d | 109 | Revision 1.20 2000/09/06 14:29:33 morsch |
110 | Use AliPythia for event generation an AliDecayPythia for decays. | |
111 | Correct handling of "nodecay" option | |
112 | ||
18edb254 | 113 | Revision 1.19 2000/07/11 18:24:56 fca |
114 | Coding convention corrections + few minor bug fixes | |
115 | ||
aee8290b | 116 | Revision 1.18 2000/06/30 12:40:34 morsch |
117 | Pythia takes care of vertex smearing. Correct conversion from Pythia units (mm) to | |
118 | Geant units (cm). | |
119 | ||
1512e357 | 120 | Revision 1.17 2000/06/09 20:34:07 morsch |
121 | All coding rule violations except RS3 corrected | |
122 | ||
f87cfe57 | 123 | Revision 1.16 2000/05/15 15:04:20 morsch |
124 | The full event is written for fNtrack = -1 | |
125 | Coding rule violations corrected. | |
126 | ||
5ddeb374 | 127 | Revision 1.15 2000/04/26 10:14:24 morsch |
128 | Particles array has one entry more than pythia particle list. Upper bound of | |
129 | particle loop changed to np-1 (R. Guernane, AM) | |
130 | ||
2a0e6f5b | 131 | Revision 1.14 2000/04/05 08:36:13 morsch |
132 | Check status code of particles in Pythia event | |
133 | to avoid double counting as partonic state and final state particle. | |
134 | ||
23211d3e | 135 | Revision 1.13 1999/11/09 07:38:48 fca |
136 | Changes for compatibility with version 2.23 of ROOT | |
137 | ||
084c1b4a | 138 | Revision 1.12 1999/11/03 17:43:20 fca |
139 | New version from G.Martinez & A.Morsch | |
140 | ||
886b6f73 | 141 | Revision 1.11 1999/09/29 09:24:14 fca |
142 | Introduction of the Copyright and cvs Log | |
4c039060 | 143 | */ |
144 | ||
fe4da5cc | 145 | #include "AliGenPythia.h" |
fff02fee | 146 | #include "AliGenPythiaEventHeader.h" |
18edb254 | 147 | #include "AliDecayerPythia.h" |
fe4da5cc | 148 | #include "AliRun.h" |
149 | #include "AliPythia.h" | |
18edb254 | 150 | #include "AliPDG.h" |
1578254f | 151 | #include <TParticle.h> |
18edb254 | 152 | #include <TSystem.h> |
f87cfe57 | 153 | |
fe4da5cc | 154 | ClassImp(AliGenPythia) |
155 | ||
156 | AliGenPythia::AliGenPythia() | |
fff02fee | 157 | :AliGenMC() |
fe4da5cc | 158 | { |
18edb254 | 159 | // Default Constructor |
2685bf00 | 160 | fParticles = 0; |
161 | fPythia = 0; | |
988b118b | 162 | fDecayer = new AliDecayerPythia(); |
11dfaf8d | 163 | SetEventListRange(); |
988b118b | 164 | SetJetPhiRange(); |
165 | SetJetEtaRange(); | |
fe4da5cc | 166 | } |
167 | ||
168 | AliGenPythia::AliGenPythia(Int_t npart) | |
fff02fee | 169 | :AliGenMC(npart) |
fe4da5cc | 170 | { |
171 | // default charm production at 5. 5 TeV | |
172 | // semimuonic decay | |
173 | // structure function GRVHO | |
174 | // | |
8b31bfac | 175 | fName = "Pythia"; |
176 | fTitle= "Particle Generator using PYTHIA"; | |
fe4da5cc | 177 | fXsection = 0.; |
811826d8 | 178 | fNucA1=0; |
179 | fNucA2=0; | |
fe4da5cc | 180 | SetProcess(); |
181 | SetStrucFunc(); | |
886b6f73 | 182 | SetForceDecay(); |
fe4da5cc | 183 | SetPtHard(); |
184 | SetEnergyCMS(); | |
18edb254 | 185 | fDecayer = new AliDecayerPythia(); |
1ed25e11 | 186 | // Set random number generator |
097ec7c1 | 187 | sRandom=fRandom; |
fff02fee | 188 | fFlavorSelect = 0; |
189 | // Produced particles | |
190 | fParticles = new TClonesArray("TParticle",1000); | |
c5d36e84 | 191 | fEventVertex.Set(3); |
988b118b | 192 | SetEventListRange(); |
193 | SetJetPhiRange(); | |
194 | SetJetEtaRange(); | |
fe4da5cc | 195 | } |
196 | ||
f87cfe57 | 197 | AliGenPythia::AliGenPythia(const AliGenPythia & Pythia) |
198 | { | |
199 | // copy constructor | |
200 | } | |
201 | ||
fe4da5cc | 202 | AliGenPythia::~AliGenPythia() |
203 | { | |
5ddeb374 | 204 | // Destructor |
fe4da5cc | 205 | } |
206 | ||
11dfaf8d | 207 | void AliGenPythia::SetEventListRange(Int_t eventFirst, Int_t eventLast) |
208 | { | |
209 | // Set a range of event numbers, for which a table | |
210 | // of generated particle will be printed | |
211 | fDebugEventFirst = eventFirst; | |
212 | fDebugEventLast = eventLast; | |
213 | if (fDebugEventLast==-1) fDebugEventLast=fDebugEventFirst; | |
214 | } | |
215 | ||
fe4da5cc | 216 | void AliGenPythia::Init() |
217 | { | |
5ddeb374 | 218 | // Initialisation |
18edb254 | 219 | SetMC(AliPythia::Instance()); |
fe4da5cc | 220 | fPythia=(AliPythia*) fgMCEvGen; |
221 | // | |
222 | fParentWeight=1./Float_t(fNpart); | |
223 | // | |
224 | // Forward Paramters to the AliPythia object | |
00d6ce7d | 225 | fDecayer->SetForceDecay(fForceDecay); |
18edb254 | 226 | fDecayer->Init(); |
00d6ce7d | 227 | |
18edb254 | 228 | |
fe4da5cc | 229 | fPythia->SetCKIN(3,fPtHardMin); |
230 | fPythia->SetCKIN(4,fPtHardMax); | |
811826d8 | 231 | if (fNucA1 > 0 && fNucA2 > 0) fPythia->SetNuclei(fNucA1, fNucA2); |
fe4da5cc | 232 | fPythia->ProcInit(fProcess,fEnergyCMS,fStrucFunc); |
18edb254 | 233 | |
234 | // fPythia->Pylist(0); | |
235 | // fPythia->Pystat(2); | |
fe4da5cc | 236 | // Parent and Children Selection |
237 | switch (fProcess) | |
238 | { | |
f1a48a38 | 239 | case kPyCharm: |
fff02fee | 240 | fParentSelect[0] = 411; |
241 | fParentSelect[1] = 421; | |
242 | fParentSelect[2] = 431; | |
243 | fParentSelect[3] = 4122; | |
244 | fFlavorSelect = 4; | |
fe4da5cc | 245 | break; |
f1a48a38 | 246 | case kPyCharmUnforced: |
b2bb450d | 247 | fParentSelect[0] = 411; |
248 | fParentSelect[1] = 421; | |
249 | fParentSelect[2] = 431; | |
250 | fParentSelect[3] = 4122; | |
8b31bfac | 251 | fFlavorSelect = 4; |
fe4da5cc | 252 | break; |
f1a48a38 | 253 | case kPyBeauty: |
fff02fee | 254 | fParentSelect[0]= 511; |
255 | fParentSelect[1]= 521; | |
256 | fParentSelect[2]= 531; | |
257 | fParentSelect[3]= 5122; | |
258 | fParentSelect[4]= 5132; | |
259 | fParentSelect[5]= 5232; | |
260 | fParentSelect[6]= 5332; | |
261 | fFlavorSelect = 5; | |
fe4da5cc | 262 | break; |
f1a48a38 | 263 | case kPyBeautyUnforced: |
fff02fee | 264 | fParentSelect[0] = 511; |
265 | fParentSelect[1] = 521; | |
266 | fParentSelect[2] = 531; | |
267 | fParentSelect[3] = 5122; | |
268 | fParentSelect[4] = 5132; | |
269 | fParentSelect[5] = 5232; | |
270 | fParentSelect[6] = 5332; | |
271 | fFlavorSelect = 5; | |
fe4da5cc | 272 | break; |
f1a48a38 | 273 | case kPyJpsiChi: |
274 | case kPyJpsi: | |
fff02fee | 275 | fParentSelect[0] = 443; |
fe4da5cc | 276 | break; |
f1a48a38 | 277 | case kPyMb: |
278 | case kPyJets: | |
279 | case kPyDirectGamma: | |
5be1fe76 | 280 | break; |
fe4da5cc | 281 | } |
fff02fee | 282 | AliGenMC::Init(); |
fe4da5cc | 283 | } |
284 | ||
285 | void AliGenPythia::Generate() | |
286 | { | |
5ddeb374 | 287 | // Generate one event |
00d6ce7d | 288 | fDecayer->ForceDecay(); |
a0b2b296 | 289 | |
9be6226f | 290 | Float_t polar[3] = {0,0,0}; |
291 | Float_t origin[3] = {0,0,0}; | |
fff02fee | 292 | Float_t p[3]; |
5be1fe76 | 293 | // converts from mm/c to s |
294 | const Float_t kconv=0.001/2.999792458e8; | |
fe4da5cc | 295 | // |
fe4da5cc | 296 | Int_t nt=0; |
297 | Int_t jev=0; | |
7921755b | 298 | Int_t j, kf; |
fe4da5cc | 299 | fTrials=0; |
fff02fee | 300 | |
fd8fb861 | 301 | // Set collision vertex position |
aee8290b | 302 | if(fVertexSmear==kPerEvent) { |
1512e357 | 303 | fPythia->SetMSTP(151,1); |
fe4da5cc | 304 | for (j=0;j<3;j++) { |
fff02fee | 305 | fPythia->SetPARP(151+j, fOsigma[j]*10.); |
fe4da5cc | 306 | } |
aee8290b | 307 | } else if (fVertexSmear==kPerTrack) { |
fe4da5cc | 308 | fPythia->SetMSTP(151,0); |
fe4da5cc | 309 | } |
fff02fee | 310 | // event loop |
fe4da5cc | 311 | while(1) |
312 | { | |
084c1b4a | 313 | fPythia->Pyevnt(); |
11dfaf8d | 314 | if (gAlice->GetEvNumber()>=fDebugEventFirst && |
315 | gAlice->GetEvNumber()<=fDebugEventLast) fPythia->Pylist(1); | |
fe4da5cc | 316 | fTrials++; |
47fc6bd5 | 317 | |
fff02fee | 318 | fPythia->ImportParticles(fParticles,"All"); |
319 | ||
320 | // | |
321 | // | |
322 | // | |
323 | Int_t i; | |
324 | ||
325 | Int_t np = fParticles->GetEntriesFast(); | |
a0b2b296 | 326 | if (np == 0 ) continue; |
327 | // Get event vertex and discard the event if the Z coord. is too big | |
4c07486d | 328 | TParticle *iparticle = (TParticle *) fParticles->At(0); |
329 | Float_t distz = iparticle->Vz()/10.; | |
330 | if(TMath::Abs(distz)>fCutVertexZ*fOsigma[2]) continue; | |
a0b2b296 | 331 | // |
4c07486d | 332 | fEventVertex[0] = iparticle->Vx()/10.+fOrigin.At(0); |
333 | fEventVertex[1] = iparticle->Vy()/10.+fOrigin.At(1); | |
334 | fEventVertex[2] = iparticle->Vz()/10.+fOrigin.At(2); | |
a0b2b296 | 335 | // |
fff02fee | 336 | Int_t* pParent = new Int_t[np]; |
337 | Int_t* pSelected = new Int_t[np]; | |
338 | Int_t* trackIt = new Int_t[np]; | |
339 | for (i=0; i< np-1; i++) { | |
340 | pParent[i] = -1; | |
341 | pSelected[i] = 0; | |
342 | } | |
fe4da5cc | 343 | printf("\n **************************************************%d\n",np); |
fff02fee | 344 | Int_t nc = 0; |
f1a48a38 | 345 | if (fProcess != kPyMb && fProcess != kPyJets && fProcess != kPyDirectGamma) { |
fd8fb861 | 346 | |
fff02fee | 347 | for (i = 0; i<np-1; i++) { |
c5d36e84 | 348 | iparticle = (TParticle *) fParticles->At(i); |
23211d3e | 349 | Int_t ks = iparticle->GetStatusCode(); |
a8228d85 | 350 | kf = CheckPDGCode(iparticle->GetPdgCode()); |
fff02fee | 351 | // No initial state partons |
2a0e6f5b | 352 | if (ks==21) continue; |
fe4da5cc | 353 | // |
fff02fee | 354 | // Heavy Flavor Selection |
5be1fe76 | 355 | // |
fff02fee | 356 | // quark ? |
357 | kf = TMath::Abs(kf); | |
358 | Int_t kfl = kf; | |
359 | // meson ? | |
360 | if (kfl > 10) kfl/=100; | |
361 | // baryon | |
362 | if (kfl > 10) kfl/=10; | |
363 | if (kfl > 10) kfl/=10; | |
364 | ||
365 | Int_t ipa = iparticle->GetFirstMother()-1; | |
366 | Int_t kfMo = 0; | |
367 | ||
368 | if (ipa > -1) { | |
369 | TParticle * mother = (TParticle *) fParticles->At(ipa); | |
370 | kfMo = TMath::Abs(mother->GetPdgCode()); | |
371 | } | |
372 | // printf("\n particle (all) %d %d %d", i, pSelected[i], kf); | |
373 | if (kfl >= fFlavorSelect) { | |
5be1fe76 | 374 | // |
fff02fee | 375 | // Heavy flavor hadron or quark |
fe4da5cc | 376 | // |
fff02fee | 377 | // Kinematic seletion on final state heavy flavor mesons |
378 | if (ParentSelected(kf) && !KinematicSelection(iparticle, 0)) | |
379 | { | |
380 | nc = -1; | |
381 | break; | |
382 | } | |
383 | pSelected[i] = 1; | |
384 | // printf("\n particle (HF) %d %d %d", i, pSelected[i], kf); | |
385 | } else { | |
386 | // Kinematic seletion on decay products | |
387 | if (fCutOnChild && ParentSelected(kfMo) && ChildSelected(kf) | |
388 | && !KinematicSelection(iparticle, 1)) | |
389 | { | |
390 | nc = -1; | |
391 | break; | |
392 | } | |
fe4da5cc | 393 | // |
fff02fee | 394 | // Decay products |
395 | // Select if mother was selected and is not tracked | |
396 | ||
397 | if (pSelected[ipa] && | |
398 | !trackIt[ipa] && // mother will be tracked ? | |
399 | kfMo != 5 && // mother is b-quark, don't store fragments | |
400 | kfMo != 4 && // mother is c-quark, don't store fragments | |
401 | kf != 92) // don't store string | |
402 | { | |
fe4da5cc | 403 | // |
fff02fee | 404 | // Semi-stable or de-selected: diselect decay products: |
fe4da5cc | 405 | // |
5be1fe76 | 406 | // |
47fc6bd5 | 407 | if (pSelected[i] == -1 || fDecayer->GetLifetime(kf) > fMaxLifeTime) |
fff02fee | 408 | { |
409 | Int_t ipF = iparticle->GetFirstDaughter(); | |
410 | Int_t ipL = iparticle->GetLastDaughter(); | |
411 | if (ipF > 0) for (j = ipF-1; j < ipL; j++) pSelected[j] = -1; | |
412 | } | |
413 | // printf("\n particle (decay) %d %d %d", i, pSelected[i], kf); | |
414 | pSelected[i] = (pSelected[i] == -1) ? 0 : 1; | |
415 | } | |
416 | } | |
417 | if (pSelected[i] == -1) pSelected[i] = 0; | |
418 | if (!pSelected[i]) continue; | |
419 | nc++; | |
420 | // Decision on tracking | |
421 | trackIt[i] = 0; | |
422 | // | |
423 | // Track final state particle | |
424 | if (ks == 1) trackIt[i] = 1; | |
425 | // Track semi-stable particles | |
8cdfd303 | 426 | if ((ks ==1) || (fDecayer->GetLifetime(kf) > fMaxLifeTime)) trackIt[i] = 1; |
fff02fee | 427 | // Track particles selected by process if undecayed. |
428 | if (fForceDecay == kNoDecay) { | |
429 | if (ParentSelected(kf)) trackIt[i] = 1; | |
430 | } else { | |
431 | if (ParentSelected(kf)) trackIt[i] = 0; | |
432 | } | |
433 | // | |
434 | // | |
435 | ||
436 | } // particle selection loop | |
437 | if (nc > -1) { | |
438 | for (i = 0; i<np-1; i++) { | |
439 | if (!pSelected[i]) continue; | |
440 | TParticle * iparticle = (TParticle *) fParticles->At(i); | |
441 | kf = CheckPDGCode(iparticle->GetPdgCode()); | |
a0b2b296 | 442 | p[0] = iparticle->Px(); |
443 | p[1] = iparticle->Py(); | |
444 | p[2] = iparticle->Pz(); | |
445 | origin[0] = fOrigin[0]+iparticle->Vx()/10.; | |
446 | origin[1] = fOrigin[1]+iparticle->Vy()/10.; | |
447 | origin[2] = fOrigin[2]+iparticle->Vz()/10.; | |
448 | Float_t tof = kconv*iparticle->T(); | |
449 | Int_t ipa = iparticle->GetFirstMother()-1; | |
fff02fee | 450 | Int_t iparent = (ipa > -1) ? pParent[ipa] : -1; |
a99cf51f | 451 | SetTrack(fTrackIt*trackIt[i] , |
fff02fee | 452 | iparent, kf, p, origin, polar, tof, kPPrimary, nt, 1.); |
453 | pParent[i] = nt; | |
a99cf51f | 454 | KeepTrack(nt); |
fff02fee | 455 | } // SetTrack loop |
456 | } | |
457 | } else { | |
458 | nc = GenerateMB(); | |
5be1fe76 | 459 | } // mb ? |
fff02fee | 460 | |
fe4da5cc | 461 | if (nc > 0) { |
5be1fe76 | 462 | jev+=nc; |
5ddeb374 | 463 | if (jev >= fNpart || fNpart == -1) { |
fe4da5cc | 464 | fKineBias=Float_t(fNpart)/Float_t(fTrials); |
23211d3e | 465 | printf("\n Trials: %i %i %i\n",fTrials, fNpart, jev); |
fd8fb861 | 466 | MakeHeader(); |
fe4da5cc | 467 | break; |
468 | } | |
469 | } | |
470 | } // event loop | |
a99cf51f | 471 | SetHighWaterMark(nt); |
fe4da5cc | 472 | // adjust weight due to kinematic selection |
473 | AdjustWeights(); | |
474 | // get cross-section | |
475 | fXsection=fPythia->GetPARI(1); | |
476 | } | |
477 | ||
fff02fee | 478 | Int_t AliGenPythia::GenerateMB() |
fe4da5cc | 479 | { |
fff02fee | 480 | Int_t i, kf, nt, iparent; |
481 | Int_t nc = 0; | |
482 | Float_t p[3]; | |
483 | Float_t polar[3] = {0,0,0}; | |
484 | Float_t origin[3] = {0,0,0}; | |
fff02fee | 485 | // converts from mm/c to s |
486 | const Float_t kconv=0.001/2.999792458e8; | |
4451ef92 | 487 | |
fff02fee | 488 | Int_t np = fParticles->GetEntriesFast(); |
489 | Int_t* pParent = new Int_t[np]; | |
490 | for (i=0; i< np-1; i++) pParent[i] = -1; | |
b2bb450d | 491 | if (fProcess == kPyJets || fProcess == kPyDirectGamma) { |
988b118b | 492 | TParticle* jet1 = (TParticle *) fParticles->At(6); |
493 | TParticle* jet2 = (TParticle *) fParticles->At(7); | |
494 | if (!CheckTrigger(jet1, jet2)) return 0; | |
495 | } | |
496 | ||
fff02fee | 497 | for (i = 0; i<np-1; i++) { |
498 | Int_t trackIt = 0; | |
499 | TParticle * iparticle = (TParticle *) fParticles->At(i); | |
500 | kf = CheckPDGCode(iparticle->GetPdgCode()); | |
501 | Int_t ks = iparticle->GetStatusCode(); | |
502 | Int_t km = iparticle->GetFirstMother(); | |
503 | // printf("\n Particle: %d %d %d", i, kf, ks); | |
504 | ||
505 | if ((ks == 1 && kf!=0 && KinematicSelection(iparticle, 0)) || | |
506 | (ks != 1) || | |
507 | (fProcess == kPyJets && ks == 21 && km == 0 && i>1)) { | |
508 | nc++; | |
509 | if (ks == 1) trackIt = 1; | |
510 | Int_t ipa = iparticle->GetFirstMother()-1; | |
fe4da5cc | 511 | |
fff02fee | 512 | iparent = (ipa > -1) ? pParent[ipa] : -1; |
fe4da5cc | 513 | |
514 | // | |
fff02fee | 515 | // store track information |
a0b2b296 | 516 | p[0] = iparticle->Px(); |
517 | p[1] = iparticle->Py(); | |
518 | p[2] = iparticle->Pz(); | |
519 | origin[0] = fOrigin[0]+iparticle->Vx()/10.; | |
520 | origin[1] = fOrigin[1]+iparticle->Vy()/10.; | |
521 | origin[2] = fOrigin[2]+iparticle->Vz()/10.; | |
fff02fee | 522 | Float_t tof=kconv*iparticle->T(); |
a99cf51f | 523 | SetTrack(fTrackIt*trackIt, iparent, kf, p, origin, polar, |
a0b2b296 | 524 | tof, kPPrimary, nt); |
a99cf51f | 525 | KeepTrack(nt); |
fff02fee | 526 | pParent[i] = nt; |
527 | } // select particle | |
528 | } // particle loop | |
529 | ||
530 | if (pParent) delete[] pParent; | |
fe4da5cc | 531 | |
fff02fee | 532 | printf("\n I've put %i particles on the stack \n",nc); |
fff02fee | 533 | return nc; |
534 | } | |
fe4da5cc | 535 | |
fe4da5cc | 536 | |
fff02fee | 537 | void AliGenPythia::FinishRun() |
538 | { | |
539 | // Print x-section summary | |
540 | fPythia->Pystat(1); | |
fe4da5cc | 541 | } |
fff02fee | 542 | |
fe4da5cc | 543 | void AliGenPythia::AdjustWeights() |
544 | { | |
5ddeb374 | 545 | // Adjust the weights after generation of all events |
546 | // | |
5ddeb374 | 547 | TParticle *part; |
fe4da5cc | 548 | Int_t ntrack=gAlice->GetNtrack(); |
549 | for (Int_t i=0; i<ntrack; i++) { | |
2ab0c725 | 550 | part= gAlice->Particle(i); |
5ddeb374 | 551 | part->SetWeight(part->GetWeight()*fKineBias); |
fe4da5cc | 552 | } |
553 | } | |
811826d8 | 554 | |
555 | void AliGenPythia::SetNuclei(Int_t a1, Int_t a2) | |
556 | { | |
557 | // Treat protons as inside nuclei with mass numbers a1 and a2 | |
558 | fNucA1 = a1; | |
559 | fNucA2 = a2; | |
560 | } | |
fff02fee | 561 | |
562 | ||
563 | void AliGenPythia::MakeHeader() | |
564 | { | |
565 | // Builds the event header, to be called after each event | |
566 | AliGenEventHeader* header = new AliGenPythiaEventHeader("Pythia"); | |
c5d36e84 | 567 | ((AliGenPythiaEventHeader*) header)->SetProcessType(fPythia->GetMSTI(1)); |
fd8fb861 | 568 | ((AliGenPythiaEventHeader*) header)->SetTrials(fTrials); |
c5d36e84 | 569 | header->SetPrimaryVertex(fEventVertex); |
570 | gAlice->SetGenEventHeader(header); | |
fff02fee | 571 | } |
811826d8 | 572 | |
988b118b | 573 | |
574 | Bool_t AliGenPythia::CheckTrigger(TParticle* jet1, TParticle* jet2) | |
575 | { | |
576 | // Check the kinematic trigger condition | |
577 | // | |
b2bb450d | 578 | Double_t eta[2]; |
579 | eta[0] = jet1->Eta(); | |
580 | eta[1] = jet2->Eta(); | |
581 | Double_t phi[2]; | |
582 | phi[0] = jet1->Phi(); | |
583 | phi[1] = jet2->Phi(); | |
584 | Int_t pdg[2]; | |
585 | pdg[0] = jet1->GetPdgCode(); | |
586 | pdg[1] = jet2->GetPdgCode(); | |
988b118b | 587 | Bool_t triggered = kFALSE; |
b2bb450d | 588 | |
589 | if (fProcess == kPyJets) { | |
590 | //Check eta range first... | |
591 | if ((eta[0] < fEtaMaxJet && eta[0] > fEtaMinJet) || | |
592 | (eta[1] < fEtaMaxJet && eta[1] > fEtaMinJet)) | |
593 | { | |
594 | //Eta is okay, now check phi range | |
595 | if ((phi[0] < fPhiMaxJet && phi[0] > fPhiMinJet) || | |
596 | (phi[1] < fPhiMaxJet && phi[1] > fPhiMinJet)) | |
597 | { | |
598 | triggered = kTRUE; | |
599 | } | |
600 | } | |
601 | } else { | |
602 | Int_t ij = 0; | |
603 | Int_t ig = 1; | |
604 | if (pdg[0] == kGamma) { | |
605 | ij = 1; | |
606 | ig = 0; | |
607 | } | |
608 | //Check eta range first... | |
609 | if ((eta[ij] < fEtaMaxJet && eta[ij] > fEtaMinJet) && | |
610 | (eta[ig] < fEtaMaxGamma && eta[ig] > fEtaMinGamma)) | |
611 | { | |
612 | //Eta is okay, now check phi range | |
613 | if ((phi[ij] < fPhiMaxJet && phi[ij] > fPhiMinJet) && | |
614 | (phi[ig] < fPhiMaxGamma && phi[ig] > fPhiMinGamma)) | |
615 | { | |
616 | triggered = kTRUE; | |
617 | } | |
618 | } | |
988b118b | 619 | } |
b2bb450d | 620 | |
621 | ||
988b118b | 622 | return triggered; |
623 | } | |
811826d8 | 624 | |
f87cfe57 | 625 | AliGenPythia& AliGenPythia::operator=(const AliGenPythia& rhs) |
626 | { | |
627 | // Assignment operator | |
628 | return *this; | |
629 | } | |
fe4da5cc | 630 | |
631 | ||
811826d8 | 632 | |
a8a6107b | 633 | #ifdef never |
18edb254 | 634 | void AliGenPythia::Streamer(TBuffer &R__b) |
635 | { | |
636 | // Stream an object of class AliGenPythia. | |
637 | ||
638 | if (R__b.IsReading()) { | |
639 | Version_t R__v = R__b.ReadVersion(); if (R__v) { } | |
640 | AliGenerator::Streamer(R__b); | |
641 | R__b >> (Int_t&)fProcess; | |
642 | R__b >> (Int_t&)fStrucFunc; | |
643 | R__b >> (Int_t&)fForceDecay; | |
644 | R__b >> fEnergyCMS; | |
645 | R__b >> fKineBias; | |
646 | R__b >> fTrials; | |
647 | fParentSelect.Streamer(R__b); | |
648 | fChildSelect.Streamer(R__b); | |
649 | R__b >> fXsection; | |
650 | // (AliPythia::Instance())->Streamer(R__b); | |
651 | R__b >> fPtHardMin; | |
652 | R__b >> fPtHardMax; | |
653 | // if (fDecayer) fDecayer->Streamer(R__b); | |
654 | } else { | |
655 | R__b.WriteVersion(AliGenPythia::IsA()); | |
656 | AliGenerator::Streamer(R__b); | |
657 | R__b << (Int_t)fProcess; | |
658 | R__b << (Int_t)fStrucFunc; | |
659 | R__b << (Int_t)fForceDecay; | |
660 | R__b << fEnergyCMS; | |
661 | R__b << fKineBias; | |
662 | R__b << fTrials; | |
663 | fParentSelect.Streamer(R__b); | |
664 | fChildSelect.Streamer(R__b); | |
665 | R__b << fXsection; | |
666 | // R__b << fPythia; | |
667 | R__b << fPtHardMin; | |
668 | R__b << fPtHardMax; | |
669 | // fDecayer->Streamer(R__b); | |
670 | } | |
671 | } | |
a8a6107b | 672 | #endif |
18edb254 | 673 |