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 "AliTRDsimpleMC.h"
34 ClassImp(AliTRDsimpleMC)
36 //_____________________________________________________________________________
37 AliTRDsimpleMC::AliTRDsimpleMC()
40 // AliTRDsimpleMC default constructor
58 fTrackEntering = kFALSE;
64 //_____________________________________________________________________________
65 AliTRDsimpleMC::AliTRDsimpleMC(const char *name, const char *title)
66 :TVirtualMC(name,title,kFALSE)
69 // AliTRDsimpleMC default constructor
87 fTrackEntering = kFALSE;
93 //_____________________________________________________________________________
94 AliTRDsimpleMC::AliTRDsimpleMC(const AliTRDsimpleMC &m):TVirtualMC(m)
97 // AliTRDsimpleMC copy constructor
100 ((AliTRDsimpleMC &) m).Copy(*this);
104 //_____________________________________________________________________________
105 AliTRDsimpleMC::~AliTRDsimpleMC()
108 // AliTRDsimpleMC destructor
113 //_____________________________________________________________________________
114 AliTRDsimpleMC &AliTRDsimpleMC::operator=(const AliTRDsimpleMC &m)
117 // Assignment operator
120 if (this != &m) ((AliTRDsimpleMC &) m).Copy(*this);
125 //_____________________________________________________________________________
126 void AliTRDsimpleMC::Copy(TObject &m) const
132 ((AliTRDsimpleMC &) m).fMaxStep = fMaxStep;
133 ((AliTRDsimpleMC &) m).fNStep = fNStep;
134 ((AliTRDsimpleMC &) m).fTrack = fTrack;
135 ((AliTRDsimpleMC &) m).fTrackPx = fTrackPx;
136 ((AliTRDsimpleMC &) m).fTrackPy = fTrackPy;
137 ((AliTRDsimpleMC &) m).fTrackPz = fTrackPz;
138 ((AliTRDsimpleMC &) m).fTrackPtot = fTrackPtot;
139 ((AliTRDsimpleMC &) m).fTrackEtot = fTrackEtot;
140 ((AliTRDsimpleMC &) m).fTrackX = fTrackX;
141 ((AliTRDsimpleMC &) m).fTrackY = fTrackY;
142 ((AliTRDsimpleMC &) m).fTrackZ = fTrackZ;
143 ((AliTRDsimpleMC &) m).fTrackStep = fTrackStep;
144 ((AliTRDsimpleMC &) m).fTrackPid = fTrackPid;
145 ((AliTRDsimpleMC &) m).fTrackCharge = fTrackCharge;
146 ((AliTRDsimpleMC &) m).fTrackMass = fTrackMass;
147 ((AliTRDsimpleMC &) m).fTrackEntering = fTrackEntering;
151 //_____________________________________________________________________________
152 void AliTRDsimpleMC::NewTrack(Int_t iTrack, Int_t pdg
153 , Double_t px, Double_t py, Double_t pz)
156 // Starts a new track.
160 fTRD = (AliTRDv1 *) gAlice->GetDetector("TRD");
161 fX0 = AliTRDgeometry::GetTime0(0) - AliTRDgeometry::DrThick();
171 fTrackEntering = kTRUE;
175 fTrackMass = 5.11e-4;
179 fTrackMass = 0.13957;
183 printf("<AliTRDsimpleMC::NewTrack> PDG code %d not implemented\n",pdg);
187 Double_t pTot2 = px*px + py*py + pz*pz;
188 fTrackPtot = TMath::Sqrt(pTot2);
189 fTrackEtot = TMath::Sqrt(pTot2 + fTrackMass*fTrackMass);
198 gAlice->GetMCApp()->SetCurrentTrack(0);
202 //_____________________________________________________________________________
203 void AliTRDsimpleMC::ProcessEvent()
206 // Process one single track:
207 // - Determines the step size.
208 // - Calculates the track position
209 // - Calls TRD step manager.
212 // The stepsize from an exponential distribution
213 fTrackStep = gRandom->Exp(fMaxStep);
215 if ((fTrackEntering) && (fNStep > 0)) {
216 fTrackEntering = kFALSE;
220 // New track position
221 Double_t d = fTrackStep / fTrackPtot;
222 fTrackX += fTrackPx * d;
223 fTrackY += fTrackPy * d;
224 fTrackZ += fTrackPz * d;
226 // Call the TRD step manager
231 //_____________________________________________________________________________
232 void AliTRDsimpleMC::TrackPosition(TLorentzVector& position) const
238 position[0] = fTrackX;
239 position[1] = fTrackY;
240 position[2] = fTrackZ;
244 //_____________________________________________________________________________
245 void AliTRDsimpleMC::TrackPosition(Double_t &x, Double_t &y, Double_t &z) const
257 //_____________________________________________________________________________
258 void AliTRDsimpleMC::TrackMomentum(TLorentzVector& momentum) const
264 momentum[0] = fTrackPx;
265 momentum[1] = fTrackPy;
266 momentum[2] = fTrackPz;
267 momentum[3] = fTrackEtot;
271 //_____________________________________________________________________________
272 void AliTRDsimpleMC::TrackMomentum(Double_t &px, Double_t &py,
273 Double_t &pz, Double_t &et) const
286 //_____________________________________________________________________________
287 Int_t AliTRDsimpleMC::VolId(const Text_t* volName) const
290 // Returns the volume IDs:
292 // 2 = amplification region
293 // 3 = drift chambers
298 if (strcmp(volName,"UJ00") == 0) {
301 else if (strcmp(volName,"UK00") == 0) {
304 else if (strcmp(volName,"UC00") == 0) {
312 //_____________________________________________________________________________
313 Int_t AliTRDsimpleMC::CurrentVolID(Int_t& copyNo) const
316 // Check for the current volume
324 if ((fTrackX-fX0) < AliTRDgeometry::DrThick()) {
327 else if ((fTrackX-fX0) < (AliTRDgeometry::DrThick() +
328 AliTRDgeometry::AmThick())) {
336 //_____________________________________________________________________________
337 const char *AliTRDsimpleMC::CurrentVolName() const
340 // Check for the current volume
343 const char *volName = "UA00";
346 if ((fTrackX-fX0) < AliTRDgeometry::DrThick()) {
349 else if ((fTrackX-fX0) < (AliTRDgeometry::DrThick() +
350 AliTRDgeometry::AmThick())) {
358 //_____________________________________________________________________________
359 Int_t AliTRDsimpleMC::CurrentVolOffID(Int_t , Int_t ©No) const
362 // Check for the current volume