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