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