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