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"
30 #include "AliGenHydjetEventHeader.h"
32 #include "AliPythiaRndm.h"
34 ClassImp(AliGenHydjet)
36 AliGenHydjet::AliGenHydjet(Int_t npart) :
39 fFrame("CMS"), // Reference frame
40 fAtomicWeigth(207), // Projectile-Target atomic weight
41 fIfbtype(0), // centrality type
42 fFixImpactParam(0), // fixed impact parameter
43 fMinImpactParam(0.), // minimum impact parameter
44 fMaxImpactParam(1.), // maximum impact parameter
45 fSoftMult(20000), // mean soft multiplicity
47 fJetProd(2), // flag Jet production (nhsel)
48 fYflow(5.), // max longitudinal flow
49 fTflow(1.), // max transverse flow
50 fSoftFract(1.), // Soft multiplicity fraction
52 fDijetProd(1), // flag dijet production
53 fMinPtHard(10.), // min pt hard
54 fStructFunction(7), // Structure Function (default CTEQ5M)
55 fMultipleInt(0), // flag multiple interaction
63 // Default PbPb collisions at 5. 5 TeV
65 fEnergyCMS = 5500.; //Energy cms
67 fTitle = "Particle Generator using Hydjet";
68 // Set random number generator
69 if (!AliPythiaRndm::GetPythiaRandom())
70 AliPythiaRndm::SetPythiaRandom(GetRandom());
73 AliGenHydjet::~AliGenHydjet()
78 void AliGenHydjet::Init()
82 SetMC(new THydjet(fEnergyCMS, fFrame,fAtomicWeigth,
83 fIfbtype,fMinImpactParam, fMaxImpactParam,
84 fFixImpactParam,fSoftMult));
86 fHydjet=(THydjet*) fMCEvGen;
88 // init hydro common blocks
89 fHydjet->SetNHSEL(fJetProd);
90 fHydjet->SetYLFL(fYflow);
91 fHydjet->SetYTFL(fTflow);
92 fHydjet->SetFPART(fSoftFract);
93 // init PYTHIA common block
94 fHydjet->SetMSEL(fDijetProd);
95 fHydjet->SetPTMIN(fMinPtHard);
96 fHydjet->SetCKIN(3,fMinPtHard);
97 fHydjet->SetMSTP(51,fStructFunction);
98 fHydjet->SetMSTP(81,0);
99 fHydjet->SetMSTU(21,1);
100 fHydjet->SetPARU(14,1.);
103 fHydjet->Initialize();
107 void AliGenHydjet::Generate()
110 ///////////////////////////////////////////////////////////////////////////////////////////
111 Float_t polar[3] = {0,0,0};
112 Float_t origin[3] = {0,0,0};
113 Float_t origin0[3] = {0,0,0};
117 // converts from mm/c to s
118 const Float_t kconv = 0.001/2.999792458e8;
121 Int_t j, kf, ks, imo;
124 for (j = 0;j < 3; j++) origin0[j] = fOrigin[j];
125 if(fVertexSmear == kPerEvent) {
127 for (j=0; j < 3; j++) origin0[j] = fVertex[j];
132 // Generate one event
133 fHydjet->GenerateEvent();
134 fHydjet->ImportParticles(&fParticles,"All");
136 Int_t np = fParticles.GetEntriesFast();
137 printf("\n **************************************************%d\n",np);
139 if (np == 0 ) continue;
141 Int_t* pSelected = new Int_t[np];
143 for (i = 0; i < np; i++) {
148 fVertex[0] = origin0[0];
149 fVertex[1] = origin0[1];
150 fVertex[2] = origin0[2];
153 // Now select the final state particles
156 for(i = 0; i<np; i++){
157 TParticle * iparticle = (TParticle *) fParticles.At(i);
158 // Is this a final state particle ?
159 if (!Stable(iparticle)) continue;
160 Bool_t selected = kTRUE;
161 kf = iparticle->GetPdgCode();
162 ks = iparticle->GetStatusCode();
163 if(!fSelectAll) selected = KinematicSelection(iparticle,0)&&SelectFlavor(kf);
164 // Put particle on the stack if selected
169 } // particle loop final state
173 // Write particles to stack
176 for(i = 0; i<np; i++) {
177 TParticle * iparticle = (TParticle *) fParticles.At(i);
178 Bool_t hasDaughter = (iparticle->GetFirstDaughter() > 0);
180 kf = iparticle->GetPdgCode();
181 ks = iparticle->GetStatusCode();
182 p[0] = iparticle->Px();
183 p[1] = iparticle->Py();
184 p[2] = iparticle->Pz();
185 origin[0] = fVertex[0]+iparticle->Vx()/10;
186 origin[1] = fVertex[1]+iparticle->Vy()/10;
187 origin[2] = fVertex[2]+iparticle->Vz()/10;
188 tof = kconv*iparticle->T();
191 //imo = iparticle->GetFirstMother();
192 //if(imo == 0) imo =-1;
193 Bool_t tFlag = (fTrackIt && !hasDaughter);
194 PushTrack(tFlag,imo,kf,p,origin,polar,tof,kPNoProcess,nt, 1., ks);
200 printf("\n I've put %i particles on the stack \n",nc);
207 Bool_t AliGenHydjet::SelectFlavor(Int_t pid)
209 // Select flavor of particle
211 // 4: charm and beauty
217 Int_t ifl = TMath::Abs(pid/100);
218 if (ifl > 10) ifl/=10;
219 res = (fFlavor == ifl);
224 Bool_t AliGenHydjet::Stable(TParticle* particle) const
226 // Return true for a stable particle
227 if (particle->GetFirstDaughter() == 0 )
236 ///////////////////////////////////
237 void AliGenHydjet::MakeHeader()
239 // Builds the event header, to be called after each event
240 AliGenEventHeader* header = new AliGenHydjetEventHeader("Hydjet");
241 ((AliGenHydjetEventHeader*) header)->SetNProduced(fHydjet->GetN());
242 ((AliGenHydjetEventHeader*) header)->SetImpactParameter(fHydjet->GetBGEN());
243 ((AliGenHydjetEventHeader*) header)->SetNbcol(fHydjet->GetNBCOL());
244 ((AliGenHydjetEventHeader*) header)->SetNpart(fHydjet->GetNPART());
245 ((AliGenHydjetEventHeader*) header)->SetNpyt(fHydjet->GetNPYT());
246 ((AliGenHydjetEventHeader*) header)->SetNhyd(fHydjet->GetNHYD());
247 // draw generation values
248 cout << "*********Hyflow ********** " << endl;
249 cout << " YTFL " << fHydjet->GetYTFL() << endl;
250 cout << " YLFL " << fHydjet->GetYLFL() << endl;
251 cout << " FPART " << fHydjet->GetFPART() << endl;
252 cout << "*********Hyjpar ********* " << endl;
253 cout << " GetNHSEL() " << fHydjet->GetNHSEL() << endl;
254 cout << " GetPTMIN() " << fHydjet->GetPTMIN() << endl;
255 cout << " GetNJET() " << fHydjet->GetNJET() << endl;
256 cout << "*********Hyfpar ********* " << endl;
257 cout << " GetBGEN() " << fHydjet->GetBGEN() << endl;
258 cout << " GetNBCOL() " << fHydjet->GetNBCOL() << endl;
259 cout << " GetNPART() " << fHydjet->GetNPART() << endl;
260 cout << " GetNPYT() " << fHydjet->GetNPYT() << endl;
261 cout << " GetNHYD() " << fHydjet->GetNHYD() << endl;
265 header->SetPrimaryVertex(fVertex);
267 fCollisionGeometry = (AliGenHydjetEventHeader*) header;
270 void AliGenHydjet::AddHeader(AliGenEventHeader* header)
272 // Passes header either to the container or to gAlice
274 fContainer->AddHeader(header);
276 gAlice->SetGenEventHeader(header);
281 void AliGenHydjet::Copy(TObject &) const
283 Fatal("Copy","Not implemented!\n");
286 AliGenHydjet& AliGenHydjet::operator=(const AliGenHydjet& rhs)