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>
28 #include <TLorentzVector.h>
33 #include "AliGeometry.h"
34 #include "AliDecayer.h"
40 fParticles("TParticle", 1000),
49 fChildPhiMax(2. * TMath::Pi()),
51 fChildThetaMax(TMath::Pi()),
59 fGeometryAcceptance(0),
60 fPdgCodeParticleforAcceptanceCut(0),
61 fNumberOfAcceptedParticles(0),
64 // Default Constructor
73 AliGenMC::AliGenMC(Int_t npart)
75 fParticles("TParticle", 1000),
84 fChildPhiMax(2. * TMath::Pi()),
86 fChildThetaMax(TMath::Pi()),
94 fGeometryAcceptance(0),
95 fPdgCodeParticleforAcceptanceCut(0),
96 fNumberOfAcceptedParticles(0),
107 for (Int_t i=0; i<8; i++) fParentSelect[i]=fChildSelect[i]=0;
110 AliGenMC::~AliGenMC()
115 void AliGenMC::Init()
119 switch (fForceDecay) {
120 case kBSemiElectronic:
121 case kSemiElectronic:
123 case kBJpsiDiElectron:
124 case kBPsiPrimeDiElectron:
127 fChildSelect[0] = kElectron;
134 case kBPsiPrimeDiMuon:
138 case kWToCharmToMuon:
141 fChildSelect[0]=kMuonMinus;
146 case kHadronicDWithout4Bodies:
147 fChildSelect[0]=kPiPlus;
148 fChildSelect[1]=kKPlus;
151 fChildSelect[0]=kKPlus;
154 fChildSelect[0]= 443;
156 case kChiToJpsiGammaToMuonMuon:
160 case kChiToJpsiGammaToElectronElectron:
165 fChildSelect[0]= kProton;
166 fChildSelect[1]= 211;
168 case kPsiPrimeJpsiDiElectron:
169 fChildSelect[0]= 211;
173 fChildSelect[0] = kGamma;
185 if (fZTarget != 0 && fAProjectile != 0)
187 fDyBoost = - 0.5 * TMath::Log(Double_t(fZProjectile) * Double_t(fATarget) /
188 (Double_t(fZTarget) * Double_t(fAProjectile)));
193 Bool_t AliGenMC::ParentSelected(Int_t ip) const
195 // True if particle is in list of parent particles to be selected
196 for (Int_t i=0; i<8; i++)
198 if (fParentSelect.At(i) == ip) return kTRUE;
203 Bool_t AliGenMC::ChildSelected(Int_t ip) const
205 // True if particle is in list of decay products to be selected
206 for (Int_t i=0; i<5; i++)
208 if (fChildSelect.At(i) == ip) return kTRUE;
213 Bool_t AliGenMC::KinematicSelection(const TParticle *particle, Int_t flag) const
215 // Perform kinematic selection
216 Double_t pz = particle->Pz();
217 Double_t pt = particle->Pt();
218 Double_t p = particle->P();
219 Double_t theta = particle->Theta();
220 Double_t mass = particle->GetCalcMass();
221 Double_t mt2 = pt * pt + mass * mass;
222 Double_t phi = particle->Phi();
223 Double_t e = particle->Energy();
226 e = TMath::Sqrt(p * p + mass * mass);
231 if (TMath::Abs(pz) < e) {
232 y = 0.5*TMath::Log((e+pz)/(e-pz));
238 y0 = 0.5*TMath::Log((e+TMath::Abs(pz))*(e+TMath::Abs(pz))/mt2);
240 if (TMath::Abs(y) < 1.e10) {
247 y = (pz < 0) ? -y0 : y0;
251 // Primary particle cuts
253 // transverse momentum cut
254 if (pt > fPtMax || pt < fPtMin) {
255 // printf("\n failed pt cut %f %f %f \n",pt,fPtMin,fPtMax);
260 if (p > fPMax || p < fPMin) {
261 // printf("\n failed p cut %f %f %f \n",p,fPMin,fPMax);
266 if (theta > fThetaMax || theta < fThetaMin) {
267 // printf("\n failed theta cut %f %f %f \n",theta,fThetaMin,fThetaMax);
272 if (y > fYMax || y < fYMin) {
273 // printf("\n failed y cut %f %f %f \n",y,fYMin,fYMax);
278 if (phi > fPhiMax || phi < fPhiMin) {
279 // printf("\n failed phi cut %f %f %f \n",phi,fPhiMin,fPhiMax);
284 // Decay product cuts
286 // transverse momentum cut
287 if (pt > fChildPtMax || pt < fChildPtMin) {
288 // printf("\n failed pt cut %f %f %f \n",pt,fChildPtMin,fChildPtMax);
293 if (p > fChildPMax || p < fChildPMin) {
294 // printf("\n failed p cut %f %f %f \n",p,fChildPMin,fChildPMax);
299 if (theta > fChildThetaMax || theta < fChildThetaMin) {
300 // printf("\n failed theta cut %f %f %f \n",theta,fChildThetaMin,fChildThetaMax);
305 if (y > fChildYMax || y < fChildYMin) {
306 // printf("\n failed y cut %f %f %f \n",y,fChildYMin,fChildYMax);
311 if (phi > fChildPhiMax || phi < fChildPhiMin) {
312 // printf("\n failed phi cut %f %f %f \n",phi,fChildPhiMin,fChildPhiMax);
320 Bool_t AliGenMC::CheckAcceptanceGeometry(Int_t np, TClonesArray* particles)
322 // Check the geometrical acceptance for particle.
325 Int_t numberOfPdgCodeParticleforAcceptanceCut = 0;
326 Int_t numberOfAcceptedPdgCodeParticleforAcceptanceCut = 0;
327 TParticle * particle;
329 for (i = 0; i < np; i++) {
330 particle = (TParticle *) particles->At(i);
331 if( TMath::Abs( particle->GetPdgCode() ) == TMath::Abs( fPdgCodeParticleforAcceptanceCut ) ) {
332 numberOfPdgCodeParticleforAcceptanceCut++;
333 if (fGeometryAcceptance->Impact(particle)) numberOfAcceptedPdgCodeParticleforAcceptanceCut++;
336 if ( numberOfAcceptedPdgCodeParticleforAcceptanceCut > (fNumberOfAcceptedParticles-1) )
344 Int_t AliGenMC::CheckPDGCode(Int_t pdgcode) const
347 // If the particle is in a diffractive state, then take action accordingly
352 //rho_diff0 -- difficult to translate, return rho0
355 //pi_diffr+ -- change to pi+
358 //omega_di0 -- change to omega0
361 //phi_diff0 -- return phi0
364 //J/psi_di0 -- return J/psi
367 //n_diffr -- return neutron
370 //p_diffr+ -- return proton
373 //non diffractive state -- return code unchanged
377 void AliGenMC::Boost()
380 // Boost cms into LHC lab frame
383 Double_t beta = TMath::TanH(fDyBoost);
384 Double_t gamma = 1./TMath::Sqrt((1.-beta)*(1.+beta));
385 Double_t gb = gamma * beta;
387 // printf("\n Boosting particles to lab frame %f %f %f", fDyBoost, beta, gamma);
390 Int_t np = fParticles.GetEntriesFast();
391 for (i = 0; i < np; i++)
393 TParticle* iparticle = (TParticle*) fParticles.At(i);
395 Double_t e = iparticle->Energy();
396 Double_t px = iparticle->Px();
397 Double_t py = iparticle->Py();
398 Double_t pz = iparticle->Pz();
400 Double_t eb = gamma * e - gb * pz;
401 Double_t pzb = -gb * e + gamma * pz;
403 iparticle->SetMomentum(px, py, pzb, eb);
407 void AliGenMC::BeamCrossAngle()
409 // Applies a boost in the y-direction in order to take into account the
410 // beam crossing angle
412 Double_t thetaPr0, phiPr0, pyPr2, pzPr2;
415 thetaPr0 = fXingAngleY / 2.;
418 // Momentum of the CMS system
419 pyPr2 = TMath::Sqrt(fEnergyCMS * fEnergyCMS/ 4 - 0.938 * 0.938) * TMath::Sin(thetaPr0);
420 pzPr2 = TMath::Sqrt(fEnergyCMS * fEnergyCMS/ 4 - 0.938 * 0.938) * TMath::Cos(thetaPr0);
422 TLorentzVector proj1Vect, proj2Vect, projVect;
423 proj1Vect.SetPxPyPzE(0., pyPr2, pzPr2, fEnergyCMS/2);
424 proj2Vect.SetPxPyPzE(0., pyPr2,-pzPr2, fEnergyCMS/2);
425 projVect = proj1Vect + proj2Vect;
426 beta=(1. / projVect.E()) * (projVect.Vect());
429 Int_t np = fParticles.GetEntriesFast();
430 for (i = 0; i < np; i++)
432 TParticle* iparticle = (TParticle*) fParticles.At(i);
434 Double_t e = iparticle->Energy();
435 Double_t px = iparticle->Px();
436 Double_t py = iparticle->Py();
437 Double_t pz = iparticle->Pz();
439 TLorentzVector partIn;
440 partIn.SetPxPyPzE(px,py,pz,e);
442 iparticle->SetMomentum(partIn.Px(),partIn.Py(),partIn.Pz(),partIn.E());
447 void AliGenMC::AddHeader(AliGenEventHeader* header)
449 // Passes header either to the container or to gAlice
451 fContainer->AddHeader(header);
453 gAlice->SetGenEventHeader(header);