]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVGEN/AliGenMC.cxx
Changes related to the initialization of random numbers generators. Now one can use...
[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
16/*
17$Log$
7cdba479 18Revision 1.16 2003/04/08 10:22:05 morsch
19Rapidity shift calculated in Init().
20
36d770d9 21Revision 1.15 2003/04/04 08:13:26 morsch
22Boost method added.
23
3b945a60 24Revision 1.14 2003/01/14 10:50:19 alibrary
25Cleanup of STEER coding conventions
26
116cbefd 27Revision 1.13 2002/10/14 14:55:35 hristov
28Merging the VirtualMC branch to the main development branch (HEAD)
29
b9d0a01d 30Revision 1.5.4.2 2002/07/24 08:56:28 alibrary
31Updating EVGEN on TVirtulaMC
32
33Revision 1.12 2002/07/19 11:42:33 morsch
34Use CalcMass()
35
cf01ee36 36Revision 1.11 2002/06/06 15:26:24 morsch
37Correct child-selection for kPhiKK
38
027677ae 39Revision 1.10 2002/06/05 14:05:46 morsch
40Decayer option kPhiKK for forced phi->K+K- decay added.
41
00cb2f27 42Revision 1.9 2002/05/30 14:58:29 morsch
43Add pointer to AliGeometry to handle geometrical acceptance. (G. MArtinez)
44
65de9f86 45Revision 1.8 2002/04/26 10:42:35 morsch
46Case kNoDecayHeavy added. (N. Carrer)
47
d5f86442 48Revision 1.7 2002/04/17 10:32:32 morsch
49Coding Rule violations corrected.
50
62d0ae06 51Revision 1.6 2002/03/26 14:19:36 morsch
52Saver calculation of rapdity.
53
fef61e14 54Revision 1.5 2002/03/12 17:02:20 morsch
55Change in calculation of rapidity, include case in which numerically e == pz.
56
95450c6d 57Revision 1.4 2001/11/27 13:13:07 morsch
58Maximum lifetime for long-lived particles to be put on the stack is parameter.
59It can be set via SetMaximumLifetime(..).
60
47fc6bd5 61Revision 1.3 2001/10/16 08:48:56 morsch
62Common vertex related code moved to base class AliGenerator.
63
b80a8e41 64Revision 1.2 2001/10/15 08:15:51 morsch
65Event vertex and vertex truncation setting moved into AliMC.
66
dba8ac91 67Revision 1.1 2001/07/13 10:56:00 morsch
68AliGenMC base class for AliGenParam and AliGenPythia commonalities.
69
e36044d6 70*/
71
62d0ae06 72// Base class for generators using external MC generators.
73// For example AliGenPythia using Pythia.
74// Provides basic functionality: setting of kinematic cuts on
75// decay products and particle selection.
76// andreas.morsch@cern.ch
77
65de9f86 78#include <TMath.h>
116cbefd 79#include <TPDGCode.h>
e36044d6 80#include <TParticle.h>
81
116cbefd 82#include "AliGenMC.h"
83
e36044d6 84 ClassImp(AliGenMC)
85
86AliGenMC::AliGenMC()
87 :AliGenerator()
88{
89// Default Constructor
90 SetCutOnChild();
91 SetChildMomentumRange();
92 SetChildPtRange();
93 SetChildPhiRange();
94 SetChildThetaRange();
95 SetChildYRange();
47fc6bd5 96 SetMaximumLifetime();
65de9f86 97 SetGeometryAcceptance();
98 SetPdgCodeParticleforAcceptanceCut();
99 SetNumberOfAcceptedParticles();
3b945a60 100 SetTarget();
101 SetProjectile();
e36044d6 102}
103
104AliGenMC::AliGenMC(Int_t npart)
105 :AliGenerator(npart)
106{
107// Constructor
108 SetCutOnChild();
109 SetChildMomentumRange();
110 SetChildPtRange();
111 SetChildPhiRange();
112 SetChildThetaRange();
113 SetChildYRange();
114//
115 fParentSelect.Set(8);
116 fChildSelect.Set(8);
117 for (Int_t i=0; i<8; i++) fParentSelect[i]=fChildSelect[i]=0;
47fc6bd5 118 SetMaximumLifetime();
65de9f86 119 SetGeometryAcceptance();
120 SetPdgCodeParticleforAcceptanceCut();
121 SetNumberOfAcceptedParticles();
3b945a60 122 SetTarget();
123 SetProjectile();
e36044d6 124}
125
126AliGenMC::AliGenMC(const AliGenMC & mc)
127{
128// copy constructor
129}
130
131AliGenMC::~AliGenMC()
132{
133// Destructor
134}
135
136void AliGenMC::Init()
137{
138//
139// Initialization
140 switch (fForceDecay) {
141 case kSemiElectronic:
142 case kDiElectron:
143 case kBJpsiDiElectron:
144 case kBPsiPrimeDiElectron:
47fc6bd5 145 fChildSelect[0] = kElectron;
e36044d6 146 break;
147 case kSemiMuonic:
148 case kDiMuon:
149 case kBJpsiDiMuon:
150 case kBPsiPrimeDiMuon:
151 case kPiToMu:
152 case kKaToMu:
153 fChildSelect[0]=kMuonMinus;
154 break;
155 case kHadronicD:
156 fChildSelect[0]=kPiPlus;
157 fChildSelect[1]=kKPlus;
158 break;
00cb2f27 159 case kPhiKK:
027677ae 160 fChildSelect[0]=kKPlus;
62d0ae06 161 case kOmega:
e36044d6 162 case kAll:
163 case kNoDecay:
d5f86442 164 case kNoDecayHeavy:
e36044d6 165 break;
166 }
36d770d9 167
168 if (fZTarget != 0 && fAProjectile != 0)
169 {
170 fDyBoost = - 0.5 * TMath::Log(Double_t(fZProjectile) * Double_t(fATarget) /
171 (Double_t(fZTarget) * Double_t(fAProjectile)));
172 }
e36044d6 173}
174
175
62d0ae06 176Bool_t AliGenMC::ParentSelected(Int_t ip) const
e36044d6 177{
178// True if particle is in list of parent particles to be selected
179 for (Int_t i=0; i<8; i++)
180 {
62d0ae06 181 if (fParentSelect.At(i) == ip) return kTRUE;
e36044d6 182 }
183 return kFALSE;
184}
185
62d0ae06 186Bool_t AliGenMC::ChildSelected(Int_t ip) const
e36044d6 187{
188// True if particle is in list of decay products to be selected
189 for (Int_t i=0; i<5; i++)
190 {
62d0ae06 191 if (fChildSelect.At(i) == ip) return kTRUE;
e36044d6 192 }
193 return kFALSE;
194}
195
62d0ae06 196Bool_t AliGenMC::KinematicSelection(TParticle *particle, Int_t flag) const
e36044d6 197{
198// Perform kinematic selection
199 Float_t px = particle->Px();
200 Float_t py = particle->Py();
201 Float_t pz = particle->Pz();
202 Float_t e = particle->Energy();
203 Float_t pt = particle->Pt();
204 Float_t p = particle->P();
205 Float_t theta = particle->Theta();
cf01ee36 206 Float_t mass = particle->GetCalcMass();
95450c6d 207 Float_t mt2 = pt * pt + mass * mass;
208
e36044d6 209 Float_t phi = Float_t(TMath::ATan2(Double_t(py),Double_t(px)));
95450c6d 210 Double_t y, y0;
211
fef61e14 212 if (TMath::Abs(pz) < e) {
95450c6d 213 y = 0.5*TMath::Log((e+pz)/(e-pz));
214 } else {
215 y = 1.e10;
216 }
e36044d6 217
95450c6d 218 if (mt2) {
219 y0 = 0.5*TMath::Log((e+TMath::Abs(pz))*(e+TMath::Abs(pz))/mt2);
e36044d6 220 } else {
95450c6d 221 if (TMath::Abs(y) < 1.e10) {
222 y0 = y;
223 } else {
224 y0 = 1.e10;
225 }
e36044d6 226 }
95450c6d 227
228 y = (pz < 0) ? -y0 : y0;
e36044d6 229
230 if (flag == 0) {
231//
232// Primary particle cuts
233//
234// transverse momentum cut
235 if (pt > fPtMax || pt < fPtMin) {
236// printf("\n failed pt cut %f %f %f \n",pt,fPtMin,fPtMax);
237 return kFALSE;
238 }
239//
240// momentum cut
241 if (p > fPMax || p < fPMin) {
242// printf("\n failed p cut %f %f %f \n",p,fPMin,fPMax);
243 return kFALSE;
244 }
245//
246// theta cut
247 if (theta > fThetaMax || theta < fThetaMin) {
248// printf("\n failed theta cut %f %f %f \n",theta,fThetaMin,fThetaMax);
249 return kFALSE;
250 }
251//
252// rapidity cut
253 if (y > fYMax || y < fYMin) {
254// printf("\n failed y cut %f %f %f \n",y,fYMin,fYMax);
255 return kFALSE;
256 }
257//
258// phi cut
259 if (phi > fPhiMax || phi < fPhiMin) {
260// printf("\n failed phi cut %f %f %f \n",phi,fPhiMin,fPhiMax);
261 return kFALSE;
262 }
263 } else {
264//
265// Decay product cuts
266//
267// transverse momentum cut
268 if (pt > fChildPtMax || pt < fChildPtMin) {
269// printf("\n failed pt cut %f %f %f \n",pt,fChildPtMin,fChildPtMax);
270 return kFALSE;
271 }
272//
273// momentum cut
274 if (p > fChildPMax || p < fChildPMin) {
275// printf("\n failed p cut %f %f %f \n",p,fChildPMin,fChildPMax);
276 return kFALSE;
277 }
278//
279// theta cut
280 if (theta > fChildThetaMax || theta < fChildThetaMin) {
281// printf("\n failed theta cut %f %f %f \n",theta,fChildThetaMin,fChildThetaMax);
282 return kFALSE;
283 }
284//
285// rapidity cut
286 if (y > fChildYMax || y < fChildYMin) {
287// printf("\n failed y cut %f %f %f \n",y,fChildYMin,fChildYMax);
288 return kFALSE;
289 }
290//
291// phi cut
292 if (phi > fChildPhiMax || phi < fChildPhiMin) {
293// printf("\n failed phi cut %f %f %f \n",phi,fChildPhiMin,fChildPhiMax);
294 return kFALSE;
295 }
296 }
297
e36044d6 298 return kTRUE;
299}
300
65de9f86 301Bool_t AliGenMC::CheckAcceptanceGeometry(Int_t np, TClonesArray* particles)
302{
303 Bool_t Check ; // All fPdgCodeParticleforAcceptanceCut particles are in in the fGeometryAcceptance acceptance
304 Int_t NumberOfPdgCodeParticleforAcceptanceCut=0;
305 Int_t NumberOfAcceptedPdgCodeParticleforAcceptanceCut=0;
306 TParticle * particle;
307 Int_t i;
308 for (i=0; i<np; i++) {
309 particle = (TParticle *) particles->At(i);
310 if( TMath::Abs( particle->GetPdgCode() ) == TMath::Abs( fPdgCodeParticleforAcceptanceCut ) ) {
311 NumberOfPdgCodeParticleforAcceptanceCut++;
312 if (fGeometryAcceptance->Impact(particle)) NumberOfAcceptedPdgCodeParticleforAcceptanceCut++;
313 }
314 }
315 if ( NumberOfAcceptedPdgCodeParticleforAcceptanceCut > (fNumberOfAcceptedParticles-1) )
316 Check = kTRUE;
317 else
318 Check = kFALSE;
319
320 return Check;
321}
322
62d0ae06 323Int_t AliGenMC::CheckPDGCode(Int_t pdgcode) const
e36044d6 324{
325//
326// If the particle is in a diffractive state, then take action accordingly
327 switch (pdgcode) {
328 case 91:
329 return 92;
330 case 110:
331 //rho_diff0 -- difficult to translate, return rho0
332 return 113;
333 case 210:
334 //pi_diffr+ -- change to pi+
335 return 211;
336 case 220:
337 //omega_di0 -- change to omega0
338 return 223;
339 case 330:
340 //phi_diff0 -- return phi0
341 return 333;
342 case 440:
343 //J/psi_di0 -- return J/psi
344 return 443;
345 case 2110:
346 //n_diffr -- return neutron
347 return 2112;
348 case 2210:
349 //p_diffr+ -- return proton
350 return 2212;
351 }
352 //non diffractive state -- return code unchanged
353 return pdgcode;
354}
3b945a60 355
36d770d9 356void AliGenMC::Boost()
3b945a60 357{
358//
359// Boost cms into LHC lab frame
360//
361
36d770d9 362 Double_t beta = TMath::TanH(fDyBoost);
3b945a60 363 Double_t gamma = 1./TMath::Sqrt(1.-beta*beta);
364 Double_t gb = gamma * beta;
365
7cdba479 366 // printf("\n Boosting particles to lab frame %f %f %f", fDyBoost, beta, gamma);
3b945a60 367
368 Int_t i;
369 Int_t np = fParticles->GetEntriesFast();
370 for (i = 0; i < np; i++)
371 {
372 TParticle* iparticle = (TParticle*) fParticles->At(i);
373
374 Double_t e = iparticle->Energy();
375 Double_t px = iparticle->Px();
376 Double_t py = iparticle->Py();
377 Double_t pz = iparticle->Pz();
378
379 Double_t eb = gamma * e - gb * pz;
380 Double_t pzb = -gb * e + gamma * pz;
381
382 iparticle->SetMomentum(px, py, pzb, eb);
383 }
384}
385
386
e36044d6 387
388AliGenMC& AliGenMC::operator=(const AliGenMC& rhs)
389{
390// Assignment operator
391 return *this;
392}
393