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()),
56 fGeometryAcceptance(0),
57 fPdgCodeParticleforAcceptanceCut(0),
58 fNumberOfAcceptedParticles(0),
61 // Default Constructor
70 AliGenMC::AliGenMC(Int_t npart)
72 fParticles("TParticle", 1000),
81 fChildPhiMax(2. * TMath::Pi()),
83 fChildThetaMax(TMath::Pi()),
91 fGeometryAcceptance(0),
92 fPdgCodeParticleforAcceptanceCut(0),
93 fNumberOfAcceptedParticles(0),
104 for (Int_t i=0; i<8; i++) fParentSelect[i]=fChildSelect[i]=0;
107 AliGenMC::~AliGenMC()
112 void AliGenMC::Init()
116 switch (fForceDecay) {
117 case kBSemiElectronic:
118 case kSemiElectronic:
120 case kBJpsiDiElectron:
121 case kBPsiPrimeDiElectron:
122 fChildSelect[0] = kElectron;
129 case kBPsiPrimeDiMuon:
133 case kWToCharmToMuon:
136 fChildSelect[0]=kMuonMinus;
141 case kHadronicDWithout4Bodies:
142 fChildSelect[0]=kPiPlus;
143 fChildSelect[1]=kKPlus;
146 fChildSelect[0]=kKPlus;
149 fChildSelect[0]= 443;
151 case kChiToJpsiGammaToMuonMuon:
155 case kChiToJpsiGammaToElectronElectron:
169 if (fZTarget != 0 && fAProjectile != 0)
171 fDyBoost = - 0.5 * TMath::Log(Double_t(fZProjectile) * Double_t(fATarget) /
172 (Double_t(fZTarget) * Double_t(fAProjectile)));
177 Bool_t AliGenMC::ParentSelected(Int_t ip) const
179 // True if particle is in list of parent particles to be selected
180 for (Int_t i=0; i<8; i++)
182 if (fParentSelect.At(i) == ip) return kTRUE;
187 Bool_t AliGenMC::ChildSelected(Int_t ip) const
189 // True if particle is in list of decay products to be selected
190 for (Int_t i=0; i<5; i++)
192 if (fChildSelect.At(i) == ip) return kTRUE;
197 Bool_t AliGenMC::KinematicSelection(TParticle *particle, Int_t flag) const
199 // Perform kinematic selection
200 Double_t pz = particle->Pz();
201 Double_t e = particle->Energy();
202 Double_t pt = particle->Pt();
203 Double_t p = particle->P();
204 Double_t theta = particle->Theta();
205 Double_t mass = particle->GetCalcMass();
206 Double_t mt2 = pt * pt + mass * mass;
207 Double_t phi = particle->Phi();
211 if (TMath::Abs(pz) < e) {
212 y = 0.5*TMath::Log((e+pz)/(e-pz));
218 y0 = 0.5*TMath::Log((e+TMath::Abs(pz))*(e+TMath::Abs(pz))/mt2);
220 if (TMath::Abs(y) < 1.e10) {
227 y = (pz < 0) ? -y0 : y0;
231 // Primary particle cuts
233 // transverse momentum cut
234 if (pt > fPtMax || pt < fPtMin) {
235 // printf("\n failed pt cut %f %f %f \n",pt,fPtMin,fPtMax);
240 if (p > fPMax || p < fPMin) {
241 // printf("\n failed p cut %f %f %f \n",p,fPMin,fPMax);
246 if (theta > fThetaMax || theta < fThetaMin) {
247 // printf("\n failed theta cut %f %f %f \n",theta,fThetaMin,fThetaMax);
252 if (y > fYMax || y < fYMin) {
253 // printf("\n failed y cut %f %f %f \n",y,fYMin,fYMax);
258 if (phi > fPhiMax || phi < fPhiMin) {
259 // printf("\n failed phi cut %f %f %f \n",phi,fPhiMin,fPhiMax);
264 // Decay product cuts
266 // transverse momentum cut
267 if (pt > fChildPtMax || pt < fChildPtMin) {
268 // printf("\n failed pt cut %f %f %f \n",pt,fChildPtMin,fChildPtMax);
273 if (p > fChildPMax || p < fChildPMin) {
274 // printf("\n failed p cut %f %f %f \n",p,fChildPMin,fChildPMax);
279 if (theta > fChildThetaMax || theta < fChildThetaMin) {
280 // printf("\n failed theta cut %f %f %f \n",theta,fChildThetaMin,fChildThetaMax);
285 if (y > fChildYMax || y < fChildYMin) {
286 // printf("\n failed y cut %f %f %f \n",y,fChildYMin,fChildYMax);
291 if (phi > fChildPhiMax || phi < fChildPhiMin) {
292 // printf("\n failed phi cut %f %f %f \n",phi,fChildPhiMin,fChildPhiMax);
300 Bool_t AliGenMC::CheckAcceptanceGeometry(Int_t np, TClonesArray* particles)
302 // Check the geometrical acceptance for particle.
305 Int_t numberOfPdgCodeParticleforAcceptanceCut = 0;
306 Int_t numberOfAcceptedPdgCodeParticleforAcceptanceCut = 0;
307 TParticle * particle;
309 for (i = 0; i < np; i++) {
310 particle = (TParticle *) particles->At(i);
311 if( TMath::Abs( particle->GetPdgCode() ) == TMath::Abs( fPdgCodeParticleforAcceptanceCut ) ) {
312 numberOfPdgCodeParticleforAcceptanceCut++;
313 if (fGeometryAcceptance->Impact(particle)) numberOfAcceptedPdgCodeParticleforAcceptanceCut++;
316 if ( numberOfAcceptedPdgCodeParticleforAcceptanceCut > (fNumberOfAcceptedParticles-1) )
324 Int_t AliGenMC::CheckPDGCode(Int_t pdgcode) const
327 // If the particle is in a diffractive state, then take action accordingly
332 //rho_diff0 -- difficult to translate, return rho0
335 //pi_diffr+ -- change to pi+
338 //omega_di0 -- change to omega0
341 //phi_diff0 -- return phi0
344 //J/psi_di0 -- return J/psi
347 //n_diffr -- return neutron
350 //p_diffr+ -- return proton
353 //non diffractive state -- return code unchanged
357 void AliGenMC::Boost()
360 // Boost cms into LHC lab frame
363 Double_t beta = TMath::TanH(fDyBoost);
364 Double_t gamma = 1./TMath::Sqrt(1.-beta*beta);
365 Double_t gb = gamma * beta;
367 // printf("\n Boosting particles to lab frame %f %f %f", fDyBoost, beta, gamma);
370 Int_t np = fParticles.GetEntriesFast();
371 for (i = 0; i < np; i++)
373 TParticle* iparticle = (TParticle*) fParticles.At(i);
375 Double_t e = iparticle->Energy();
376 Double_t px = iparticle->Px();
377 Double_t py = iparticle->Py();
378 Double_t pz = iparticle->Pz();
380 Double_t eb = gamma * e - gb * pz;
381 Double_t pzb = -gb * e + gamma * pz;
383 iparticle->SetMomentum(px, py, pzb, eb);
387 void AliGenMC::AddHeader(AliGenEventHeader* header)
389 // Passes header either to the container or to gAlice
391 fContainer->AddHeader(header);
393 gAlice->SetGenEventHeader(header);