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 **************************************************************************/
18 // Generator using Hydjet as an external generator
19 // The main Hydjet options are accessable for the user through this interface.
20 // Uses the THydjet implementation of TGenerator.
22 // Rafael Diaz Valdes (rafael.diaz.valdes@cern.ch)
24 #include <Riostream.h>
26 #include <TParticle.h>
27 #include <TClonesArray.h>
29 #include "AliGenHydjet.h"
31 #include "AliGenHydjetEventHeader.h"
33 #include "AliPythiaRndm.h"
38 ClassImp(AliGenHydjet)
40 AliGenHydjet::AliGenHydjet(Int_t npart) :
43 fFrame("CMS"), // Reference frame
44 fAtomicWeigth(207), // Projectile-Target atomic weight
45 fIfbtype(0), // centrality type
46 fFixImpactParam(0), // fixed impact parameter
47 fMinImpactParam(0.), // minimum impact parameter
48 fMaxImpactParam(1.), // maximum impact parameter
49 fSoftMult(20000), // mean soft multiplicity
51 fJetProd(2), // flag Jet production (nhsel)
52 fYflow(5.), // max longitudinal flow
53 fTflow(1.), // max transverse flow
54 fSoftFract(1.), // Soft multiplicity fraction
56 fDijetProd(1), // flag dijet production
57 fMinPtHard(10.), // min pt hard
58 fStructFunction(7), // Structure Function (default CTEQ5M)
59 fMultipleInt(0), // flag multiple interaction
67 // Default PbPb collisions at 5. 5 TeV
69 fEnergyCMS = 5500.; //Energy cms
71 fTitle = "Particle Generator using Hydjet";
72 // Set random number generator
73 if (!AliPythiaRndm::GetPythiaRandom())
74 AliPythiaRndm::SetPythiaRandom(GetRandom());
77 AliGenHydjet::~AliGenHydjet()
82 void AliGenHydjet::Init()
86 SetMC(new THydjet(fEnergyCMS, fFrame,fAtomicWeigth,
87 fIfbtype,fMinImpactParam, fMaxImpactParam,
88 fFixImpactParam,fSoftMult));
90 fHydjet=(THydjet*) fMCEvGen;
92 // init hydro common blocks
93 fHydjet->SetNHSEL(fJetProd);
94 fHydjet->SetYLFL(fYflow);
95 fHydjet->SetYTFL(fTflow);
96 fHydjet->SetFPART(fSoftFract);
97 // init PYTHIA common block
98 fHydjet->SetMSEL(fDijetProd);
99 fHydjet->SetPTMIN(fMinPtHard);
100 fHydjet->SetCKIN(3,fMinPtHard);
101 fHydjet->SetMSTP(51,fStructFunction);
102 fHydjet->SetMSTP(81,0);
103 fHydjet->SetMSTU(21,1);
104 fHydjet->SetPARU(14,1.);
107 fHydjet->Initialize();
111 void AliGenHydjet::Generate()
114 ///////////////////////////////////////////////////////////////////////////////////////////
115 Float_t polar[3] = {0,0,0};
116 Float_t origin[3] = {0,0,0};
117 Float_t origin0[3] = {0,0,0};
122 // converts from mm/c to s
123 const Float_t kconv = 0.001/2.999792458e8;
126 Int_t j, kf, ks, imo;
129 for (j = 0;j < 3; j++) origin0[j] = fOrigin[j];
131 if(fVertexSmear == kPerEvent) {
133 for (j=0; j < 3; j++) origin0[j] = fVertex[j];
139 // Generate one event
140 fHydjet->GenerateEvent();
141 fHydjet->ImportParticles(&fParticles,"All");
143 Int_t np = fParticles.GetEntriesFast();
145 if (np == 0 ) continue;
147 Int_t* pSelected = new Int_t[np];
149 for (i = 0; i < np; i++) {
154 fVertex[0] = origin0[0];
155 fVertex[1] = origin0[1];
156 fVertex[2] = origin0[2];
160 // Now select the final state particles
163 for(i = 0; i<np; i++){
164 TParticle * iparticle = (TParticle *) fParticles.At(i);
165 // Is this a final state particle ?
166 if (!Stable(iparticle)) continue;
167 Bool_t selected = kTRUE;
168 kf = iparticle->GetPdgCode();
169 ks = iparticle->GetStatusCode();
170 if(!fSelectAll) selected = KinematicSelection(iparticle,0)&&SelectFlavor(kf);
171 // Put particle on the stack if selected
176 } // particle loop final state
180 // Write particles to stack
183 for(i = 0; i<np; i++) {
184 TParticle * iparticle = (TParticle *) fParticles.At(i);
185 Bool_t hasDaughter = (iparticle->GetFirstDaughter() > 0);
187 kf = iparticle->GetPdgCode();
188 ks = iparticle->GetStatusCode();
189 p[0] = iparticle->Px();
190 p[1] = iparticle->Py();
191 p[2] = iparticle->Pz();
192 origin[0] = fVertex[0]+iparticle->Vx()/10;
193 origin[1] = fVertex[1]+iparticle->Vy()/10;
194 origin[2] = fVertex[2]+iparticle->Vz()/10;
195 tof = fTime + kconv*iparticle->T();
198 //imo = iparticle->GetFirstMother();
199 //if(imo == 0) imo =-1;
200 Bool_t tFlag = (fTrackIt && !hasDaughter);
201 PushTrack(tFlag,imo,kf,p,origin,polar,tof,kPNoProcess,nt, 1., ks);
207 AliInfo(Form("\n I've put %i particles on the stack \n",nc));
214 Bool_t AliGenHydjet::SelectFlavor(Int_t pid)
216 // Select flavor of particle
218 // 4: charm and beauty
224 Int_t ifl = TMath::Abs(pid/100);
225 if (ifl > 10) ifl/=10;
226 res = (fFlavor == ifl);
231 Bool_t AliGenHydjet::Stable(TParticle* particle) const
233 // Return true for a stable particle
234 if (particle->GetFirstDaughter() == 0 )
243 ///////////////////////////////////
244 void AliGenHydjet::MakeHeader()
246 // Builds the event header, to be called after each event
247 AliGenEventHeader* header = new AliGenHydjetEventHeader("Hydjet");
248 ((AliGenHydjetEventHeader*) header)->SetNProduced(fHydjet->GetN());
249 ((AliGenHydjetEventHeader*) header)->SetImpactParameter(fHydjet->GetBGEN());
250 ((AliGenHydjetEventHeader*) header)->SetNbcol(fHydjet->GetNBCOL());
251 ((AliGenHydjetEventHeader*) header)->SetNpart(fHydjet->GetNPART());
252 ((AliGenHydjetEventHeader*) header)->SetNpyt(fHydjet->GetNPYT());
253 ((AliGenHydjetEventHeader*) header)->SetNhyd(fHydjet->GetNHYD());
254 // draw generation values
255 cout << "*********Hyflow ********** " << endl;
256 cout << " YTFL " << fHydjet->GetYTFL() << endl;
257 cout << " YLFL " << fHydjet->GetYLFL() << endl;
258 cout << " FPART " << fHydjet->GetFPART() << endl;
259 cout << "*********Hyjpar ********* " << endl;
260 cout << " GetNHSEL() " << fHydjet->GetNHSEL() << endl;
261 cout << " GetPTMIN() " << fHydjet->GetPTMIN() << endl;
262 cout << " GetNJET() " << fHydjet->GetNJET() << endl;
263 cout << "*********Hyfpar ********* " << endl;
264 cout << " GetBGEN() " << fHydjet->GetBGEN() << endl;
265 cout << " GetNBCOL() " << fHydjet->GetNBCOL() << endl;
266 cout << " GetNPART() " << fHydjet->GetNPART() << endl;
267 cout << " GetNPYT() " << fHydjet->GetNPYT() << endl;
268 cout << " GetNHYD() " << fHydjet->GetNHYD() << endl;
272 header->SetPrimaryVertex(fVertex);
273 header->SetInteractionTime(fTime);
275 fCollisionGeometry = (AliGenHydjetEventHeader*) header;
278 void AliGenHydjet::AddHeader(AliGenEventHeader* header)
280 // Passes header either to the container or to gAlice
282 fContainer->AddHeader(header);
284 gAlice->SetGenEventHeader(header);
289 void AliGenHydjet::Copy(TObject &) const
291 Fatal("Copy","Not implemented!\n");
294 AliGenHydjet& AliGenHydjet::operator=(const AliGenHydjet& rhs)