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"
39 fParticles("TParticle", 1000),
48 fChildPhiMax(2. * TMath::Pi()),
50 fChildThetaMax(TMath::Pi()),
58 fGeometryAcceptance(0),
59 fPdgCodeParticleforAcceptanceCut(0),
60 fNumberOfAcceptedParticles(0),
63 // Default Constructor
72 AliGenMC::AliGenMC(Int_t npart)
74 fParticles("TParticle", 1000),
83 fChildPhiMax(2. * TMath::Pi()),
85 fChildThetaMax(TMath::Pi()),
93 fGeometryAcceptance(0),
94 fPdgCodeParticleforAcceptanceCut(0),
95 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:
126 fChildSelect[0] = kElectron;
133 case kBPsiPrimeDiMuon:
137 case kWToCharmToMuon:
140 fChildSelect[0]=kMuonMinus;
145 case kHadronicDWithout4Bodies:
146 fChildSelect[0]=kPiPlus;
147 fChildSelect[1]=kKPlus;
150 fChildSelect[0]=kKPlus;
153 fChildSelect[0]= 443;
155 case kChiToJpsiGammaToMuonMuon:
159 case kChiToJpsiGammaToElectronElectron:
164 fChildSelect[0]= kProton;
165 fChildSelect[1]= 211;
167 case kPsiPrimeJpsiDiElectron:
168 fChildSelect[0]= 211;
172 fChildSelect[0] = kGamma;
184 if (fZTarget != 0 && fAProjectile != 0)
186 fDyBoost = - 0.5 * TMath::Log(Double_t(fZProjectile) * Double_t(fATarget) /
187 (Double_t(fZTarget) * Double_t(fAProjectile)));
192 Bool_t AliGenMC::ParentSelected(Int_t ip) const
194 // True if particle is in list of parent particles to be selected
195 for (Int_t i=0; i<8; i++)
197 if (fParentSelect.At(i) == ip) return kTRUE;
202 Bool_t AliGenMC::ChildSelected(Int_t ip) const
204 // True if particle is in list of decay products to be selected
205 for (Int_t i=0; i<5; i++)
207 if (fChildSelect.At(i) == ip) return kTRUE;
212 Bool_t AliGenMC::KinematicSelection(TParticle *particle, Int_t flag) const
214 // Perform kinematic selection
215 Double_t pz = particle->Pz();
216 Double_t pt = particle->Pt();
217 Double_t p = particle->P();
218 Double_t theta = particle->Theta();
219 Double_t mass = particle->GetCalcMass();
220 Double_t mt2 = pt * pt + mass * mass;
221 Double_t phi = particle->Phi();
222 Double_t e = particle->Energy();
225 e = TMath::Sqrt(p * p + mass * mass);
230 if (TMath::Abs(pz) < e) {
231 y = 0.5*TMath::Log((e+pz)/(e-pz));
237 y0 = 0.5*TMath::Log((e+TMath::Abs(pz))*(e+TMath::Abs(pz))/mt2);
239 if (TMath::Abs(y) < 1.e10) {
246 y = (pz < 0) ? -y0 : y0;
250 // Primary particle cuts
252 // transverse momentum cut
253 if (pt > fPtMax || pt < fPtMin) {
254 // printf("\n failed pt cut %f %f %f \n",pt,fPtMin,fPtMax);
259 if (p > fPMax || p < fPMin) {
260 // printf("\n failed p cut %f %f %f \n",p,fPMin,fPMax);
265 if (theta > fThetaMax || theta < fThetaMin) {
266 // printf("\n failed theta cut %f %f %f \n",theta,fThetaMin,fThetaMax);
271 if (y > fYMax || y < fYMin) {
272 // printf("\n failed y cut %f %f %f \n",y,fYMin,fYMax);
277 if (phi > fPhiMax || phi < fPhiMin) {
278 // printf("\n failed phi cut %f %f %f \n",phi,fPhiMin,fPhiMax);
283 // Decay product cuts
285 // transverse momentum cut
286 if (pt > fChildPtMax || pt < fChildPtMin) {
287 // printf("\n failed pt cut %f %f %f \n",pt,fChildPtMin,fChildPtMax);
292 if (p > fChildPMax || p < fChildPMin) {
293 // printf("\n failed p cut %f %f %f \n",p,fChildPMin,fChildPMax);
298 if (theta > fChildThetaMax || theta < fChildThetaMin) {
299 // printf("\n failed theta cut %f %f %f \n",theta,fChildThetaMin,fChildThetaMax);
304 if (y > fChildYMax || y < fChildYMin) {
305 // printf("\n failed y cut %f %f %f \n",y,fChildYMin,fChildYMax);
310 if (phi > fChildPhiMax || phi < fChildPhiMin) {
311 // printf("\n failed phi cut %f %f %f \n",phi,fChildPhiMin,fChildPhiMax);
319 Bool_t AliGenMC::CheckAcceptanceGeometry(Int_t np, TClonesArray* particles)
321 // Check the geometrical acceptance for particle.
324 Int_t numberOfPdgCodeParticleforAcceptanceCut = 0;
325 Int_t numberOfAcceptedPdgCodeParticleforAcceptanceCut = 0;
326 TParticle * particle;
328 for (i = 0; i < np; i++) {
329 particle = (TParticle *) particles->At(i);
330 if( TMath::Abs( particle->GetPdgCode() ) == TMath::Abs( fPdgCodeParticleforAcceptanceCut ) ) {
331 numberOfPdgCodeParticleforAcceptanceCut++;
332 if (fGeometryAcceptance->Impact(particle)) numberOfAcceptedPdgCodeParticleforAcceptanceCut++;
335 if ( numberOfAcceptedPdgCodeParticleforAcceptanceCut > (fNumberOfAcceptedParticles-1) )
343 Int_t AliGenMC::CheckPDGCode(Int_t pdgcode) const
346 // If the particle is in a diffractive state, then take action accordingly
351 //rho_diff0 -- difficult to translate, return rho0
354 //pi_diffr+ -- change to pi+
357 //omega_di0 -- change to omega0
360 //phi_diff0 -- return phi0
363 //J/psi_di0 -- return J/psi
366 //n_diffr -- return neutron
369 //p_diffr+ -- return proton
372 //non diffractive state -- return code unchanged
376 void AliGenMC::Boost()
379 // Boost cms into LHC lab frame
382 Double_t beta = TMath::TanH(fDyBoost);
383 Double_t gamma = 1./TMath::Sqrt((1.-beta)*(1.+beta));
384 Double_t gb = gamma * beta;
386 // printf("\n Boosting particles to lab frame %f %f %f", fDyBoost, beta, gamma);
389 Int_t np = fParticles.GetEntriesFast();
390 for (i = 0; i < np; i++)
392 TParticle* iparticle = (TParticle*) fParticles.At(i);
394 Double_t e = iparticle->Energy();
395 Double_t px = iparticle->Px();
396 Double_t py = iparticle->Py();
397 Double_t pz = iparticle->Pz();
399 Double_t eb = gamma * e - gb * pz;
400 Double_t pzb = -gb * e + gamma * pz;
402 iparticle->SetMomentum(px, py, pzb, eb);
406 void AliGenMC::BeamCrossAngle()
408 // Applies a boost in the y-direction in order to take into account the
409 // beam crossing angle
411 Double_t thetaPr0, phiPr0, pyPr2, pzPr2;
414 thetaPr0 = fXingAngleY / 2.;
417 // Momentum of the CMS system
418 pyPr2 = TMath::Sqrt(fEnergyCMS * fEnergyCMS/ 4 - 0.938 * 0.938) * TMath::Sin(thetaPr0);
419 pzPr2 = TMath::Sqrt(fEnergyCMS * fEnergyCMS/ 4 - 0.938 * 0.938) * TMath::Cos(thetaPr0);
421 TLorentzVector proj1Vect, proj2Vect, projVect;
422 proj1Vect.SetPxPyPzE(0., pyPr2, pzPr2, fEnergyCMS/2);
423 proj2Vect.SetPxPyPzE(0., pyPr2,-pzPr2, fEnergyCMS/2);
424 projVect = proj1Vect + proj2Vect;
425 beta=(1. / projVect.E()) * (projVect.Vect());
428 Int_t np = fParticles.GetEntriesFast();
429 for (i = 0; i < np; i++)
431 TParticle* iparticle = (TParticle*) fParticles.At(i);
433 Double_t e = iparticle->Energy();
434 Double_t px = iparticle->Px();
435 Double_t py = iparticle->Py();
436 Double_t pz = iparticle->Pz();
438 TLorentzVector partIn;
439 partIn.SetPxPyPzE(px,py,pz,e);
441 iparticle->SetMomentum(partIn.Px(),partIn.Py(),partIn.Pz(),partIn.E());
446 void AliGenMC::AddHeader(AliGenEventHeader* header)
448 // Passes header either to the container or to gAlice
450 fContainer->AddHeader(header);
452 gAlice->SetGenEventHeader(header);