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;
137 case kBPsiPrimeDiMuon:
141 case kWToCharmToMuon:
144 fChildSelect[0]=kMuonMinus;
149 case kHadronicDWithout4Bodies:
150 case kHadronicDWithV0:
151 case kHadronicDWithout4BodiesWithV0:
152 fChildSelect[0]=kPiPlus;
153 fChildSelect[1]=kKPlus;
156 fChildSelect[0]=kKPlus;
159 case kBJpsiUndecayed:
160 fChildSelect[0]= 443;
162 case kChiToJpsiGammaToMuonMuon:
166 case kChiToJpsiGammaToElectronElectron:
171 fChildSelect[0]= kProton;
172 fChildSelect[1]= 211;
174 case kPsiPrimeJpsiDiElectron:
175 fChildSelect[0]= 211;
179 fChildSelect[0] = kGamma;
192 if (fZTarget != 0 && fAProjectile != 0)
194 fDyBoost = - 0.5 * TMath::Log(Double_t(fZProjectile) * Double_t(fATarget) /
195 (Double_t(fZTarget) * Double_t(fAProjectile)));
200 Bool_t AliGenMC::ParentSelected(Int_t ip) const
202 // True if particle is in list of parent particles to be selected
203 for (Int_t i=0; i<8; i++)
205 if (fParentSelect.At(i) == ip) return kTRUE;
210 Bool_t AliGenMC::ChildSelected(Int_t ip) const
212 // True if particle is in list of decay products to be selected
213 for (Int_t i=0; i<5; i++)
215 if (fChildSelect.At(i) == ip) return kTRUE;
220 Bool_t AliGenMC::KinematicSelection(const TParticle *particle, Int_t flag) const
222 // Perform kinematic selection
223 Double_t pz = particle->Pz();
224 Double_t pt = particle->Pt();
225 Double_t p = particle->P();
226 Double_t theta = particle->Theta();
227 Double_t mass = particle->GetCalcMass();
228 Double_t mt2 = pt * pt + mass * mass;
229 Double_t phi = particle->Phi();
230 Double_t e = particle->Energy();
233 e = TMath::Sqrt(p * p + mass * mass);
238 if (TMath::Abs(pz) < e) {
239 y = 0.5*TMath::Log((e+pz)/(e-pz));
245 y0 = 0.5*TMath::Log((e+TMath::Abs(pz))*(e+TMath::Abs(pz))/mt2);
247 if (TMath::Abs(y) < 1.e10) {
254 y = (pz < 0) ? -y0 : y0;
258 // Primary particle cuts
260 // transverse momentum cut
261 if (pt > fPtMax || pt < fPtMin) {
262 // printf("\n failed pt cut %f %f %f \n",pt,fPtMin,fPtMax);
267 if (p > fPMax || p < fPMin) {
268 // printf("\n failed p cut %f %f %f \n",p,fPMin,fPMax);
273 if (theta > fThetaMax || theta < fThetaMin) {
274 // printf("\n failed theta cut %f %f %f \n",theta,fThetaMin,fThetaMax);
279 if (y > fYMax || y < fYMin) {
280 // printf("\n failed y cut %f %f %f \n",y,fYMin,fYMax);
285 if (phi > fPhiMax || phi < fPhiMin) {
286 // printf("\n failed phi cut %f %f %f \n",phi,fPhiMin,fPhiMax);
291 // Decay product cuts
293 // transverse momentum cut
294 if (pt > fChildPtMax || pt < fChildPtMin) {
295 // printf("\n failed pt cut %f %f %f \n",pt,fChildPtMin,fChildPtMax);
300 if (p > fChildPMax || p < fChildPMin) {
301 // printf("\n failed p cut %f %f %f \n",p,fChildPMin,fChildPMax);
306 if (theta > fChildThetaMax || theta < fChildThetaMin) {
307 // printf("\n failed theta cut %f %f %f \n",theta,fChildThetaMin,fChildThetaMax);
312 if (y > fChildYMax || y < fChildYMin) {
313 // printf("\n failed y cut %f %f %f \n",y,fChildYMin,fChildYMax);
318 if (phi > fChildPhiMax || phi < fChildPhiMin) {
319 // printf("\n failed phi cut %f %f %f \n",phi,fChildPhiMin,fChildPhiMax);
327 Bool_t AliGenMC::CheckAcceptanceGeometry(Int_t np, TClonesArray* particles)
329 // Check the geometrical acceptance for particle.
332 Int_t numberOfPdgCodeParticleforAcceptanceCut = 0;
333 Int_t numberOfAcceptedPdgCodeParticleforAcceptanceCut = 0;
334 TParticle * particle;
336 for (i = 0; i < np; i++) {
337 particle = (TParticle *) particles->At(i);
338 if( TMath::Abs( particle->GetPdgCode() ) == TMath::Abs( fPdgCodeParticleforAcceptanceCut ) ) {
339 numberOfPdgCodeParticleforAcceptanceCut++;
340 if (fGeometryAcceptance->Impact(particle)) numberOfAcceptedPdgCodeParticleforAcceptanceCut++;
343 if ( numberOfAcceptedPdgCodeParticleforAcceptanceCut > (fNumberOfAcceptedParticles-1) )
351 Int_t AliGenMC::CheckPDGCode(Int_t pdgcode) const
354 // If the particle is in a diffractive state, then take action accordingly
359 //rho_diff0 -- difficult to translate, return rho0
362 //pi_diffr+ -- change to pi+
365 //omega_di0 -- change to omega0
368 //phi_diff0 -- return phi0
371 //J/psi_di0 -- return J/psi
374 //n_diffr -- return neutron
377 //p_diffr+ -- return proton
380 //non diffractive state -- return code unchanged
384 void AliGenMC::Boost()
387 // Boost cms into LHC lab frame
390 Double_t beta = TMath::TanH(fDyBoost);
391 Double_t gamma = 1./TMath::Sqrt((1.-beta)*(1.+beta));
392 Double_t gb = gamma * beta;
394 // printf("\n Boosting particles to lab frame %f %f %f", fDyBoost, beta, gamma);
397 Int_t np = fParticles.GetEntriesFast();
398 for (i = 0; i < np; i++)
400 TParticle* iparticle = (TParticle*) fParticles.At(i);
402 Double_t e = iparticle->Energy();
403 Double_t px = iparticle->Px();
404 Double_t py = iparticle->Py();
405 Double_t pz = iparticle->Pz();
407 Double_t eb = gamma * e - gb * pz;
408 Double_t pzb = -gb * e + gamma * pz;
410 iparticle->SetMomentum(px, py, pzb, eb);
414 void AliGenMC::BeamCrossAngle()
416 // Applies a boost in the y-direction in order to take into account the
417 // beam crossing angle
419 Double_t thetaPr0, pyPr2, pzPr2;
422 thetaPr0 = fXingAngleY / 2.;
424 // Momentum of the CMS system
425 pyPr2 = TMath::Sqrt(fEnergyCMS * fEnergyCMS/ 4 - 0.938 * 0.938) * TMath::Sin(thetaPr0);
426 pzPr2 = TMath::Sqrt(fEnergyCMS * fEnergyCMS/ 4 - 0.938 * 0.938) * TMath::Cos(thetaPr0);
428 TLorentzVector proj1Vect, proj2Vect, projVect;
429 proj1Vect.SetPxPyPzE(0., pyPr2, pzPr2, fEnergyCMS/2);
430 proj2Vect.SetPxPyPzE(0., pyPr2,-pzPr2, fEnergyCMS/2);
431 projVect = proj1Vect + proj2Vect;
432 beta=(1. / projVect.E()) * (projVect.Vect());
435 Int_t np = fParticles.GetEntriesFast();
436 for (i = 0; i < np; i++)
438 TParticle* iparticle = (TParticle*) fParticles.At(i);
440 Double_t e = iparticle->Energy();
441 Double_t px = iparticle->Px();
442 Double_t py = iparticle->Py();
443 Double_t pz = iparticle->Pz();
445 TLorentzVector partIn;
446 partIn.SetPxPyPzE(px,py,pz,e);
448 iparticle->SetMomentum(partIn.Px(),partIn.Py(),partIn.Pz(),partIn.E());
453 void AliGenMC::AddHeader(AliGenEventHeader* header)
455 // Passes header either to the container or to gAlice
457 header->SetName(fName);
458 fContainer->AddHeader(header);
460 gAlice->SetGenEventHeader(header);