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