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 // Base class for generators using external MC generators.
19 // For example AliGenPythia using Pythia.
20 // Provides basic functionality: setting of kinematic cuts on
21 // decay products and particle selection.
22 // andreas.morsch@cern.ch
26 #include <TParticle.h>
35 // Default Constructor
37 SetChildMomentumRange();
43 SetGeometryAcceptance();
44 SetPdgCodeParticleforAcceptanceCut();
45 SetNumberOfAcceptedParticles();
50 AliGenMC::AliGenMC(Int_t npart)
55 SetChildMomentumRange();
63 for (Int_t i=0; i<8; i++) fParentSelect[i]=fChildSelect[i]=0;
65 SetGeometryAcceptance();
66 SetPdgCodeParticleforAcceptanceCut();
67 SetNumberOfAcceptedParticles();
72 AliGenMC::AliGenMC(const AliGenMC & mc):
88 switch (fForceDecay) {
91 case kBJpsiDiElectron:
92 case kBPsiPrimeDiElectron:
93 fChildSelect[0] = kElectron;
98 case kBPsiPrimeDiMuon:
101 fChildSelect[0]=kMuonMinus;
104 fChildSelect[0]=kPiPlus;
105 fChildSelect[1]=kKPlus;
108 fChildSelect[0]=kKPlus;
116 if (fZTarget != 0 && fAProjectile != 0)
118 fDyBoost = - 0.5 * TMath::Log(Double_t(fZProjectile) * Double_t(fATarget) /
119 (Double_t(fZTarget) * Double_t(fAProjectile)));
124 Bool_t AliGenMC::ParentSelected(Int_t ip) const
126 // True if particle is in list of parent particles to be selected
127 for (Int_t i=0; i<8; i++)
129 if (fParentSelect.At(i) == ip) return kTRUE;
134 Bool_t AliGenMC::ChildSelected(Int_t ip) const
136 // True if particle is in list of decay products to be selected
137 for (Int_t i=0; i<5; i++)
139 if (fChildSelect.At(i) == ip) return kTRUE;
144 Bool_t AliGenMC::KinematicSelection(TParticle *particle, Int_t flag) const
146 // Perform kinematic selection
147 Float_t pz = particle->Pz();
148 Float_t e = particle->Energy();
149 Float_t pt = particle->Pt();
150 Float_t p = particle->P();
151 Float_t theta = particle->Theta();
152 Float_t mass = particle->GetCalcMass();
153 Float_t mt2 = pt * pt + mass * mass;
154 Float_t phi = particle->Phi();
158 if (TMath::Abs(pz) < e) {
159 y = 0.5*TMath::Log((e+pz)/(e-pz));
165 y0 = 0.5*TMath::Log((e+TMath::Abs(pz))*(e+TMath::Abs(pz))/mt2);
167 if (TMath::Abs(y) < 1.e10) {
174 y = (pz < 0) ? -y0 : y0;
178 // Primary particle cuts
180 // transverse momentum cut
181 if (pt > fPtMax || pt < fPtMin) {
182 // printf("\n failed pt cut %f %f %f \n",pt,fPtMin,fPtMax);
187 if (p > fPMax || p < fPMin) {
188 // printf("\n failed p cut %f %f %f \n",p,fPMin,fPMax);
193 if (theta > fThetaMax || theta < fThetaMin) {
194 // printf("\n failed theta cut %f %f %f \n",theta,fThetaMin,fThetaMax);
199 if (y > fYMax || y < fYMin) {
200 // printf("\n failed y cut %f %f %f \n",y,fYMin,fYMax);
205 if (phi > fPhiMax || phi < fPhiMin) {
206 // printf("\n failed phi cut %f %f %f \n",phi,fPhiMin,fPhiMax);
211 // Decay product cuts
213 // transverse momentum cut
214 if (pt > fChildPtMax || pt < fChildPtMin) {
215 // printf("\n failed pt cut %f %f %f \n",pt,fChildPtMin,fChildPtMax);
220 if (p > fChildPMax || p < fChildPMin) {
221 // printf("\n failed p cut %f %f %f \n",p,fChildPMin,fChildPMax);
226 if (theta > fChildThetaMax || theta < fChildThetaMin) {
227 // printf("\n failed theta cut %f %f %f \n",theta,fChildThetaMin,fChildThetaMax);
232 if (y > fChildYMax || y < fChildYMin) {
233 // printf("\n failed y cut %f %f %f \n",y,fChildYMin,fChildYMax);
238 if (phi > fChildPhiMax || phi < fChildPhiMin) {
239 // printf("\n failed phi cut %f %f %f \n",phi,fChildPhiMin,fChildPhiMax);
247 Bool_t AliGenMC::CheckAcceptanceGeometry(Int_t np, TClonesArray* particles)
249 Bool_t Check ; // All fPdgCodeParticleforAcceptanceCut particles are in in the fGeometryAcceptance acceptance
250 Int_t NumberOfPdgCodeParticleforAcceptanceCut=0;
251 Int_t NumberOfAcceptedPdgCodeParticleforAcceptanceCut=0;
252 TParticle * particle;
254 for (i=0; i<np; i++) {
255 particle = (TParticle *) particles->At(i);
256 if( TMath::Abs( particle->GetPdgCode() ) == TMath::Abs( fPdgCodeParticleforAcceptanceCut ) ) {
257 NumberOfPdgCodeParticleforAcceptanceCut++;
258 if (fGeometryAcceptance->Impact(particle)) NumberOfAcceptedPdgCodeParticleforAcceptanceCut++;
261 if ( NumberOfAcceptedPdgCodeParticleforAcceptanceCut > (fNumberOfAcceptedParticles-1) )
269 Int_t AliGenMC::CheckPDGCode(Int_t pdgcode) const
272 // If the particle is in a diffractive state, then take action accordingly
277 //rho_diff0 -- difficult to translate, return rho0
280 //pi_diffr+ -- change to pi+
283 //omega_di0 -- change to omega0
286 //phi_diff0 -- return phi0
289 //J/psi_di0 -- return J/psi
292 //n_diffr -- return neutron
295 //p_diffr+ -- return proton
298 //non diffractive state -- return code unchanged
302 void AliGenMC::Boost()
305 // Boost cms into LHC lab frame
308 Double_t beta = TMath::TanH(fDyBoost);
309 Double_t gamma = 1./TMath::Sqrt(1.-beta*beta);
310 Double_t gb = gamma * beta;
312 // printf("\n Boosting particles to lab frame %f %f %f", fDyBoost, beta, gamma);
315 Int_t np = fParticles->GetEntriesFast();
316 for (i = 0; i < np; i++)
318 TParticle* iparticle = (TParticle*) fParticles->At(i);
320 Double_t e = iparticle->Energy();
321 Double_t px = iparticle->Px();
322 Double_t py = iparticle->Py();
323 Double_t pz = iparticle->Pz();
325 Double_t eb = gamma * e - gb * pz;
326 Double_t pzb = -gb * e + gamma * pz;
328 iparticle->SetMomentum(px, py, pzb, eb);
334 AliGenMC& AliGenMC::operator=(const AliGenMC& rhs)
336 // Assignment operator
341 void AliGenMC::Copy(AliGenMC&) const
346 Fatal("Copy","Not implemented!\n");