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$ |
65de9f86 |
18 | Revision 1.8 2002/04/26 10:42:35 morsch |
19 | Case kNoDecayHeavy added. (N. Carrer) |
20 | |
d5f86442 |
21 | Revision 1.7 2002/04/17 10:32:32 morsch |
22 | Coding Rule violations corrected. |
23 | |
62d0ae06 |
24 | Revision 1.6 2002/03/26 14:19:36 morsch |
25 | Saver calculation of rapdity. |
26 | |
fef61e14 |
27 | Revision 1.5 2002/03/12 17:02:20 morsch |
28 | Change in calculation of rapidity, include case in which numerically e == pz. |
29 | |
95450c6d |
30 | Revision 1.4 2001/11/27 13:13:07 morsch |
31 | Maximum lifetime for long-lived particles to be put on the stack is parameter. |
32 | It can be set via SetMaximumLifetime(..). |
33 | |
47fc6bd5 |
34 | Revision 1.3 2001/10/16 08:48:56 morsch |
35 | Common vertex related code moved to base class AliGenerator. |
36 | |
b80a8e41 |
37 | Revision 1.2 2001/10/15 08:15:51 morsch |
38 | Event vertex and vertex truncation setting moved into AliMC. |
39 | |
dba8ac91 |
40 | Revision 1.1 2001/07/13 10:56:00 morsch |
41 | AliGenMC base class for AliGenParam and AliGenPythia commonalities. |
42 | |
e36044d6 |
43 | */ |
44 | |
62d0ae06 |
45 | // Base class for generators using external MC generators. |
46 | // For example AliGenPythia using Pythia. |
47 | // Provides basic functionality: setting of kinematic cuts on |
48 | // decay products and particle selection. |
49 | // andreas.morsch@cern.ch |
50 | |
e36044d6 |
51 | #include "AliGenMC.h" |
52 | #include "AliPDG.h" |
65de9f86 |
53 | #include <TMath.h> |
e36044d6 |
54 | #include <TParticle.h> |
55 | |
56 | ClassImp(AliGenMC) |
57 | |
58 | AliGenMC::AliGenMC() |
59 | :AliGenerator() |
60 | { |
61 | // Default Constructor |
62 | SetCutOnChild(); |
63 | SetChildMomentumRange(); |
64 | SetChildPtRange(); |
65 | SetChildPhiRange(); |
66 | SetChildThetaRange(); |
67 | SetChildYRange(); |
47fc6bd5 |
68 | SetMaximumLifetime(); |
65de9f86 |
69 | SetGeometryAcceptance(); |
70 | SetPdgCodeParticleforAcceptanceCut(); |
71 | SetNumberOfAcceptedParticles(); |
e36044d6 |
72 | } |
73 | |
74 | AliGenMC::AliGenMC(Int_t npart) |
75 | :AliGenerator(npart) |
76 | { |
77 | // Constructor |
78 | SetCutOnChild(); |
79 | SetChildMomentumRange(); |
80 | SetChildPtRange(); |
81 | SetChildPhiRange(); |
82 | SetChildThetaRange(); |
83 | SetChildYRange(); |
84 | // |
85 | fParentSelect.Set(8); |
86 | fChildSelect.Set(8); |
87 | for (Int_t i=0; i<8; i++) fParentSelect[i]=fChildSelect[i]=0; |
47fc6bd5 |
88 | SetMaximumLifetime(); |
65de9f86 |
89 | SetGeometryAcceptance(); |
90 | SetPdgCodeParticleforAcceptanceCut(); |
91 | SetNumberOfAcceptedParticles(); |
e36044d6 |
92 | } |
93 | |
94 | AliGenMC::AliGenMC(const AliGenMC & mc) |
95 | { |
96 | // copy constructor |
97 | } |
98 | |
99 | AliGenMC::~AliGenMC() |
100 | { |
101 | // Destructor |
102 | } |
103 | |
104 | void AliGenMC::Init() |
105 | { |
106 | // |
107 | // Initialization |
108 | switch (fForceDecay) { |
109 | case kSemiElectronic: |
110 | case kDiElectron: |
111 | case kBJpsiDiElectron: |
112 | case kBPsiPrimeDiElectron: |
47fc6bd5 |
113 | fChildSelect[0] = kElectron; |
e36044d6 |
114 | break; |
115 | case kSemiMuonic: |
116 | case kDiMuon: |
117 | case kBJpsiDiMuon: |
118 | case kBPsiPrimeDiMuon: |
119 | case kPiToMu: |
120 | case kKaToMu: |
121 | fChildSelect[0]=kMuonMinus; |
122 | break; |
123 | case kHadronicD: |
124 | fChildSelect[0]=kPiPlus; |
125 | fChildSelect[1]=kKPlus; |
126 | break; |
62d0ae06 |
127 | case kOmega: |
e36044d6 |
128 | case kAll: |
129 | case kNoDecay: |
d5f86442 |
130 | case kNoDecayHeavy: |
e36044d6 |
131 | break; |
132 | } |
133 | } |
134 | |
135 | |
62d0ae06 |
136 | Bool_t AliGenMC::ParentSelected(Int_t ip) const |
e36044d6 |
137 | { |
138 | // True if particle is in list of parent particles to be selected |
139 | for (Int_t i=0; i<8; i++) |
140 | { |
62d0ae06 |
141 | if (fParentSelect.At(i) == ip) return kTRUE; |
e36044d6 |
142 | } |
143 | return kFALSE; |
144 | } |
145 | |
62d0ae06 |
146 | Bool_t AliGenMC::ChildSelected(Int_t ip) const |
e36044d6 |
147 | { |
148 | // True if particle is in list of decay products to be selected |
149 | for (Int_t i=0; i<5; i++) |
150 | { |
62d0ae06 |
151 | if (fChildSelect.At(i) == ip) return kTRUE; |
e36044d6 |
152 | } |
153 | return kFALSE; |
154 | } |
155 | |
62d0ae06 |
156 | Bool_t AliGenMC::KinematicSelection(TParticle *particle, Int_t flag) const |
e36044d6 |
157 | { |
158 | // Perform kinematic selection |
159 | Float_t px = particle->Px(); |
160 | Float_t py = particle->Py(); |
161 | Float_t pz = particle->Pz(); |
162 | Float_t e = particle->Energy(); |
163 | Float_t pt = particle->Pt(); |
164 | Float_t p = particle->P(); |
165 | Float_t theta = particle->Theta(); |
95450c6d |
166 | Float_t mass = particle->GetMass(); |
167 | Float_t mt2 = pt * pt + mass * mass; |
168 | |
e36044d6 |
169 | Float_t phi = Float_t(TMath::ATan2(Double_t(py),Double_t(px))); |
95450c6d |
170 | Double_t y, y0; |
171 | |
fef61e14 |
172 | if (TMath::Abs(pz) < e) { |
95450c6d |
173 | y = 0.5*TMath::Log((e+pz)/(e-pz)); |
174 | } else { |
175 | y = 1.e10; |
176 | } |
e36044d6 |
177 | |
95450c6d |
178 | if (mt2) { |
179 | y0 = 0.5*TMath::Log((e+TMath::Abs(pz))*(e+TMath::Abs(pz))/mt2); |
e36044d6 |
180 | } else { |
95450c6d |
181 | if (TMath::Abs(y) < 1.e10) { |
182 | y0 = y; |
183 | } else { |
184 | y0 = 1.e10; |
185 | } |
e36044d6 |
186 | } |
95450c6d |
187 | |
188 | y = (pz < 0) ? -y0 : y0; |
e36044d6 |
189 | |
190 | if (flag == 0) { |
191 | // |
192 | // Primary particle cuts |
193 | // |
194 | // transverse momentum cut |
195 | if (pt > fPtMax || pt < fPtMin) { |
196 | // printf("\n failed pt cut %f %f %f \n",pt,fPtMin,fPtMax); |
197 | return kFALSE; |
198 | } |
199 | // |
200 | // momentum cut |
201 | if (p > fPMax || p < fPMin) { |
202 | // printf("\n failed p cut %f %f %f \n",p,fPMin,fPMax); |
203 | return kFALSE; |
204 | } |
205 | // |
206 | // theta cut |
207 | if (theta > fThetaMax || theta < fThetaMin) { |
208 | // printf("\n failed theta cut %f %f %f \n",theta,fThetaMin,fThetaMax); |
209 | return kFALSE; |
210 | } |
211 | // |
212 | // rapidity cut |
213 | if (y > fYMax || y < fYMin) { |
214 | // printf("\n failed y cut %f %f %f \n",y,fYMin,fYMax); |
215 | return kFALSE; |
216 | } |
217 | // |
218 | // phi cut |
219 | if (phi > fPhiMax || phi < fPhiMin) { |
220 | // printf("\n failed phi cut %f %f %f \n",phi,fPhiMin,fPhiMax); |
221 | return kFALSE; |
222 | } |
223 | } else { |
224 | // |
225 | // Decay product cuts |
226 | // |
227 | // transverse momentum cut |
228 | if (pt > fChildPtMax || pt < fChildPtMin) { |
229 | // printf("\n failed pt cut %f %f %f \n",pt,fChildPtMin,fChildPtMax); |
230 | return kFALSE; |
231 | } |
232 | // |
233 | // momentum cut |
234 | if (p > fChildPMax || p < fChildPMin) { |
235 | // printf("\n failed p cut %f %f %f \n",p,fChildPMin,fChildPMax); |
236 | return kFALSE; |
237 | } |
238 | // |
239 | // theta cut |
240 | if (theta > fChildThetaMax || theta < fChildThetaMin) { |
241 | // printf("\n failed theta cut %f %f %f \n",theta,fChildThetaMin,fChildThetaMax); |
242 | return kFALSE; |
243 | } |
244 | // |
245 | // rapidity cut |
246 | if (y > fChildYMax || y < fChildYMin) { |
247 | // printf("\n failed y cut %f %f %f \n",y,fChildYMin,fChildYMax); |
248 | return kFALSE; |
249 | } |
250 | // |
251 | // phi cut |
252 | if (phi > fChildPhiMax || phi < fChildPhiMin) { |
253 | // printf("\n failed phi cut %f %f %f \n",phi,fChildPhiMin,fChildPhiMax); |
254 | return kFALSE; |
255 | } |
256 | } |
257 | |
e36044d6 |
258 | return kTRUE; |
259 | } |
260 | |
65de9f86 |
261 | Bool_t AliGenMC::CheckAcceptanceGeometry(Int_t np, TClonesArray* particles) |
262 | { |
263 | Bool_t Check ; // All fPdgCodeParticleforAcceptanceCut particles are in in the fGeometryAcceptance acceptance |
264 | Int_t NumberOfPdgCodeParticleforAcceptanceCut=0; |
265 | Int_t NumberOfAcceptedPdgCodeParticleforAcceptanceCut=0; |
266 | TParticle * particle; |
267 | Int_t i; |
268 | for (i=0; i<np; i++) { |
269 | particle = (TParticle *) particles->At(i); |
270 | if( TMath::Abs( particle->GetPdgCode() ) == TMath::Abs( fPdgCodeParticleforAcceptanceCut ) ) { |
271 | NumberOfPdgCodeParticleforAcceptanceCut++; |
272 | if (fGeometryAcceptance->Impact(particle)) NumberOfAcceptedPdgCodeParticleforAcceptanceCut++; |
273 | } |
274 | } |
275 | if ( NumberOfAcceptedPdgCodeParticleforAcceptanceCut > (fNumberOfAcceptedParticles-1) ) |
276 | Check = kTRUE; |
277 | else |
278 | Check = kFALSE; |
279 | |
280 | return Check; |
281 | } |
282 | |
62d0ae06 |
283 | Int_t AliGenMC::CheckPDGCode(Int_t pdgcode) const |
e36044d6 |
284 | { |
285 | // |
286 | // If the particle is in a diffractive state, then take action accordingly |
287 | switch (pdgcode) { |
288 | case 91: |
289 | return 92; |
290 | case 110: |
291 | //rho_diff0 -- difficult to translate, return rho0 |
292 | return 113; |
293 | case 210: |
294 | //pi_diffr+ -- change to pi+ |
295 | return 211; |
296 | case 220: |
297 | //omega_di0 -- change to omega0 |
298 | return 223; |
299 | case 330: |
300 | //phi_diff0 -- return phi0 |
301 | return 333; |
302 | case 440: |
303 | //J/psi_di0 -- return J/psi |
304 | return 443; |
305 | case 2110: |
306 | //n_diffr -- return neutron |
307 | return 2112; |
308 | case 2210: |
309 | //p_diffr+ -- return proton |
310 | return 2212; |
311 | } |
312 | //non diffractive state -- return code unchanged |
313 | return pdgcode; |
314 | } |
315 | |
316 | AliGenMC& AliGenMC::operator=(const AliGenMC& rhs) |
317 | { |
318 | // Assignment operator |
319 | return *this; |
320 | } |
321 | |