1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
19 // Generator using the TPythia interface (via AliPythia)
20 // to generate jets in pp collisions.
21 // Using SetNuclei() also nuclear modifications to the structure functions
22 // can be taken into account.
23 // Using SetQuenchingFactor(f) quenched jets can be modelled by superimposing
24 // two jets with energies e * f and e * (1-f)
26 // andreas.morsch@cern.ch
30 #include "AliGenPythiaJets.h"
32 #include <TParticle.h>
33 #include <TClonesArray.h>
35 ClassImp(AliGenPythiaJets)
37 AliGenPythiaJets::AliGenPythiaJets()
40 // Default Constructor
43 AliGenPythiaJets::AliGenPythiaJets(Int_t npart)
47 fTitle= "Jet Generator using PYTHIA";
50 AliGenPythiaJets::~AliGenPythiaJets()
55 void AliGenPythiaJets::Init()
59 printf("AliGenPythiaJets::Init() \n");
64 fEtMinJetQ[0] = fEtMinJet * fQuench;
65 fEtMaxJetQ[0] = fEtMaxJet * fQuench;
66 fEtMinJetQ[1] = fEtMinJet * (1. - fQuench);
67 fEtMaxJetQ[1] = fEtMaxJet * (1. - fQuench);
68 fPtHardMinQ[0] = fPtHardMin * fQuench;
69 fPtHardMaxQ[0] = fPtHardMax * fQuench;
70 fPtHardMinQ[1] = fPtHardMin * (1. - fQuench);
71 fPtHardMaxQ[1] = fPtHardMax * (1. - fQuench);
75 void AliGenPythiaJets::Generate()
78 fDecayer->ForceDecay();
80 Float_t polar[3] = {0,0,0};
81 Float_t origin[3] = {0,0,0};
83 // converts from mm/c to s
84 const Float_t kconv=0.001/2.999792458e8;
92 // Set collision vertex position
93 if(fVertexSmear==kPerEvent) {
94 fPythia->SetMSTP(151,1);
96 fPythia->SetPARP(151+j, fOsigma[j]*10.);
98 } else if (fVertexSmear==kPerTrack) {
99 fPythia->SetMSTP(151,0);
105 fPythia->SetCKIN(3,fPtHardMinQ[jev]);
106 fPythia->SetCKIN(4,fPtHardMaxQ[jev]);
107 fEtMinJet = fEtMinJetQ[jev];
108 fEtMaxJet = fEtMaxJetQ[jev];
112 if (gAlice->GetEvNumber()>=fDebugEventFirst &&
113 gAlice->GetEvNumber()<=fDebugEventLast) fPythia->Pylist(1);
116 // Has this jet triggered
118 if ((fEtMinJet != -1) && ! CheckTrigger()) continue;
120 fPythia->ImportParticles(fParticles,"All");
122 Int_t np = fParticles->GetEntriesFast();
123 if (np == 0 ) continue;
124 // Get event vertex and discard the event if the z coord. is too big
125 TParticle *iparticle = (TParticle *) fParticles->At(0);
126 Float_t distz = iparticle->Vz()/10.;
127 if(TMath::Abs(distz)>fCutVertexZ*fOsigma[2]) continue;
130 fVertex[0] = iparticle->Vx()/10.+fOrigin.At(0);
131 fVertex[1] = iparticle->Vy()/10.+fOrigin.At(1);
132 fVertex[2] = iparticle->Vz()/10.+fOrigin.At(2);
134 Int_t* pParent = new Int_t[np];
135 for (i=0; i< np; i++) pParent[i] = -1;
139 for (i = 0; i<np; i++) {
141 TParticle * iparticle = (TParticle *) fParticles->At(i);
142 kf = CheckPDGCode(iparticle->GetPdgCode());
143 Int_t ks = iparticle->GetStatusCode();
144 Int_t km = iparticle->GetFirstMother();
145 if ((ks == 1 && kf !=0 && KinematicSelection(iparticle, 0)) ||
147 (fProcess == kPyJets && ks == 21 && km == 0 && i > 1)) {
149 if (ks == 1) trackIt = 1;
150 Int_t ipa = iparticle->GetFirstMother() - 1;
151 iparent = (ipa > -1) ? pParent[ipa] : -1;
153 // Store track information
155 p[0] = iparticle->Px();
156 p[1] = iparticle->Py();
157 p[2] = iparticle->Pz();
158 origin[0] = fOrigin[0]+iparticle->Vx()/10.;
159 origin[1] = fOrigin[1]+iparticle->Vy()/10.;
160 origin[2] = fOrigin[2]+iparticle->Vz()/10.;
161 Float_t tof=kconv*iparticle->T();
162 PushTrack(fTrackIt*trackIt, iparent, kf, p, origin, polar,
163 tof, kPPrimary, nt, 1., ks);
169 if (pParent) delete[] pParent;
170 printf("\n AliGenPythiaJets: I've put %i particles on the stack \n",nc);
173 if ((fQuench <= 0.) || (fQuench > 0. && jev == 2)) {
174 fKineBias=Float_t(fNpart)/Float_t(fTrials);
175 printf("\n Trials: %i %i %i\n",fTrials, fNpart, jev);
182 SetHighWaterMark(nt);
184 fXsection=fPythia->GetPARI(1);
187 Bool_t AliGenPythiaJets::CheckTrigger()
189 // Check the kinematic trigger condition
191 Bool_t triggered = kFALSE;
196 // Use Pythia clustering on parton level to determine jet axis
198 GetJets(njets, ntrig, jets);
202 Float_t px = jets[0][0];
203 Float_t py = jets[1][0];
204 Float_t pz = jets[2][0];
205 Float_t e = jets[3][0];
207 Float_t phi = TMath::Pi()+TMath::ATan2(-py,-px);
208 TransformEvent(beta, -2. * TMath::Pi() / 3. + phi);
213 void AliGenPythiaJets::TransformEvent(Float_t beta, Float_t phi)
216 // Perform Lorentz Transformation and Rotation
218 Float_t gamma = 1./TMath::Sqrt(1. - beta * beta);
219 Int_t npart = (fPythia->GetPyjets())->N;
221 for (Int_t part = 0; part < npart; part++) {
222 Float_t px = (fPythia->GetPyjets())->P[0][part];
223 Float_t py = (fPythia->GetPyjets())->P[1][part];
224 Float_t pz = (fPythia->GetPyjets())->P[2][part];
225 Float_t e = (fPythia->GetPyjets())->P[3][part];
229 Float_t pzt = gamma * pz - gamma * beta * e;
230 Float_t et = -gamma * beta * pz + gamma * e;
234 Float_t pxt = TMath::Cos(phi) * px + TMath::Sin(phi) * py;
235 Float_t pyt = - TMath::Sin(phi) * px + TMath::Cos(phi) * py;
238 (fPythia->GetPyjets())->P[0][part] = pxt;
239 (fPythia->GetPyjets())->P[1][part] = pyt;
240 (fPythia->GetPyjets())->P[2][part] = pzt;
241 (fPythia->GetPyjets())->P[3][part] = et;