Option kBJpsi added.
[u/mrichter/AliRoot.git] / EVGEN / AliGenMC.cxx
CommitLineData
e36044d6 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
88cb7938 16/* $Id$ */
e36044d6 17
62d0ae06 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
23
65de9f86 24#include <TMath.h>
116cbefd 25#include <TPDGCode.h>
e36044d6 26#include <TParticle.h>
27
116cbefd 28#include "AliGenMC.h"
29
198bb1c7 30ClassImp(AliGenMC)
e36044d6 31
32AliGenMC::AliGenMC()
198bb1c7 33 :AliGenerator()
e36044d6 34{
35// Default Constructor
36 SetCutOnChild();
37 SetChildMomentumRange();
38 SetChildPtRange();
39 SetChildPhiRange();
40 SetChildThetaRange();
41 SetChildYRange();
47fc6bd5 42 SetMaximumLifetime();
65de9f86 43 SetGeometryAcceptance();
44 SetPdgCodeParticleforAcceptanceCut();
45 SetNumberOfAcceptedParticles();
3b945a60 46 SetTarget();
47 SetProjectile();
e033748b 48 fParentSelect.Set(8);
49 fChildSelect.Set(8);
f0a0032d 50 fForceDecay = kAll;
e36044d6 51}
52
53AliGenMC::AliGenMC(Int_t npart)
198bb1c7 54 :AliGenerator(npart)
e36044d6 55{
56// Constructor
57 SetCutOnChild();
58 SetChildMomentumRange();
59 SetChildPtRange();
60 SetChildPhiRange();
61 SetChildThetaRange();
62 SetChildYRange();
63//
64 fParentSelect.Set(8);
65 fChildSelect.Set(8);
66 for (Int_t i=0; i<8; i++) fParentSelect[i]=fChildSelect[i]=0;
47fc6bd5 67 SetMaximumLifetime();
65de9f86 68 SetGeometryAcceptance();
69 SetPdgCodeParticleforAcceptanceCut();
70 SetNumberOfAcceptedParticles();
3b945a60 71 SetTarget();
72 SetProjectile();
f0a0032d 73 fForceDecay = kAll;
e36044d6 74}
75
198bb1c7 76AliGenMC::AliGenMC(const AliGenMC & mc):
77 AliGenerator(mc)
e36044d6 78{
198bb1c7 79// Copy constructor
80 mc.Copy(*this);
e36044d6 81}
82
83AliGenMC::~AliGenMC()
84{
85// Destructor
86}
87
88void AliGenMC::Init()
89{
90//
91// Initialization
92 switch (fForceDecay) {
93 case kSemiElectronic:
94 case kDiElectron:
95 case kBJpsiDiElectron:
96 case kBPsiPrimeDiElectron:
47fc6bd5 97 fChildSelect[0] = kElectron;
e36044d6 98 break;
2dcb5874 99 case kHardMuons:
e36044d6 100 case kSemiMuonic:
101 case kDiMuon:
102 case kBJpsiDiMuon:
103 case kBPsiPrimeDiMuon:
104 case kPiToMu:
105 case kKaToMu:
106 fChildSelect[0]=kMuonMinus;
107 break;
108 case kHadronicD:
109 fChildSelect[0]=kPiPlus;
110 fChildSelect[1]=kKPlus;
111 break;
00cb2f27 112 case kPhiKK:
027677ae 113 fChildSelect[0]=kKPlus;
56d47239 114 break;
115 case kBJpsi:
116 fChildSelect[0]=443;
117 break;
62d0ae06 118 case kOmega:
e36044d6 119 case kAll:
120 case kNoDecay:
d5f86442 121 case kNoDecayHeavy:
e36044d6 122 break;
123 }
36d770d9 124
125 if (fZTarget != 0 && fAProjectile != 0)
126 {
127 fDyBoost = - 0.5 * TMath::Log(Double_t(fZProjectile) * Double_t(fATarget) /
128 (Double_t(fZTarget) * Double_t(fAProjectile)));
129 }
e36044d6 130}
131
132
62d0ae06 133Bool_t AliGenMC::ParentSelected(Int_t ip) const
e36044d6 134{
135// True if particle is in list of parent particles to be selected
136 for (Int_t i=0; i<8; i++)
137 {
62d0ae06 138 if (fParentSelect.At(i) == ip) return kTRUE;
e36044d6 139 }
140 return kFALSE;
141}
142
62d0ae06 143Bool_t AliGenMC::ChildSelected(Int_t ip) const
e36044d6 144{
145// True if particle is in list of decay products to be selected
146 for (Int_t i=0; i<5; i++)
147 {
62d0ae06 148 if (fChildSelect.At(i) == ip) return kTRUE;
e36044d6 149 }
150 return kFALSE;
151}
152
62d0ae06 153Bool_t AliGenMC::KinematicSelection(TParticle *particle, Int_t flag) const
e36044d6 154{
155// Perform kinematic selection
e36044d6 156 Float_t pz = particle->Pz();
157 Float_t e = particle->Energy();
158 Float_t pt = particle->Pt();
159 Float_t p = particle->P();
160 Float_t theta = particle->Theta();
cf01ee36 161 Float_t mass = particle->GetCalcMass();
95450c6d 162 Float_t mt2 = pt * pt + mass * mass;
0b6d2cb3 163 Float_t phi = particle->Phi();
95450c6d 164
95450c6d 165 Double_t y, y0;
166
fef61e14 167 if (TMath::Abs(pz) < e) {
95450c6d 168 y = 0.5*TMath::Log((e+pz)/(e-pz));
169 } else {
170 y = 1.e10;
171 }
e36044d6 172
95450c6d 173 if (mt2) {
174 y0 = 0.5*TMath::Log((e+TMath::Abs(pz))*(e+TMath::Abs(pz))/mt2);
e36044d6 175 } else {
95450c6d 176 if (TMath::Abs(y) < 1.e10) {
177 y0 = y;
178 } else {
179 y0 = 1.e10;
180 }
e36044d6 181 }
95450c6d 182
183 y = (pz < 0) ? -y0 : y0;
e36044d6 184
185 if (flag == 0) {
186//
187// Primary particle cuts
188//
189// transverse momentum cut
190 if (pt > fPtMax || pt < fPtMin) {
191// printf("\n failed pt cut %f %f %f \n",pt,fPtMin,fPtMax);
192 return kFALSE;
193 }
194//
195// momentum cut
196 if (p > fPMax || p < fPMin) {
197// printf("\n failed p cut %f %f %f \n",p,fPMin,fPMax);
198 return kFALSE;
199 }
200//
201// theta cut
202 if (theta > fThetaMax || theta < fThetaMin) {
203// printf("\n failed theta cut %f %f %f \n",theta,fThetaMin,fThetaMax);
204 return kFALSE;
205 }
206//
207// rapidity cut
208 if (y > fYMax || y < fYMin) {
209// printf("\n failed y cut %f %f %f \n",y,fYMin,fYMax);
210 return kFALSE;
211 }
212//
213// phi cut
214 if (phi > fPhiMax || phi < fPhiMin) {
215// printf("\n failed phi cut %f %f %f \n",phi,fPhiMin,fPhiMax);
216 return kFALSE;
217 }
218 } else {
219//
220// Decay product cuts
221//
222// transverse momentum cut
223 if (pt > fChildPtMax || pt < fChildPtMin) {
224// printf("\n failed pt cut %f %f %f \n",pt,fChildPtMin,fChildPtMax);
225 return kFALSE;
226 }
227//
228// momentum cut
229 if (p > fChildPMax || p < fChildPMin) {
230// printf("\n failed p cut %f %f %f \n",p,fChildPMin,fChildPMax);
231 return kFALSE;
232 }
233//
234// theta cut
235 if (theta > fChildThetaMax || theta < fChildThetaMin) {
236// printf("\n failed theta cut %f %f %f \n",theta,fChildThetaMin,fChildThetaMax);
237 return kFALSE;
238 }
239//
240// rapidity cut
241 if (y > fChildYMax || y < fChildYMin) {
242// printf("\n failed y cut %f %f %f \n",y,fChildYMin,fChildYMax);
243 return kFALSE;
244 }
245//
246// phi cut
247 if (phi > fChildPhiMax || phi < fChildPhiMin) {
248// printf("\n failed phi cut %f %f %f \n",phi,fChildPhiMin,fChildPhiMax);
249 return kFALSE;
250 }
251 }
252
e36044d6 253 return kTRUE;
254}
255
65de9f86 256Bool_t AliGenMC::CheckAcceptanceGeometry(Int_t np, TClonesArray* particles)
257{
e033748b 258// Check the geometrical acceptance for particle.
259
260 Bool_t check ;
261 Int_t numberOfPdgCodeParticleforAcceptanceCut = 0;
262 Int_t numberOfAcceptedPdgCodeParticleforAcceptanceCut = 0;
65de9f86 263 TParticle * particle;
264 Int_t i;
e033748b 265 for (i = 0; i < np; i++) {
65de9f86 266 particle = (TParticle *) particles->At(i);
267 if( TMath::Abs( particle->GetPdgCode() ) == TMath::Abs( fPdgCodeParticleforAcceptanceCut ) ) {
e033748b 268 numberOfPdgCodeParticleforAcceptanceCut++;
269 if (fGeometryAcceptance->Impact(particle)) numberOfAcceptedPdgCodeParticleforAcceptanceCut++;
65de9f86 270 }
271 }
e033748b 272 if ( numberOfAcceptedPdgCodeParticleforAcceptanceCut > (fNumberOfAcceptedParticles-1) )
273 check = kTRUE;
65de9f86 274 else
e033748b 275 check = kFALSE;
65de9f86 276
e033748b 277 return check;
65de9f86 278}
279
62d0ae06 280Int_t AliGenMC::CheckPDGCode(Int_t pdgcode) const
e36044d6 281{
282//
283// If the particle is in a diffractive state, then take action accordingly
284 switch (pdgcode) {
285 case 91:
286 return 92;
287 case 110:
288 //rho_diff0 -- difficult to translate, return rho0
289 return 113;
290 case 210:
291 //pi_diffr+ -- change to pi+
292 return 211;
293 case 220:
294 //omega_di0 -- change to omega0
295 return 223;
296 case 330:
297 //phi_diff0 -- return phi0
298 return 333;
299 case 440:
300 //J/psi_di0 -- return J/psi
301 return 443;
302 case 2110:
303 //n_diffr -- return neutron
304 return 2112;
305 case 2210:
306 //p_diffr+ -- return proton
307 return 2212;
308 }
309 //non diffractive state -- return code unchanged
310 return pdgcode;
311}
3b945a60 312
36d770d9 313void AliGenMC::Boost()
3b945a60 314{
315//
316// Boost cms into LHC lab frame
317//
318
36d770d9 319 Double_t beta = TMath::TanH(fDyBoost);
3b945a60 320 Double_t gamma = 1./TMath::Sqrt(1.-beta*beta);
321 Double_t gb = gamma * beta;
322
7cdba479 323 // printf("\n Boosting particles to lab frame %f %f %f", fDyBoost, beta, gamma);
3b945a60 324
325 Int_t i;
326 Int_t np = fParticles->GetEntriesFast();
327 for (i = 0; i < np; i++)
328 {
329 TParticle* iparticle = (TParticle*) fParticles->At(i);
330
331 Double_t e = iparticle->Energy();
332 Double_t px = iparticle->Px();
333 Double_t py = iparticle->Py();
334 Double_t pz = iparticle->Pz();
335
336 Double_t eb = gamma * e - gb * pz;
337 Double_t pzb = -gb * e + gamma * pz;
338
339 iparticle->SetMomentum(px, py, pzb, eb);
340 }
341}
342
343
e36044d6 344
345AliGenMC& AliGenMC::operator=(const AliGenMC& rhs)
346{
347// Assignment operator
198bb1c7 348 rhs.Copy(*this);
e36044d6 349 return *this;
350}
351
dc1d768c 352void AliGenMC::Copy(TObject&) const
198bb1c7 353{
354 //
355 // Copy
356 //
357 Fatal("Copy","Not implemented!\n");
358}
359
360