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"
45 fChildPhiMax(2. * TMath::Pi()),
47 fChildThetaMax(TMath::Pi()),
61 fGeometryAcceptance(0),
62 fPdgCodeParticleforAcceptanceCut(0),
63 fNumberOfAcceptedParticles(2)
65 // Default Constructor
68 AliGenMC::AliGenMC(Int_t npart)
79 fChildPhiMax(2. * TMath::Pi()),
81 fChildThetaMax(TMath::Pi()),
95 fGeometryAcceptance(0),
96 fPdgCodeParticleforAcceptanceCut(0),
97 fNumberOfAcceptedParticles(2)
101 for (Int_t i=0; i<8; i++) fParentSelect[i]=fChildSelect[i]=0;
104 AliGenMC::AliGenMC(const AliGenMC & mc):
115 fChildPhiMax(2. * TMath::Pi()),
117 fChildThetaMax(TMath::Pi()),
123 fMaxLifeTime(1.e-15),
131 fGeometryAcceptance(0),
132 fPdgCodeParticleforAcceptanceCut(0),
133 fNumberOfAcceptedParticles(2)
139 AliGenMC::~AliGenMC()
144 void AliGenMC::Init()
148 switch (fForceDecay) {
149 case kSemiElectronic:
151 case kBJpsiDiElectron:
152 case kBPsiPrimeDiElectron:
153 fChildSelect[0] = kElectron;
159 case kBPsiPrimeDiMuon:
163 case kWToCharmToMuon:
165 fChildSelect[0]=kMuonMinus;
170 fChildSelect[0]=kPiPlus;
171 fChildSelect[1]=kKPlus;
174 fChildSelect[0]=kKPlus;
186 if (fZTarget != 0 && fAProjectile != 0)
188 fDyBoost = - 0.5 * TMath::Log(Double_t(fZProjectile) * Double_t(fATarget) /
189 (Double_t(fZTarget) * Double_t(fAProjectile)));
194 Bool_t AliGenMC::ParentSelected(Int_t ip) const
196 // True if particle is in list of parent particles to be selected
197 for (Int_t i=0; i<8; i++)
199 if (fParentSelect.At(i) == ip) return kTRUE;
204 Bool_t AliGenMC::ChildSelected(Int_t ip) const
206 // True if particle is in list of decay products to be selected
207 for (Int_t i=0; i<5; i++)
209 if (fChildSelect.At(i) == ip) return kTRUE;
214 Bool_t AliGenMC::KinematicSelection(TParticle *particle, Int_t flag) const
216 // Perform kinematic selection
217 Float_t pz = particle->Pz();
218 Float_t e = particle->Energy();
219 Float_t pt = particle->Pt();
220 Float_t p = particle->P();
221 Float_t theta = particle->Theta();
222 Float_t mass = particle->GetCalcMass();
223 Float_t mt2 = pt * pt + mass * mass;
224 Float_t phi = particle->Phi();
228 if (TMath::Abs(pz) < e) {
229 y = 0.5*TMath::Log((e+pz)/(e-pz));
235 y0 = 0.5*TMath::Log((e+TMath::Abs(pz))*(e+TMath::Abs(pz))/mt2);
237 if (TMath::Abs(y) < 1.e10) {
244 y = (pz < 0) ? -y0 : y0;
248 // Primary particle cuts
250 // transverse momentum cut
251 if (pt > fPtMax || pt < fPtMin) {
252 // printf("\n failed pt cut %f %f %f \n",pt,fPtMin,fPtMax);
257 if (p > fPMax || p < fPMin) {
258 // printf("\n failed p cut %f %f %f \n",p,fPMin,fPMax);
263 if (theta > fThetaMax || theta < fThetaMin) {
264 // printf("\n failed theta cut %f %f %f \n",theta,fThetaMin,fThetaMax);
269 if (y > fYMax || y < fYMin) {
270 // printf("\n failed y cut %f %f %f \n",y,fYMin,fYMax);
275 if (phi > fPhiMax || phi < fPhiMin) {
276 // printf("\n failed phi cut %f %f %f \n",phi,fPhiMin,fPhiMax);
281 // Decay product cuts
283 // transverse momentum cut
284 if (pt > fChildPtMax || pt < fChildPtMin) {
285 // printf("\n failed pt cut %f %f %f \n",pt,fChildPtMin,fChildPtMax);
290 if (p > fChildPMax || p < fChildPMin) {
291 // printf("\n failed p cut %f %f %f \n",p,fChildPMin,fChildPMax);
296 if (theta > fChildThetaMax || theta < fChildThetaMin) {
297 // printf("\n failed theta cut %f %f %f \n",theta,fChildThetaMin,fChildThetaMax);
302 if (y > fChildYMax || y < fChildYMin) {
303 // printf("\n failed y cut %f %f %f \n",y,fChildYMin,fChildYMax);
308 if (phi > fChildPhiMax || phi < fChildPhiMin) {
309 // printf("\n failed phi cut %f %f %f \n",phi,fChildPhiMin,fChildPhiMax);
317 Bool_t AliGenMC::CheckAcceptanceGeometry(Int_t np, TClonesArray* particles)
319 // Check the geometrical acceptance for particle.
322 Int_t numberOfPdgCodeParticleforAcceptanceCut = 0;
323 Int_t numberOfAcceptedPdgCodeParticleforAcceptanceCut = 0;
324 TParticle * particle;
326 for (i = 0; i < np; i++) {
327 particle = (TParticle *) particles->At(i);
328 if( TMath::Abs( particle->GetPdgCode() ) == TMath::Abs( fPdgCodeParticleforAcceptanceCut ) ) {
329 numberOfPdgCodeParticleforAcceptanceCut++;
330 if (fGeometryAcceptance->Impact(particle)) numberOfAcceptedPdgCodeParticleforAcceptanceCut++;
333 if ( numberOfAcceptedPdgCodeParticleforAcceptanceCut > (fNumberOfAcceptedParticles-1) )
341 Int_t AliGenMC::CheckPDGCode(Int_t pdgcode) const
344 // If the particle is in a diffractive state, then take action accordingly
349 //rho_diff0 -- difficult to translate, return rho0
352 //pi_diffr+ -- change to pi+
355 //omega_di0 -- change to omega0
358 //phi_diff0 -- return phi0
361 //J/psi_di0 -- return J/psi
364 //n_diffr -- return neutron
367 //p_diffr+ -- return proton
370 //non diffractive state -- return code unchanged
374 void AliGenMC::Boost()
377 // Boost cms into LHC lab frame
380 Double_t beta = TMath::TanH(fDyBoost);
381 Double_t gamma = 1./TMath::Sqrt(1.-beta*beta);
382 Double_t gb = gamma * beta;
384 // printf("\n Boosting particles to lab frame %f %f %f", fDyBoost, beta, gamma);
387 Int_t np = fParticles->GetEntriesFast();
388 for (i = 0; i < np; i++)
390 TParticle* iparticle = (TParticle*) fParticles->At(i);
392 Double_t e = iparticle->Energy();
393 Double_t px = iparticle->Px();
394 Double_t py = iparticle->Py();
395 Double_t pz = iparticle->Pz();
397 Double_t eb = gamma * e - gb * pz;
398 Double_t pzb = -gb * e + gamma * pz;
400 iparticle->SetMomentum(px, py, pzb, eb);
406 AliGenMC& AliGenMC::operator=(const AliGenMC& rhs)
408 // Assignment operator
413 void AliGenMC::Copy(TObject&) const
418 Fatal("Copy","Not implemented!\n");