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.15 2000/04/03 15:42:12 morsch
19 Cuts on primary particles are separated from those on the decay products. Methods
20 SetChildMomentumRange, SetChildPtRange, SetChildPhiRange, SetChildThetaRange added.
22 Revision 1.14 1999/11/09 07:38:48 fca
23 Changes for compatibility with version 2.23 of ROOT
25 Revision 1.13 1999/11/04 11:30:31 fca
26 Correct the logics for SetForceDecay
28 Revision 1.12 1999/11/03 17:43:20 fca
29 New version from G.Martinez & A.Morsch
31 Revision 1.11 1999/09/29 09:24:14 fca
32 Introduction of the Copyright and cvs Log
36 #include "AliGenParam.h"
37 #include "AliGenMUONlib.h"
38 #include "AliGenPHOSlib.h"
40 #include "AliPythia.h"
41 #include <TParticle.h>
45 //------------------------------------------------------------
49 <img src="picts/AliGenParam.gif">
53 //____________________________________________________________
54 //____________________________________________________________
55 AliGenParam::AliGenParam()
64 SetChildMomentumRange();
71 //____________________________________________________________
73 AliGenParam::AliGenParam(Int_t npart, Param_t param) :AliGenerator(npart)
77 // fName="HMESONpara";
78 // fTitle="Heavy Mesons Parametrisation";
79 fPtParaFunc = AliGenMUONlib::GetPt(param);
80 fYParaFunc = AliGenMUONlib::GetY(param);
81 fIpParaFunc = AliGenMUONlib::GetIp(param);
88 for (Int_t i=0; i<5; i++) fChildSelect[i]=0;
91 SetChildMomentumRange();
98 AliGenParam::AliGenParam(Int_t npart, Param_t param,
99 Double_t (*PtPara) (Double_t*, Double_t*),
100 Double_t (*YPara ) (Double_t* ,Double_t*),
105 // Gines Martinez 1/10/99
106 fPtParaFunc = PtPara;
108 fIpParaFunc = IpPara;
115 for (Int_t i=0; i<5; i++) fChildSelect[i]=0;
118 SetChildMomentumRange();
121 SetChildThetaRange();
125 //____________________________________________________________
126 AliGenParam::~AliGenParam()
133 //____________________________________________________________
134 void AliGenParam::Init()
137 SetMC(new AliPythia());
138 fPythia= (AliPythia*) fgMCEvGen;
142 <img src="picts/AliGenParam.gif">
146 fPtPara = new TF1("Pt-Parametrization",fPtParaFunc,fPtMin,fPtMax,0);
147 // Set representation precision to 10 MeV
148 Int_t npx= Int_t((fPtMax-fPtMin)/fDeltaPt);
150 fPtPara->SetNpx(npx);
152 fYPara = new TF1("Y -Parametrization",fYParaFunc,fYMin,fYMax,0);
153 TF1* ptPara = new TF1("Pt-Parametrization",fPtParaFunc,0,15,0);
154 TF1* yPara = new TF1("Y -Parametrization",fYParaFunc,-6,6,0);
161 fdNdy0=fYParaFunc(&y1,&y2);
163 // Integral over generation region
164 Float_t intYS = yPara ->Integral(fYMin, fYMax);
165 Float_t intPt0 = ptPara->Integral(0,15);
166 Float_t intPtS = ptPara->Integral(fPtMin,fPtMax);
167 Float_t phiWgt=(fPhiMax-fPhiMin)/2./TMath::Pi();
168 if (fAnalog == analog) {
169 fYWgt = intYS/fdNdy0;
170 fPtWgt = intPtS/intPt0;
171 fParentWeight = fYWgt*fPtWgt*phiWgt/fNpart;
173 fYWgt = intYS/fdNdy0;
174 fPtWgt = (fPtMax-fPtMin)/intPt0;
175 fParentWeight = fYWgt*fPtWgt*phiWgt/fNpart;
178 // particle decay related initialization
179 fPythia->DefineParticles();
180 // semimuonic decays of charm and beauty
181 fPythia->ForceDecay(fForceDecay);
187 case b_jpsi_dielectron:
188 case b_psip_dielectron:
210 //____________________________________________________________
211 void AliGenParam::Generate()
214 // Generate 'npart' of light and heavy mesons (J/Psi, upsilon or phi, Pion,
215 // Kaons, Etas, Omegas) and Baryons (proton, antiprotons, neutrons and
216 // antineutrons in the the desired theta, phi and momentum windows;
217 // Gaussian smearing on the vertex is done if selected.
218 // The decay of heavy mesons is done using lujet,
219 // and the childern particle are tracked by GEANT
220 // However, light mesons are directly tracked by GEANT
221 // setting fForceDecay = nodecay (SetForceDecay(nodecay))
225 Float_t polar[3]= {0,0,0}; // Polarisation of the parent particle (for GEANT tracking)
226 Float_t origin0[3]; // Origin of the generated parent particle (for GEANT tracking)
227 Float_t pt, pl, ptot; // Transverse, logitudinal and total momenta of the parent particle
228 Float_t phi, theta; // Phi and theta spherical angles of the parent particle momentum
230 och[3], pch[10][3]; // Momentum, polarisation and origin of the children particles from lujet
232 Int_t nt, i, j, kfch[10];
235 static TClonesArray *particles;
237 if(!particles) particles=new TClonesArray("TParticle",1000);
241 // Calculating vertex position per event
242 for (j=0;j<3;j++) origin0[j]=fOrigin[j];
243 if(fVertexSmear==perEvent) {
246 origin0[j]+=fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
247 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
251 // Generating fNpart particles
256 Int_t iPart = fIpParaFunc();
257 fChildWeight=(fPythia->GetBraPart(iPart))*fParentWeight;
258 Float_t am=fPythia->GetPMAS(fPythia->Lucomp(iPart),1);
262 phi=fPhiMin+random[0]*(fPhiMax-fPhiMin);
265 ty=Float_t(TMath::TanH(fYPara->GetRandom()));
268 if (fAnalog == analog) {
269 pt=fPtPara->GetRandom();
273 pt=fPtMin+random[1]*(fPtMax-fPtMin);
275 wgtp=fParentWeight*fPtParaFunc(& ptd, &dummy);
276 wgtch=fChildWeight*fPtParaFunc(& ptd, &dummy);
278 xmt=sqrt(pt*pt+am*am);
279 pl=xmt*ty/sqrt(1.-ty*ty);
280 theta=TMath::ATan2(pt,pl);
282 if(theta<fThetaMin || theta>fThetaMax) continue;
283 ptot=TMath::Sqrt(pt*pt+pl*pl);
285 if(ptot<fPMin || ptot>fPMax) continue;
286 p[0]=pt*TMath::Cos(phi);
287 p[1]=pt*TMath::Sin(phi);
289 if(fVertexSmear==perTrack) {
293 fOrigin[j]+fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
294 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
298 // Looking at fForceDecay :
299 // if fForceDecay != none Primary particle decays using
300 // AliPythia and children are tracked by GEANT
302 // if fForceDecay == none Primary particle is tracked by GEANT
303 // (In the latest, make sure that GEANT actually does all the decays you want)
305 if (fForceDecay != nodecay) {
306 // Using lujet to decay particle
307 Float_t energy=TMath::Sqrt(ptot*ptot+am*am);
308 fPythia->DecayParticle(iPart,energy,theta,phi);
310 // select decay particles
311 Int_t np=fPythia->ImportParticles(particles,"All");
313 for (i = 1; i<np; i++) {
314 TParticle * iparticle = (TParticle *) particles->At(i);
315 Int_t kf = iparticle->GetPdgCode();
318 if (ChildSelected(TMath::Abs(kf)))
320 pc[0]=iparticle->Px();
321 pc[1]=iparticle->Py();
322 pc[2]=iparticle->Pz();
323 och[0]=origin0[0]+iparticle->Vx()/10;
324 och[1]=origin0[1]+iparticle->Vy()/10;
325 och[2]=origin0[2]+iparticle->Vz()/10;
327 Float_t ptChild=TMath::Sqrt(pc[0]*pc[0]+pc[1]*pc[1]);
328 Float_t pChild=TMath::Sqrt(ptChild*ptChild+pc[2]*pc[2]);
329 Float_t thetaChild=TMath::ATan2(ptChild,pc[2]);
330 Float_t phiChild=TMath::ATan2(pc[1],pc[0]);
332 ((ptChild > fChildPtMin && ptChild <fChildPtMax) &&
333 (pChild > fChildPMin && pChild <fChildPMax) &&
334 (thetaChild > fChildThetaMin && thetaChild <fChildThetaMax) &&
335 (phiChild > fChildPhiMin && phiChild <fChildPhiMax));
353 } // if child selection
355 } // decay particle loop
357 if ((fCutOnChild && ncsel >0) || !fCutOnChild){
362 SetTrack(0,-1,iPart,p,origin0,polar,0,"Primary",nt,wgtp);
365 for (i=0; i< ncsel; i++) {
366 gAlice->SetTrack(fTrackIt,iparent,kfch[i],
367 &pch[i][0],och,polar,
369 gAlice->KeepTrack(nt);
372 } // kinematic selection
373 else // nodecay option, so parent will be tracked by GEANT (pions, kaons, eta, omegas, baryons)
376 SetTrack(fTrackIt,-1,iPart,p,origin0,polar,0,"Primary",nt,wgtp);
384 Bool_t AliGenParam::ChildSelected(Int_t ip)
386 // True if particle is in list of selected children
387 for (Int_t i=0; i<5; i++)
389 if (fChildSelect[i]==ip) return kTRUE;
394 Bool_t AliGenParam::KinematicSelection(TParticle *particle)
396 // Perform kinematic cuts
397 Float_t px=particle->Px();
398 Float_t py=particle->Py();
399 Float_t pz=particle->Pz();
402 Float_t p=TMath::Sqrt(px*px+py*py+pz*pz);
403 if (p > fPMax || p < fPMin)
405 // printf("\n failed p cut %f %f %f \n",p,fPMin,fPMax);
408 Float_t pt=TMath::Sqrt(px*px+py*py);
412 Float_t theta = Float_t(TMath::ATan2(Double_t(pt),Double_t(p)));
413 if (theta > fThetaMax || theta < fThetaMin)
415 // printf("\n failed theta cut %f %f %f \n",theta,fThetaMin,fThetaMax);