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.11 1999/09/29 09:24:14 fca
19 Introduction of the Copyright and cvs Log
23 #include "AliGenParam.h"
24 #include "AliGenMUONlib.h"
25 #include "AliGenPHOSlib.h"
27 #include "AliPythia.h"
28 #include <TDirectory.h>
32 #include <TParticle.h>
36 //------------------------------------------------------------
40 <img src="picts/AliGenParam.gif">
44 //____________________________________________________________
45 //____________________________________________________________
46 AliGenParam::AliGenParam()
56 //____________________________________________________________
58 AliGenParam::AliGenParam(Int_t npart, Param_t param) :AliGenerator(npart)
61 // fName="HMESONpara";
62 // fTitle="Heavy Mesons Parametrisation";
63 fPtParaFunc = AliGenMUONlib::GetPt(param);
64 fYParaFunc = AliGenMUONlib::GetY(param);
65 fIpParaFunc = AliGenMUONlib::GetIp(param);
72 for (Int_t i=0; i<5; i++) fChildSelect[i]=0;
77 AliGenParam::AliGenParam(Int_t npart, Param_t param,
78 Double_t (*PtPara) (Double_t*, Double_t*),
79 Double_t (*YPara ) (Double_t* ,Double_t*),
83 // Gines Martinez 1/10/99
94 for (Int_t i=0; i<5; i++) fChildSelect[i]=0;
99 //____________________________________________________________
100 AliGenParam::~AliGenParam()
106 //____________________________________________________________
107 void AliGenParam::Init()
109 SetMC(new AliPythia());
110 fPythia= (AliPythia*) fgMCEvGen;
112 // End of the test !!!
115 <img src="picts/AliGenParam.gif">
119 fPtPara = new TF1("Pt-Parametrization",fPtParaFunc,fPtMin,fPtMax,0);
120 fYPara = new TF1("Y -Parametrization",fYParaFunc,fYMin,fYMax,0);
121 TF1* PtPara = new TF1("Pt-Parametrization",fPtParaFunc,0,15,0);
122 TF1* YPara = new TF1("Y -Parametrization",fYParaFunc,-6,6,0);
129 fdNdy0=fYParaFunc(&y1,&y2);
131 // Integral over generation region
132 Float_t IntYS = YPara ->Integral(fYMin, fYMax);
133 Float_t IntPt0 = PtPara->Integral(0,15);
134 Float_t IntPtS = PtPara->Integral(fPtMin,fPtMax);
135 Float_t PhiWgt=(fPhiMax-fPhiMin)/2./TMath::Pi();
136 if (fAnalog == analog) {
137 fYWgt = IntYS/fdNdy0;
138 fPtWgt = IntPtS/IntPt0;
139 fParentWeight = fYWgt*fPtWgt*PhiWgt/fNpart;
141 fYWgt = IntYS/fdNdy0;
142 fPtWgt = (fPtMax-fPtMin)/IntPt0;
143 fParentWeight = fYWgt*fPtWgt*PhiWgt/fNpart;
146 // particle decay related initialization
147 fPythia->DefineParticles();
148 // semimuonic decays of charm and beauty
149 fPythia->ForceDecay(fForceDecay);
155 case b_jpsi_dielectron:
156 case b_psip_dielectron:
178 //____________________________________________________________
179 void AliGenParam::Generate()
181 // Generate 'npart' of heavy mesons (J/Psi, upsilon or phi) in the
182 // the desired theta, phi and momentum windows; Gaussian smearing
183 // on the vertex is done if selected
186 //printf("Generate !!!!!!!!!!!!!\n");
188 Float_t polar[3]= {0,0,0};
191 Float_t pt, pl, ptot;
193 Float_t p[3], pc[3], och[3], pch[10][3];
195 Int_t nt, i, j, kfch[10];
198 static TClonesArray *particles;
200 if(!particles) particles=new TClonesArray("TParticle",1000);
203 for (j=0;j<3;j++) origin0[j]=fOrigin[j];
204 if(fVertexSmear==perEvent) {
207 origin0[j]+=fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
208 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
216 Int_t Ipart = fIpParaFunc();
217 fChildWeight=(fPythia->GetBraPart(Ipart))*fParentWeight;
218 Float_t am=fPythia->GetPMAS(fPythia->LuComp(Ipart),1);
222 phi=fPhiMin+random[0]*(fPhiMax-fPhiMin);
225 ty=Float_t(TMath::TanH(fYPara->GetRandom()));
228 if (fAnalog == analog) {
229 pt=fPtPara->GetRandom();
233 pt=fPtMin+random[1]*(fPtMax-fPtMin);
235 wgtp=fParentWeight*fPtParaFunc(& ptd, &dummy);
236 wgtch=fChildWeight*fPtParaFunc(& ptd, &dummy);
238 xmt=sqrt(pt*pt+am*am);
239 pl=xmt*ty/sqrt(1.-ty*ty);
240 theta=TMath::ATan2(pt,pl);
241 if(theta<fThetaMin || theta>fThetaMax) continue;
242 ptot=TMath::Sqrt(pt*pt+pl*pl);
243 if(ptot<fPMin || ptot>fPMax) continue;
244 p[0]=pt*TMath::Cos(phi);
245 p[1]=pt*TMath::Sin(phi);
247 if(fVertexSmear==perTrack) {
251 fOrigin[j]+fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
252 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
256 // use lujet to decay particle
257 if (fForceDecay != nodecay) {
258 Float_t energy=TMath::Sqrt(ptot*ptot+am*am);
259 fPythia->DecayParticle(Ipart,energy,theta,phi);
260 // fPythia->LuList(1);
261 //printf("origin0 %f %f %f\n",origin0[0],origin0[1],origin0[2]);
262 //printf("fCutOnChild %d \n",fCutOnChild);
265 Int_t np=fPythia->ImportParticles(particles,"All");
266 //printf("np %d \n",np);
268 for (i = 1; i<np; i++) {
269 TParticle * iparticle = (TParticle *) particles->At(i);
270 Int_t kf = iparticle->GetPdgCode();
273 if (ChildSelected(TMath::Abs(kf)))
275 pc[0]=iparticle->Px();
276 pc[1]=iparticle->Py();
277 pc[2]=iparticle->Pz();
278 och[0]=origin0[0]+iparticle->Vx()/10;
279 och[1]=origin0[1]+iparticle->Vy()/10;
280 och[2]=origin0[2]+iparticle->Vz()/10;
282 Float_t PtChild=TMath::Sqrt(pc[0]*pc[0]+pc[1]*pc[1]);
283 Float_t PChild=TMath::Sqrt(PtChild*PtChild+pc[2]*pc[2]);
284 Float_t ThetaChild=TMath::ATan2(PtChild,pc[2]);
285 Float_t PhiChild=TMath::ATan2(pc[1],pc[0])+TMath::Pi();
287 ((PtChild > fPtMin && PtChild <fPtMax) &&
288 (PChild > fPMin && PChild <fPMax) &&
289 (ThetaChild>fThetaMin && ThetaChild<fThetaMax) &&
290 (PhiChild > fPhiMin && PhiChild <fPhiMax));
308 } // if child selection
310 } // decay particle loop
312 if ((fCutOnChild && ncsel >0) || !fCutOnChild){
317 SetTrack(0,-1,Ipart,p,origin0,polar,0,"Primary",nt,wgtp);
320 for (i=0; i< ncsel; i++) {
321 gAlice->SetTrack(fTrackIt,iparent,kfch[i],
322 &pch[i][0],och,polar,
324 gAlice->KeepTrack(nt);
328 SetTrack(fTrackIt,-1,Ipart,p,origin0,polar,0,"Primary",nt,wgtp);
330 } // kinematic selection
336 Bool_t AliGenParam::ChildSelected(Int_t ip)
338 for (Int_t i=0; i<5; i++)
340 if (fChildSelect[i]==ip) return kTRUE;
345 Bool_t AliGenParam::KinematicSelection(TParticle *particle)
347 Float_t px=particle->Px();
348 Float_t py=particle->Py();
349 Float_t pz=particle->Pz();
352 Float_t p=TMath::Sqrt(px*px+py*py+pz*pz);
353 if (p > fPMax || p < fPMin)
355 // printf("\n failed p cut %f %f %f \n",p,fPMin,fPMax);
358 Float_t pt=TMath::Sqrt(px*px+py*py);
362 Float_t theta = Float_t(TMath::ATan2(Double_t(pt),Double_t(p)));
363 if (theta > fThetaMax || theta < fThetaMin)
365 // printf("\n failed theta cut %f %f %f \n",theta,fThetaMin,fThetaMax);