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.17 2003/04/30 14:48:21 hristov
19 Changes related to the initialization of random numbers generators. Now one can use its own randoms for each module, particle generator, and/or tracking package. The interface with Fortran is simplified and some inter-library dependencies are avoided. Future improvements are welcome...
21 Revision 1.16 2003/04/08 10:22:05 morsch
22 Rapidity shift calculated in Init().
24 Revision 1.15 2003/04/04 08:13:26 morsch
27 Revision 1.14 2003/01/14 10:50:19 alibrary
28 Cleanup of STEER coding conventions
30 Revision 1.13 2002/10/14 14:55:35 hristov
31 Merging the VirtualMC branch to the main development branch (HEAD)
33 Revision 1.5.4.2 2002/07/24 08:56:28 alibrary
34 Updating EVGEN on TVirtulaMC
36 Revision 1.12 2002/07/19 11:42:33 morsch
39 Revision 1.11 2002/06/06 15:26:24 morsch
40 Correct child-selection for kPhiKK
42 Revision 1.10 2002/06/05 14:05:46 morsch
43 Decayer option kPhiKK for forced phi->K+K- decay added.
45 Revision 1.9 2002/05/30 14:58:29 morsch
46 Add pointer to AliGeometry to handle geometrical acceptance. (G. MArtinez)
48 Revision 1.8 2002/04/26 10:42:35 morsch
49 Case kNoDecayHeavy added. (N. Carrer)
51 Revision 1.7 2002/04/17 10:32:32 morsch
52 Coding Rule violations corrected.
54 Revision 1.6 2002/03/26 14:19:36 morsch
55 Saver calculation of rapdity.
57 Revision 1.5 2002/03/12 17:02:20 morsch
58 Change in calculation of rapidity, include case in which numerically e == pz.
60 Revision 1.4 2001/11/27 13:13:07 morsch
61 Maximum lifetime for long-lived particles to be put on the stack is parameter.
62 It can be set via SetMaximumLifetime(..).
64 Revision 1.3 2001/10/16 08:48:56 morsch
65 Common vertex related code moved to base class AliGenerator.
67 Revision 1.2 2001/10/15 08:15:51 morsch
68 Event vertex and vertex truncation setting moved into AliMC.
70 Revision 1.1 2001/07/13 10:56:00 morsch
71 AliGenMC base class for AliGenParam and AliGenPythia commonalities.
75 // Base class for generators using external MC generators.
76 // For example AliGenPythia using Pythia.
77 // Provides basic functionality: setting of kinematic cuts on
78 // decay products and particle selection.
79 // andreas.morsch@cern.ch
83 #include <TParticle.h>
92 // Default Constructor
94 SetChildMomentumRange();
100 SetGeometryAcceptance();
101 SetPdgCodeParticleforAcceptanceCut();
102 SetNumberOfAcceptedParticles();
107 AliGenMC::AliGenMC(Int_t npart)
112 SetChildMomentumRange();
115 SetChildThetaRange();
118 fParentSelect.Set(8);
120 for (Int_t i=0; i<8; i++) fParentSelect[i]=fChildSelect[i]=0;
121 SetMaximumLifetime();
122 SetGeometryAcceptance();
123 SetPdgCodeParticleforAcceptanceCut();
124 SetNumberOfAcceptedParticles();
129 AliGenMC::AliGenMC(const AliGenMC & mc)
134 AliGenMC::~AliGenMC()
139 void AliGenMC::Init()
143 switch (fForceDecay) {
144 case kSemiElectronic:
146 case kBJpsiDiElectron:
147 case kBPsiPrimeDiElectron:
148 fChildSelect[0] = kElectron;
153 case kBPsiPrimeDiMuon:
156 fChildSelect[0]=kMuonMinus;
159 fChildSelect[0]=kPiPlus;
160 fChildSelect[1]=kKPlus;
163 fChildSelect[0]=kKPlus;
171 if (fZTarget != 0 && fAProjectile != 0)
173 fDyBoost = - 0.5 * TMath::Log(Double_t(fZProjectile) * Double_t(fATarget) /
174 (Double_t(fZTarget) * Double_t(fAProjectile)));
179 Bool_t AliGenMC::ParentSelected(Int_t ip) const
181 // True if particle is in list of parent particles to be selected
182 for (Int_t i=0; i<8; i++)
184 if (fParentSelect.At(i) == ip) return kTRUE;
189 Bool_t AliGenMC::ChildSelected(Int_t ip) const
191 // True if particle is in list of decay products to be selected
192 for (Int_t i=0; i<5; i++)
194 if (fChildSelect.At(i) == ip) return kTRUE;
199 Bool_t AliGenMC::KinematicSelection(TParticle *particle, Int_t flag) const
201 // Perform kinematic selection
202 Float_t pz = particle->Pz();
203 Float_t e = particle->Energy();
204 Float_t pt = particle->Pt();
205 Float_t p = particle->P();
206 Float_t theta = particle->Theta();
207 Float_t mass = particle->GetCalcMass();
208 Float_t mt2 = pt * pt + mass * mass;
209 Float_t phi = particle->Phi();
213 if (TMath::Abs(pz) < e) {
214 y = 0.5*TMath::Log((e+pz)/(e-pz));
220 y0 = 0.5*TMath::Log((e+TMath::Abs(pz))*(e+TMath::Abs(pz))/mt2);
222 if (TMath::Abs(y) < 1.e10) {
229 y = (pz < 0) ? -y0 : y0;
233 // Primary particle cuts
235 // transverse momentum cut
236 if (pt > fPtMax || pt < fPtMin) {
237 // printf("\n failed pt cut %f %f %f \n",pt,fPtMin,fPtMax);
242 if (p > fPMax || p < fPMin) {
243 // printf("\n failed p cut %f %f %f \n",p,fPMin,fPMax);
248 if (theta > fThetaMax || theta < fThetaMin) {
249 // printf("\n failed theta cut %f %f %f \n",theta,fThetaMin,fThetaMax);
254 if (y > fYMax || y < fYMin) {
255 // printf("\n failed y cut %f %f %f \n",y,fYMin,fYMax);
260 if (phi > fPhiMax || phi < fPhiMin) {
261 // printf("\n failed phi cut %f %f %f \n",phi,fPhiMin,fPhiMax);
266 // Decay product cuts
268 // transverse momentum cut
269 if (pt > fChildPtMax || pt < fChildPtMin) {
270 // printf("\n failed pt cut %f %f %f \n",pt,fChildPtMin,fChildPtMax);
275 if (p > fChildPMax || p < fChildPMin) {
276 // printf("\n failed p cut %f %f %f \n",p,fChildPMin,fChildPMax);
281 if (theta > fChildThetaMax || theta < fChildThetaMin) {
282 // printf("\n failed theta cut %f %f %f \n",theta,fChildThetaMin,fChildThetaMax);
287 if (y > fChildYMax || y < fChildYMin) {
288 // printf("\n failed y cut %f %f %f \n",y,fChildYMin,fChildYMax);
293 if (phi > fChildPhiMax || phi < fChildPhiMin) {
294 // printf("\n failed phi cut %f %f %f \n",phi,fChildPhiMin,fChildPhiMax);
302 Bool_t AliGenMC::CheckAcceptanceGeometry(Int_t np, TClonesArray* particles)
304 Bool_t Check ; // All fPdgCodeParticleforAcceptanceCut particles are in in the fGeometryAcceptance acceptance
305 Int_t NumberOfPdgCodeParticleforAcceptanceCut=0;
306 Int_t NumberOfAcceptedPdgCodeParticleforAcceptanceCut=0;
307 TParticle * particle;
309 for (i=0; i<np; i++) {
310 particle = (TParticle *) particles->At(i);
311 if( TMath::Abs( particle->GetPdgCode() ) == TMath::Abs( fPdgCodeParticleforAcceptanceCut ) ) {
312 NumberOfPdgCodeParticleforAcceptanceCut++;
313 if (fGeometryAcceptance->Impact(particle)) NumberOfAcceptedPdgCodeParticleforAcceptanceCut++;
316 if ( NumberOfAcceptedPdgCodeParticleforAcceptanceCut > (fNumberOfAcceptedParticles-1) )
324 Int_t AliGenMC::CheckPDGCode(Int_t pdgcode) const
327 // If the particle is in a diffractive state, then take action accordingly
332 //rho_diff0 -- difficult to translate, return rho0
335 //pi_diffr+ -- change to pi+
338 //omega_di0 -- change to omega0
341 //phi_diff0 -- return phi0
344 //J/psi_di0 -- return J/psi
347 //n_diffr -- return neutron
350 //p_diffr+ -- return proton
353 //non diffractive state -- return code unchanged
357 void AliGenMC::Boost()
360 // Boost cms into LHC lab frame
363 Double_t beta = TMath::TanH(fDyBoost);
364 Double_t gamma = 1./TMath::Sqrt(1.-beta*beta);
365 Double_t gb = gamma * beta;
367 // printf("\n Boosting particles to lab frame %f %f %f", fDyBoost, beta, gamma);
370 Int_t np = fParticles->GetEntriesFast();
371 for (i = 0; i < np; i++)
373 TParticle* iparticle = (TParticle*) fParticles->At(i);
375 Double_t e = iparticle->Energy();
376 Double_t px = iparticle->Px();
377 Double_t py = iparticle->Py();
378 Double_t pz = iparticle->Pz();
380 Double_t eb = gamma * e - gb * pz;
381 Double_t pzb = -gb * e + gamma * pz;
383 iparticle->SetMomentum(px, py, pzb, eb);
389 AliGenMC& AliGenMC::operator=(const AliGenMC& rhs)
391 // Assignment operator