]>
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" | |
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}; | |
a920faf9 | 292 | Float_t p[4]; |
8d2cd130 | 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(); | |
a920faf9 | 485 | p[3] = iparticle->Energy(); |
486 | ||
8d2cd130 | 487 | origin[0] = fOrigin[0]+iparticle->Vx()/10.; |
488 | origin[1] = fOrigin[1]+iparticle->Vy()/10.; | |
489 | origin[2] = fOrigin[2]+iparticle->Vz()/10.; | |
490 | Float_t tof = kconv*iparticle->T(); | |
491 | Int_t ipa = iparticle->GetFirstMother()-1; | |
492 | Int_t iparent = (ipa > -1) ? pParent[ipa] : -1; | |
a920faf9 | 493 | |
494 | PushTrack(fTrackIt*trackIt[i], iparent, kf, | |
495 | p[0], p[1], p[2], p[3], | |
496 | origin[0], origin[1], origin[2], tof, | |
497 | polar[0], polar[1], polar[2], | |
498 | kPPrimary, nt, 1., ks); | |
8d2cd130 | 499 | pParent[i] = nt; |
500 | KeepTrack(nt); | |
642f15cf | 501 | } // PushTrack loop |
8d2cd130 | 502 | } |
503 | } else { | |
504 | nc = GenerateMB(); | |
505 | } // mb ? | |
506 | ||
507 | if (pParent) delete[] pParent; | |
508 | if (pSelected) delete[] pSelected; | |
509 | if (trackIt) delete[] trackIt; | |
510 | ||
511 | if (nc > 0) { | |
512 | switch (fCountMode) { | |
513 | case kCountAll: | |
514 | // printf(" Count all \n"); | |
515 | jev += nc; | |
516 | break; | |
517 | case kCountParents: | |
518 | // printf(" Count parents \n"); | |
519 | jev += nParents; | |
520 | break; | |
521 | case kCountTrackables: | |
522 | // printf(" Count trackable \n"); | |
523 | jev += nTkbles; | |
524 | break; | |
525 | } | |
526 | if (jev >= fNpart || fNpart == -1) { | |
527 | fKineBias=Float_t(fNpart)/Float_t(fTrials); | |
528 | printf("\n Trials: %i %i %i\n",fTrials, fNpart, jev); | |
529 | ||
530 | fQ += fPythia->GetVINT(51); | |
531 | fX1 += fPythia->GetVINT(41); | |
532 | fX2 += fPythia->GetVINT(42); | |
533 | fTrialsRun += fTrials; | |
534 | fNev++; | |
535 | MakeHeader(); | |
536 | break; | |
537 | } | |
538 | } | |
539 | } // event loop | |
540 | SetHighWaterMark(nt); | |
541 | // adjust weight due to kinematic selection | |
b88f5cea | 542 | // AdjustWeights(); |
8d2cd130 | 543 | // get cross-section |
544 | fXsection=fPythia->GetPARI(1); | |
545 | } | |
546 | ||
547 | Int_t AliGenPythia::GenerateMB() | |
548 | { | |
549 | // | |
550 | // Min Bias selection and other global selections | |
551 | // | |
552 | Int_t i, kf, nt, iparent; | |
553 | Int_t nc = 0; | |
554 | Float_t p[3]; | |
555 | Float_t polar[3] = {0,0,0}; | |
556 | Float_t origin[3] = {0,0,0}; | |
557 | // converts from mm/c to s | |
558 | const Float_t kconv=0.001/2.999792458e8; | |
559 | ||
560 | Int_t np = fParticles->GetEntriesFast(); | |
561 | Int_t* pParent = new Int_t[np]; | |
562 | for (i=0; i< np; i++) pParent[i] = -1; | |
563 | if (fProcess == kPyJets || fProcess == kPyDirectGamma) { | |
564 | TParticle* jet1 = (TParticle *) fParticles->At(6); | |
565 | TParticle* jet2 = (TParticle *) fParticles->At(7); | |
566 | if (!CheckTrigger(jet1, jet2)) return 0; | |
567 | } | |
568 | ||
569 | for (i = 0; i<np; i++) { | |
570 | Int_t trackIt = 0; | |
571 | TParticle * iparticle = (TParticle *) fParticles->At(i); | |
572 | kf = CheckPDGCode(iparticle->GetPdgCode()); | |
573 | Int_t ks = iparticle->GetStatusCode(); | |
574 | Int_t km = iparticle->GetFirstMother(); | |
575 | if ((ks == 1 && kf!=0 && KinematicSelection(iparticle, 0)) || | |
576 | (ks != 1) || | |
577 | (fProcess == kPyJets && ks == 21 && km == 0 && i>1)) { | |
578 | nc++; | |
579 | if (ks == 1) trackIt = 1; | |
580 | Int_t ipa = iparticle->GetFirstMother()-1; | |
581 | ||
582 | iparent = (ipa > -1) ? pParent[ipa] : -1; | |
583 | ||
584 | // | |
585 | // store track information | |
586 | p[0] = iparticle->Px(); | |
587 | p[1] = iparticle->Py(); | |
588 | p[2] = iparticle->Pz(); | |
a920faf9 | 589 | p[3] = iparticle->Energy(); |
590 | ||
8d2cd130 | 591 | origin[0] = fOrigin[0]+iparticle->Vx()/10.; |
592 | origin[1] = fOrigin[1]+iparticle->Vy()/10.; | |
593 | origin[2] = fOrigin[2]+iparticle->Vz()/10.; | |
594 | Float_t tof=kconv*iparticle->T(); | |
a920faf9 | 595 | |
596 | PushTrack(fTrackIt*trackIt, iparent, kf, | |
597 | p[0], p[1], p[2], p[3], | |
598 | origin[0], origin[1], origin[2], tof, | |
599 | polar[0], polar[1], polar[2], | |
600 | kPPrimary, nt, 1., ks); | |
8d2cd130 | 601 | KeepTrack(nt); |
602 | pParent[i] = nt; | |
603 | } // select particle | |
604 | } // particle loop | |
605 | ||
606 | if (pParent) delete[] pParent; | |
607 | ||
608 | printf("\n I've put %i particles on the stack \n",nc); | |
609 | return nc; | |
610 | } | |
611 | ||
612 | ||
613 | void AliGenPythia::FinishRun() | |
614 | { | |
615 | // Print x-section summary | |
616 | fPythia->Pystat(1); | |
617 | fQ /= fNev; | |
618 | fX1 /= fNev; | |
619 | fX2 /= fNev; | |
620 | printf("\nTotal number of Pyevnt() calls %d\n", fTrialsRun); | |
621 | printf("\nMean Q, x1, x2: %f %f %f\n", fQ, fX1, fX2); | |
622 | ||
623 | ||
624 | } | |
625 | ||
626 | void AliGenPythia::AdjustWeights() | |
627 | { | |
628 | // Adjust the weights after generation of all events | |
629 | // | |
630 | TParticle *part; | |
5d12ce38 | 631 | Int_t ntrack=gAlice->GetMCApp()->GetNtrack(); |
8d2cd130 | 632 | for (Int_t i=0; i<ntrack; i++) { |
5d12ce38 | 633 | part= gAlice->GetMCApp()->Particle(i); |
8d2cd130 | 634 | part->SetWeight(part->GetWeight()*fKineBias); |
635 | } | |
636 | } | |
637 | ||
638 | void AliGenPythia::SetNuclei(Int_t a1, Int_t a2) | |
639 | { | |
640 | // Treat protons as inside nuclei with mass numbers a1 and a2 | |
1d568bc2 | 641 | |
1a626d4e | 642 | fAProjectile = a1; |
643 | fATarget = a2; | |
1d568bc2 | 644 | fSetNuclei = kTRUE; |
8d2cd130 | 645 | } |
646 | ||
647 | ||
648 | void AliGenPythia::MakeHeader() | |
649 | { | |
650 | // Builds the event header, to be called after each event | |
e5c87a3d | 651 | if (fHeader) delete fHeader; |
652 | fHeader = new AliGenPythiaEventHeader("Pythia"); | |
8d2cd130 | 653 | // |
654 | // Event type | |
e5c87a3d | 655 | ((AliGenPythiaEventHeader*) fHeader)->SetProcessType(fPythia->GetMSTI(1)); |
8d2cd130 | 656 | // |
657 | // Number of trials | |
e5c87a3d | 658 | ((AliGenPythiaEventHeader*) fHeader)->SetTrials(fTrials); |
8d2cd130 | 659 | // |
660 | // Event Vertex | |
d25cfd65 | 661 | fHeader->SetPrimaryVertex(fVertex); |
8d2cd130 | 662 | // |
663 | // Jets that have triggered | |
664 | if (fProcess == kPyJets) | |
665 | { | |
666 | Int_t ntrig, njet; | |
667 | Float_t jets[4][10]; | |
668 | GetJets(njet, ntrig, jets); | |
669 | ||
670 | for (Int_t i = 0; i < ntrig; i++) { | |
e5c87a3d | 671 | ((AliGenPythiaEventHeader*) fHeader)->AddJet(jets[0][i], jets[1][i], jets[2][i], |
8d2cd130 | 672 | jets[3][i]); |
673 | } | |
674 | } | |
e5c87a3d | 675 | gAlice->SetGenEventHeader(fHeader); |
8d2cd130 | 676 | } |
677 | ||
678 | ||
679 | Bool_t AliGenPythia::CheckTrigger(TParticle* jet1, TParticle* jet2) | |
680 | { | |
681 | // Check the kinematic trigger condition | |
682 | // | |
683 | Double_t eta[2]; | |
684 | eta[0] = jet1->Eta(); | |
685 | eta[1] = jet2->Eta(); | |
686 | Double_t phi[2]; | |
687 | phi[0] = jet1->Phi(); | |
688 | phi[1] = jet2->Phi(); | |
689 | Int_t pdg[2]; | |
690 | pdg[0] = jet1->GetPdgCode(); | |
691 | pdg[1] = jet2->GetPdgCode(); | |
692 | Bool_t triggered = kFALSE; | |
693 | ||
694 | if (fProcess == kPyJets) { | |
695 | Int_t njets = 0; | |
696 | Int_t ntrig = 0; | |
697 | Float_t jets[4][10]; | |
698 | // | |
699 | // Use Pythia clustering on parton level to determine jet axis | |
700 | // | |
701 | GetJets(njets, ntrig, jets); | |
702 | ||
703 | if (ntrig) triggered = kTRUE; | |
704 | // | |
705 | } else { | |
706 | Int_t ij = 0; | |
707 | Int_t ig = 1; | |
708 | if (pdg[0] == kGamma) { | |
709 | ij = 1; | |
710 | ig = 0; | |
711 | } | |
712 | //Check eta range first... | |
713 | if ((eta[ij] < fEtaMaxJet && eta[ij] > fEtaMinJet) && | |
714 | (eta[ig] < fEtaMaxGamma && eta[ig] > fEtaMinGamma)) | |
715 | { | |
716 | //Eta is okay, now check phi range | |
717 | if ((phi[ij] < fPhiMaxJet && phi[ij] > fPhiMinJet) && | |
718 | (phi[ig] < fPhiMaxGamma && phi[ig] > fPhiMinGamma)) | |
719 | { | |
720 | triggered = kTRUE; | |
721 | } | |
722 | } | |
723 | } | |
724 | return triggered; | |
725 | } | |
726 | ||
727 | AliGenPythia& AliGenPythia::operator=(const AliGenPythia& rhs) | |
728 | { | |
729 | // Assignment operator | |
014a9521 | 730 | rhs.Copy(*this); |
8d2cd130 | 731 | return *this; |
732 | } | |
733 | ||
734 | void AliGenPythia::LoadEvent() | |
735 | { | |
736 | // | |
737 | // Load event into Pythia Common Block | |
738 | // | |
739 | ||
7ea3ea5b | 740 | AliRunLoader* rl = AliRunLoader::GetRunLoader(); |
741 | Int_t npart = (rl->Stack())-> GetNprimary(); | |
8d2cd130 | 742 | (fPythia->GetPyjets())->N = npart; |
743 | ||
744 | for (Int_t part = 0; part < npart; part++) { | |
7ea3ea5b | 745 | TParticle *MPart = (rl->Stack())->Particle(part); |
8d2cd130 | 746 | Int_t kf = MPart->GetPdgCode(); |
747 | Int_t ks = MPart->GetStatusCode(); | |
748 | Float_t px = MPart->Px(); | |
749 | Float_t py = MPart->Py(); | |
750 | Float_t pz = MPart->Pz(); | |
751 | Float_t e = MPart->Energy(); | |
a920faf9 | 752 | Float_t m = MPart->GetCalcMass(); |
8d2cd130 | 753 | |
754 | ||
755 | (fPythia->GetPyjets())->P[0][part] = px; | |
756 | (fPythia->GetPyjets())->P[1][part] = py; | |
757 | (fPythia->GetPyjets())->P[2][part] = pz; | |
758 | (fPythia->GetPyjets())->P[3][part] = e; | |
759 | (fPythia->GetPyjets())->P[4][part] = m; | |
760 | ||
761 | (fPythia->GetPyjets())->K[1][part] = kf; | |
762 | (fPythia->GetPyjets())->K[0][part] = ks; | |
763 | } | |
764 | } | |
765 | ||
014a9521 | 766 | void AliGenPythia::RecJetsUA1(Int_t& njets, Float_t jets [4][50]) |
8d2cd130 | 767 | { |
768 | // | |
769 | // Calls the Pythia jet finding algorithm to find jets in the current event | |
770 | // | |
771 | // | |
8d2cd130 | 772 | // |
773 | // Save jets | |
774 | Int_t n = fPythia->GetN(); | |
775 | ||
776 | // | |
777 | // Run Jet Finder | |
778 | fPythia->Pycell(njets); | |
779 | Int_t i; | |
780 | for (i = 0; i < njets; i++) { | |
781 | Float_t px = (fPythia->GetPyjets())->P[0][n+i]; | |
782 | Float_t py = (fPythia->GetPyjets())->P[1][n+i]; | |
783 | Float_t pz = (fPythia->GetPyjets())->P[2][n+i]; | |
784 | Float_t e = (fPythia->GetPyjets())->P[3][n+i]; | |
785 | ||
786 | jets[0][i] = px; | |
787 | jets[1][i] = py; | |
788 | jets[2][i] = pz; | |
789 | jets[3][i] = e; | |
790 | } | |
791 | } | |
792 | ||
793 | ||
794 | ||
795 | void AliGenPythia::GetJets(Int_t& nJets, Int_t& nJetsTrig, Float_t jets[4][10]) | |
796 | { | |
797 | // | |
798 | // Calls the Pythia clustering algorithm to find jets in the current event | |
799 | // | |
800 | Int_t n = fPythia->GetN(); | |
801 | nJets = 0; | |
802 | nJetsTrig = 0; | |
803 | if (fJetReconstruction == kCluster) { | |
804 | // | |
805 | // Configure cluster algorithm | |
806 | // | |
807 | fPythia->SetPARU(43, 2.); | |
808 | fPythia->SetMSTU(41, 1); | |
809 | // | |
810 | // Call cluster algorithm | |
811 | // | |
812 | fPythia->Pyclus(nJets); | |
813 | // | |
814 | // Loading jets from common block | |
815 | // | |
816 | } else { | |
592f8307 | 817 | |
8d2cd130 | 818 | // |
819 | // Run Jet Finder | |
820 | fPythia->Pycell(nJets); | |
821 | } | |
822 | ||
823 | Int_t i; | |
824 | for (i = 0; i < nJets; i++) { | |
825 | Float_t px = (fPythia->GetPyjets())->P[0][n+i]; | |
826 | Float_t py = (fPythia->GetPyjets())->P[1][n+i]; | |
827 | Float_t pz = (fPythia->GetPyjets())->P[2][n+i]; | |
828 | Float_t e = (fPythia->GetPyjets())->P[3][n+i]; | |
829 | Float_t pt = TMath::Sqrt(px * px + py * py); | |
a920faf9 | 830 | Float_t phi = TMath::Pi() + TMath::ATan2(-py, -px); |
8d2cd130 | 831 | Float_t theta = TMath::ATan2(pt,pz); |
832 | Float_t et = e * TMath::Sin(theta); | |
833 | Float_t eta = -TMath::Log(TMath::Tan(theta / 2.)); | |
834 | ||
835 | if ( | |
836 | eta > fEtaMinJet && eta < fEtaMaxJet && | |
675eb105 | 837 | phi > fPhiMinJet && phi < fPhiMaxJet && |
8d2cd130 | 838 | et > fEtMinJet && et < fEtMaxJet |
839 | ) | |
840 | { | |
841 | jets[0][nJetsTrig] = px; | |
842 | jets[1][nJetsTrig] = py; | |
843 | jets[2][nJetsTrig] = pz; | |
844 | jets[3][nJetsTrig] = e; | |
845 | nJetsTrig++; | |
846 | ||
847 | } else { | |
848 | // printf("\n........-Jet #%d: %10.3f %10.3f %10.3f %10.3f \n", i, pt, et, eta, phi * kRaddeg); | |
849 | } | |
850 | } | |
851 | } | |
852 | ||
853 | ||
854 | #ifdef never | |
855 | void AliGenPythia::Streamer(TBuffer &R__b) | |
856 | { | |
857 | // Stream an object of class AliGenPythia. | |
858 | ||
859 | if (R__b.IsReading()) { | |
860 | Version_t R__v = R__b.ReadVersion(); if (R__v) { } | |
861 | AliGenerator::Streamer(R__b); | |
862 | R__b >> (Int_t&)fProcess; | |
863 | R__b >> (Int_t&)fStrucFunc; | |
864 | R__b >> (Int_t&)fForceDecay; | |
865 | R__b >> fEnergyCMS; | |
866 | R__b >> fKineBias; | |
867 | R__b >> fTrials; | |
868 | fParentSelect.Streamer(R__b); | |
869 | fChildSelect.Streamer(R__b); | |
870 | R__b >> fXsection; | |
871 | // (AliPythia::Instance())->Streamer(R__b); | |
872 | R__b >> fPtHardMin; | |
873 | R__b >> fPtHardMax; | |
874 | // if (fDecayer) fDecayer->Streamer(R__b); | |
875 | } else { | |
876 | R__b.WriteVersion(AliGenPythia::IsA()); | |
877 | AliGenerator::Streamer(R__b); | |
878 | R__b << (Int_t)fProcess; | |
879 | R__b << (Int_t)fStrucFunc; | |
880 | R__b << (Int_t)fForceDecay; | |
881 | R__b << fEnergyCMS; | |
882 | R__b << fKineBias; | |
883 | R__b << fTrials; | |
884 | fParentSelect.Streamer(R__b); | |
885 | fChildSelect.Streamer(R__b); | |
886 | R__b << fXsection; | |
887 | // R__b << fPythia; | |
888 | R__b << fPtHardMin; | |
889 | R__b << fPtHardMax; | |
890 | // fDecayer->Streamer(R__b); | |
891 | } | |
892 | } | |
893 | #endif | |
894 |