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>
32 #include "AliGenEventHeader.h"
34 #include "AliGeometry.h"
35 #include "AliDecayer.h"
41 fParticles("TParticle", 1000),
50 fChildPhiMax(2. * TMath::Pi()),
52 fChildThetaMax(TMath::Pi()),
60 fGeometryAcceptance(0),
61 fPdgCodeParticleforAcceptanceCut(0),
62 fNumberOfAcceptedParticles(0),
65 // Default Constructor
74 AliGenMC::AliGenMC(Int_t npart)
76 fParticles("TParticle", 1000),
85 fChildPhiMax(2. * TMath::Pi()),
87 fChildThetaMax(TMath::Pi()),
95 fGeometryAcceptance(0),
96 fPdgCodeParticleforAcceptanceCut(0),
97 fNumberOfAcceptedParticles(0),
108 for (Int_t i=0; i<8; i++) fParentSelect[i]=fChildSelect[i]=0;
111 AliGenMC::~AliGenMC()
116 void AliGenMC::Init()
120 switch (fForceDecay) {
121 case kBSemiElectronic:
122 case kSemiElectronic:
124 case kBJpsiDiElectron:
125 case kBPsiPrimeDiElectron:
128 fChildSelect[0] = kElectron;
136 case kBPsiPrimeDiMuon:
140 case kWToCharmToMuon:
143 fChildSelect[0]=kMuonMinus;
148 case kHadronicDWithout4Bodies:
149 fChildSelect[0]=kPiPlus;
150 fChildSelect[1]=kKPlus;
153 fChildSelect[0]=kKPlus;
156 fChildSelect[0]= 443;
158 case kChiToJpsiGammaToMuonMuon:
162 case kChiToJpsiGammaToElectronElectron:
167 fChildSelect[0]= kProton;
168 fChildSelect[1]= 211;
170 case kPsiPrimeJpsiDiElectron:
171 fChildSelect[0]= 211;
175 fChildSelect[0] = kGamma;
188 if (fZTarget != 0 && fAProjectile != 0)
190 fDyBoost = - 0.5 * TMath::Log(Double_t(fZProjectile) * Double_t(fATarget) /
191 (Double_t(fZTarget) * Double_t(fAProjectile)));
196 Bool_t AliGenMC::ParentSelected(Int_t ip) const
198 // True if particle is in list of parent particles to be selected
199 for (Int_t i=0; i<8; i++)
201 if (fParentSelect.At(i) == ip) return kTRUE;
206 Bool_t AliGenMC::ChildSelected(Int_t ip) const
208 // True if particle is in list of decay products to be selected
209 for (Int_t i=0; i<5; i++)
211 if (fChildSelect.At(i) == ip) return kTRUE;
216 Bool_t AliGenMC::KinematicSelection(const TParticle *particle, Int_t flag) const
218 // Perform kinematic selection
219 Double_t pz = particle->Pz();
220 Double_t pt = particle->Pt();
221 Double_t p = particle->P();
222 Double_t theta = particle->Theta();
223 Double_t mass = particle->GetCalcMass();
224 Double_t mt2 = pt * pt + mass * mass;
225 Double_t phi = particle->Phi();
226 Double_t e = particle->Energy();
229 e = TMath::Sqrt(p * p + mass * mass);
234 if (TMath::Abs(pz) < e) {
235 y = 0.5*TMath::Log((e+pz)/(e-pz));
241 y0 = 0.5*TMath::Log((e+TMath::Abs(pz))*(e+TMath::Abs(pz))/mt2);
243 if (TMath::Abs(y) < 1.e10) {
250 y = (pz < 0) ? -y0 : y0;
254 // Primary particle cuts
256 // transverse momentum cut
257 if (pt > fPtMax || pt < fPtMin) {
258 // printf("\n failed pt cut %f %f %f \n",pt,fPtMin,fPtMax);
263 if (p > fPMax || p < fPMin) {
264 // printf("\n failed p cut %f %f %f \n",p,fPMin,fPMax);
269 if (theta > fThetaMax || theta < fThetaMin) {
270 // printf("\n failed theta cut %f %f %f \n",theta,fThetaMin,fThetaMax);
275 if (y > fYMax || y < fYMin) {
276 // printf("\n failed y cut %f %f %f \n",y,fYMin,fYMax);
281 if (phi > fPhiMax || phi < fPhiMin) {
282 // printf("\n failed phi cut %f %f %f \n",phi,fPhiMin,fPhiMax);
287 // Decay product cuts
289 // transverse momentum cut
290 if (pt > fChildPtMax || pt < fChildPtMin) {
291 // printf("\n failed pt cut %f %f %f \n",pt,fChildPtMin,fChildPtMax);
296 if (p > fChildPMax || p < fChildPMin) {
297 // printf("\n failed p cut %f %f %f \n",p,fChildPMin,fChildPMax);
302 if (theta > fChildThetaMax || theta < fChildThetaMin) {
303 // printf("\n failed theta cut %f %f %f \n",theta,fChildThetaMin,fChildThetaMax);
308 if (y > fChildYMax || y < fChildYMin) {
309 // printf("\n failed y cut %f %f %f \n",y,fChildYMin,fChildYMax);
314 if (phi > fChildPhiMax || phi < fChildPhiMin) {
315 // printf("\n failed phi cut %f %f %f \n",phi,fChildPhiMin,fChildPhiMax);
323 Bool_t AliGenMC::CheckAcceptanceGeometry(Int_t np, TClonesArray* particles)
325 // Check the geometrical acceptance for particle.
328 Int_t numberOfPdgCodeParticleforAcceptanceCut = 0;
329 Int_t numberOfAcceptedPdgCodeParticleforAcceptanceCut = 0;
330 TParticle * particle;
332 for (i = 0; i < np; i++) {
333 particle = (TParticle *) particles->At(i);
334 if( TMath::Abs( particle->GetPdgCode() ) == TMath::Abs( fPdgCodeParticleforAcceptanceCut ) ) {
335 numberOfPdgCodeParticleforAcceptanceCut++;
336 if (fGeometryAcceptance->Impact(particle)) numberOfAcceptedPdgCodeParticleforAcceptanceCut++;
339 if ( numberOfAcceptedPdgCodeParticleforAcceptanceCut > (fNumberOfAcceptedParticles-1) )
347 Int_t AliGenMC::CheckPDGCode(Int_t pdgcode) const
350 // If the particle is in a diffractive state, then take action accordingly
355 //rho_diff0 -- difficult to translate, return rho0
358 //pi_diffr+ -- change to pi+
361 //omega_di0 -- change to omega0
364 //phi_diff0 -- return phi0
367 //J/psi_di0 -- return J/psi
370 //n_diffr -- return neutron
373 //p_diffr+ -- return proton
376 //non diffractive state -- return code unchanged
380 void AliGenMC::Boost()
383 // Boost cms into LHC lab frame
386 Double_t beta = TMath::TanH(fDyBoost);
387 Double_t gamma = 1./TMath::Sqrt((1.-beta)*(1.+beta));
388 Double_t gb = gamma * beta;
390 printf("\n Boosting particles to lab frame %f %f %f", fDyBoost, beta, gamma);
393 Int_t np = fParticles.GetEntriesFast();
394 for (i = 0; i < np; i++)
396 TParticle* iparticle = (TParticle*) fParticles.At(i);
398 Double_t e = iparticle->Energy();
399 Double_t px = iparticle->Px();
400 Double_t py = iparticle->Py();
401 Double_t pz = iparticle->Pz();
403 Double_t eb = gamma * e - gb * pz;
404 Double_t pzb = -gb * e + gamma * pz;
406 iparticle->SetMomentum(px, py, pzb, eb);
410 void AliGenMC::BeamCrossAngle()
412 // Applies a boost in the y-direction in order to take into account the
413 // beam crossing angle
415 Double_t thetaPr0, phiPr0, pyPr2, pzPr2;
418 thetaPr0 = fXingAngleY / 2.;
421 // Momentum of the CMS system
422 pyPr2 = TMath::Sqrt(fEnergyCMS * fEnergyCMS/ 4 - 0.938 * 0.938) * TMath::Sin(thetaPr0);
423 pzPr2 = TMath::Sqrt(fEnergyCMS * fEnergyCMS/ 4 - 0.938 * 0.938) * TMath::Cos(thetaPr0);
425 TLorentzVector proj1Vect, proj2Vect, projVect;
426 proj1Vect.SetPxPyPzE(0., pyPr2, pzPr2, fEnergyCMS/2);
427 proj2Vect.SetPxPyPzE(0., pyPr2,-pzPr2, fEnergyCMS/2);
428 projVect = proj1Vect + proj2Vect;
429 beta=(1. / projVect.E()) * (projVect.Vect());
432 Int_t np = fParticles.GetEntriesFast();
433 for (i = 0; i < np; i++)
435 TParticle* iparticle = (TParticle*) fParticles.At(i);
437 Double_t e = iparticle->Energy();
438 Double_t px = iparticle->Px();
439 Double_t py = iparticle->Py();
440 Double_t pz = iparticle->Pz();
442 TLorentzVector partIn;
443 partIn.SetPxPyPzE(px,py,pz,e);
445 iparticle->SetMomentum(partIn.Px(),partIn.Py(),partIn.Pz(),partIn.E());
450 void AliGenMC::AddHeader(AliGenEventHeader* header)
452 // Passes header either to the container or to gAlice
454 header->SetName(fName);
455 fContainer->AddHeader(header);
457 gAlice->SetGenEventHeader(header);