]>
Commit | Line | Data |
---|---|---|
8d2cd130 | 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 | ||
7cdba479 | 16 | /* $Id$ */ |
8d2cd130 | 17 | |
18 | // | |
19 | // Generator using the TPythia interface (via AliPythia) | |
20 | // to generate pp collisions. | |
21 | // Using SetNuclei() also nuclear modifications to the structure functions | |
22 | // can be taken into account. This makes, of course, only sense for the | |
23 | // generation of the products of hard processes (heavy flavor, jets ...) | |
24 | // | |
25 | // andreas.morsch@cern.ch | |
26 | // | |
27 | ||
28 | #include <TDatabasePDG.h> | |
29 | #include <TParticle.h> | |
30 | #include <TPDGCode.h> | |
31 | #include <TSystem.h> | |
32 | #include <TTree.h> | |
33 | ||
34 | #include "AliConst.h" | |
35 | #include "AliDecayerPythia.h" | |
36 | #include "AliGenPythia.h" | |
5fa4b20b | 37 | #include "AliHeader.h" |
8d2cd130 | 38 | #include "AliGenPythiaEventHeader.h" |
39 | #include "AliPythia.h" | |
7cdba479 | 40 | #include "AliPythiaRndm.h" |
8d2cd130 | 41 | #include "AliRun.h" |
7ea3ea5b | 42 | #include "AliStack.h" |
43 | #include "AliRunLoader.h" | |
5d12ce38 | 44 | #include "AliMC.h" |
8d2cd130 | 45 | |
014a9521 | 46 | ClassImp(AliGenPythia) |
8d2cd130 | 47 | |
48 | AliGenPythia::AliGenPythia() | |
49 | :AliGenMC() | |
50 | { | |
51 | // Default Constructor | |
52 | fParticles = 0; | |
53 | fPythia = 0; | |
e5c87a3d | 54 | fHeader = 0; |
5fffd0fe | 55 | fReadFromFile = 0; |
8d2cd130 | 56 | fDecayer = new AliDecayerPythia(); |
57 | SetEventListRange(); | |
58 | SetJetPhiRange(); | |
59 | SetJetEtaRange(); | |
60 | SetJetEtRange(); | |
61 | SetGammaPhiRange(); | |
62 | SetGammaEtaRange(); | |
63 | SetPtKick(); | |
7ea3ea5b | 64 | SetQuench(); |
5fa4b20b | 65 | SetHadronisation(); |
1d568bc2 | 66 | fSetNuclei = kFALSE; |
7cdba479 | 67 | if (!AliPythiaRndm::GetPythiaRandom()) |
68 | AliPythiaRndm::SetPythiaRandom(GetRandom()); | |
8d2cd130 | 69 | } |
70 | ||
71 | AliGenPythia::AliGenPythia(Int_t npart) | |
72 | :AliGenMC(npart) | |
73 | { | |
74 | // default charm production at 5. 5 TeV | |
75 | // semimuonic decay | |
76 | // structure function GRVHO | |
77 | // | |
78 | fName = "Pythia"; | |
79 | fTitle= "Particle Generator using PYTHIA"; | |
80 | fXsection = 0.; | |
5fffd0fe | 81 | fReadFromFile = 0; |
8d2cd130 | 82 | SetProcess(); |
83 | SetStrucFunc(); | |
84 | SetForceDecay(); | |
85 | SetPtHard(); | |
86 | SetYHard(); | |
87 | SetEnergyCMS(); | |
88 | fDecayer = new AliDecayerPythia(); | |
89 | // Set random number generator | |
7cdba479 | 90 | if (!AliPythiaRndm::GetPythiaRandom()) |
91 | AliPythiaRndm::SetPythiaRandom(GetRandom()); | |
8d2cd130 | 92 | fFlavorSelect = 0; |
93 | // Produced particles | |
94 | fParticles = new TClonesArray("TParticle",1000); | |
e5c87a3d | 95 | fHeader = 0; |
8d2cd130 | 96 | SetEventListRange(); |
97 | SetJetPhiRange(); | |
98 | SetJetEtaRange(); | |
99 | SetJetEtRange(); | |
100 | SetGammaPhiRange(); | |
101 | SetGammaEtaRange(); | |
102 | SetJetReconstructionMode(); | |
7ea3ea5b | 103 | SetQuench(); |
5fa4b20b | 104 | SetHadronisation(); |
8d2cd130 | 105 | SetPtKick(); |
106 | // Options determining what to keep in the stack (Heavy flavour generation) | |
107 | fStackFillOpt = kFlavorSelection; // Keep particle with selected flavor | |
108 | fFeedDownOpt = kTRUE; // allow feed down from higher family | |
109 | // Fragmentation on/off | |
110 | fFragmentation = kTRUE; | |
111 | // Default counting mode | |
112 | fCountMode = kCountAll; | |
592f8307 | 113 | // Pycel |
114 | SetPycellParameters(); | |
1d568bc2 | 115 | fSetNuclei = kFALSE; |
8d2cd130 | 116 | } |
117 | ||
118 | AliGenPythia::AliGenPythia(const AliGenPythia & Pythia) | |
f936b8ea | 119 | :AliGenMC(Pythia) |
8d2cd130 | 120 | { |
121 | // copy constructor | |
122 | Pythia.Copy(*this); | |
123 | } | |
124 | ||
125 | AliGenPythia::~AliGenPythia() | |
126 | { | |
127 | // Destructor | |
128 | } | |
129 | ||
592f8307 | 130 | void AliGenPythia::SetPycellParameters(Float_t etamax, Int_t neta, Int_t nphi, |
131 | Float_t thresh, Float_t etseed, Float_t minet, Float_t r) | |
132 | { | |
133 | // Set pycell parameters | |
134 | fPycellEtaMax = etamax; | |
135 | fPycellNEta = neta; | |
136 | fPycellNPhi = nphi; | |
137 | fPycellThreshold = thresh; | |
138 | fPycellEtSeed = etseed; | |
139 | fPycellMinEtJet = minet; | |
140 | fPycellMaxRadius = r; | |
141 | } | |
142 | ||
143 | ||
144 | ||
8d2cd130 | 145 | void AliGenPythia::SetEventListRange(Int_t eventFirst, Int_t eventLast) |
146 | { | |
147 | // Set a range of event numbers, for which a table | |
148 | // of generated particle will be printed | |
149 | fDebugEventFirst = eventFirst; | |
150 | fDebugEventLast = eventLast; | |
151 | if (fDebugEventLast==-1) fDebugEventLast=fDebugEventFirst; | |
152 | } | |
153 | ||
154 | void AliGenPythia::Init() | |
155 | { | |
156 | // Initialisation | |
157 | ||
158 | SetMC(AliPythia::Instance()); | |
b88f5cea | 159 | fPythia=(AliPythia*) fMCEvGen; |
e2bddf81 | 160 | |
8d2cd130 | 161 | // |
162 | fParentWeight=1./Float_t(fNpart); | |
163 | // | |
164 | // Forward Paramters to the AliPythia object | |
165 | fDecayer->SetForceDecay(fForceDecay); | |
166 | fDecayer->Init(); | |
167 | ||
168 | ||
169 | fPythia->SetCKIN(3,fPtHardMin); | |
170 | fPythia->SetCKIN(4,fPtHardMax); | |
171 | fPythia->SetCKIN(7,fYHardMin); | |
172 | fPythia->SetCKIN(8,fYHardMax); | |
173 | ||
1a626d4e | 174 | if (fAProjectile > 0 && fATarget > 0) fPythia->SetNuclei(fAProjectile, fATarget); |
8d2cd130 | 175 | // Fragmentation? |
176 | if (fFragmentation) { | |
177 | fPythia->SetMSTP(111,1); | |
178 | } else { | |
179 | fPythia->SetMSTP(111,0); | |
180 | } | |
181 | ||
182 | ||
183 | // initial state radiation | |
184 | fPythia->SetMSTP(61,fGinit); | |
185 | // final state radiation | |
186 | fPythia->SetMSTP(71,fGfinal); | |
187 | // pt - kick | |
188 | if (fPtKick > 0.) { | |
189 | fPythia->SetMSTP(91,1); | |
190 | fPythia->SetPARP(91,fPtKick); | |
191 | } else { | |
192 | fPythia->SetMSTP(91,0); | |
193 | } | |
194 | ||
5fa4b20b | 195 | |
196 | if (fReadFromFile) { | |
197 | fRL = AliRunLoader::Open(fFileName, "Partons"); | |
198 | fRL->LoadKinematics(); | |
199 | fRL->LoadHeader(); | |
200 | } else { | |
201 | fRL = 0x0; | |
202 | } | |
203 | ||
204 | ||
8d2cd130 | 205 | // |
206 | fPythia->ProcInit(fProcess,fEnergyCMS,fStrucFunc); | |
207 | ||
208 | // Parent and Children Selection | |
209 | switch (fProcess) | |
210 | { | |
211 | case kPyCharm: | |
212 | case kPyCharmUnforced: | |
adf4d898 | 213 | case kPyCharmPbPbMNR: |
aabc7187 | 214 | case kPyCharmppMNR: |
215 | case kPyCharmpPbMNR: | |
8d2cd130 | 216 | fParentSelect[0] = 411; |
217 | fParentSelect[1] = 421; | |
218 | fParentSelect[2] = 431; | |
219 | fParentSelect[3] = 4122; | |
220 | fFlavorSelect = 4; | |
221 | break; | |
adf4d898 | 222 | case kPyD0PbPbMNR: |
223 | case kPyD0pPbMNR: | |
224 | case kPyD0ppMNR: | |
8d2cd130 | 225 | fParentSelect[0] = 421; |
226 | fFlavorSelect = 4; | |
227 | break; | |
90d7b703 | 228 | case kPyDPlusPbPbMNR: |
229 | case kPyDPluspPbMNR: | |
230 | case kPyDPlusppMNR: | |
231 | fParentSelect[0] = 411; | |
232 | fFlavorSelect = 4; | |
233 | break; | |
8d2cd130 | 234 | case kPyBeauty: |
adf4d898 | 235 | case kPyBeautyPbPbMNR: |
236 | case kPyBeautypPbMNR: | |
237 | case kPyBeautyppMNR: | |
8d2cd130 | 238 | fParentSelect[0]= 511; |
239 | fParentSelect[1]= 521; | |
240 | fParentSelect[2]= 531; | |
241 | fParentSelect[3]= 5122; | |
242 | fParentSelect[4]= 5132; | |
243 | fParentSelect[5]= 5232; | |
244 | fParentSelect[6]= 5332; | |
245 | fFlavorSelect = 5; | |
246 | break; | |
247 | case kPyBeautyUnforced: | |
248 | fParentSelect[0] = 511; | |
249 | fParentSelect[1] = 521; | |
250 | fParentSelect[2] = 531; | |
251 | fParentSelect[3] = 5122; | |
252 | fParentSelect[4] = 5132; | |
253 | fParentSelect[5] = 5232; | |
254 | fParentSelect[6] = 5332; | |
255 | fFlavorSelect = 5; | |
256 | break; | |
257 | case kPyJpsiChi: | |
258 | case kPyJpsi: | |
259 | fParentSelect[0] = 443; | |
260 | break; | |
261 | case kPyMb: | |
262 | case kPyMbNonDiffr: | |
263 | case kPyJets: | |
264 | case kPyDirectGamma: | |
265 | break; | |
266 | } | |
267 | // | |
592f8307 | 268 | // |
269 | // JetFinder for Trigger | |
270 | // | |
271 | // Configure detector (EMCAL like) | |
272 | // | |
273 | fPythia->SetPARU(51, fPycellEtaMax); | |
274 | fPythia->SetMSTU(51, fPycellNEta); | |
275 | fPythia->SetMSTU(52, fPycellNPhi); | |
276 | // | |
277 | // Configure Jet Finder | |
278 | // | |
279 | fPythia->SetPARU(58, fPycellThreshold); | |
280 | fPythia->SetPARU(52, fPycellEtSeed); | |
281 | fPythia->SetPARU(53, fPycellMinEtJet); | |
282 | fPythia->SetPARU(54, fPycellMaxRadius); | |
283 | fPythia->SetMSTU(54, 2); | |
284 | // | |
8d2cd130 | 285 | // This counts the total number of calls to Pyevnt() per run. |
286 | fTrialsRun = 0; | |
287 | fQ = 0.; | |
288 | fX1 = 0.; | |
289 | fX2 = 0.; | |
290 | fNev = 0 ; | |
291 | // | |
1d568bc2 | 292 | // |
293 | // | |
8d2cd130 | 294 | AliGenMC::Init(); |
1d568bc2 | 295 | // |
296 | // | |
297 | // | |
298 | if (fSetNuclei) { | |
299 | fDyBoost = 0; | |
300 | Warning("Init","SetNuclei used. Use SetProjectile + SetTarget instead. fDyBoost has been reset to 0\n"); | |
301 | } | |
32d6ef7d | 302 | |
303 | if (fQuench) { | |
5fa4b20b | 304 | fPythia->InitQuenching(0., 0.1, 0.6e6, 0); |
32d6ef7d | 305 | } |
306 | ||
8d2cd130 | 307 | } |
308 | ||
309 | void AliGenPythia::Generate() | |
310 | { | |
311 | // Generate one event | |
e5c87a3d | 312 | |
8d2cd130 | 313 | fDecayer->ForceDecay(); |
314 | ||
315 | Float_t polar[3] = {0,0,0}; | |
316 | Float_t origin[3] = {0,0,0}; | |
a920faf9 | 317 | Float_t p[4]; |
8d2cd130 | 318 | // converts from mm/c to s |
319 | const Float_t kconv=0.001/2.999792458e8; | |
320 | // | |
321 | Int_t nt=0; | |
322 | Int_t jev=0; | |
323 | Int_t j, kf; | |
324 | fTrials=0; | |
2590ccf9 | 325 | |
8d2cd130 | 326 | |
327 | // Set collision vertex position | |
2590ccf9 | 328 | if (fVertexSmear == kPerEvent) Vertex(); |
329 | ||
8d2cd130 | 330 | // event loop |
331 | while(1) | |
332 | { | |
32d6ef7d | 333 | // |
5fa4b20b | 334 | // Produce event |
32d6ef7d | 335 | // |
32d6ef7d | 336 | // |
5fa4b20b | 337 | // Switch hadronisation off |
338 | // | |
339 | fPythia->SetMSTJ(1, 0); | |
32d6ef7d | 340 | // |
5fa4b20b | 341 | // Either produce new event or read partons from file |
342 | // | |
343 | if (!fReadFromFile) { | |
344 | fPythia->Pyevnt(); | |
345 | fNpartons = fPythia->GetN(); | |
346 | } else { | |
347 | printf("Loading Event %d\n",AliRunLoader::GetRunLoader()->GetEventNumber()); | |
348 | fRL->GetEvent(AliRunLoader::GetRunLoader()->GetEventNumber()); | |
349 | fPythia->SetN(0); | |
350 | LoadEvent(fRL->Stack(), 0 , 1); | |
351 | fPythia->Pyedit(21); | |
352 | } | |
353 | ||
32d6ef7d | 354 | // |
355 | // Run quenching routine | |
356 | // | |
5fa4b20b | 357 | if (fQuench == 1) { |
358 | fPythia->Quench(); | |
359 | } else if (fQuench == 2){ | |
360 | fPythia->Pyquen(208., 0, 0.); | |
361 | } | |
32d6ef7d | 362 | // |
5fa4b20b | 363 | // Switch hadronisation on |
32d6ef7d | 364 | // |
5fa4b20b | 365 | fPythia->SetMSTJ(1, 1); |
366 | // | |
367 | // .. and perform hadronisation | |
368 | // printf("Calling hadronisation %d\n", fPythia->GetN()); | |
369 | fPythia->Pyexec(); | |
370 | ||
e2bddf81 | 371 | if (gAlice) { |
372 | if (gAlice->GetEvNumber()>=fDebugEventFirst && | |
373 | gAlice->GetEvNumber()<=fDebugEventLast) fPythia->Pylist(1); | |
374 | } | |
7ea3ea5b | 375 | |
8d2cd130 | 376 | fTrials++; |
8d2cd130 | 377 | fPythia->ImportParticles(fParticles,"All"); |
1d568bc2 | 378 | Boost(); |
8d2cd130 | 379 | // |
380 | // | |
381 | // | |
382 | Int_t i; | |
383 | ||
5fa4b20b | 384 | |
8d2cd130 | 385 | Int_t np = fParticles->GetEntriesFast(); |
5fa4b20b | 386 | |
8d2cd130 | 387 | if (np == 0 ) continue; |
8d2cd130 | 388 | // |
2590ccf9 | 389 | |
8d2cd130 | 390 | // |
391 | Int_t* pParent = new Int_t[np]; | |
392 | Int_t* pSelected = new Int_t[np]; | |
393 | Int_t* trackIt = new Int_t[np]; | |
5fa4b20b | 394 | for (i = 0; i < np; i++) { |
8d2cd130 | 395 | pParent[i] = -1; |
396 | pSelected[i] = 0; | |
397 | trackIt[i] = 0; | |
398 | } | |
399 | ||
400 | Int_t nc = 0; // Total n. of selected particles | |
401 | Int_t nParents = 0; // Selected parents | |
402 | Int_t nTkbles = 0; // Trackable particles | |
403 | if (fProcess != kPyMb && fProcess != kPyJets && | |
404 | fProcess != kPyDirectGamma && | |
405 | fProcess != kPyMbNonDiffr) { | |
406 | ||
5fa4b20b | 407 | for (i = 0; i < np; i++) { |
2590ccf9 | 408 | TParticle* iparticle = (TParticle *) fParticles->At(i); |
8d2cd130 | 409 | Int_t ks = iparticle->GetStatusCode(); |
410 | kf = CheckPDGCode(iparticle->GetPdgCode()); | |
411 | // No initial state partons | |
412 | if (ks==21) continue; | |
413 | // | |
414 | // Heavy Flavor Selection | |
415 | // | |
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 | // What to keep in Stack? | |
433 | Bool_t flavorOK = kFALSE; | |
434 | Bool_t selectOK = kFALSE; | |
435 | if (fFeedDownOpt) { | |
32d6ef7d | 436 | if (kfl >= fFlavorSelect) flavorOK = kTRUE; |
8d2cd130 | 437 | } else { |
32d6ef7d | 438 | if (kfl > fFlavorSelect) { |
439 | nc = -1; | |
440 | break; | |
441 | } | |
442 | if (kfl == fFlavorSelect) flavorOK = kTRUE; | |
8d2cd130 | 443 | } |
444 | switch (fStackFillOpt) { | |
445 | case kFlavorSelection: | |
32d6ef7d | 446 | selectOK = kTRUE; |
447 | break; | |
8d2cd130 | 448 | case kParentSelection: |
32d6ef7d | 449 | if (ParentSelected(kf) || kf <= 10) selectOK = kTRUE; |
450 | break; | |
8d2cd130 | 451 | } |
452 | if (flavorOK && selectOK) { | |
453 | // | |
454 | // Heavy flavor hadron or quark | |
455 | // | |
456 | // Kinematic seletion on final state heavy flavor mesons | |
457 | if (ParentSelected(kf) && !KinematicSelection(iparticle, 0)) | |
458 | { | |
459 | continue; | |
460 | } | |
461 | pSelected[i] = 1; | |
462 | if (ParentSelected(kf)) ++nParents; // Update parent count | |
463 | // printf("\n particle (HF) %d %d %d", i, pSelected[i], kf); | |
464 | } else { | |
465 | // Kinematic seletion on decay products | |
466 | if (fCutOnChild && ParentSelected(kfMo) && ChildSelected(kf) | |
467 | && !KinematicSelection(iparticle, 1)) | |
468 | { | |
469 | continue; | |
470 | } | |
471 | // | |
472 | // Decay products | |
473 | // Select if mother was selected and is not tracked | |
474 | ||
475 | if (pSelected[ipa] && | |
476 | !trackIt[ipa] && // mother will be tracked ? | |
477 | kfMo != 5 && // mother is b-quark, don't store fragments | |
478 | kfMo != 4 && // mother is c-quark, don't store fragments | |
479 | kf != 92) // don't store string | |
480 | { | |
481 | // | |
482 | // Semi-stable or de-selected: diselect decay products: | |
483 | // | |
484 | // | |
485 | if (pSelected[i] == -1 || fDecayer->GetLifetime(kf) > fMaxLifeTime) | |
486 | { | |
487 | Int_t ipF = iparticle->GetFirstDaughter(); | |
488 | Int_t ipL = iparticle->GetLastDaughter(); | |
489 | if (ipF > 0) for (j = ipF-1; j < ipL; j++) pSelected[j] = -1; | |
490 | } | |
491 | // printf("\n particle (decay) %d %d %d", i, pSelected[i], kf); | |
492 | pSelected[i] = (pSelected[i] == -1) ? 0 : 1; | |
493 | } | |
494 | } | |
495 | if (pSelected[i] == -1) pSelected[i] = 0; | |
496 | if (!pSelected[i]) continue; | |
497 | // Count quarks only if you did not include fragmentation | |
498 | if (fFragmentation && kf <= 10) continue; | |
499 | nc++; | |
500 | // Decision on tracking | |
501 | trackIt[i] = 0; | |
502 | // | |
503 | // Track final state particle | |
504 | if (ks == 1) trackIt[i] = 1; | |
505 | // Track semi-stable particles | |
d25cfd65 | 506 | if ((ks == 1) || (fDecayer->GetLifetime(kf) > fMaxLifeTime)) trackIt[i] = 1; |
8d2cd130 | 507 | // Track particles selected by process if undecayed. |
508 | if (fForceDecay == kNoDecay) { | |
509 | if (ParentSelected(kf)) trackIt[i] = 1; | |
510 | } else { | |
511 | if (ParentSelected(kf)) trackIt[i] = 0; | |
512 | } | |
513 | if (trackIt[i] == 1) ++nTkbles; // Update trackable counter | |
514 | // | |
515 | // | |
516 | ||
517 | } // particle selection loop | |
518 | if (nc > 0) { | |
519 | for (i = 0; i<np; i++) { | |
520 | if (!pSelected[i]) continue; | |
521 | TParticle * iparticle = (TParticle *) fParticles->At(i); | |
522 | kf = CheckPDGCode(iparticle->GetPdgCode()); | |
523 | Int_t ks = iparticle->GetStatusCode(); | |
524 | p[0] = iparticle->Px(); | |
525 | p[1] = iparticle->Py(); | |
526 | p[2] = iparticle->Pz(); | |
a920faf9 | 527 | p[3] = iparticle->Energy(); |
528 | ||
2590ccf9 | 529 | origin[0] = fVertex[0]+iparticle->Vx()/10; // [cm] |
530 | origin[1] = fVertex[1]+iparticle->Vy()/10; // [cm] | |
531 | origin[2] = fVertex[2]+iparticle->Vz()/10; // [cm] | |
532 | ||
8d2cd130 | 533 | Float_t tof = kconv*iparticle->T(); |
534 | Int_t ipa = iparticle->GetFirstMother()-1; | |
535 | Int_t iparent = (ipa > -1) ? pParent[ipa] : -1; | |
a920faf9 | 536 | |
537 | PushTrack(fTrackIt*trackIt[i], iparent, kf, | |
538 | p[0], p[1], p[2], p[3], | |
539 | origin[0], origin[1], origin[2], tof, | |
540 | polar[0], polar[1], polar[2], | |
541 | kPPrimary, nt, 1., ks); | |
8d2cd130 | 542 | pParent[i] = nt; |
543 | KeepTrack(nt); | |
642f15cf | 544 | } // PushTrack loop |
8d2cd130 | 545 | } |
546 | } else { | |
547 | nc = GenerateMB(); | |
548 | } // mb ? | |
549 | ||
550 | if (pParent) delete[] pParent; | |
551 | if (pSelected) delete[] pSelected; | |
552 | if (trackIt) delete[] trackIt; | |
553 | ||
554 | if (nc > 0) { | |
555 | switch (fCountMode) { | |
556 | case kCountAll: | |
557 | // printf(" Count all \n"); | |
558 | jev += nc; | |
559 | break; | |
560 | case kCountParents: | |
561 | // printf(" Count parents \n"); | |
562 | jev += nParents; | |
563 | break; | |
564 | case kCountTrackables: | |
565 | // printf(" Count trackable \n"); | |
566 | jev += nTkbles; | |
567 | break; | |
568 | } | |
569 | if (jev >= fNpart || fNpart == -1) { | |
570 | fKineBias=Float_t(fNpart)/Float_t(fTrials); | |
571 | printf("\n Trials: %i %i %i\n",fTrials, fNpart, jev); | |
572 | ||
573 | fQ += fPythia->GetVINT(51); | |
574 | fX1 += fPythia->GetVINT(41); | |
575 | fX2 += fPythia->GetVINT(42); | |
576 | fTrialsRun += fTrials; | |
577 | fNev++; | |
578 | MakeHeader(); | |
579 | break; | |
580 | } | |
581 | } | |
582 | } // event loop | |
583 | SetHighWaterMark(nt); | |
584 | // adjust weight due to kinematic selection | |
b88f5cea | 585 | // AdjustWeights(); |
8d2cd130 | 586 | // get cross-section |
587 | fXsection=fPythia->GetPARI(1); | |
588 | } | |
589 | ||
590 | Int_t AliGenPythia::GenerateMB() | |
591 | { | |
592 | // | |
593 | // Min Bias selection and other global selections | |
594 | // | |
595 | Int_t i, kf, nt, iparent; | |
596 | Int_t nc = 0; | |
bf950da8 | 597 | Float_t p[4]; |
8d2cd130 | 598 | Float_t polar[3] = {0,0,0}; |
599 | Float_t origin[3] = {0,0,0}; | |
600 | // converts from mm/c to s | |
601 | const Float_t kconv=0.001/2.999792458e8; | |
602 | ||
5fa4b20b | 603 | |
604 | ||
605 | Int_t np = (fHadronisation) ? fParticles->GetEntriesFast() : fNpartons; | |
606 | ||
607 | ||
8d2cd130 | 608 | Int_t* pParent = new Int_t[np]; |
609 | for (i=0; i< np; i++) pParent[i] = -1; | |
610 | if (fProcess == kPyJets || fProcess == kPyDirectGamma) { | |
611 | TParticle* jet1 = (TParticle *) fParticles->At(6); | |
612 | TParticle* jet2 = (TParticle *) fParticles->At(7); | |
613 | if (!CheckTrigger(jet1, jet2)) return 0; | |
614 | } | |
615 | ||
616 | for (i = 0; i<np; i++) { | |
617 | Int_t trackIt = 0; | |
618 | TParticle * iparticle = (TParticle *) fParticles->At(i); | |
619 | kf = CheckPDGCode(iparticle->GetPdgCode()); | |
620 | Int_t ks = iparticle->GetStatusCode(); | |
621 | Int_t km = iparticle->GetFirstMother(); | |
622 | if ((ks == 1 && kf!=0 && KinematicSelection(iparticle, 0)) || | |
623 | (ks != 1) || | |
624 | (fProcess == kPyJets && ks == 21 && km == 0 && i>1)) { | |
625 | nc++; | |
626 | if (ks == 1) trackIt = 1; | |
627 | Int_t ipa = iparticle->GetFirstMother()-1; | |
628 | ||
629 | iparent = (ipa > -1) ? pParent[ipa] : -1; | |
630 | ||
631 | // | |
632 | // store track information | |
633 | p[0] = iparticle->Px(); | |
634 | p[1] = iparticle->Py(); | |
635 | p[2] = iparticle->Pz(); | |
a920faf9 | 636 | p[3] = iparticle->Energy(); |
1406f599 | 637 | |
a920faf9 | 638 | |
2590ccf9 | 639 | origin[0] = fVertex[0]+iparticle->Vx()/10; // [cm] |
640 | origin[1] = fVertex[1]+iparticle->Vy()/10; // [cm] | |
641 | origin[2] = fVertex[2]+iparticle->Vz()/10; // [cm] | |
642 | ||
8d2cd130 | 643 | Float_t tof=kconv*iparticle->T(); |
a920faf9 | 644 | |
645 | PushTrack(fTrackIt*trackIt, iparent, kf, | |
646 | p[0], p[1], p[2], p[3], | |
647 | origin[0], origin[1], origin[2], tof, | |
648 | polar[0], polar[1], polar[2], | |
649 | kPPrimary, nt, 1., ks); | |
5fa4b20b | 650 | // |
651 | // Special Treatment to store color-flow | |
652 | // | |
653 | if (ks == 3 || ks == 13 || ks == 14) { | |
654 | TParticle* particle = 0; | |
655 | if (fStack) { | |
656 | particle = fStack->Particle(nt); | |
657 | } else { | |
658 | particle = gAlice->Stack()->Particle(nt); | |
659 | } | |
660 | particle->SetFirstDaughter(fPythia->GetK(2, i)); | |
661 | particle->SetLastDaughter(fPythia->GetK(3, i)); | |
662 | } | |
663 | ||
8d2cd130 | 664 | KeepTrack(nt); |
665 | pParent[i] = nt; | |
666 | } // select particle | |
667 | } // particle loop | |
668 | ||
669 | if (pParent) delete[] pParent; | |
670 | ||
671 | printf("\n I've put %i particles on the stack \n",nc); | |
672 | return nc; | |
673 | } | |
674 | ||
675 | ||
676 | void AliGenPythia::FinishRun() | |
677 | { | |
678 | // Print x-section summary | |
679 | fPythia->Pystat(1); | |
680 | fQ /= fNev; | |
681 | fX1 /= fNev; | |
682 | fX2 /= fNev; | |
683 | printf("\nTotal number of Pyevnt() calls %d\n", fTrialsRun); | |
684 | printf("\nMean Q, x1, x2: %f %f %f\n", fQ, fX1, fX2); | |
685 | ||
686 | ||
687 | } | |
688 | ||
689 | void AliGenPythia::AdjustWeights() | |
690 | { | |
691 | // Adjust the weights after generation of all events | |
692 | // | |
e2bddf81 | 693 | if (gAlice) { |
694 | TParticle *part; | |
695 | Int_t ntrack=gAlice->GetMCApp()->GetNtrack(); | |
696 | for (Int_t i=0; i<ntrack; i++) { | |
697 | part= gAlice->GetMCApp()->Particle(i); | |
698 | part->SetWeight(part->GetWeight()*fKineBias); | |
699 | } | |
8d2cd130 | 700 | } |
701 | } | |
702 | ||
703 | void AliGenPythia::SetNuclei(Int_t a1, Int_t a2) | |
704 | { | |
705 | // Treat protons as inside nuclei with mass numbers a1 and a2 | |
1d568bc2 | 706 | |
1a626d4e | 707 | fAProjectile = a1; |
708 | fATarget = a2; | |
1d568bc2 | 709 | fSetNuclei = kTRUE; |
8d2cd130 | 710 | } |
711 | ||
712 | ||
713 | void AliGenPythia::MakeHeader() | |
714 | { | |
715 | // Builds the event header, to be called after each event | |
e5c87a3d | 716 | if (fHeader) delete fHeader; |
717 | fHeader = new AliGenPythiaEventHeader("Pythia"); | |
8d2cd130 | 718 | // |
719 | // Event type | |
e5c87a3d | 720 | ((AliGenPythiaEventHeader*) fHeader)->SetProcessType(fPythia->GetMSTI(1)); |
8d2cd130 | 721 | // |
722 | // Number of trials | |
e5c87a3d | 723 | ((AliGenPythiaEventHeader*) fHeader)->SetTrials(fTrials); |
8d2cd130 | 724 | // |
725 | // Event Vertex | |
d25cfd65 | 726 | fHeader->SetPrimaryVertex(fVertex); |
8d2cd130 | 727 | // |
728 | // Jets that have triggered | |
729 | if (fProcess == kPyJets) | |
730 | { | |
731 | Int_t ntrig, njet; | |
732 | Float_t jets[4][10]; | |
733 | GetJets(njet, ntrig, jets); | |
734 | ||
735 | for (Int_t i = 0; i < ntrig; i++) { | |
e5c87a3d | 736 | ((AliGenPythiaEventHeader*) fHeader)->AddJet(jets[0][i], jets[1][i], jets[2][i], |
8d2cd130 | 737 | jets[3][i]); |
738 | } | |
739 | } | |
5fa4b20b | 740 | // |
741 | // Copy relevant information from external header, if present. | |
742 | // | |
743 | Float_t uqJet[4]; | |
744 | ||
745 | if (fRL) { | |
746 | AliGenPythiaEventHeader* exHeader = (AliGenPythiaEventHeader*) (fRL->GetHeader()->GenEventHeader()); | |
747 | for (Int_t i = 0; i < exHeader->NTriggerJets(); i++) | |
748 | { | |
749 | printf("Adding Jet %d %d \n", i, exHeader->NTriggerJets()); | |
750 | ||
751 | ||
752 | exHeader->TriggerJet(i, uqJet); | |
753 | ((AliGenPythiaEventHeader*) fHeader)->AddUQJet(uqJet[0], uqJet[1], uqJet[2], uqJet[3]); | |
754 | } | |
755 | } | |
756 | // | |
757 | // Store quenching parameters | |
758 | // | |
759 | if (fQuench){ | |
760 | Double_t z[4]; | |
761 | Double_t xp, yp; | |
762 | ||
763 | fPythia->GetQuenchingParameters(xp, yp, z); | |
764 | ||
765 | ((AliGenPythiaEventHeader*) fHeader)->SetXYJet(xp, yp); | |
766 | ((AliGenPythiaEventHeader*) fHeader)->SetZQuench(z); | |
767 | } | |
768 | ||
769 | // | |
770 | // Pass header to RunLoader | |
771 | // | |
772 | AliRunLoader::GetRunLoader()->GetHeader()->SetGenEventHeader(fHeader); | |
8d2cd130 | 773 | } |
774 | ||
775 | ||
776 | Bool_t AliGenPythia::CheckTrigger(TParticle* jet1, TParticle* jet2) | |
777 | { | |
778 | // Check the kinematic trigger condition | |
779 | // | |
780 | Double_t eta[2]; | |
781 | eta[0] = jet1->Eta(); | |
782 | eta[1] = jet2->Eta(); | |
783 | Double_t phi[2]; | |
784 | phi[0] = jet1->Phi(); | |
785 | phi[1] = jet2->Phi(); | |
786 | Int_t pdg[2]; | |
787 | pdg[0] = jet1->GetPdgCode(); | |
788 | pdg[1] = jet2->GetPdgCode(); | |
789 | Bool_t triggered = kFALSE; | |
790 | ||
791 | if (fProcess == kPyJets) { | |
792 | Int_t njets = 0; | |
793 | Int_t ntrig = 0; | |
794 | Float_t jets[4][10]; | |
795 | // | |
796 | // Use Pythia clustering on parton level to determine jet axis | |
797 | // | |
798 | GetJets(njets, ntrig, jets); | |
799 | ||
800 | if (ntrig) triggered = kTRUE; | |
801 | // | |
802 | } else { | |
803 | Int_t ij = 0; | |
804 | Int_t ig = 1; | |
805 | if (pdg[0] == kGamma) { | |
806 | ij = 1; | |
807 | ig = 0; | |
808 | } | |
809 | //Check eta range first... | |
810 | if ((eta[ij] < fEtaMaxJet && eta[ij] > fEtaMinJet) && | |
811 | (eta[ig] < fEtaMaxGamma && eta[ig] > fEtaMinGamma)) | |
812 | { | |
813 | //Eta is okay, now check phi range | |
814 | if ((phi[ij] < fPhiMaxJet && phi[ij] > fPhiMinJet) && | |
815 | (phi[ig] < fPhiMaxGamma && phi[ig] > fPhiMinGamma)) | |
816 | { | |
817 | triggered = kTRUE; | |
818 | } | |
819 | } | |
820 | } | |
821 | return triggered; | |
822 | } | |
823 | ||
824 | AliGenPythia& AliGenPythia::operator=(const AliGenPythia& rhs) | |
825 | { | |
826 | // Assignment operator | |
014a9521 | 827 | rhs.Copy(*this); |
8d2cd130 | 828 | return *this; |
829 | } | |
830 | ||
5fa4b20b | 831 | void AliGenPythia::LoadEvent(AliStack* stack, Int_t flag, Int_t reHadr) |
8d2cd130 | 832 | { |
833 | // | |
834 | // Load event into Pythia Common Block | |
835 | // | |
5fa4b20b | 836 | |
32d6ef7d | 837 | Int_t npart = stack -> GetNprimary(); |
838 | Int_t n0 = 0; | |
839 | ||
840 | if (!flag) { | |
841 | (fPythia->GetPyjets())->N = npart; | |
842 | } else { | |
843 | n0 = (fPythia->GetPyjets())->N; | |
844 | (fPythia->GetPyjets())->N = n0 + npart; | |
845 | } | |
846 | ||
847 | ||
8d2cd130 | 848 | for (Int_t part = 0; part < npart; part++) { |
32d6ef7d | 849 | TParticle *MPart = stack->Particle(part); |
850 | ||
5fa4b20b | 851 | Int_t kf = MPart->GetPdgCode(); |
852 | Int_t ks = MPart->GetStatusCode(); | |
853 | Int_t idf = MPart->GetFirstDaughter(); | |
854 | Int_t idl = MPart->GetLastDaughter(); | |
855 | ||
856 | if (reHadr) { | |
857 | if (ks == 11 || ks == 12) { | |
858 | ks -= 10; | |
859 | idf = -1; | |
860 | idl = -1; | |
861 | } | |
862 | } | |
32d6ef7d | 863 | |
8d2cd130 | 864 | Float_t px = MPart->Px(); |
865 | Float_t py = MPart->Py(); | |
866 | Float_t pz = MPart->Pz(); | |
867 | Float_t e = MPart->Energy(); | |
a920faf9 | 868 | Float_t m = MPart->GetCalcMass(); |
8d2cd130 | 869 | |
870 | ||
32d6ef7d | 871 | (fPythia->GetPyjets())->P[0][part+n0] = px; |
872 | (fPythia->GetPyjets())->P[1][part+n0] = py; | |
873 | (fPythia->GetPyjets())->P[2][part+n0] = pz; | |
874 | (fPythia->GetPyjets())->P[3][part+n0] = e; | |
875 | (fPythia->GetPyjets())->P[4][part+n0] = m; | |
8d2cd130 | 876 | |
32d6ef7d | 877 | (fPythia->GetPyjets())->K[1][part+n0] = kf; |
878 | (fPythia->GetPyjets())->K[0][part+n0] = ks; | |
5fa4b20b | 879 | (fPythia->GetPyjets())->K[3][part+n0] = idf + 1; |
880 | (fPythia->GetPyjets())->K[4][part+n0] = idl + 1; | |
881 | (fPythia->GetPyjets())->K[2][part+n0] = MPart->GetFirstMother() + 1; | |
8d2cd130 | 882 | } |
883 | } | |
884 | ||
5fa4b20b | 885 | |
014a9521 | 886 | void AliGenPythia::RecJetsUA1(Int_t& njets, Float_t jets [4][50]) |
8d2cd130 | 887 | { |
888 | // | |
889 | // Calls the Pythia jet finding algorithm to find jets in the current event | |
890 | // | |
891 | // | |
8d2cd130 | 892 | // |
893 | // Save jets | |
894 | Int_t n = fPythia->GetN(); | |
895 | ||
896 | // | |
897 | // Run Jet Finder | |
898 | fPythia->Pycell(njets); | |
899 | Int_t i; | |
900 | for (i = 0; i < njets; i++) { | |
901 | Float_t px = (fPythia->GetPyjets())->P[0][n+i]; | |
902 | Float_t py = (fPythia->GetPyjets())->P[1][n+i]; | |
903 | Float_t pz = (fPythia->GetPyjets())->P[2][n+i]; | |
904 | Float_t e = (fPythia->GetPyjets())->P[3][n+i]; | |
905 | ||
906 | jets[0][i] = px; | |
907 | jets[1][i] = py; | |
908 | jets[2][i] = pz; | |
909 | jets[3][i] = e; | |
910 | } | |
911 | } | |
912 | ||
913 | ||
914 | ||
915 | void AliGenPythia::GetJets(Int_t& nJets, Int_t& nJetsTrig, Float_t jets[4][10]) | |
916 | { | |
917 | // | |
918 | // Calls the Pythia clustering algorithm to find jets in the current event | |
919 | // | |
920 | Int_t n = fPythia->GetN(); | |
921 | nJets = 0; | |
922 | nJetsTrig = 0; | |
923 | if (fJetReconstruction == kCluster) { | |
924 | // | |
925 | // Configure cluster algorithm | |
926 | // | |
927 | fPythia->SetPARU(43, 2.); | |
928 | fPythia->SetMSTU(41, 1); | |
929 | // | |
930 | // Call cluster algorithm | |
931 | // | |
932 | fPythia->Pyclus(nJets); | |
933 | // | |
934 | // Loading jets from common block | |
935 | // | |
936 | } else { | |
592f8307 | 937 | |
8d2cd130 | 938 | // |
939 | // Run Jet Finder | |
940 | fPythia->Pycell(nJets); | |
941 | } | |
942 | ||
943 | Int_t i; | |
944 | for (i = 0; i < nJets; i++) { | |
945 | Float_t px = (fPythia->GetPyjets())->P[0][n+i]; | |
946 | Float_t py = (fPythia->GetPyjets())->P[1][n+i]; | |
947 | Float_t pz = (fPythia->GetPyjets())->P[2][n+i]; | |
948 | Float_t e = (fPythia->GetPyjets())->P[3][n+i]; | |
949 | Float_t pt = TMath::Sqrt(px * px + py * py); | |
a920faf9 | 950 | Float_t phi = TMath::Pi() + TMath::ATan2(-py, -px); |
8d2cd130 | 951 | Float_t theta = TMath::ATan2(pt,pz); |
952 | Float_t et = e * TMath::Sin(theta); | |
953 | Float_t eta = -TMath::Log(TMath::Tan(theta / 2.)); | |
954 | ||
955 | if ( | |
956 | eta > fEtaMinJet && eta < fEtaMaxJet && | |
675eb105 | 957 | phi > fPhiMinJet && phi < fPhiMaxJet && |
8d2cd130 | 958 | et > fEtMinJet && et < fEtMaxJet |
959 | ) | |
960 | { | |
961 | jets[0][nJetsTrig] = px; | |
962 | jets[1][nJetsTrig] = py; | |
963 | jets[2][nJetsTrig] = pz; | |
964 | jets[3][nJetsTrig] = e; | |
965 | nJetsTrig++; | |
5fa4b20b | 966 | // printf("\n........-Jet #%d: %10.3f %10.3f %10.3f %10.3f \n", i, pt, et, eta, phi * kRaddeg); |
8d2cd130 | 967 | } else { |
968 | // printf("\n........-Jet #%d: %10.3f %10.3f %10.3f %10.3f \n", i, pt, et, eta, phi * kRaddeg); | |
969 | } | |
970 | } | |
971 | } | |
972 | ||
973 | ||
974 | #ifdef never | |
975 | void AliGenPythia::Streamer(TBuffer &R__b) | |
976 | { | |
977 | // Stream an object of class AliGenPythia. | |
978 | ||
979 | if (R__b.IsReading()) { | |
980 | Version_t R__v = R__b.ReadVersion(); if (R__v) { } | |
981 | AliGenerator::Streamer(R__b); | |
982 | R__b >> (Int_t&)fProcess; | |
983 | R__b >> (Int_t&)fStrucFunc; | |
984 | R__b >> (Int_t&)fForceDecay; | |
985 | R__b >> fEnergyCMS; | |
986 | R__b >> fKineBias; | |
987 | R__b >> fTrials; | |
988 | fParentSelect.Streamer(R__b); | |
989 | fChildSelect.Streamer(R__b); | |
990 | R__b >> fXsection; | |
991 | // (AliPythia::Instance())->Streamer(R__b); | |
992 | R__b >> fPtHardMin; | |
993 | R__b >> fPtHardMax; | |
994 | // if (fDecayer) fDecayer->Streamer(R__b); | |
995 | } else { | |
996 | R__b.WriteVersion(AliGenPythia::IsA()); | |
997 | AliGenerator::Streamer(R__b); | |
998 | R__b << (Int_t)fProcess; | |
999 | R__b << (Int_t)fStrucFunc; | |
1000 | R__b << (Int_t)fForceDecay; | |
1001 | R__b << fEnergyCMS; | |
1002 | R__b << fKineBias; | |
1003 | R__b << fTrials; | |
1004 | fParentSelect.Streamer(R__b); | |
1005 | fChildSelect.Streamer(R__b); | |
1006 | R__b << fXsection; | |
1007 | // R__b << fPythia; | |
1008 | R__b << fPtHardMin; | |
1009 | R__b << fPtHardMax; | |
1010 | // fDecayer->Streamer(R__b); | |
1011 | } | |
1012 | } | |
1013 | #endif | |
1014 | ||
90d7b703 | 1015 |