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