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