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