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>
31 #include "AliGeometry.h"
37 fParticles("TParticle", 1000),
46 fChildPhiMax(2. * TMath::Pi()),
48 fChildThetaMax(TMath::Pi()),
62 fGeometryAcceptance(0),
63 fPdgCodeParticleforAcceptanceCut(0),
64 fNumberOfAcceptedParticles(0),
68 // Default Constructor
71 AliGenMC::AliGenMC(Int_t npart)
73 fParticles("TParticle", 1000),
82 fChildPhiMax(2. * TMath::Pi()),
84 fChildThetaMax(TMath::Pi()),
98 fGeometryAcceptance(0),
99 fPdgCodeParticleforAcceptanceCut(0),
100 fNumberOfAcceptedParticles(0),
106 for (Int_t i=0; i<8; i++) fParentSelect[i]=fChildSelect[i]=0;
109 AliGenMC::~AliGenMC()
114 void AliGenMC::Init()
118 switch (fForceDecay) {
119 case kBSemiElectronic:
120 case kSemiElectronic:
122 case kBJpsiDiElectron:
123 case kBPsiPrimeDiElectron:
124 fChildSelect[0] = kElectron;
131 case kBPsiPrimeDiMuon:
135 case kWToCharmToMuon:
138 fChildSelect[0]=kMuonMinus;
143 case kHadronicDWithout4Bodies:
144 fChildSelect[0]=kPiPlus;
145 fChildSelect[1]=kKPlus;
148 fChildSelect[0]=kKPlus;
151 fChildSelect[0]= 443;
153 case kChiToJpsiGammaToMuonMuon:
157 case kChiToJpsiGammaToElectronElectron:
171 if (fZTarget != 0 && fAProjectile != 0)
173 fDyBoost = - 0.5 * TMath::Log(Double_t(fZProjectile) * Double_t(fATarget) /
174 (Double_t(fZTarget) * Double_t(fAProjectile)));
179 Bool_t AliGenMC::ParentSelected(Int_t ip) const
181 // True if particle is in list of parent particles to be selected
182 for (Int_t i=0; i<8; i++)
184 if (fParentSelect.At(i) == ip) return kTRUE;
189 Bool_t AliGenMC::ChildSelected(Int_t ip) const
191 // True if particle is in list of decay products to be selected
192 for (Int_t i=0; i<5; i++)
194 if (fChildSelect.At(i) == ip) return kTRUE;
199 Bool_t AliGenMC::KinematicSelection(TParticle *particle, Int_t flag) const
201 // Perform kinematic selection
202 Double_t pz = particle->Pz();
203 Double_t e = particle->Energy();
204 Double_t pt = particle->Pt();
205 Double_t p = particle->P();
206 Double_t theta = particle->Theta();
207 Double_t mass = particle->GetCalcMass();
208 Double_t mt2 = pt * pt + mass * mass;
209 Double_t phi = particle->Phi();
213 if (TMath::Abs(pz) < e) {
214 y = 0.5*TMath::Log((e+pz)/(e-pz));
220 y0 = 0.5*TMath::Log((e+TMath::Abs(pz))*(e+TMath::Abs(pz))/mt2);
222 if (TMath::Abs(y) < 1.e10) {
229 y = (pz < 0) ? -y0 : y0;
233 // Primary particle cuts
235 // transverse momentum cut
236 if (pt > fPtMax || pt < fPtMin) {
237 // printf("\n failed pt cut %f %f %f \n",pt,fPtMin,fPtMax);
242 if (p > fPMax || p < fPMin) {
243 // printf("\n failed p cut %f %f %f \n",p,fPMin,fPMax);
248 if (theta > fThetaMax || theta < fThetaMin) {
249 // printf("\n failed theta cut %f %f %f \n",theta,fThetaMin,fThetaMax);
254 if (y > fYMax || y < fYMin) {
255 // printf("\n failed y cut %f %f %f \n",y,fYMin,fYMax);
260 if (phi > fPhiMax || phi < fPhiMin) {
261 // printf("\n failed phi cut %f %f %f \n",phi,fPhiMin,fPhiMax);
266 // Decay product cuts
268 // transverse momentum cut
269 if (pt > fChildPtMax || pt < fChildPtMin) {
270 // printf("\n failed pt cut %f %f %f \n",pt,fChildPtMin,fChildPtMax);
275 if (p > fChildPMax || p < fChildPMin) {
276 // printf("\n failed p cut %f %f %f \n",p,fChildPMin,fChildPMax);
281 if (theta > fChildThetaMax || theta < fChildThetaMin) {
282 // printf("\n failed theta cut %f %f %f \n",theta,fChildThetaMin,fChildThetaMax);
287 if (y > fChildYMax || y < fChildYMin) {
288 // printf("\n failed y cut %f %f %f \n",y,fChildYMin,fChildYMax);
293 if (phi > fChildPhiMax || phi < fChildPhiMin) {
294 // printf("\n failed phi cut %f %f %f \n",phi,fChildPhiMin,fChildPhiMax);
302 Bool_t AliGenMC::CheckAcceptanceGeometry(Int_t np, TClonesArray* particles)
304 // Check the geometrical acceptance for particle.
307 Int_t numberOfPdgCodeParticleforAcceptanceCut = 0;
308 Int_t numberOfAcceptedPdgCodeParticleforAcceptanceCut = 0;
309 TParticle * particle;
311 for (i = 0; i < np; i++) {
312 particle = (TParticle *) particles->At(i);
313 if( TMath::Abs( particle->GetPdgCode() ) == TMath::Abs( fPdgCodeParticleforAcceptanceCut ) ) {
314 numberOfPdgCodeParticleforAcceptanceCut++;
315 if (fGeometryAcceptance->Impact(particle)) numberOfAcceptedPdgCodeParticleforAcceptanceCut++;
318 if ( numberOfAcceptedPdgCodeParticleforAcceptanceCut > (fNumberOfAcceptedParticles-1) )
326 Int_t AliGenMC::CheckPDGCode(Int_t pdgcode) const
329 // If the particle is in a diffractive state, then take action accordingly
334 //rho_diff0 -- difficult to translate, return rho0
337 //pi_diffr+ -- change to pi+
340 //omega_di0 -- change to omega0
343 //phi_diff0 -- return phi0
346 //J/psi_di0 -- return J/psi
349 //n_diffr -- return neutron
352 //p_diffr+ -- return proton
355 //non diffractive state -- return code unchanged
359 void AliGenMC::Boost()
362 // Boost cms into LHC lab frame
365 Double_t beta = TMath::TanH(fDyBoost);
366 Double_t gamma = 1./TMath::Sqrt(1.-beta*beta);
367 Double_t gb = gamma * beta;
369 // printf("\n Boosting particles to lab frame %f %f %f", fDyBoost, beta, gamma);
372 Int_t np = fParticles.GetEntriesFast();
373 for (i = 0; i < np; i++)
375 TParticle* iparticle = (TParticle*) fParticles.At(i);
377 Double_t e = iparticle->Energy();
378 Double_t px = iparticle->Px();
379 Double_t py = iparticle->Py();
380 Double_t pz = iparticle->Pz();
382 Double_t eb = gamma * e - gb * pz;
383 Double_t pzb = -gb * e + gamma * pz;
385 iparticle->SetMomentum(px, py, pzb, eb);
389 void AliGenMC::AddHeader(AliGenEventHeader* header)
391 // Passes header either to the container or to gAlice
393 fContainer->AddHeader(header);
395 gAlice->SetGenEventHeader(header);