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 Revision 1.13 1999/11/04 11:30:31 fca
19 Correct the logics for SetForceDecay
21 Revision 1.12 1999/11/03 17:43:20 fca
22 New version from G.Martinez & A.Morsch
24 Revision 1.11 1999/09/29 09:24:14 fca
25 Introduction of the Copyright and cvs Log
29 #include "AliGenParam.h"
30 #include "AliGenMUONlib.h"
31 #include "AliGenPHOSlib.h"
33 #include "AliPythia.h"
34 #include <TDirectory.h>
38 #include <TParticle.h>
42 //------------------------------------------------------------
46 <img src="picts/AliGenParam.gif">
50 //____________________________________________________________
51 //____________________________________________________________
52 AliGenParam::AliGenParam()
62 //____________________________________________________________
64 AliGenParam::AliGenParam(Int_t npart, Param_t param) :AliGenerator(npart)
67 // fName="HMESONpara";
68 // fTitle="Heavy Mesons Parametrisation";
69 fPtParaFunc = AliGenMUONlib::GetPt(param);
70 fYParaFunc = AliGenMUONlib::GetY(param);
71 fIpParaFunc = AliGenMUONlib::GetIp(param);
78 for (Int_t i=0; i<5; i++) fChildSelect[i]=0;
83 AliGenParam::AliGenParam(Int_t npart, Param_t param,
84 Double_t (*PtPara) (Double_t*, Double_t*),
85 Double_t (*YPara ) (Double_t* ,Double_t*),
89 // Gines Martinez 1/10/99
99 for (Int_t i=0; i<5; i++) fChildSelect[i]=0;
104 //____________________________________________________________
105 AliGenParam::~AliGenParam()
111 //____________________________________________________________
112 void AliGenParam::Init()
114 SetMC(new AliPythia());
115 fPythia= (AliPythia*) fgMCEvGen;
117 // End of the test !!!
120 <img src="picts/AliGenParam.gif">
124 fPtPara = new TF1("Pt-Parametrization",fPtParaFunc,fPtMin,fPtMax,0);
125 fYPara = new TF1("Y -Parametrization",fYParaFunc,fYMin,fYMax,0);
126 TF1* PtPara = new TF1("Pt-Parametrization",fPtParaFunc,0,15,0);
127 TF1* YPara = new TF1("Y -Parametrization",fYParaFunc,-6,6,0);
134 fdNdy0=fYParaFunc(&y1,&y2);
136 // Integral over generation region
137 Float_t IntYS = YPara ->Integral(fYMin, fYMax);
138 Float_t IntPt0 = PtPara->Integral(0,15);
139 Float_t IntPtS = PtPara->Integral(fPtMin,fPtMax);
140 Float_t PhiWgt=(fPhiMax-fPhiMin)/2./TMath::Pi();
141 if (fAnalog == analog) {
142 fYWgt = IntYS/fdNdy0;
143 fPtWgt = IntPtS/IntPt0;
144 fParentWeight = fYWgt*fPtWgt*PhiWgt/fNpart;
146 fYWgt = IntYS/fdNdy0;
147 fPtWgt = (fPtMax-fPtMin)/IntPt0;
148 fParentWeight = fYWgt*fPtWgt*PhiWgt/fNpart;
151 // particle decay related initialization
152 fPythia->DefineParticles();
153 // semimuonic decays of charm and beauty
154 fPythia->ForceDecay(fForceDecay);
160 case b_jpsi_dielectron:
161 case b_psip_dielectron:
183 //____________________________________________________________
184 void AliGenParam::Generate()
187 // Generate 'npart' of light and heavy mesons (J/Psi, upsilon or phi, Pion,
188 // Kaons, Etas, Omegas) and Baryons (proton, antiprotons, neutrons and
189 // antineutrons in the the desired theta, phi and momentum windows;
190 // Gaussian smearing on the vertex is done if selected.
191 // The decay of heavy mesons is done using lujet, and the childern particle are tracked by GEANT
192 // However, light mesons are directly tracked by GEANT setting fForceDecay = nodecay (SetForceDecay(nodecay))
195 // printf("Generate !!!!!!!!!!!!!\n");
197 Float_t polar[3]= {0,0,0}; // Polarisation of the parent particle (for GEANT tracking)
198 Float_t origin0[3]; // Origin of the generated parent particle (for GEANT tracking)
199 Float_t pt, pl, ptot; // Transverse, logitudinal and total momenta of the parent particle
200 Float_t phi, theta; // Phi and theta spherical angles of the parent particle momentum
202 och[3], pch[10][3]; // Momentum, polarisation and origin of the children particles from lujet
204 Int_t nt, i, j, kfch[10];
207 static TClonesArray *particles;
209 if(!particles) particles=new TClonesArray("TParticle",1000);
213 // Calculating vertex position per event
214 for (j=0;j<3;j++) origin0[j]=fOrigin[j];
215 if(fVertexSmear==perEvent) {
218 origin0[j]+=fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
219 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
223 // Generating fNpart particles
228 Int_t Ipart = fIpParaFunc();
229 fChildWeight=(fPythia->GetBraPart(Ipart))*fParentWeight;
230 Float_t am=fPythia->GetPMAS(fPythia->Lucomp(Ipart),1);
234 phi=fPhiMin+random[0]*(fPhiMax-fPhiMin);
237 ty=Float_t(TMath::TanH(fYPara->GetRandom()));
240 if (fAnalog == analog) {
241 pt=fPtPara->GetRandom();
245 pt=fPtMin+random[1]*(fPtMax-fPtMin);
247 wgtp=fParentWeight*fPtParaFunc(& ptd, &dummy);
248 wgtch=fChildWeight*fPtParaFunc(& ptd, &dummy);
250 xmt=sqrt(pt*pt+am*am);
251 pl=xmt*ty/sqrt(1.-ty*ty);
252 theta=TMath::ATan2(pt,pl);
253 if(theta<fThetaMin || theta>fThetaMax) continue;
254 ptot=TMath::Sqrt(pt*pt+pl*pl);
255 if(ptot<fPMin || ptot>fPMax) continue;
256 p[0]=pt*TMath::Cos(phi);
257 p[1]=pt*TMath::Sin(phi);
259 if(fVertexSmear==perTrack) {
263 fOrigin[j]+fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
264 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
268 // Looking at fForceDecay :
269 // if fForceDecay != none Primary particle decays using
270 // AliPythia and children are tracked by GEANT
272 // if fForceDecay == none Primary particle is tracked by GEANT
273 // (In the latest, make sure that GEANT actually does all the decays you want)
275 if (fForceDecay != nodecay) {
276 // Using lujet to decay particle
277 Float_t energy=TMath::Sqrt(ptot*ptot+am*am);
278 fPythia->DecayParticle(Ipart,energy,theta,phi);
279 // fPythia->LuList(1);
280 //printf("origin0 %f %f %f\n",origin0[0],origin0[1],origin0[2]);
281 //printf("fCutOnChild %d \n",fCutOnChild);
284 Int_t np=fPythia->ImportParticles(particles,"All");
285 //printf("np %d \n",np);
287 for (i = 1; i<np; i++) {
288 TParticle * iparticle = (TParticle *) particles->At(i);
289 Int_t kf = iparticle->GetPdgCode();
292 if (ChildSelected(TMath::Abs(kf)))
294 pc[0]=iparticle->Px();
295 pc[1]=iparticle->Py();
296 pc[2]=iparticle->Pz();
297 och[0]=origin0[0]+iparticle->Vx()/10;
298 och[1]=origin0[1]+iparticle->Vy()/10;
299 och[2]=origin0[2]+iparticle->Vz()/10;
301 Float_t PtChild=TMath::Sqrt(pc[0]*pc[0]+pc[1]*pc[1]);
302 Float_t PChild=TMath::Sqrt(PtChild*PtChild+pc[2]*pc[2]);
303 Float_t ThetaChild=TMath::ATan2(PtChild,pc[2]);
304 Float_t PhiChild=TMath::ATan2(pc[1],pc[0])+TMath::Pi();
306 ((PtChild > fPtMin && PtChild <fPtMax) &&
307 (PChild > fPMin && PChild <fPMax) &&
308 (ThetaChild>fThetaMin && ThetaChild<fThetaMax) &&
309 (PhiChild > fPhiMin && PhiChild <fPhiMax));
327 } // if child selection
329 } // decay particle loop
331 if ((fCutOnChild && ncsel >0) || !fCutOnChild){
336 SetTrack(0,-1,Ipart,p,origin0,polar,0,"Primary",nt,wgtp);
339 for (i=0; i< ncsel; i++) {
340 gAlice->SetTrack(fTrackIt,iparent,kfch[i],
341 &pch[i][0],och,polar,
343 gAlice->KeepTrack(nt);
346 } // kinematic selection
347 else // nodecay option, so parent will be tracked by GEANT (pions, kaons, eta, omegas, baryons)
350 SetTrack(fTrackIt,-1,Ipart,p,origin0,polar,0,"Primary",nt,wgtp);
358 Bool_t AliGenParam::ChildSelected(Int_t ip)
360 for (Int_t i=0; i<5; i++)
362 if (fChildSelect[i]==ip) return kTRUE;
367 Bool_t AliGenParam::KinematicSelection(TParticle *particle)
369 Float_t px=particle->Px();
370 Float_t py=particle->Py();
371 Float_t pz=particle->Pz();
374 Float_t p=TMath::Sqrt(px*px+py*py+pz*pz);
375 if (p > fPMax || p < fPMin)
377 // printf("\n failed p cut %f %f %f \n",p,fPMin,fPMax);
380 Float_t pt=TMath::Sqrt(px*px+py*py);
384 Float_t theta = Float_t(TMath::ATan2(Double_t(pt),Double_t(p)));
385 if (theta > fThetaMax || theta < fThetaMin)
387 // printf("\n failed theta cut %f %f %f \n",theta,fThetaMin,fThetaMax);