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