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