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();
53 AliGenMC::AliGenMC(Int_t npart)
58 SetChildMomentumRange();
66 for (Int_t i=0; i<8; i++) fParentSelect[i]=fChildSelect[i]=0;
68 SetGeometryAcceptance();
69 SetPdgCodeParticleforAcceptanceCut();
70 SetNumberOfAcceptedParticles();
76 AliGenMC::AliGenMC(const AliGenMC & mc):
92 switch (fForceDecay) {
95 case kBJpsiDiElectron:
96 case kBPsiPrimeDiElectron:
97 fChildSelect[0] = kElectron;
103 case kBPsiPrimeDiMuon:
106 fChildSelect[0]=kMuonMinus;
109 fChildSelect[0]=kPiPlus;
110 fChildSelect[1]=kKPlus;
113 fChildSelect[0]=kKPlus;
121 if (fZTarget != 0 && fAProjectile != 0)
123 fDyBoost = - 0.5 * TMath::Log(Double_t(fZProjectile) * Double_t(fATarget) /
124 (Double_t(fZTarget) * Double_t(fAProjectile)));
129 Bool_t AliGenMC::ParentSelected(Int_t ip) const
131 // True if particle is in list of parent particles to be selected
132 for (Int_t i=0; i<8; i++)
134 if (fParentSelect.At(i) == ip) return kTRUE;
139 Bool_t AliGenMC::ChildSelected(Int_t ip) const
141 // True if particle is in list of decay products to be selected
142 for (Int_t i=0; i<5; i++)
144 if (fChildSelect.At(i) == ip) return kTRUE;
149 Bool_t AliGenMC::KinematicSelection(TParticle *particle, Int_t flag) const
151 // Perform kinematic selection
152 Float_t pz = particle->Pz();
153 Float_t e = particle->Energy();
154 Float_t pt = particle->Pt();
155 Float_t p = particle->P();
156 Float_t theta = particle->Theta();
157 Float_t mass = particle->GetCalcMass();
158 Float_t mt2 = pt * pt + mass * mass;
159 Float_t phi = particle->Phi();
163 if (TMath::Abs(pz) < e) {
164 y = 0.5*TMath::Log((e+pz)/(e-pz));
170 y0 = 0.5*TMath::Log((e+TMath::Abs(pz))*(e+TMath::Abs(pz))/mt2);
172 if (TMath::Abs(y) < 1.e10) {
179 y = (pz < 0) ? -y0 : y0;
183 // Primary particle cuts
185 // transverse momentum cut
186 if (pt > fPtMax || pt < fPtMin) {
187 // printf("\n failed pt cut %f %f %f \n",pt,fPtMin,fPtMax);
192 if (p > fPMax || p < fPMin) {
193 // printf("\n failed p cut %f %f %f \n",p,fPMin,fPMax);
198 if (theta > fThetaMax || theta < fThetaMin) {
199 // printf("\n failed theta cut %f %f %f \n",theta,fThetaMin,fThetaMax);
204 if (y > fYMax || y < fYMin) {
205 // printf("\n failed y cut %f %f %f \n",y,fYMin,fYMax);
210 if (phi > fPhiMax || phi < fPhiMin) {
211 // printf("\n failed phi cut %f %f %f \n",phi,fPhiMin,fPhiMax);
216 // Decay product cuts
218 // transverse momentum cut
219 if (pt > fChildPtMax || pt < fChildPtMin) {
220 // printf("\n failed pt cut %f %f %f \n",pt,fChildPtMin,fChildPtMax);
225 if (p > fChildPMax || p < fChildPMin) {
226 // printf("\n failed p cut %f %f %f \n",p,fChildPMin,fChildPMax);
231 if (theta > fChildThetaMax || theta < fChildThetaMin) {
232 // printf("\n failed theta cut %f %f %f \n",theta,fChildThetaMin,fChildThetaMax);
237 if (y > fChildYMax || y < fChildYMin) {
238 // printf("\n failed y cut %f %f %f \n",y,fChildYMin,fChildYMax);
243 if (phi > fChildPhiMax || phi < fChildPhiMin) {
244 // printf("\n failed phi cut %f %f %f \n",phi,fChildPhiMin,fChildPhiMax);
252 Bool_t AliGenMC::CheckAcceptanceGeometry(Int_t np, TClonesArray* particles)
254 // Check the geometrical acceptance for particle.
257 Int_t numberOfPdgCodeParticleforAcceptanceCut = 0;
258 Int_t numberOfAcceptedPdgCodeParticleforAcceptanceCut = 0;
259 TParticle * particle;
261 for (i = 0; i < np; i++) {
262 particle = (TParticle *) particles->At(i);
263 if( TMath::Abs( particle->GetPdgCode() ) == TMath::Abs( fPdgCodeParticleforAcceptanceCut ) ) {
264 numberOfPdgCodeParticleforAcceptanceCut++;
265 if (fGeometryAcceptance->Impact(particle)) numberOfAcceptedPdgCodeParticleforAcceptanceCut++;
268 if ( numberOfAcceptedPdgCodeParticleforAcceptanceCut > (fNumberOfAcceptedParticles-1) )
276 Int_t AliGenMC::CheckPDGCode(Int_t pdgcode) const
279 // If the particle is in a diffractive state, then take action accordingly
284 //rho_diff0 -- difficult to translate, return rho0
287 //pi_diffr+ -- change to pi+
290 //omega_di0 -- change to omega0
293 //phi_diff0 -- return phi0
296 //J/psi_di0 -- return J/psi
299 //n_diffr -- return neutron
302 //p_diffr+ -- return proton
305 //non diffractive state -- return code unchanged
309 void AliGenMC::Boost()
312 // Boost cms into LHC lab frame
315 Double_t beta = TMath::TanH(fDyBoost);
316 Double_t gamma = 1./TMath::Sqrt(1.-beta*beta);
317 Double_t gb = gamma * beta;
319 // printf("\n Boosting particles to lab frame %f %f %f", fDyBoost, beta, gamma);
322 Int_t np = fParticles->GetEntriesFast();
323 for (i = 0; i < np; i++)
325 TParticle* iparticle = (TParticle*) fParticles->At(i);
327 Double_t e = iparticle->Energy();
328 Double_t px = iparticle->Px();
329 Double_t py = iparticle->Py();
330 Double_t pz = iparticle->Pz();
332 Double_t eb = gamma * e - gb * pz;
333 Double_t pzb = -gb * e + gamma * pz;
335 iparticle->SetMomentum(px, py, pzb, eb);
341 AliGenMC& AliGenMC::operator=(const AliGenMC& rhs)
343 // Assignment operator
348 void AliGenMC::Copy(TObject&) const
353 Fatal("Copy","Not implemented!\n");