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