fForceDecay initialized to kAll in constructors
[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;
62d0ae06 114 case kOmega:
e36044d6 115 case kAll:
116 case kNoDecay:
d5f86442 117 case kNoDecayHeavy:
e36044d6 118 break;
119 }
36d770d9 120
121 if (fZTarget != 0 && fAProjectile != 0)
122 {
123 fDyBoost = - 0.5 * TMath::Log(Double_t(fZProjectile) * Double_t(fATarget) /
124 (Double_t(fZTarget) * Double_t(fAProjectile)));
125 }
e36044d6 126}
127
128
62d0ae06 129Bool_t AliGenMC::ParentSelected(Int_t ip) const
e36044d6 130{
131// True if particle is in list of parent particles to be selected
132 for (Int_t i=0; i<8; i++)
133 {
62d0ae06 134 if (fParentSelect.At(i) == ip) return kTRUE;
e36044d6 135 }
136 return kFALSE;
137}
138
62d0ae06 139Bool_t AliGenMC::ChildSelected(Int_t ip) const
e36044d6 140{
141// True if particle is in list of decay products to be selected
142 for (Int_t i=0; i<5; i++)
143 {
62d0ae06 144 if (fChildSelect.At(i) == ip) return kTRUE;
e36044d6 145 }
146 return kFALSE;
147}
148
62d0ae06 149Bool_t AliGenMC::KinematicSelection(TParticle *particle, Int_t flag) const
e36044d6 150{
151// Perform kinematic selection
e36044d6 152 Float_t pz = particle->Pz();
153 Float_t e = particle->Energy();
154 Float_t pt = particle->Pt();
155 Float_t p = particle->P();
156 Float_t theta = particle->Theta();
cf01ee36 157 Float_t mass = particle->GetCalcMass();
95450c6d 158 Float_t mt2 = pt * pt + mass * mass;
0b6d2cb3 159 Float_t phi = particle->Phi();
95450c6d 160
95450c6d 161 Double_t y, y0;
162
fef61e14 163 if (TMath::Abs(pz) < e) {
95450c6d 164 y = 0.5*TMath::Log((e+pz)/(e-pz));
165 } else {
166 y = 1.e10;
167 }
e36044d6 168
95450c6d 169 if (mt2) {
170 y0 = 0.5*TMath::Log((e+TMath::Abs(pz))*(e+TMath::Abs(pz))/mt2);
e36044d6 171 } else {
95450c6d 172 if (TMath::Abs(y) < 1.e10) {
173 y0 = y;
174 } else {
175 y0 = 1.e10;
176 }
e36044d6 177 }
95450c6d 178
179 y = (pz < 0) ? -y0 : y0;
e36044d6 180
181 if (flag == 0) {
182//
183// Primary particle cuts
184//
185// transverse momentum cut
186 if (pt > fPtMax || pt < fPtMin) {
187// printf("\n failed pt cut %f %f %f \n",pt,fPtMin,fPtMax);
188 return kFALSE;
189 }
190//
191// momentum cut
192 if (p > fPMax || p < fPMin) {
193// printf("\n failed p cut %f %f %f \n",p,fPMin,fPMax);
194 return kFALSE;
195 }
196//
197// theta cut
198 if (theta > fThetaMax || theta < fThetaMin) {
199// printf("\n failed theta cut %f %f %f \n",theta,fThetaMin,fThetaMax);
200 return kFALSE;
201 }
202//
203// rapidity cut
204 if (y > fYMax || y < fYMin) {
205// printf("\n failed y cut %f %f %f \n",y,fYMin,fYMax);
206 return kFALSE;
207 }
208//
209// phi cut
210 if (phi > fPhiMax || phi < fPhiMin) {
211// printf("\n failed phi cut %f %f %f \n",phi,fPhiMin,fPhiMax);
212 return kFALSE;
213 }
214 } else {
215//
216// Decay product cuts
217//
218// transverse momentum cut
219 if (pt > fChildPtMax || pt < fChildPtMin) {
220// printf("\n failed pt cut %f %f %f \n",pt,fChildPtMin,fChildPtMax);
221 return kFALSE;
222 }
223//
224// momentum cut
225 if (p > fChildPMax || p < fChildPMin) {
226// printf("\n failed p cut %f %f %f \n",p,fChildPMin,fChildPMax);
227 return kFALSE;
228 }
229//
230// theta cut
231 if (theta > fChildThetaMax || theta < fChildThetaMin) {
232// printf("\n failed theta cut %f %f %f \n",theta,fChildThetaMin,fChildThetaMax);
233 return kFALSE;
234 }
235//
236// rapidity cut
237 if (y > fChildYMax || y < fChildYMin) {
238// printf("\n failed y cut %f %f %f \n",y,fChildYMin,fChildYMax);
239 return kFALSE;
240 }
241//
242// phi cut
243 if (phi > fChildPhiMax || phi < fChildPhiMin) {
244// printf("\n failed phi cut %f %f %f \n",phi,fChildPhiMin,fChildPhiMax);
245 return kFALSE;
246 }
247 }
248
e36044d6 249 return kTRUE;
250}
251
65de9f86 252Bool_t AliGenMC::CheckAcceptanceGeometry(Int_t np, TClonesArray* particles)
253{
e033748b 254// Check the geometrical acceptance for particle.
255
256 Bool_t check ;
257 Int_t numberOfPdgCodeParticleforAcceptanceCut = 0;
258 Int_t numberOfAcceptedPdgCodeParticleforAcceptanceCut = 0;
65de9f86 259 TParticle * particle;
260 Int_t i;
e033748b 261 for (i = 0; i < np; i++) {
65de9f86 262 particle = (TParticle *) particles->At(i);
263 if( TMath::Abs( particle->GetPdgCode() ) == TMath::Abs( fPdgCodeParticleforAcceptanceCut ) ) {
e033748b 264 numberOfPdgCodeParticleforAcceptanceCut++;
265 if (fGeometryAcceptance->Impact(particle)) numberOfAcceptedPdgCodeParticleforAcceptanceCut++;
65de9f86 266 }
267 }
e033748b 268 if ( numberOfAcceptedPdgCodeParticleforAcceptanceCut > (fNumberOfAcceptedParticles-1) )
269 check = kTRUE;
65de9f86 270 else
e033748b 271 check = kFALSE;
65de9f86 272
e033748b 273 return check;
65de9f86 274}
275
62d0ae06 276Int_t AliGenMC::CheckPDGCode(Int_t pdgcode) const
e36044d6 277{
278//
279// If the particle is in a diffractive state, then take action accordingly
280 switch (pdgcode) {
281 case 91:
282 return 92;
283 case 110:
284 //rho_diff0 -- difficult to translate, return rho0
285 return 113;
286 case 210:
287 //pi_diffr+ -- change to pi+
288 return 211;
289 case 220:
290 //omega_di0 -- change to omega0
291 return 223;
292 case 330:
293 //phi_diff0 -- return phi0
294 return 333;
295 case 440:
296 //J/psi_di0 -- return J/psi
297 return 443;
298 case 2110:
299 //n_diffr -- return neutron
300 return 2112;
301 case 2210:
302 //p_diffr+ -- return proton
303 return 2212;
304 }
305 //non diffractive state -- return code unchanged
306 return pdgcode;
307}
3b945a60 308
36d770d9 309void AliGenMC::Boost()
3b945a60 310{
311//
312// Boost cms into LHC lab frame
313//
314
36d770d9 315 Double_t beta = TMath::TanH(fDyBoost);
3b945a60 316 Double_t gamma = 1./TMath::Sqrt(1.-beta*beta);
317 Double_t gb = gamma * beta;
318
7cdba479 319 // printf("\n Boosting particles to lab frame %f %f %f", fDyBoost, beta, gamma);
3b945a60 320
321 Int_t i;
322 Int_t np = fParticles->GetEntriesFast();
323 for (i = 0; i < np; i++)
324 {
325 TParticle* iparticle = (TParticle*) fParticles->At(i);
326
327 Double_t e = iparticle->Energy();
328 Double_t px = iparticle->Px();
329 Double_t py = iparticle->Py();
330 Double_t pz = iparticle->Pz();
331
332 Double_t eb = gamma * e - gb * pz;
333 Double_t pzb = -gb * e + gamma * pz;
334
335 iparticle->SetMomentum(px, py, pzb, eb);
336 }
337}
338
339
e36044d6 340
341AliGenMC& AliGenMC::operator=(const AliGenMC& rhs)
342{
343// Assignment operator
198bb1c7 344 rhs.Copy(*this);
e36044d6 345 return *this;
346}
347
dc1d768c 348void AliGenMC::Copy(TObject&) const
198bb1c7 349{
350 //
351 // Copy
352 //
353 Fatal("Copy","Not implemented!\n");
354}
355
356