]>
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> | |
8d2cd130 | 33 | #include "AliConst.h" |
34 | #include "AliDecayerPythia.h" | |
35 | #include "AliGenPythia.h" | |
5fa4b20b | 36 | #include "AliHeader.h" |
8d2cd130 | 37 | #include "AliGenPythiaEventHeader.h" |
38 | #include "AliPythia.h" | |
7cdba479 | 39 | #include "AliPythiaRndm.h" |
8d2cd130 | 40 | #include "AliRun.h" |
7ea3ea5b | 41 | #include "AliStack.h" |
42 | #include "AliRunLoader.h" | |
5d12ce38 | 43 | #include "AliMC.h" |
7c21f297 | 44 | #include "pyquenCommon.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; | |
589380c6 | 266 | case kPyW: |
267 | break; | |
8d2cd130 | 268 | } |
269 | // | |
592f8307 | 270 | // |
271 | // JetFinder for Trigger | |
272 | // | |
273 | // Configure detector (EMCAL like) | |
274 | // | |
275 | fPythia->SetPARU(51, fPycellEtaMax); | |
276 | fPythia->SetMSTU(51, fPycellNEta); | |
277 | fPythia->SetMSTU(52, fPycellNPhi); | |
278 | // | |
279 | // Configure Jet Finder | |
280 | // | |
281 | fPythia->SetPARU(58, fPycellThreshold); | |
282 | fPythia->SetPARU(52, fPycellEtSeed); | |
283 | fPythia->SetPARU(53, fPycellMinEtJet); | |
284 | fPythia->SetPARU(54, fPycellMaxRadius); | |
285 | fPythia->SetMSTU(54, 2); | |
286 | // | |
8d2cd130 | 287 | // This counts the total number of calls to Pyevnt() per run. |
288 | fTrialsRun = 0; | |
289 | fQ = 0.; | |
290 | fX1 = 0.; | |
291 | fX2 = 0.; | |
292 | fNev = 0 ; | |
293 | // | |
1d568bc2 | 294 | // |
295 | // | |
8d2cd130 | 296 | AliGenMC::Init(); |
1d568bc2 | 297 | // |
298 | // | |
299 | // | |
300 | if (fSetNuclei) { | |
301 | fDyBoost = 0; | |
302 | Warning("Init","SetNuclei used. Use SetProjectile + SetTarget instead. fDyBoost has been reset to 0\n"); | |
303 | } | |
32d6ef7d | 304 | |
305 | if (fQuench) { | |
5fa4b20b | 306 | fPythia->InitQuenching(0., 0.1, 0.6e6, 0); |
32d6ef7d | 307 | } |
308 | ||
8d2cd130 | 309 | } |
310 | ||
311 | void AliGenPythia::Generate() | |
312 | { | |
313 | // Generate one event | |
e5c87a3d | 314 | |
8d2cd130 | 315 | fDecayer->ForceDecay(); |
316 | ||
317 | Float_t polar[3] = {0,0,0}; | |
318 | Float_t origin[3] = {0,0,0}; | |
a920faf9 | 319 | Float_t p[4]; |
8d2cd130 | 320 | // converts from mm/c to s |
321 | const Float_t kconv=0.001/2.999792458e8; | |
322 | // | |
323 | Int_t nt=0; | |
324 | Int_t jev=0; | |
325 | Int_t j, kf; | |
326 | fTrials=0; | |
2590ccf9 | 327 | |
8d2cd130 | 328 | |
329 | // Set collision vertex position | |
2590ccf9 | 330 | if (fVertexSmear == kPerEvent) Vertex(); |
331 | ||
8d2cd130 | 332 | // event loop |
333 | while(1) | |
334 | { | |
32d6ef7d | 335 | // |
5fa4b20b | 336 | // Produce event |
32d6ef7d | 337 | // |
32d6ef7d | 338 | // |
5fa4b20b | 339 | // Switch hadronisation off |
340 | // | |
341 | fPythia->SetMSTJ(1, 0); | |
32d6ef7d | 342 | // |
5fa4b20b | 343 | // Either produce new event or read partons from file |
344 | // | |
345 | if (!fReadFromFile) { | |
346 | fPythia->Pyevnt(); | |
347 | fNpartons = fPythia->GetN(); | |
348 | } else { | |
349 | printf("Loading Event %d\n",AliRunLoader::GetRunLoader()->GetEventNumber()); | |
350 | fRL->GetEvent(AliRunLoader::GetRunLoader()->GetEventNumber()); | |
351 | fPythia->SetN(0); | |
352 | LoadEvent(fRL->Stack(), 0 , 1); | |
353 | fPythia->Pyedit(21); | |
354 | } | |
355 | ||
32d6ef7d | 356 | // |
357 | // Run quenching routine | |
358 | // | |
5fa4b20b | 359 | if (fQuench == 1) { |
360 | fPythia->Quench(); | |
361 | } else if (fQuench == 2){ | |
362 | fPythia->Pyquen(208., 0, 0.); | |
363 | } | |
32d6ef7d | 364 | // |
5fa4b20b | 365 | // Switch hadronisation on |
32d6ef7d | 366 | // |
5fa4b20b | 367 | fPythia->SetMSTJ(1, 1); |
368 | // | |
369 | // .. and perform hadronisation | |
370 | // printf("Calling hadronisation %d\n", fPythia->GetN()); | |
371 | fPythia->Pyexec(); | |
8d2cd130 | 372 | fTrials++; |
8d2cd130 | 373 | fPythia->ImportParticles(fParticles,"All"); |
1d568bc2 | 374 | Boost(); |
8d2cd130 | 375 | // |
376 | // | |
377 | // | |
378 | Int_t i; | |
379 | ||
5fa4b20b | 380 | |
8d2cd130 | 381 | Int_t np = fParticles->GetEntriesFast(); |
5fa4b20b | 382 | |
7c21f297 | 383 | if (np == 0) continue; |
8d2cd130 | 384 | // |
2590ccf9 | 385 | |
8d2cd130 | 386 | // |
387 | Int_t* pParent = new Int_t[np]; | |
388 | Int_t* pSelected = new Int_t[np]; | |
389 | Int_t* trackIt = new Int_t[np]; | |
5fa4b20b | 390 | for (i = 0; i < np; i++) { |
8d2cd130 | 391 | pParent[i] = -1; |
392 | pSelected[i] = 0; | |
393 | trackIt[i] = 0; | |
394 | } | |
395 | ||
396 | Int_t nc = 0; // Total n. of selected particles | |
397 | Int_t nParents = 0; // Selected parents | |
398 | Int_t nTkbles = 0; // Trackable particles | |
399 | if (fProcess != kPyMb && fProcess != kPyJets && | |
400 | fProcess != kPyDirectGamma && | |
589380c6 | 401 | fProcess != kPyMbNonDiffr && |
402 | fProcess != kPyW) { | |
8d2cd130 | 403 | |
5fa4b20b | 404 | for (i = 0; i < np; i++) { |
2590ccf9 | 405 | TParticle* iparticle = (TParticle *) fParticles->At(i); |
8d2cd130 | 406 | Int_t ks = iparticle->GetStatusCode(); |
407 | kf = CheckPDGCode(iparticle->GetPdgCode()); | |
408 | // No initial state partons | |
409 | if (ks==21) continue; | |
410 | // | |
411 | // Heavy Flavor Selection | |
412 | // | |
413 | // quark ? | |
414 | kf = TMath::Abs(kf); | |
415 | Int_t kfl = kf; | |
9ff6c04c | 416 | // Resonance |
417 | if (kfl > 100000) kfl %= 100000; | |
183a5ca9 | 418 | if (kfl > 10000) kfl %= 10000; |
8d2cd130 | 419 | // meson ? |
420 | if (kfl > 10) kfl/=100; | |
421 | // baryon | |
422 | if (kfl > 10) kfl/=10; | |
8d2cd130 | 423 | Int_t ipa = iparticle->GetFirstMother()-1; |
424 | Int_t kfMo = 0; | |
425 | ||
426 | if (ipa > -1) { | |
427 | TParticle * mother = (TParticle *) fParticles->At(ipa); | |
428 | kfMo = TMath::Abs(mother->GetPdgCode()); | |
429 | } | |
430 | // What to keep in Stack? | |
431 | Bool_t flavorOK = kFALSE; | |
432 | Bool_t selectOK = kFALSE; | |
433 | if (fFeedDownOpt) { | |
32d6ef7d | 434 | if (kfl >= fFlavorSelect) flavorOK = kTRUE; |
8d2cd130 | 435 | } else { |
32d6ef7d | 436 | if (kfl > fFlavorSelect) { |
437 | nc = -1; | |
438 | break; | |
439 | } | |
440 | if (kfl == fFlavorSelect) flavorOK = kTRUE; | |
8d2cd130 | 441 | } |
442 | switch (fStackFillOpt) { | |
443 | case kFlavorSelection: | |
32d6ef7d | 444 | selectOK = kTRUE; |
445 | break; | |
8d2cd130 | 446 | case kParentSelection: |
32d6ef7d | 447 | if (ParentSelected(kf) || kf <= 10) selectOK = kTRUE; |
448 | break; | |
8d2cd130 | 449 | } |
450 | if (flavorOK && selectOK) { | |
451 | // | |
452 | // Heavy flavor hadron or quark | |
453 | // | |
454 | // Kinematic seletion on final state heavy flavor mesons | |
455 | if (ParentSelected(kf) && !KinematicSelection(iparticle, 0)) | |
456 | { | |
9ff6c04c | 457 | continue; |
8d2cd130 | 458 | } |
459 | pSelected[i] = 1; | |
460 | if (ParentSelected(kf)) ++nParents; // Update parent count | |
461 | // printf("\n particle (HF) %d %d %d", i, pSelected[i], kf); | |
462 | } else { | |
463 | // Kinematic seletion on decay products | |
464 | if (fCutOnChild && ParentSelected(kfMo) && ChildSelected(kf) | |
9ff6c04c | 465 | && !KinematicSelection(iparticle, 1)) |
8d2cd130 | 466 | { |
9ff6c04c | 467 | continue; |
8d2cd130 | 468 | } |
469 | // | |
470 | // Decay products | |
471 | // Select if mother was selected and is not tracked | |
472 | ||
473 | if (pSelected[ipa] && | |
474 | !trackIt[ipa] && // mother will be tracked ? | |
475 | kfMo != 5 && // mother is b-quark, don't store fragments | |
476 | kfMo != 4 && // mother is c-quark, don't store fragments | |
477 | kf != 92) // don't store string | |
478 | { | |
479 | // | |
480 | // Semi-stable or de-selected: diselect decay products: | |
481 | // | |
482 | // | |
483 | if (pSelected[i] == -1 || fDecayer->GetLifetime(kf) > fMaxLifeTime) | |
484 | { | |
485 | Int_t ipF = iparticle->GetFirstDaughter(); | |
486 | Int_t ipL = iparticle->GetLastDaughter(); | |
487 | if (ipF > 0) for (j = ipF-1; j < ipL; j++) pSelected[j] = -1; | |
488 | } | |
489 | // printf("\n particle (decay) %d %d %d", i, pSelected[i], kf); | |
490 | pSelected[i] = (pSelected[i] == -1) ? 0 : 1; | |
491 | } | |
492 | } | |
493 | if (pSelected[i] == -1) pSelected[i] = 0; | |
494 | if (!pSelected[i]) continue; | |
495 | // Count quarks only if you did not include fragmentation | |
496 | if (fFragmentation && kf <= 10) continue; | |
9ff6c04c | 497 | |
8d2cd130 | 498 | nc++; |
499 | // Decision on tracking | |
500 | trackIt[i] = 0; | |
501 | // | |
502 | // Track final state particle | |
503 | if (ks == 1) trackIt[i] = 1; | |
504 | // Track semi-stable particles | |
d25cfd65 | 505 | if ((ks == 1) || (fDecayer->GetLifetime(kf) > fMaxLifeTime)) trackIt[i] = 1; |
8d2cd130 | 506 | // Track particles selected by process if undecayed. |
507 | if (fForceDecay == kNoDecay) { | |
508 | if (ParentSelected(kf)) trackIt[i] = 1; | |
509 | } else { | |
510 | if (ParentSelected(kf)) trackIt[i] = 0; | |
511 | } | |
512 | if (trackIt[i] == 1) ++nTkbles; // Update trackable counter | |
513 | // | |
514 | // | |
515 | ||
516 | } // particle selection loop | |
517 | if (nc > 0) { | |
518 | for (i = 0; i<np; i++) { | |
519 | if (!pSelected[i]) continue; | |
520 | TParticle * iparticle = (TParticle *) fParticles->At(i); | |
521 | kf = CheckPDGCode(iparticle->GetPdgCode()); | |
522 | Int_t ks = iparticle->GetStatusCode(); | |
523 | p[0] = iparticle->Px(); | |
524 | p[1] = iparticle->Py(); | |
525 | p[2] = iparticle->Pz(); | |
a920faf9 | 526 | p[3] = iparticle->Energy(); |
527 | ||
2590ccf9 | 528 | origin[0] = fVertex[0]+iparticle->Vx()/10; // [cm] |
529 | origin[1] = fVertex[1]+iparticle->Vy()/10; // [cm] | |
530 | origin[2] = fVertex[2]+iparticle->Vz()/10; // [cm] | |
531 | ||
8d2cd130 | 532 | Float_t tof = kconv*iparticle->T(); |
533 | Int_t ipa = iparticle->GetFirstMother()-1; | |
534 | Int_t iparent = (ipa > -1) ? pParent[ipa] : -1; | |
a920faf9 | 535 | |
536 | PushTrack(fTrackIt*trackIt[i], iparent, kf, | |
537 | p[0], p[1], p[2], p[3], | |
538 | origin[0], origin[1], origin[2], tof, | |
539 | polar[0], polar[1], polar[2], | |
540 | kPPrimary, nt, 1., ks); | |
8d2cd130 | 541 | pParent[i] = nt; |
542 | KeepTrack(nt); | |
642f15cf | 543 | } // PushTrack loop |
8d2cd130 | 544 | } |
545 | } else { | |
546 | nc = GenerateMB(); | |
547 | } // mb ? | |
548 | ||
549 | if (pParent) delete[] pParent; | |
550 | if (pSelected) delete[] pSelected; | |
551 | if (trackIt) delete[] trackIt; | |
552 | ||
553 | if (nc > 0) { | |
554 | switch (fCountMode) { | |
555 | case kCountAll: | |
556 | // printf(" Count all \n"); | |
557 | jev += nc; | |
558 | break; | |
559 | case kCountParents: | |
560 | // printf(" Count parents \n"); | |
561 | jev += nParents; | |
562 | break; | |
563 | case kCountTrackables: | |
564 | // printf(" Count trackable \n"); | |
565 | jev += nTkbles; | |
566 | break; | |
567 | } | |
568 | if (jev >= fNpart || fNpart == -1) { | |
569 | fKineBias=Float_t(fNpart)/Float_t(fTrials); | |
570 | printf("\n Trials: %i %i %i\n",fTrials, fNpart, jev); | |
571 | ||
572 | fQ += fPythia->GetVINT(51); | |
573 | fX1 += fPythia->GetVINT(41); | |
574 | fX2 += fPythia->GetVINT(42); | |
575 | fTrialsRun += fTrials; | |
576 | fNev++; | |
577 | MakeHeader(); | |
578 | break; | |
579 | } | |
580 | } | |
581 | } // event loop | |
582 | SetHighWaterMark(nt); | |
583 | // adjust weight due to kinematic selection | |
b88f5cea | 584 | // AdjustWeights(); |
8d2cd130 | 585 | // get cross-section |
586 | fXsection=fPythia->GetPARI(1); | |
587 | } | |
588 | ||
589 | Int_t AliGenPythia::GenerateMB() | |
590 | { | |
591 | // | |
592 | // Min Bias selection and other global selections | |
593 | // | |
594 | Int_t i, kf, nt, iparent; | |
595 | Int_t nc = 0; | |
bf950da8 | 596 | Float_t p[4]; |
8d2cd130 | 597 | Float_t polar[3] = {0,0,0}; |
598 | Float_t origin[3] = {0,0,0}; | |
599 | // converts from mm/c to s | |
600 | const Float_t kconv=0.001/2.999792458e8; | |
601 | ||
5fa4b20b | 602 | |
603 | ||
604 | Int_t np = (fHadronisation) ? fParticles->GetEntriesFast() : fNpartons; | |
605 | ||
606 | ||
8d2cd130 | 607 | Int_t* pParent = new Int_t[np]; |
608 | for (i=0; i< np; i++) pParent[i] = -1; | |
609 | if (fProcess == kPyJets || fProcess == kPyDirectGamma) { | |
610 | TParticle* jet1 = (TParticle *) fParticles->At(6); | |
611 | TParticle* jet2 = (TParticle *) fParticles->At(7); | |
612 | if (!CheckTrigger(jet1, jet2)) return 0; | |
613 | } | |
614 | ||
615 | for (i = 0; i<np; i++) { | |
616 | Int_t trackIt = 0; | |
617 | TParticle * iparticle = (TParticle *) fParticles->At(i); | |
618 | kf = CheckPDGCode(iparticle->GetPdgCode()); | |
619 | Int_t ks = iparticle->GetStatusCode(); | |
620 | Int_t km = iparticle->GetFirstMother(); | |
621 | if ((ks == 1 && kf!=0 && KinematicSelection(iparticle, 0)) || | |
622 | (ks != 1) || | |
623 | (fProcess == kPyJets && ks == 21 && km == 0 && i>1)) { | |
624 | nc++; | |
625 | if (ks == 1) trackIt = 1; | |
626 | Int_t ipa = iparticle->GetFirstMother()-1; | |
627 | ||
628 | iparent = (ipa > -1) ? pParent[ipa] : -1; | |
629 | ||
630 | // | |
631 | // store track information | |
632 | p[0] = iparticle->Px(); | |
633 | p[1] = iparticle->Py(); | |
634 | p[2] = iparticle->Pz(); | |
a920faf9 | 635 | p[3] = iparticle->Energy(); |
1406f599 | 636 | |
a920faf9 | 637 | |
2590ccf9 | 638 | origin[0] = fVertex[0]+iparticle->Vx()/10; // [cm] |
639 | origin[1] = fVertex[1]+iparticle->Vy()/10; // [cm] | |
640 | origin[2] = fVertex[2]+iparticle->Vz()/10; // [cm] | |
641 | ||
8d2cd130 | 642 | Float_t tof=kconv*iparticle->T(); |
a920faf9 | 643 | |
644 | PushTrack(fTrackIt*trackIt, iparent, kf, | |
645 | p[0], p[1], p[2], p[3], | |
646 | origin[0], origin[1], origin[2], tof, | |
647 | polar[0], polar[1], polar[2], | |
648 | kPPrimary, nt, 1., ks); | |
5fa4b20b | 649 | // |
650 | // Special Treatment to store color-flow | |
651 | // | |
652 | if (ks == 3 || ks == 13 || ks == 14) { | |
653 | TParticle* particle = 0; | |
654 | if (fStack) { | |
655 | particle = fStack->Particle(nt); | |
656 | } else { | |
657 | particle = gAlice->Stack()->Particle(nt); | |
658 | } | |
659 | particle->SetFirstDaughter(fPythia->GetK(2, i)); | |
660 | particle->SetLastDaughter(fPythia->GetK(3, i)); | |
661 | } | |
662 | ||
8d2cd130 | 663 | KeepTrack(nt); |
664 | pParent[i] = nt; | |
665 | } // select particle | |
666 | } // particle loop | |
667 | ||
668 | if (pParent) delete[] pParent; | |
669 | ||
670 | printf("\n I've put %i particles on the stack \n",nc); | |
671 | return nc; | |
672 | } | |
673 | ||
674 | ||
675 | void AliGenPythia::FinishRun() | |
676 | { | |
677 | // Print x-section summary | |
678 | fPythia->Pystat(1); | |
2779fc64 | 679 | |
680 | if (fNev > 0.) { | |
681 | fQ /= fNev; | |
682 | fX1 /= fNev; | |
683 | fX2 /= fNev; | |
684 | } | |
685 | ||
8d2cd130 | 686 | printf("\nTotal number of Pyevnt() calls %d\n", fTrialsRun); |
687 | printf("\nMean Q, x1, x2: %f %f %f\n", fQ, fX1, fX2); | |
8d2cd130 | 688 | } |
689 | ||
690 | void AliGenPythia::AdjustWeights() | |
691 | { | |
692 | // Adjust the weights after generation of all events | |
693 | // | |
e2bddf81 | 694 | if (gAlice) { |
695 | TParticle *part; | |
696 | Int_t ntrack=gAlice->GetMCApp()->GetNtrack(); | |
697 | for (Int_t i=0; i<ntrack; i++) { | |
698 | part= gAlice->GetMCApp()->Particle(i); | |
699 | part->SetWeight(part->GetWeight()*fKineBias); | |
700 | } | |
8d2cd130 | 701 | } |
702 | } | |
703 | ||
704 | void AliGenPythia::SetNuclei(Int_t a1, Int_t a2) | |
705 | { | |
706 | // Treat protons as inside nuclei with mass numbers a1 and a2 | |
1d568bc2 | 707 | |
1a626d4e | 708 | fAProjectile = a1; |
709 | fATarget = a2; | |
1d568bc2 | 710 | fSetNuclei = kTRUE; |
8d2cd130 | 711 | } |
712 | ||
713 | ||
714 | void AliGenPythia::MakeHeader() | |
715 | { | |
183a5ca9 | 716 | if (gAlice) { |
717 | if (gAlice->GetEvNumber()>=fDebugEventFirst && | |
718 | gAlice->GetEvNumber()<=fDebugEventLast) fPythia->Pylist(1); | |
719 | } | |
720 | ||
8d2cd130 | 721 | // Builds the event header, to be called after each event |
e5c87a3d | 722 | if (fHeader) delete fHeader; |
723 | fHeader = new AliGenPythiaEventHeader("Pythia"); | |
8d2cd130 | 724 | // |
725 | // Event type | |
e5c87a3d | 726 | ((AliGenPythiaEventHeader*) fHeader)->SetProcessType(fPythia->GetMSTI(1)); |
8d2cd130 | 727 | // |
728 | // Number of trials | |
e5c87a3d | 729 | ((AliGenPythiaEventHeader*) fHeader)->SetTrials(fTrials); |
8d2cd130 | 730 | // |
731 | // Event Vertex | |
d25cfd65 | 732 | fHeader->SetPrimaryVertex(fVertex); |
8d2cd130 | 733 | // |
734 | // Jets that have triggered | |
735 | if (fProcess == kPyJets) | |
736 | { | |
737 | Int_t ntrig, njet; | |
738 | Float_t jets[4][10]; | |
739 | GetJets(njet, ntrig, jets); | |
9ff6c04c | 740 | |
8d2cd130 | 741 | |
742 | for (Int_t i = 0; i < ntrig; i++) { | |
e5c87a3d | 743 | ((AliGenPythiaEventHeader*) fHeader)->AddJet(jets[0][i], jets[1][i], jets[2][i], |
8d2cd130 | 744 | jets[3][i]); |
745 | } | |
746 | } | |
5fa4b20b | 747 | // |
748 | // Copy relevant information from external header, if present. | |
749 | // | |
750 | Float_t uqJet[4]; | |
751 | ||
752 | if (fRL) { | |
753 | AliGenPythiaEventHeader* exHeader = (AliGenPythiaEventHeader*) (fRL->GetHeader()->GenEventHeader()); | |
754 | for (Int_t i = 0; i < exHeader->NTriggerJets(); i++) | |
755 | { | |
756 | printf("Adding Jet %d %d \n", i, exHeader->NTriggerJets()); | |
757 | ||
758 | ||
759 | exHeader->TriggerJet(i, uqJet); | |
760 | ((AliGenPythiaEventHeader*) fHeader)->AddUQJet(uqJet[0], uqJet[1], uqJet[2], uqJet[3]); | |
761 | } | |
762 | } | |
763 | // | |
764 | // Store quenching parameters | |
765 | // | |
766 | if (fQuench){ | |
767 | Double_t z[4]; | |
768 | Double_t xp, yp; | |
7c21f297 | 769 | if (fQuench == 1) { |
770 | // Pythia::Quench() | |
771 | fPythia->GetQuenchingParameters(xp, yp, z); | |
772 | } else { | |
773 | // Pyquen | |
774 | Double_t r1 = PARIMP.rb1; | |
775 | Double_t r2 = PARIMP.rb2; | |
776 | Double_t b = PARIMP.b1; | |
777 | Double_t r = 0.5 * TMath::Sqrt(2. * (r1 * r1 + r2 * r2) - b * b); | |
778 | Double_t phi = PARIMP.psib1; | |
779 | xp = r * TMath::Cos(phi); | |
780 | yp = r * TMath::Sin(phi); | |
781 | ||
782 | } | |
783 | ((AliGenPythiaEventHeader*) fHeader)->SetXYJet(xp, yp); | |
784 | ((AliGenPythiaEventHeader*) fHeader)->SetZQuench(z); | |
785 | } | |
5fa4b20b | 786 | |
787 | // | |
788 | // Pass header to RunLoader | |
789 | // | |
790 | AliRunLoader::GetRunLoader()->GetHeader()->SetGenEventHeader(fHeader); | |
8d2cd130 | 791 | } |
792 | ||
793 | ||
794 | Bool_t AliGenPythia::CheckTrigger(TParticle* jet1, TParticle* jet2) | |
795 | { | |
796 | // Check the kinematic trigger condition | |
797 | // | |
798 | Double_t eta[2]; | |
799 | eta[0] = jet1->Eta(); | |
800 | eta[1] = jet2->Eta(); | |
801 | Double_t phi[2]; | |
802 | phi[0] = jet1->Phi(); | |
803 | phi[1] = jet2->Phi(); | |
804 | Int_t pdg[2]; | |
805 | pdg[0] = jet1->GetPdgCode(); | |
806 | pdg[1] = jet2->GetPdgCode(); | |
807 | Bool_t triggered = kFALSE; | |
808 | ||
809 | if (fProcess == kPyJets) { | |
810 | Int_t njets = 0; | |
811 | Int_t ntrig = 0; | |
812 | Float_t jets[4][10]; | |
813 | // | |
814 | // Use Pythia clustering on parton level to determine jet axis | |
815 | // | |
816 | GetJets(njets, ntrig, jets); | |
817 | ||
818 | if (ntrig) triggered = kTRUE; | |
819 | // | |
820 | } else { | |
821 | Int_t ij = 0; | |
822 | Int_t ig = 1; | |
823 | if (pdg[0] == kGamma) { | |
824 | ij = 1; | |
825 | ig = 0; | |
826 | } | |
827 | //Check eta range first... | |
828 | if ((eta[ij] < fEtaMaxJet && eta[ij] > fEtaMinJet) && | |
829 | (eta[ig] < fEtaMaxGamma && eta[ig] > fEtaMinGamma)) | |
830 | { | |
831 | //Eta is okay, now check phi range | |
832 | if ((phi[ij] < fPhiMaxJet && phi[ij] > fPhiMinJet) && | |
833 | (phi[ig] < fPhiMaxGamma && phi[ig] > fPhiMinGamma)) | |
834 | { | |
835 | triggered = kTRUE; | |
836 | } | |
837 | } | |
838 | } | |
839 | return triggered; | |
840 | } | |
841 | ||
842 | AliGenPythia& AliGenPythia::operator=(const AliGenPythia& rhs) | |
843 | { | |
844 | // Assignment operator | |
014a9521 | 845 | rhs.Copy(*this); |
8d2cd130 | 846 | return *this; |
847 | } | |
848 | ||
5fa4b20b | 849 | void AliGenPythia::LoadEvent(AliStack* stack, Int_t flag, Int_t reHadr) |
8d2cd130 | 850 | { |
851 | // | |
852 | // Load event into Pythia Common Block | |
853 | // | |
5fa4b20b | 854 | |
32d6ef7d | 855 | Int_t npart = stack -> GetNprimary(); |
856 | Int_t n0 = 0; | |
857 | ||
858 | if (!flag) { | |
859 | (fPythia->GetPyjets())->N = npart; | |
860 | } else { | |
861 | n0 = (fPythia->GetPyjets())->N; | |
862 | (fPythia->GetPyjets())->N = n0 + npart; | |
863 | } | |
864 | ||
865 | ||
8d2cd130 | 866 | for (Int_t part = 0; part < npart; part++) { |
32d6ef7d | 867 | TParticle *MPart = stack->Particle(part); |
868 | ||
5fa4b20b | 869 | Int_t kf = MPart->GetPdgCode(); |
870 | Int_t ks = MPart->GetStatusCode(); | |
871 | Int_t idf = MPart->GetFirstDaughter(); | |
872 | Int_t idl = MPart->GetLastDaughter(); | |
873 | ||
874 | if (reHadr) { | |
875 | if (ks == 11 || ks == 12) { | |
876 | ks -= 10; | |
877 | idf = -1; | |
878 | idl = -1; | |
879 | } | |
880 | } | |
32d6ef7d | 881 | |
8d2cd130 | 882 | Float_t px = MPart->Px(); |
883 | Float_t py = MPart->Py(); | |
884 | Float_t pz = MPart->Pz(); | |
885 | Float_t e = MPart->Energy(); | |
a920faf9 | 886 | Float_t m = MPart->GetCalcMass(); |
8d2cd130 | 887 | |
888 | ||
32d6ef7d | 889 | (fPythia->GetPyjets())->P[0][part+n0] = px; |
890 | (fPythia->GetPyjets())->P[1][part+n0] = py; | |
891 | (fPythia->GetPyjets())->P[2][part+n0] = pz; | |
892 | (fPythia->GetPyjets())->P[3][part+n0] = e; | |
893 | (fPythia->GetPyjets())->P[4][part+n0] = m; | |
8d2cd130 | 894 | |
32d6ef7d | 895 | (fPythia->GetPyjets())->K[1][part+n0] = kf; |
896 | (fPythia->GetPyjets())->K[0][part+n0] = ks; | |
5fa4b20b | 897 | (fPythia->GetPyjets())->K[3][part+n0] = idf + 1; |
898 | (fPythia->GetPyjets())->K[4][part+n0] = idl + 1; | |
899 | (fPythia->GetPyjets())->K[2][part+n0] = MPart->GetFirstMother() + 1; | |
8d2cd130 | 900 | } |
901 | } | |
902 | ||
5fa4b20b | 903 | |
014a9521 | 904 | void AliGenPythia::RecJetsUA1(Int_t& njets, Float_t jets [4][50]) |
8d2cd130 | 905 | { |
906 | // | |
907 | // Calls the Pythia jet finding algorithm to find jets in the current event | |
908 | // | |
909 | // | |
8d2cd130 | 910 | // |
911 | // Save jets | |
912 | Int_t n = fPythia->GetN(); | |
913 | ||
914 | // | |
915 | // Run Jet Finder | |
916 | fPythia->Pycell(njets); | |
917 | Int_t i; | |
918 | for (i = 0; i < njets; i++) { | |
919 | Float_t px = (fPythia->GetPyjets())->P[0][n+i]; | |
920 | Float_t py = (fPythia->GetPyjets())->P[1][n+i]; | |
921 | Float_t pz = (fPythia->GetPyjets())->P[2][n+i]; | |
922 | Float_t e = (fPythia->GetPyjets())->P[3][n+i]; | |
923 | ||
924 | jets[0][i] = px; | |
925 | jets[1][i] = py; | |
926 | jets[2][i] = pz; | |
927 | jets[3][i] = e; | |
928 | } | |
929 | } | |
930 | ||
931 | ||
932 | ||
933 | void AliGenPythia::GetJets(Int_t& nJets, Int_t& nJetsTrig, Float_t jets[4][10]) | |
934 | { | |
935 | // | |
936 | // Calls the Pythia clustering algorithm to find jets in the current event | |
937 | // | |
938 | Int_t n = fPythia->GetN(); | |
939 | nJets = 0; | |
940 | nJetsTrig = 0; | |
941 | if (fJetReconstruction == kCluster) { | |
942 | // | |
943 | // Configure cluster algorithm | |
944 | // | |
945 | fPythia->SetPARU(43, 2.); | |
946 | fPythia->SetMSTU(41, 1); | |
947 | // | |
948 | // Call cluster algorithm | |
949 | // | |
950 | fPythia->Pyclus(nJets); | |
951 | // | |
952 | // Loading jets from common block | |
953 | // | |
954 | } else { | |
592f8307 | 955 | |
8d2cd130 | 956 | // |
957 | // Run Jet Finder | |
958 | fPythia->Pycell(nJets); | |
959 | } | |
960 | ||
961 | Int_t i; | |
962 | for (i = 0; i < nJets; i++) { | |
963 | Float_t px = (fPythia->GetPyjets())->P[0][n+i]; | |
964 | Float_t py = (fPythia->GetPyjets())->P[1][n+i]; | |
965 | Float_t pz = (fPythia->GetPyjets())->P[2][n+i]; | |
966 | Float_t e = (fPythia->GetPyjets())->P[3][n+i]; | |
967 | Float_t pt = TMath::Sqrt(px * px + py * py); | |
a920faf9 | 968 | Float_t phi = TMath::Pi() + TMath::ATan2(-py, -px); |
8d2cd130 | 969 | Float_t theta = TMath::ATan2(pt,pz); |
970 | Float_t et = e * TMath::Sin(theta); | |
971 | Float_t eta = -TMath::Log(TMath::Tan(theta / 2.)); | |
8d2cd130 | 972 | if ( |
973 | eta > fEtaMinJet && eta < fEtaMaxJet && | |
675eb105 | 974 | phi > fPhiMinJet && phi < fPhiMaxJet && |
8d2cd130 | 975 | et > fEtMinJet && et < fEtMaxJet |
976 | ) | |
977 | { | |
978 | jets[0][nJetsTrig] = px; | |
979 | jets[1][nJetsTrig] = py; | |
980 | jets[2][nJetsTrig] = pz; | |
981 | jets[3][nJetsTrig] = e; | |
982 | nJetsTrig++; | |
5fa4b20b | 983 | // printf("\n........-Jet #%d: %10.3f %10.3f %10.3f %10.3f \n", i, pt, et, eta, phi * kRaddeg); |
8d2cd130 | 984 | } else { |
985 | // printf("\n........-Jet #%d: %10.3f %10.3f %10.3f %10.3f \n", i, pt, et, eta, phi * kRaddeg); | |
986 | } | |
987 | } | |
988 | } | |
989 | ||
990 | ||
991 | #ifdef never | |
992 | void AliGenPythia::Streamer(TBuffer &R__b) | |
993 | { | |
994 | // Stream an object of class AliGenPythia. | |
995 | ||
996 | if (R__b.IsReading()) { | |
997 | Version_t R__v = R__b.ReadVersion(); if (R__v) { } | |
998 | AliGenerator::Streamer(R__b); | |
999 | R__b >> (Int_t&)fProcess; | |
1000 | R__b >> (Int_t&)fStrucFunc; | |
1001 | R__b >> (Int_t&)fForceDecay; | |
1002 | R__b >> fEnergyCMS; | |
1003 | R__b >> fKineBias; | |
1004 | R__b >> fTrials; | |
1005 | fParentSelect.Streamer(R__b); | |
1006 | fChildSelect.Streamer(R__b); | |
1007 | R__b >> fXsection; | |
1008 | // (AliPythia::Instance())->Streamer(R__b); | |
1009 | R__b >> fPtHardMin; | |
1010 | R__b >> fPtHardMax; | |
1011 | // if (fDecayer) fDecayer->Streamer(R__b); | |
1012 | } else { | |
1013 | R__b.WriteVersion(AliGenPythia::IsA()); | |
1014 | AliGenerator::Streamer(R__b); | |
1015 | R__b << (Int_t)fProcess; | |
1016 | R__b << (Int_t)fStrucFunc; | |
1017 | R__b << (Int_t)fForceDecay; | |
1018 | R__b << fEnergyCMS; | |
1019 | R__b << fKineBias; | |
1020 | R__b << fTrials; | |
1021 | fParentSelect.Streamer(R__b); | |
1022 | fChildSelect.Streamer(R__b); | |
1023 | R__b << fXsection; | |
1024 | // R__b << fPythia; | |
1025 | R__b << fPtHardMin; | |
1026 | R__b << fPtHardMax; | |
1027 | // fDecayer->Streamer(R__b); | |
1028 | } | |
1029 | } | |
1030 | #endif | |
1031 | ||
90d7b703 | 1032 | |
589380c6 | 1033 |