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 **************************************************************************/
20 #include "AliGenParam.h"
21 #include "AliGenMUONlib.h"
23 #include "AliPythia.h"
24 #include <TDirectory.h>
28 #include <TParticle.h>
32 //------------------------------------------------------------
36 <img src="picts/AliGenParam.gif">
40 //____________________________________________________________
41 //____________________________________________________________
42 AliGenParam::AliGenParam()
52 //____________________________________________________________
53 AliGenParam::AliGenParam(Int_t npart, Param_t param)
54 // Double_t (*PtPara)(Double_t*, Double_t*),
55 // Double_t (*YPara) (Double_t* ,Double_t*))
59 // fName="HMESONpara";
60 // fTitle="Heavy Mesons Parametrisation";
61 fPtParaFunc = AliGenMUONlib::GetPt(param);
62 fYParaFunc = AliGenMUONlib::GetY(param);
63 fIpParaFunc = AliGenMUONlib::GetIp(param);
70 for (Int_t i=0; i<5; i++) fChildSelect[i]=0;
75 //____________________________________________________________
76 AliGenParam::~AliGenParam()
82 //____________________________________________________________
83 void AliGenParam::Init()
85 SetMC(new AliPythia());
86 fPythia= (AliPythia*) fgMCEvGen;
88 // End of the test !!!
91 <img src="picts/AliGenParam.gif">
95 fPtPara = new TF1("Pt-Parametrization",fPtParaFunc,fPtMin,fPtMax,0);
96 fYPara = new TF1("Y -Parametrization",fYParaFunc,fYMin,fYMax,0);
97 TF1* PtPara = new TF1("Pt-Parametrization",fPtParaFunc,0,15,0);
98 TF1* YPara = new TF1("Y -Parametrization",fYParaFunc,-6,6,0);
105 fdNdy0=fYParaFunc(&y1,&y2);
107 // Integral over generation region
108 Float_t IntYS = YPara ->Integral(fYMin, fYMax);
109 Float_t IntPt0 = PtPara->Integral(0,15);
110 Float_t IntPtS = PtPara->Integral(fPtMin,fPtMax);
111 Float_t PhiWgt=(fPhiMax-fPhiMin)/2./TMath::Pi();
112 if (fAnalog == analog) {
113 fYWgt = IntYS/fdNdy0;
114 fPtWgt = IntPtS/IntPt0;
115 fParentWeight = fYWgt*fPtWgt*PhiWgt/fNpart;
117 fYWgt = IntYS/fdNdy0;
118 fPtWgt = (fPtMax-fPtMin)/IntPt0;
119 fParentWeight = fYWgt*fPtWgt*PhiWgt/fNpart;
122 // particle decay related initialization
123 fPythia->DefineParticles();
124 // semimuonic decays of charm and beauty
125 fPythia->ForceDecay(fForceDecay);
131 case b_jpsi_dielectron:
132 case b_psip_dielectron:
151 //____________________________________________________________
152 void AliGenParam::Generate()
154 // Generate 'npart' of heavy mesons (J/Psi, upsilon or phi) in the
155 // the desired theta, phi and momentum windows; Gaussian smearing
156 // on the vertex is done if selected
159 //printf("Generate !!!!!!!!!!!!!\n");
161 Float_t polar[3]= {0,0,0};
163 Float_t origin[3], origin0[3];
164 Float_t pt, pl, ptot;
166 Float_t p[3], pc[3], och[3], pch[10][3];
168 Int_t nt, i, j, kfch[10];
171 static TClonesArray *particles;
173 if(!particles) particles=new TClonesArray("TParticle",1000);
176 for (j=0;j<3;j++) origin0[j]=fOrigin[j];
177 if(fVertexSmear==perEvent) {
180 origin0[j]+=fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
181 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
189 Int_t Ipart = fIpParaFunc();
190 fChildWeight=(fPythia->GetBraPart(Ipart))*fParentWeight;
191 Float_t am=fPythia->GetPMAS(fPythia->LuComp(Ipart),1);
195 phi=fPhiMin+random[0]*(fPhiMax-fPhiMin);
198 ty=Float_t(TMath::TanH(fYPara->GetRandom()));
201 if (fAnalog == analog) {
202 pt=fPtPara->GetRandom();
206 pt=fPtMin+random[1]*(fPtMax-fPtMin);
208 wgtp=fParentWeight*fPtParaFunc(& ptd, &dummy);
209 wgtch=fChildWeight*fPtParaFunc(& ptd, &dummy);
211 xmt=sqrt(pt*pt+am*am);
212 pl=xmt*ty/sqrt(1.-ty*ty);
213 theta=TMath::ATan2(pt,pl);
214 if(theta<fThetaMin || theta>fThetaMax) continue;
215 ptot=TMath::Sqrt(pt*pt+pl*pl);
216 if(ptot<fPMin || ptot>fPMax) continue;
217 p[0]=pt*TMath::Cos(phi);
218 p[1]=pt*TMath::Sin(phi);
220 if(fVertexSmear==perTrack) {
224 fOrigin[j]+fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
225 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
229 // use lujet to decay particle
231 Float_t energy=TMath::Sqrt(ptot*ptot+am*am);
232 fPythia->DecayParticle(Ipart,energy,theta,phi);
233 // fPythia->LuList(1);
236 //printf("origin0 %f %f %f\n",origin0[0],origin0[1],origin0[2]);
237 //printf("fCutOnChild %d \n",fCutOnChild);
240 Int_t np=fPythia->ImportParticles(particles,"All");
241 //printf("np %d \n",np);
243 for (i = 1; i<np; i++) {
244 TParticle * iparticle = (TParticle *) particles->At(i);
245 Int_t kf = iparticle->GetPdgCode();
246 //printf("kf %d\n",kf);
249 if (ChildSelected(TMath::Abs(kf)))
251 pc[0]=iparticle->Px();
252 pc[1]=iparticle->Py();
253 pc[2]=iparticle->Pz();
254 och[0]=origin0[0]+iparticle->Vx()/10;
255 och[1]=origin0[1]+iparticle->Vy()/10;
256 och[2]=origin0[2]+iparticle->Vz()/10;
258 Float_t PtChild=TMath::Sqrt(pc[0]*pc[0]+pc[1]*pc[1]);
259 Float_t PChild=TMath::Sqrt(PtChild*PtChild+pc[2]*pc[2]);
260 Float_t ThetaChild=TMath::ATan2(PtChild,pc[2]);
261 Float_t PhiChild=TMath::ATan2(pc[1],pc[0])+TMath::Pi();
263 ((PtChild > fPtMin && PtChild <fPtMax) &&
264 (PChild > fPMin && PChild <fPMax) &&
265 (ThetaChild>fThetaMin && ThetaChild<fThetaMax) &&
266 (PhiChild > fPhiMin && PhiChild <fPhiMax));
284 } // if child selection
286 } // decay particle loop
288 if ((fCutOnChild && ncsel >0) || !fCutOnChild){
293 SetTrack(0,-1,Ipart,p,origin,polar,0,"Primary",nt,wgtp);
296 for (i=0; i< ncsel; i++) {
297 gAlice->SetTrack(fTrackIt,iparent,kfch[i],
298 &pch[i][0],och,polar,
300 gAlice->KeepTrack(nt);
303 } // kinematic selection
309 Bool_t AliGenParam::ChildSelected(Int_t ip)
311 for (Int_t i=0; i<5; i++)
313 if (fChildSelect[i]==ip) return kTRUE;
318 Bool_t AliGenParam::KinematicSelection(TParticle *particle)
320 Float_t px=particle->Px();
321 Float_t py=particle->Py();
322 Float_t pz=particle->Pz();
325 Float_t p=TMath::Sqrt(px*px+py*py+pz*pz);
326 if (p > fPMax || p < fPMin)
328 // printf("\n failed p cut %f %f %f \n",p,fPMin,fPMax);
331 Float_t pt=TMath::Sqrt(px*px+py*py);
335 Float_t theta = Float_t(TMath::ATan2(Double_t(pt),Double_t(p)));
336 if (theta > fThetaMax || theta < fThetaMin)
338 // printf("\n failed theta cut %f %f %f \n",theta,fThetaMin,fThetaMax);