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.16 2003/04/08 10:22:05 morsch
19 Rapidity shift calculated in Init().
21 Revision 1.15 2003/04/04 08:13:26 morsch
24 Revision 1.14 2003/01/14 10:50:19 alibrary
25 Cleanup of STEER coding conventions
27 Revision 1.13 2002/10/14 14:55:35 hristov
28 Merging the VirtualMC branch to the main development branch (HEAD)
30 Revision 1.5.4.2 2002/07/24 08:56:28 alibrary
31 Updating EVGEN on TVirtulaMC
33 Revision 1.12 2002/07/19 11:42:33 morsch
36 Revision 1.11 2002/06/06 15:26:24 morsch
37 Correct child-selection for kPhiKK
39 Revision 1.10 2002/06/05 14:05:46 morsch
40 Decayer option kPhiKK for forced phi->K+K- decay added.
42 Revision 1.9 2002/05/30 14:58:29 morsch
43 Add pointer to AliGeometry to handle geometrical acceptance. (G. MArtinez)
45 Revision 1.8 2002/04/26 10:42:35 morsch
46 Case kNoDecayHeavy added. (N. Carrer)
48 Revision 1.7 2002/04/17 10:32:32 morsch
49 Coding Rule violations corrected.
51 Revision 1.6 2002/03/26 14:19:36 morsch
52 Saver calculation of rapdity.
54 Revision 1.5 2002/03/12 17:02:20 morsch
55 Change in calculation of rapidity, include case in which numerically e == pz.
57 Revision 1.4 2001/11/27 13:13:07 morsch
58 Maximum lifetime for long-lived particles to be put on the stack is parameter.
59 It can be set via SetMaximumLifetime(..).
61 Revision 1.3 2001/10/16 08:48:56 morsch
62 Common vertex related code moved to base class AliGenerator.
64 Revision 1.2 2001/10/15 08:15:51 morsch
65 Event vertex and vertex truncation setting moved into AliMC.
67 Revision 1.1 2001/07/13 10:56:00 morsch
68 AliGenMC base class for AliGenParam and AliGenPythia commonalities.
72 // Base class for generators using external MC generators.
73 // For example AliGenPythia using Pythia.
74 // Provides basic functionality: setting of kinematic cuts on
75 // decay products and particle selection.
76 // andreas.morsch@cern.ch
80 #include <TParticle.h>
89 // Default Constructor
91 SetChildMomentumRange();
97 SetGeometryAcceptance();
98 SetPdgCodeParticleforAcceptanceCut();
99 SetNumberOfAcceptedParticles();
104 AliGenMC::AliGenMC(Int_t npart)
109 SetChildMomentumRange();
112 SetChildThetaRange();
115 fParentSelect.Set(8);
117 for (Int_t i=0; i<8; i++) fParentSelect[i]=fChildSelect[i]=0;
118 SetMaximumLifetime();
119 SetGeometryAcceptance();
120 SetPdgCodeParticleforAcceptanceCut();
121 SetNumberOfAcceptedParticles();
126 AliGenMC::AliGenMC(const AliGenMC & mc)
131 AliGenMC::~AliGenMC()
136 void AliGenMC::Init()
140 switch (fForceDecay) {
141 case kSemiElectronic:
143 case kBJpsiDiElectron:
144 case kBPsiPrimeDiElectron:
145 fChildSelect[0] = kElectron;
150 case kBPsiPrimeDiMuon:
153 fChildSelect[0]=kMuonMinus;
156 fChildSelect[0]=kPiPlus;
157 fChildSelect[1]=kKPlus;
160 fChildSelect[0]=kKPlus;
168 if (fZTarget != 0 && fAProjectile != 0)
170 fDyBoost = - 0.5 * TMath::Log(Double_t(fZProjectile) * Double_t(fATarget) /
171 (Double_t(fZTarget) * Double_t(fAProjectile)));
176 Bool_t AliGenMC::ParentSelected(Int_t ip) const
178 // True if particle is in list of parent particles to be selected
179 for (Int_t i=0; i<8; i++)
181 if (fParentSelect.At(i) == ip) return kTRUE;
186 Bool_t AliGenMC::ChildSelected(Int_t ip) const
188 // True if particle is in list of decay products to be selected
189 for (Int_t i=0; i<5; i++)
191 if (fChildSelect.At(i) == ip) return kTRUE;
196 Bool_t AliGenMC::KinematicSelection(TParticle *particle, Int_t flag) const
198 // Perform kinematic selection
199 Float_t px = particle->Px();
200 Float_t py = particle->Py();
201 Float_t pz = particle->Pz();
202 Float_t e = particle->Energy();
203 Float_t pt = particle->Pt();
204 Float_t p = particle->P();
205 Float_t theta = particle->Theta();
206 Float_t mass = particle->GetCalcMass();
207 Float_t mt2 = pt * pt + mass * mass;
209 Float_t phi = Float_t(TMath::ATan2(Double_t(py),Double_t(px)));
212 if (TMath::Abs(pz) < e) {
213 y = 0.5*TMath::Log((e+pz)/(e-pz));
219 y0 = 0.5*TMath::Log((e+TMath::Abs(pz))*(e+TMath::Abs(pz))/mt2);
221 if (TMath::Abs(y) < 1.e10) {
228 y = (pz < 0) ? -y0 : y0;
232 // Primary particle cuts
234 // transverse momentum cut
235 if (pt > fPtMax || pt < fPtMin) {
236 // printf("\n failed pt cut %f %f %f \n",pt,fPtMin,fPtMax);
241 if (p > fPMax || p < fPMin) {
242 // printf("\n failed p cut %f %f %f \n",p,fPMin,fPMax);
247 if (theta > fThetaMax || theta < fThetaMin) {
248 // printf("\n failed theta cut %f %f %f \n",theta,fThetaMin,fThetaMax);
253 if (y > fYMax || y < fYMin) {
254 // printf("\n failed y cut %f %f %f \n",y,fYMin,fYMax);
259 if (phi > fPhiMax || phi < fPhiMin) {
260 // printf("\n failed phi cut %f %f %f \n",phi,fPhiMin,fPhiMax);
265 // Decay product cuts
267 // transverse momentum cut
268 if (pt > fChildPtMax || pt < fChildPtMin) {
269 // printf("\n failed pt cut %f %f %f \n",pt,fChildPtMin,fChildPtMax);
274 if (p > fChildPMax || p < fChildPMin) {
275 // printf("\n failed p cut %f %f %f \n",p,fChildPMin,fChildPMax);
280 if (theta > fChildThetaMax || theta < fChildThetaMin) {
281 // printf("\n failed theta cut %f %f %f \n",theta,fChildThetaMin,fChildThetaMax);
286 if (y > fChildYMax || y < fChildYMin) {
287 // printf("\n failed y cut %f %f %f \n",y,fChildYMin,fChildYMax);
292 if (phi > fChildPhiMax || phi < fChildPhiMin) {
293 // printf("\n failed phi cut %f %f %f \n",phi,fChildPhiMin,fChildPhiMax);
301 Bool_t AliGenMC::CheckAcceptanceGeometry(Int_t np, TClonesArray* particles)
303 Bool_t Check ; // All fPdgCodeParticleforAcceptanceCut particles are in in the fGeometryAcceptance acceptance
304 Int_t NumberOfPdgCodeParticleforAcceptanceCut=0;
305 Int_t NumberOfAcceptedPdgCodeParticleforAcceptanceCut=0;
306 TParticle * particle;
308 for (i=0; i<np; i++) {
309 particle = (TParticle *) particles->At(i);
310 if( TMath::Abs( particle->GetPdgCode() ) == TMath::Abs( fPdgCodeParticleforAcceptanceCut ) ) {
311 NumberOfPdgCodeParticleforAcceptanceCut++;
312 if (fGeometryAcceptance->Impact(particle)) NumberOfAcceptedPdgCodeParticleforAcceptanceCut++;
315 if ( NumberOfAcceptedPdgCodeParticleforAcceptanceCut > (fNumberOfAcceptedParticles-1) )
323 Int_t AliGenMC::CheckPDGCode(Int_t pdgcode) const
326 // If the particle is in a diffractive state, then take action accordingly
331 //rho_diff0 -- difficult to translate, return rho0
334 //pi_diffr+ -- change to pi+
337 //omega_di0 -- change to omega0
340 //phi_diff0 -- return phi0
343 //J/psi_di0 -- return J/psi
346 //n_diffr -- return neutron
349 //p_diffr+ -- return proton
352 //non diffractive state -- return code unchanged
356 void AliGenMC::Boost()
359 // Boost cms into LHC lab frame
362 Double_t beta = TMath::TanH(fDyBoost);
363 Double_t gamma = 1./TMath::Sqrt(1.-beta*beta);
364 Double_t gb = gamma * beta;
366 // printf("\n Boosting particles to lab frame %f %f %f", fDyBoost, beta, gamma);
369 Int_t np = fParticles->GetEntriesFast();
370 for (i = 0; i < np; i++)
372 TParticle* iparticle = (TParticle*) fParticles->At(i);
374 Double_t e = iparticle->Energy();
375 Double_t px = iparticle->Px();
376 Double_t py = iparticle->Py();
377 Double_t pz = iparticle->Pz();
379 Double_t eb = gamma * e - gb * pz;
380 Double_t pzb = -gb * e + gamma * pz;
382 iparticle->SetMomentum(px, py, pzb, eb);
388 AliGenMC& AliGenMC::operator=(const AliGenMC& rhs)
390 // Assignment operator