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 // Class to generate particles from using paramtrized pT and y distributions.
19 // Distributions are obtained from pointer to object of type AliGenLib.
20 // (For example AliGenMUONlib)
21 // Decays are performed using Pythia.
22 // andreas.morsch@cern.ch
25 #include <TClonesArray.h>
26 #include <TDatabasePDG.h>
29 #include <TLorentzVector.h>
31 #include <TParticle.h>
32 #include <TParticlePDG.h>
34 #include <TVirtualMC.h>
36 #include "AliDecayer.h"
37 #include "AliGenMUONlib.h"
38 #include "AliGenParam.h"
44 //------------------------------------------------------------
48 <img src="picts/AliGenParam.gif">
52 //____________________________________________________________
53 AliGenParam::AliGenParam():
68 // Default constructor
70 //____________________________________________________________
71 AliGenParam::AliGenParam(Int_t npart, AliGenLib * Library, Int_t param, char* tname)
73 fPtParaFunc(Library->GetPt(param, tname)),
74 fYParaFunc (Library->GetY (param, tname)),
75 fIpParaFunc(Library->GetIp(param, tname)),
87 // Constructor using number of particles parameterisation id and library
89 fTitle= "Particle Generator using pT and y parameterisation";
93 //____________________________________________________________
94 AliGenParam::AliGenParam(Int_t npart, Int_t param, const char* tname, const char* name):
110 // Constructor using parameterisation id and number of particles
113 fTitle= "Particle Generator using pT and y parameterisation";
115 AliGenLib* pLibrary = new AliGenMUONlib();
116 fPtParaFunc = pLibrary->GetPt(param, tname);
117 fYParaFunc = pLibrary->GetY (param, tname);
118 fIpParaFunc = pLibrary->GetIp(param, tname);
122 for (Int_t i=0; i<5; i++) fChildSelect[i]=0;
125 SetChildMomentumRange();
128 SetChildThetaRange();
130 //____________________________________________________________
132 AliGenParam::AliGenParam(Int_t npart, Int_t param,
133 Double_t (*PtPara) (Double_t*, Double_t*),
134 Double_t (*YPara ) (Double_t* ,Double_t*),
135 Int_t (*IpPara) (TRandom *))
153 // Gines Martinez 1/10/99
155 fTitle= "Particle Generator using pT and y parameterisation";
159 for (Int_t i=0; i<5; i++) fChildSelect[i]=0;
162 SetChildMomentumRange();
165 SetChildThetaRange();
168 //____________________________________________________________
169 AliGenParam::~AliGenParam()
176 //____________________________________________________________
177 void AliGenParam::Init()
181 if (gMC) fDecayer = gMC->GetDecayer();
184 <img src="picts/AliGenParam.gif">
188 sprintf(name, "pt-parameterisation for %s", GetName());
190 if (fPtPara) fPtPara->Delete();
191 fPtPara = new TF1(name, fPtParaFunc, fPtMin, fPtMax,0);
192 gROOT->GetListOfFunctions()->Remove(fPtPara);
193 // Set representation precision to 10 MeV
194 Int_t npx= Int_t((fPtMax - fPtMin) / fDeltaPt);
196 fPtPara->SetNpx(npx);
198 sprintf(name, "y-parameterisation for %s", GetName());
199 if (fYPara) fYPara->Delete();
200 fYPara = new TF1(name, fYParaFunc, fYMin, fYMax, 0);
201 gROOT->GetListOfFunctions()->Remove(fYPara);
204 sprintf(name, "pt-for-%s", GetName());
205 TF1 ptPara(name ,fPtParaFunc, 0, 15, 0);
206 sprintf(name, "y-for-%s", GetName());
207 TF1 yPara(name, fYParaFunc, -6, 6, 0);
214 fdNdy0=fYParaFunc(&y1,&y2);
216 // Integral over generation region
217 Float_t intYS = yPara.Integral(fYMin, fYMax,(Double_t*) 0x0,1.e-6);
218 Float_t intPt0 = ptPara.Integral(0,15,(Double_t *) 0x0,1.e-6);
219 Float_t intPtS = ptPara.Integral(fPtMin,fPtMax,(Double_t*) 0x0,1.e-6);
220 Float_t phiWgt=(fPhiMax-fPhiMin)/2./TMath::Pi();
221 if (fAnalog == kAnalog) {
222 fYWgt = intYS/fdNdy0;
223 fPtWgt = intPtS/intPt0;
224 fParentWeight = fYWgt*fPtWgt*phiWgt/fNpart;
226 fYWgt = intYS/fdNdy0;
227 fPtWgt = (fPtMax-fPtMin)/intPt0;
228 fParentWeight = fYWgt*fPtWgt*phiWgt/fNpart;
231 // particle decay related initialization
232 fDecayer->SetForceDecay(fForceDecay);
239 //____________________________________________________________
240 void AliGenParam::Generate()
243 // Generate 'npart' of light and heavy mesons (J/Psi, upsilon or phi, Pion,
244 // Kaons, Etas, Omegas) and Baryons (proton, antiprotons, neutrons and
245 // antineutrons in the the desired theta, phi and momentum windows;
246 // Gaussian smearing on the vertex is done if selected.
247 // The decay of heavy mesons is done using lujet,
248 // and the childern particle are tracked by GEANT
249 // However, light mesons are directly tracked by GEANT
250 // setting fForceDecay = nodecay (SetForceDecay(nodecay))
253 // Reinitialize decayer
254 fDecayer->SetForceDecay(fForceDecay);
258 Float_t polar[3]= {0,0,0}; // Polarisation of the parent particle (for GEANT tracking)
259 Float_t origin0[3]; // Origin of the generated parent particle (for GEANT tracking)
260 Float_t pt, pl, ptot; // Transverse, logitudinal and total momenta of the parent particle
261 Float_t phi, theta; // Phi and theta spherical angles of the parent particle momentum
263 och[3]; // Momentum, polarisation and origin of the children particles from lujet
268 static TClonesArray *particles;
270 if(!particles) particles = new TClonesArray("TParticle",1000);
272 TDatabasePDG *pDataBase = TDatabasePDG::Instance();
276 // Calculating vertex position per event
277 for (j=0;j<3;j++) origin0[j]=fOrigin[j];
278 if(fVertexSmear==kPerEvent) {
280 for (j=0;j<3;j++) origin0[j]=fVertex[j];
285 // Generating fNpart particles
290 Int_t iPart = fIpParaFunc(fRandom);
291 fChildWeight=(fDecayer->GetPartialBranchingRatio(iPart))*fParentWeight;
292 TParticlePDG *particle = pDataBase->GetParticle(iPart);
293 Float_t am = particle->Mass();
298 phi=fPhiMin+random[0]*(fPhiMax-fPhiMin);
301 ty = TMath::TanH(fYPara->GetRandom());
304 if (fAnalog == kAnalog) {
305 pt=fPtPara->GetRandom();
309 pt=fPtMin+random[1]*(fPtMax-fPtMin);
311 wgtp=fParentWeight*fPtParaFunc(& ptd, &dummy);
312 wgtch=fChildWeight*fPtParaFunc(& ptd, &dummy);
314 xmt=sqrt(pt*pt+am*am);
315 if (TMath::Abs(ty)==1.) {
318 "Division by 0: Please check you rapidity range !");
321 pl=xmt*ty/sqrt(1.-ty*ty);
322 theta=TMath::ATan2(pt,pl);
324 if(theta<fThetaMin || theta>fThetaMax) continue;
325 ptot=TMath::Sqrt(pt*pt+pl*pl);
327 if(ptot<fPMin || ptot>fPMax) continue;
329 p[0]=pt*TMath::Cos(phi);
330 p[1]=pt*TMath::Sin(phi);
332 if(fVertexSmear==kPerTrack) {
336 fOrigin[j]+fOsigma[j]*TMath::Cos(2*random[2*j]*TMath::Pi())*
337 TMath::Sqrt(-2*TMath::Log(random[2*j+1]));
341 // Looking at fForceDecay :
342 // if fForceDecay != none Primary particle decays using
343 // AliPythia and children are tracked by GEANT
345 // if fForceDecay == none Primary particle is tracked by GEANT
346 // (In the latest, make sure that GEANT actually does all the decays you want)
349 if (fForceDecay != kNoDecay) {
350 // Using lujet to decay particle
351 Float_t energy=TMath::Sqrt(ptot*ptot+am*am);
352 TLorentzVector pmom(p[0], p[1], p[2], energy);
353 fDecayer->Decay(iPart,&pmom);
355 // select decay particles
356 Int_t np=fDecayer->ImportParticles(particles);
358 // Selecting GeometryAcceptance for particles fPdgCodeParticleforAcceptanceCut;
359 if (fGeometryAcceptance)
360 if (!CheckAcceptanceGeometry(np,particles)) continue;
362 Int_t* pFlag = new Int_t[np];
363 Int_t* pParent = new Int_t[np];
364 Int_t* pSelected = new Int_t[np];
365 Int_t* trackIt = new Int_t[np];
367 for (i=0; i<np; i++) {
374 TParticle* iparticle = (TParticle *) particles->At(0);
376 for (i = 1; i<np ; i++) {
378 iparticle = (TParticle *) particles->At(i);
379 Int_t kf = iparticle->GetPdgCode();
380 Int_t ks = iparticle->GetStatusCode();
384 ipF = iparticle->GetFirstDaughter();
385 ipL = iparticle->GetLastDaughter();
386 if (ipF > 0) for (j=ipF-1; j<ipL; j++) pFlag[j]=1;
390 // flag decay products of particles with long life-time (c tau > .3 mum)
393 // TParticlePDG *particle = pDataBase->GetParticle(kf);
395 Double_t lifeTime = fDecayer->GetLifetime(kf);
396 // Double_t mass = particle->Mass();
397 // Double_t width = particle->Width();
398 if (lifeTime > (Double_t) fMaxLifeTime) {
399 ipF = iparticle->GetFirstDaughter();
400 ipL = iparticle->GetLastDaughter();
401 if (ipF > 0) for (j=ipF-1; j<ipL; j++) pFlag[j]=1;
410 if (ChildSelected(TMath::Abs(kf)) || fForceDecay == kAll && trackIt[i])
413 pc[0]=iparticle->Px();
414 pc[1]=iparticle->Py();
415 pc[2]=iparticle->Pz();
416 Bool_t childok = KinematicSelection(iparticle, 1);
427 } // if child selection
429 } // decay particle loop
430 } // if decay products
433 if ((fCutOnChild && ncsel >0) || !fCutOnChild){
437 PushTrack(0, -1, iPart, p, origin0, polar, 0, kPPrimary, nt, wgtp);
443 for (i = 1; i < np; i++) {
445 TParticle* iparticle = (TParticle *) particles->At(i);
446 Int_t kf = iparticle->GetPdgCode();
447 Int_t ipa = iparticle->GetFirstMother()-1;
449 och[0] = origin0[0]+iparticle->Vx()/10;
450 och[1] = origin0[1]+iparticle->Vy()/10;
451 och[2] = origin0[2]+iparticle->Vz()/10;
452 pc[0] = iparticle->Px();
453 pc[1] = iparticle->Py();
454 pc[2] = iparticle->Pz();
457 iparent = pParent[ipa];
462 PushTrack(fTrackIt*trackIt[i], iparent, kf,
464 0, kPDecay, nt, wgtch);
471 if (pFlag) delete[] pFlag;
472 if (pParent) delete[] pParent;
473 if (pSelected) delete[] pSelected;
474 if (trackIt) delete[] trackIt;
475 } // kinematic selection
476 else // nodecay option, so parent will be tracked by GEANT (pions, kaons, eta, omegas, baryons)
479 PushTrack(fTrackIt,-1,iPart,p,origin0,polar,0,kPPrimary,nt,wgtp);
485 SetHighWaterMark(nt);
487 //____________________________________________________________________________________
488 Float_t AliGenParam::GetRelativeArea(Float_t ptMin, Float_t ptMax, Float_t yMin, Float_t yMax, Float_t phiMin, Float_t phiMax)
491 // Normalisation for selected kinematic region
494 fPtPara->Integral(ptMin,ptMax,(Double_t *)0,1.e-6) / fPtPara->Integral( fPtPara->GetXmin(), fPtPara->GetXmax(),(Double_t *)0,1.e-6) *
495 fYPara->Integral(yMin,yMax,(Double_t *)0,1.e-6)/fYPara->Integral(fYPara->GetXmin(),fYPara->GetXmax(),(Double_t *)0,1.e-6) *
496 (phiMax-phiMin)/360.;
497 return TMath::Abs(ratio);
500 //____________________________________________________________________________________
502 void AliGenParam::Draw( const char * /*opt*/)
505 // Draw the pT and y Distributions
507 TCanvas *c0 = new TCanvas("c0","Canvas 0",400,10,600,700);
511 fPtPara->GetHistogram()->SetXTitle("p_{T} (GeV)");
514 fYPara->GetHistogram()->SetXTitle("y");