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