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