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