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