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