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
24 #include <TClonesArray.h>
27 #include <TParticle.h>
30 #include "AliGeometry.h"
37 // Default Constructor
39 SetChildMomentumRange();
45 SetGeometryAcceptance();
46 SetPdgCodeParticleforAcceptanceCut();
47 SetNumberOfAcceptedParticles();
55 AliGenMC::AliGenMC(Int_t npart)
60 SetChildMomentumRange();
68 for (Int_t i=0; i<8; i++) fParentSelect[i]=fChildSelect[i]=0;
70 SetGeometryAcceptance();
71 SetPdgCodeParticleforAcceptanceCut();
72 SetNumberOfAcceptedParticles();
78 AliGenMC::AliGenMC(const AliGenMC & mc):
94 switch (fForceDecay) {
97 case kBJpsiDiElectron:
98 case kBPsiPrimeDiElectron:
99 fChildSelect[0] = kElectron;
105 case kBPsiPrimeDiMuon:
109 case kWToCharmToMuon:
111 fChildSelect[0]=kMuonMinus;
116 fChildSelect[0]=kPiPlus;
117 fChildSelect[1]=kKPlus;
120 fChildSelect[0]=kKPlus;
132 if (fZTarget != 0 && fAProjectile != 0)
134 fDyBoost = - 0.5 * TMath::Log(Double_t(fZProjectile) * Double_t(fATarget) /
135 (Double_t(fZTarget) * Double_t(fAProjectile)));
140 Bool_t AliGenMC::ParentSelected(Int_t ip) const
142 // True if particle is in list of parent particles to be selected
143 for (Int_t i=0; i<8; i++)
145 if (fParentSelect.At(i) == ip) return kTRUE;
150 Bool_t AliGenMC::ChildSelected(Int_t ip) const
152 // True if particle is in list of decay products to be selected
153 for (Int_t i=0; i<5; i++)
155 if (fChildSelect.At(i) == ip) return kTRUE;
160 Bool_t AliGenMC::KinematicSelection(TParticle *particle, Int_t flag) const
162 // Perform kinematic selection
163 Float_t pz = particle->Pz();
164 Float_t e = particle->Energy();
165 Float_t pt = particle->Pt();
166 Float_t p = particle->P();
167 Float_t theta = particle->Theta();
168 Float_t mass = particle->GetCalcMass();
169 Float_t mt2 = pt * pt + mass * mass;
170 Float_t phi = particle->Phi();
174 if (TMath::Abs(pz) < e) {
175 y = 0.5*TMath::Log((e+pz)/(e-pz));
181 y0 = 0.5*TMath::Log((e+TMath::Abs(pz))*(e+TMath::Abs(pz))/mt2);
183 if (TMath::Abs(y) < 1.e10) {
190 y = (pz < 0) ? -y0 : y0;
194 // Primary particle cuts
196 // transverse momentum cut
197 if (pt > fPtMax || pt < fPtMin) {
198 // printf("\n failed pt cut %f %f %f \n",pt,fPtMin,fPtMax);
203 if (p > fPMax || p < fPMin) {
204 // printf("\n failed p cut %f %f %f \n",p,fPMin,fPMax);
209 if (theta > fThetaMax || theta < fThetaMin) {
210 // printf("\n failed theta cut %f %f %f \n",theta,fThetaMin,fThetaMax);
215 if (y > fYMax || y < fYMin) {
216 // printf("\n failed y cut %f %f %f \n",y,fYMin,fYMax);
221 if (phi > fPhiMax || phi < fPhiMin) {
222 // printf("\n failed phi cut %f %f %f \n",phi,fPhiMin,fPhiMax);
227 // Decay product cuts
229 // transverse momentum cut
230 if (pt > fChildPtMax || pt < fChildPtMin) {
231 // printf("\n failed pt cut %f %f %f \n",pt,fChildPtMin,fChildPtMax);
236 if (p > fChildPMax || p < fChildPMin) {
237 // printf("\n failed p cut %f %f %f \n",p,fChildPMin,fChildPMax);
242 if (theta > fChildThetaMax || theta < fChildThetaMin) {
243 // printf("\n failed theta cut %f %f %f \n",theta,fChildThetaMin,fChildThetaMax);
248 if (y > fChildYMax || y < fChildYMin) {
249 // printf("\n failed y cut %f %f %f \n",y,fChildYMin,fChildYMax);
254 if (phi > fChildPhiMax || phi < fChildPhiMin) {
255 // printf("\n failed phi cut %f %f %f \n",phi,fChildPhiMin,fChildPhiMax);
263 Bool_t AliGenMC::CheckAcceptanceGeometry(Int_t np, TClonesArray* particles)
265 // Check the geometrical acceptance for particle.
268 Int_t numberOfPdgCodeParticleforAcceptanceCut = 0;
269 Int_t numberOfAcceptedPdgCodeParticleforAcceptanceCut = 0;
270 TParticle * particle;
272 for (i = 0; i < np; i++) {
273 particle = (TParticle *) particles->At(i);
274 if( TMath::Abs( particle->GetPdgCode() ) == TMath::Abs( fPdgCodeParticleforAcceptanceCut ) ) {
275 numberOfPdgCodeParticleforAcceptanceCut++;
276 if (fGeometryAcceptance->Impact(particle)) numberOfAcceptedPdgCodeParticleforAcceptanceCut++;
279 if ( numberOfAcceptedPdgCodeParticleforAcceptanceCut > (fNumberOfAcceptedParticles-1) )
287 Int_t AliGenMC::CheckPDGCode(Int_t pdgcode) const
290 // If the particle is in a diffractive state, then take action accordingly
295 //rho_diff0 -- difficult to translate, return rho0
298 //pi_diffr+ -- change to pi+
301 //omega_di0 -- change to omega0
304 //phi_diff0 -- return phi0
307 //J/psi_di0 -- return J/psi
310 //n_diffr -- return neutron
313 //p_diffr+ -- return proton
316 //non diffractive state -- return code unchanged
320 void AliGenMC::Boost()
323 // Boost cms into LHC lab frame
326 Double_t beta = TMath::TanH(fDyBoost);
327 Double_t gamma = 1./TMath::Sqrt(1.-beta*beta);
328 Double_t gb = gamma * beta;
330 // printf("\n Boosting particles to lab frame %f %f %f", fDyBoost, beta, gamma);
333 Int_t np = fParticles->GetEntriesFast();
334 for (i = 0; i < np; i++)
336 TParticle* iparticle = (TParticle*) fParticles->At(i);
338 Double_t e = iparticle->Energy();
339 Double_t px = iparticle->Px();
340 Double_t py = iparticle->Py();
341 Double_t pz = iparticle->Pz();
343 Double_t eb = gamma * e - gb * pz;
344 Double_t pzb = -gb * e + gamma * pz;
346 iparticle->SetMomentum(px, py, pzb, eb);
352 AliGenMC& AliGenMC::operator=(const AliGenMC& rhs)
354 // Assignment operator
359 void AliGenMC::Copy(TObject&) const
364 Fatal("Copy","Not implemented!\n");