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