]>
Commit | Line | Data |
---|---|---|
16bf9884 | 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$ | |
18 | */ | |
19 | ||
20 | /////////////////////////////////////////////////////////////////////////////// | |
21 | // // | |
22 | // Simple TRD Monte Carlo class // | |
23 | // // | |
24 | /////////////////////////////////////////////////////////////////////////////// | |
25 | ||
26 | #include <stdlib.h> | |
27 | ||
28 | #include <TLorentzVector.h> | |
29 | ||
30 | #include "AliRun.h" | |
31 | ||
32 | #include "AliTRDsimpleMC.h" | |
33 | #include "AliTRDgeometry.h" | |
34 | #include "AliTRDv1.h" | |
35 | ||
36 | ClassImp(AliTRDsimpleMC) | |
37 | ||
38 | //_____________________________________________________________________________ | |
39 | AliTRDsimpleMC::AliTRDsimpleMC():AliMC() | |
40 | { | |
41 | // | |
42 | // AliTRDsimpleMC default constructor | |
43 | // | |
44 | ||
45 | fMaxStep = 0.0; | |
46 | fNStep = 0; | |
47 | fTrack = 0; | |
48 | fTrackPx = 0.0; | |
49 | fTrackPy = 0.0; | |
50 | fTrackPz = 0.0; | |
51 | fTrackPtot = 0.0; | |
52 | fTrackEtot = 0.0; | |
53 | fTrackX = 0.0; | |
54 | fTrackY = 0.0; | |
55 | fTrackZ = 0.0; | |
56 | fTrackStep = 0.0; | |
57 | fTrackPid = 0; | |
58 | fTrackCharge = 0.0; | |
59 | fTrackMass = 0.0; | |
60 | fTrackEntering = kFALSE; | |
61 | ||
62 | fTRD = NULL; | |
63 | ||
64 | } | |
65 | ||
66 | //_____________________________________________________________________________ | |
67 | AliTRDsimpleMC::AliTRDsimpleMC(const char *name, const char *title) | |
68 | :AliMC(name,title) | |
69 | { | |
70 | // | |
71 | // AliTRDsimpleMC default constructor | |
72 | // | |
73 | ||
74 | fMaxStep = 0.0; | |
75 | fNStep = 0; | |
76 | fTrack = 0; | |
77 | fTrackPx = 0.0; | |
78 | fTrackPy = 0.0; | |
79 | fTrackPz = 0.0; | |
80 | fTrackPtot = 0.0; | |
81 | fTrackEtot = 0.0; | |
82 | fTrackX = 0.0; | |
83 | fTrackY = 0.0; | |
84 | fTrackZ = 0.0; | |
85 | fTrackStep = 0.0; | |
86 | fTrackPid = 0; | |
87 | fTrackCharge = 0.0; | |
88 | fTrackMass = 0.0; | |
89 | fTrackEntering = kFALSE; | |
90 | ||
91 | fTRD = NULL; | |
92 | ||
93 | } | |
94 | ||
95 | //_____________________________________________________________________________ | |
96 | AliTRDsimpleMC::AliTRDsimpleMC(const AliTRDsimpleMC &m) | |
97 | { | |
98 | // | |
99 | // AliTRDsimpleMC copy constructor | |
100 | // | |
101 | ||
102 | ((AliTRDsimpleMC &) m).Copy(*this); | |
103 | ||
104 | } | |
105 | ||
106 | //_____________________________________________________________________________ | |
107 | AliTRDsimpleMC::~AliTRDsimpleMC() | |
108 | { | |
109 | // | |
110 | // AliTRDsimpleMC destructor | |
111 | // | |
112 | ||
113 | } | |
114 | ||
115 | //_____________________________________________________________________________ | |
116 | AliTRDsimpleMC &AliTRDsimpleMC::operator=(const AliTRDsimpleMC &m) | |
117 | { | |
118 | // | |
119 | // Assignment operator | |
120 | // | |
121 | ||
122 | if (this != &m) ((AliTRDsimpleMC &) m).Copy(*this); | |
123 | return *this; | |
124 | ||
125 | } | |
126 | ||
127 | //_____________________________________________________________________________ | |
128 | void AliTRDsimpleMC::Copy(TObject &m) | |
129 | { | |
130 | // | |
131 | // Copy function | |
132 | // | |
133 | ||
134 | ((AliTRDsimpleMC &) m).fMaxStep = fMaxStep; | |
135 | ((AliTRDsimpleMC &) m).fNStep = fNStep; | |
136 | ((AliTRDsimpleMC &) m).fTrack = fTrack; | |
137 | ((AliTRDsimpleMC &) m).fTrackPx = fTrackPx; | |
138 | ((AliTRDsimpleMC &) m).fTrackPy = fTrackPy; | |
139 | ((AliTRDsimpleMC &) m).fTrackPz = fTrackPz; | |
140 | ((AliTRDsimpleMC &) m).fTrackPtot = fTrackPtot; | |
141 | ((AliTRDsimpleMC &) m).fTrackEtot = fTrackEtot; | |
142 | ((AliTRDsimpleMC &) m).fTrackX = fTrackX; | |
143 | ((AliTRDsimpleMC &) m).fTrackY = fTrackY; | |
144 | ((AliTRDsimpleMC &) m).fTrackZ = fTrackZ; | |
145 | ((AliTRDsimpleMC &) m).fTrackStep = fTrackStep; | |
146 | ((AliTRDsimpleMC &) m).fTrackPid = fTrackPid; | |
147 | ((AliTRDsimpleMC &) m).fTrackCharge = fTrackCharge; | |
148 | ((AliTRDsimpleMC &) m).fTrackMass = fTrackMass; | |
149 | ((AliTRDsimpleMC &) m).fTrackEntering = fTrackEntering; | |
150 | ||
151 | } | |
152 | ||
153 | //_____________________________________________________________________________ | |
154 | void AliTRDsimpleMC::NewTrack(Int_t iTrack, Int_t pdg | |
155 | , Double_t px, Double_t py, Double_t pz) | |
156 | { | |
157 | // | |
158 | // Starts a new track. | |
159 | // | |
160 | ||
161 | if (!fTRD) { | |
162 | fTRD = (AliTRDv1 *) gAlice->GetDetector("TRD"); | |
163 | AliTRDgeometry *geometry = fTRD->GetGeometry(); | |
164 | fX0 = geometry->GetTime0(0) - AliTRDgeometry::DrThick(); | |
165 | } | |
166 | ||
167 | fTRD->ResetHits(); | |
168 | ||
169 | fTrack = iTrack; | |
170 | fMaxStep = 0.0; | |
171 | fNStep = 0; | |
172 | fTrackStep = 0.0; | |
173 | fTrackPid = pdg; | |
174 | fTrackEntering = kTRUE; | |
175 | ||
176 | switch (pdg) { | |
177 | case kPdgElectron: | |
178 | fTrackMass = 5.11e-4; | |
179 | fTrackCharge = -1.0; | |
180 | break; | |
181 | case kPdgPion: | |
182 | fTrackMass = 0.13957; | |
183 | fTrackCharge = 1.0; | |
184 | break; | |
185 | default: | |
186 | printf("<AliTRDsimpleMC::NewTrack> PDG code %d not implemented\n",pdg); | |
187 | break; | |
188 | }; | |
189 | ||
190 | Double_t pTot2 = px*px + py*py + pz*pz; | |
191 | fTrackPtot = TMath::Sqrt(pTot2); | |
192 | fTrackEtot = TMath::Sqrt(pTot2 + fTrackMass*fTrackMass); | |
193 | fTrackPx = px; | |
194 | fTrackPy = py; | |
195 | fTrackPz = pz; | |
196 | ||
197 | fTrackX = fX0; | |
198 | fTrackY = 0.0; | |
199 | fTrackZ = 0.0; | |
200 | ||
201 | gAlice->SetCurrentTrack(-1); | |
202 | ||
203 | } | |
204 | ||
205 | //_____________________________________________________________________________ | |
206 | void AliTRDsimpleMC::ProcessEvent() | |
207 | { | |
208 | // | |
209 | // Process one single track: | |
210 | // - Determines the step size. | |
211 | // - Calculates the track position | |
212 | // - Calls TRD step manager. | |
213 | // | |
214 | ||
215 | // The stepsize from an exponential distribution | |
216 | fTrackStep = gRandom->Exp(fMaxStep); | |
217 | ||
218 | if ((fTrackEntering) && (fNStep > 0)) { | |
219 | fTrackEntering = kFALSE; | |
220 | } | |
221 | fNStep++; | |
222 | ||
223 | // New track position | |
224 | Double_t d = fTrackStep / fTrackPtot; | |
225 | fTrackX += fTrackPx * d; | |
226 | fTrackY += fTrackPy * d; | |
227 | fTrackZ += fTrackPz * d; | |
228 | ||
229 | // Call the TRD step manager | |
230 | fTRD->StepManager(); | |
231 | ||
232 | } | |
233 | ||
234 | //_____________________________________________________________________________ | |
235 | void AliTRDsimpleMC::TrackPosition(TLorentzVector& position) const | |
236 | { | |
237 | // | |
238 | // Track Position | |
239 | // | |
240 | ||
241 | position[0] = fTrackX; | |
242 | position[1] = fTrackY; | |
243 | position[2] = fTrackZ; | |
244 | ||
245 | } | |
246 | ||
247 | //_____________________________________________________________________________ | |
248 | void AliTRDsimpleMC::TrackMomentum(TLorentzVector& momentum) const | |
249 | { | |
250 | // | |
251 | // Track Momentum | |
252 | // | |
253 | ||
254 | momentum[0] = fTrackPx; | |
255 | momentum[1] = fTrackPy; | |
256 | momentum[2] = fTrackPz; | |
257 | momentum[3] = fTrackEtot; | |
258 | ||
259 | } | |
260 | ||
261 | //_____________________________________________________________________________ | |
262 | Int_t AliTRDsimpleMC::VolId(const Text_t* volName) const | |
263 | { | |
264 | // | |
265 | // Returns the volume IDs: | |
266 | // 1 = drift region | |
267 | // 2 = amplification region | |
268 | // 3 = drift chambers | |
269 | // | |
270 | ||
271 | Int_t volId = -1; | |
272 | ||
273 | if (strcmp(volName,"UL05") == 0) { | |
274 | volId = kVolDrRg; | |
275 | } | |
276 | else if (strcmp(volName,"UL06") == 0) { | |
277 | volId = kVolAmRg; | |
278 | } | |
279 | else if (strcmp(volName,"UCII") == 0) { | |
280 | volId = kVolDrCh; | |
281 | } | |
282 | ||
283 | return volId; | |
284 | ||
285 | } | |
286 | ||
287 | //_____________________________________________________________________________ | |
288 | Int_t AliTRDsimpleMC::CurrentVolID(Int_t& copyNo) const | |
289 | { | |
290 | // | |
291 | // Check for the current volume | |
292 | // | |
293 | ||
294 | Int_t volId = -1; | |
295 | ||
296 | copyNo = 0; | |
297 | ||
298 | // Drift region | |
299 | if ((fTrackX-fX0) < AliTRDgeometry::DrThick()) { | |
300 | volId = kVolDrRg; | |
301 | } | |
302 | else if ((fTrackX-fX0) < (AliTRDgeometry::DrThick() + | |
303 | AliTRDgeometry::AmThick())) { | |
304 | volId = kVolAmRg; | |
305 | } | |
306 | ||
307 | return volId; | |
308 | ||
309 | } | |
310 | ||
311 | //_____________________________________________________________________________ | |
312 | Int_t AliTRDsimpleMC::CurrentVolOffID(Int_t off, Int_t ©No) const | |
313 | { | |
314 | // | |
315 | // Check for the current volume | |
316 | // | |
317 | ||
318 | copyNo = 1; | |
319 | return kVolDrCh; | |
320 | ||
321 | } |