1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////////
20 // Simple TRD Monte Carlo class //
22 ///////////////////////////////////////////////////////////////////////////////
26 #include <TLorentzVector.h>
29 #include "AliTRDgeometry.h"
30 #include "AliTRDparameter.h"
31 #include "AliTRDsimpleMC.h"
33 #include "AliTRDparameter.h"
36 ClassImp(AliTRDsimpleMC)
38 //_____________________________________________________________________________
39 AliTRDsimpleMC::AliTRDsimpleMC()
42 // AliTRDsimpleMC default constructor
60 fTrackEntering = kFALSE;
67 //_____________________________________________________________________________
68 AliTRDsimpleMC::AliTRDsimpleMC(const char *name, const char *title)
69 :TVirtualMC(name,title,kFALSE)
72 // AliTRDsimpleMC default constructor
90 fTrackEntering = kFALSE;
97 //_____________________________________________________________________________
98 AliTRDsimpleMC::AliTRDsimpleMC(const AliTRDsimpleMC &m):TVirtualMC(m)
101 // AliTRDsimpleMC copy constructor
104 ((AliTRDsimpleMC &) m).Copy(*this);
108 //_____________________________________________________________________________
109 AliTRDsimpleMC::~AliTRDsimpleMC()
112 // AliTRDsimpleMC destructor
117 //_____________________________________________________________________________
118 AliTRDsimpleMC &AliTRDsimpleMC::operator=(const AliTRDsimpleMC &m)
121 // Assignment operator
124 if (this != &m) ((AliTRDsimpleMC &) m).Copy(*this);
129 //_____________________________________________________________________________
130 void AliTRDsimpleMC::Copy(TObject &m)
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;
155 //_____________________________________________________________________________
156 void AliTRDsimpleMC::NewTrack(Int_t iTrack, Int_t pdg
157 , Double_t px, Double_t py, Double_t pz)
160 // Starts a new track.
164 fPar = new AliTRDparameter("TRDparameter","Standard TRD parameter");
168 fTRD = (AliTRDv1 *) gAlice->GetDetector("TRD");
169 fX0 = fPar->GetTime0(0) - AliTRDgeometry::DrThick();
179 fTrackEntering = kTRUE;
183 fTrackMass = 5.11e-4;
187 fTrackMass = 0.13957;
191 printf("<AliTRDsimpleMC::NewTrack> PDG code %d not implemented\n",pdg);
195 Double_t pTot2 = px*px + py*py + pz*pz;
196 fTrackPtot = TMath::Sqrt(pTot2);
197 fTrackEtot = TMath::Sqrt(pTot2 + fTrackMass*fTrackMass);
206 gAlice->GetMCApp()->SetCurrentTrack(0);
210 //_____________________________________________________________________________
211 void AliTRDsimpleMC::ProcessEvent()
214 // Process one single track:
215 // - Determines the step size.
216 // - Calculates the track position
217 // - Calls TRD step manager.
220 // The stepsize from an exponential distribution
221 fTrackStep = gRandom->Exp(fMaxStep);
223 if ((fTrackEntering) && (fNStep > 0)) {
224 fTrackEntering = kFALSE;
228 // New track position
229 Double_t d = fTrackStep / fTrackPtot;
230 fTrackX += fTrackPx * d;
231 fTrackY += fTrackPy * d;
232 fTrackZ += fTrackPz * d;
234 // Call the TRD step manager
239 //_____________________________________________________________________________
240 void AliTRDsimpleMC::TrackPosition(TLorentzVector& position) const
246 position[0] = fTrackX;
247 position[1] = fTrackY;
248 position[2] = fTrackZ;
252 //_____________________________________________________________________________
253 void AliTRDsimpleMC::TrackPosition(Double_t &x, Double_t &y, Double_t &z) const
265 //_____________________________________________________________________________
266 void AliTRDsimpleMC::TrackMomentum(TLorentzVector& momentum) const
272 momentum[0] = fTrackPx;
273 momentum[1] = fTrackPy;
274 momentum[2] = fTrackPz;
275 momentum[3] = fTrackEtot;
279 //_____________________________________________________________________________
280 void AliTRDsimpleMC::TrackMomentum(Double_t &px, Double_t &py,
281 Double_t &pz, Double_t &et) const
294 //_____________________________________________________________________________
295 Int_t AliTRDsimpleMC::VolId(const Text_t* volName) const
298 // Returns the volume IDs:
300 // 2 = amplification region
301 // 3 = drift chambers
306 if (strcmp(volName,"UJ00") == 0) {
309 else if (strcmp(volName,"UK00") == 0) {
312 else if (strcmp(volName,"UC00") == 0) {
320 //_____________________________________________________________________________
321 Int_t AliTRDsimpleMC::CurrentVolID(Int_t& copyNo) const
324 // Check for the current volume
332 if ((fTrackX-fX0) < AliTRDgeometry::DrThick()) {
335 else if ((fTrackX-fX0) < (AliTRDgeometry::DrThick() +
336 AliTRDgeometry::AmThick())) {
344 //_____________________________________________________________________________
345 const char *AliTRDsimpleMC::CurrentVolName() const
348 // Check for the current volume
351 const char *volName = "UA00";
354 if ((fTrackX-fX0) < AliTRDgeometry::DrThick()) {
357 else if ((fTrackX-fX0) < (AliTRDgeometry::DrThick() +
358 AliTRDgeometry::AmThick())) {
366 //_____________________________________________________________________________
367 Int_t AliTRDsimpleMC::CurrentVolOffID(Int_t , Int_t ©No) const
370 // Check for the current volume