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 **************************************************************************/
20 ///////////////////////////////////////////////////////////////////////////////
22 // Simple TRD Monte Carlo class //
24 ///////////////////////////////////////////////////////////////////////////////
28 #include <TLorentzVector.h>
32 #include "AliTRDsimpleMC.h"
33 #include "AliTRDgeometry.h"
36 ClassImp(AliTRDsimpleMC)
38 //_____________________________________________________________________________
39 AliTRDsimpleMC::AliTRDsimpleMC():AliMC()
42 // AliTRDsimpleMC default constructor
60 fTrackEntering = kFALSE;
66 //_____________________________________________________________________________
67 AliTRDsimpleMC::AliTRDsimpleMC(const char *name, const char *title)
71 // AliTRDsimpleMC default constructor
89 fTrackEntering = kFALSE;
95 //_____________________________________________________________________________
96 AliTRDsimpleMC::AliTRDsimpleMC(const AliTRDsimpleMC &m)
99 // AliTRDsimpleMC copy constructor
102 ((AliTRDsimpleMC &) m).Copy(*this);
106 //_____________________________________________________________________________
107 AliTRDsimpleMC::~AliTRDsimpleMC()
110 // AliTRDsimpleMC destructor
115 //_____________________________________________________________________________
116 AliTRDsimpleMC &AliTRDsimpleMC::operator=(const AliTRDsimpleMC &m)
119 // Assignment operator
122 if (this != &m) ((AliTRDsimpleMC &) m).Copy(*this);
127 //_____________________________________________________________________________
128 void AliTRDsimpleMC::Copy(TObject &m)
134 ((AliTRDsimpleMC &) m).fMaxStep = fMaxStep;
135 ((AliTRDsimpleMC &) m).fNStep = fNStep;
136 ((AliTRDsimpleMC &) m).fTrack = fTrack;
137 ((AliTRDsimpleMC &) m).fTrackPx = fTrackPx;
138 ((AliTRDsimpleMC &) m).fTrackPy = fTrackPy;
139 ((AliTRDsimpleMC &) m).fTrackPz = fTrackPz;
140 ((AliTRDsimpleMC &) m).fTrackPtot = fTrackPtot;
141 ((AliTRDsimpleMC &) m).fTrackEtot = fTrackEtot;
142 ((AliTRDsimpleMC &) m).fTrackX = fTrackX;
143 ((AliTRDsimpleMC &) m).fTrackY = fTrackY;
144 ((AliTRDsimpleMC &) m).fTrackZ = fTrackZ;
145 ((AliTRDsimpleMC &) m).fTrackStep = fTrackStep;
146 ((AliTRDsimpleMC &) m).fTrackPid = fTrackPid;
147 ((AliTRDsimpleMC &) m).fTrackCharge = fTrackCharge;
148 ((AliTRDsimpleMC &) m).fTrackMass = fTrackMass;
149 ((AliTRDsimpleMC &) m).fTrackEntering = fTrackEntering;
153 //_____________________________________________________________________________
154 void AliTRDsimpleMC::NewTrack(Int_t iTrack, Int_t pdg
155 , Double_t px, Double_t py, Double_t pz)
158 // Starts a new track.
162 fTRD = (AliTRDv1 *) gAlice->GetDetector("TRD");
163 AliTRDgeometry *geometry = fTRD->GetGeometry();
164 fX0 = geometry->GetTime0(0) - AliTRDgeometry::DrThick();
174 fTrackEntering = kTRUE;
178 fTrackMass = 5.11e-4;
182 fTrackMass = 0.13957;
186 printf("<AliTRDsimpleMC::NewTrack> PDG code %d not implemented\n",pdg);
190 Double_t pTot2 = px*px + py*py + pz*pz;
191 fTrackPtot = TMath::Sqrt(pTot2);
192 fTrackEtot = TMath::Sqrt(pTot2 + fTrackMass*fTrackMass);
201 gAlice->SetCurrentTrack(-1);
205 //_____________________________________________________________________________
206 void AliTRDsimpleMC::ProcessEvent()
209 // Process one single track:
210 // - Determines the step size.
211 // - Calculates the track position
212 // - Calls TRD step manager.
215 // The stepsize from an exponential distribution
216 fTrackStep = gRandom->Exp(fMaxStep);
218 if ((fTrackEntering) && (fNStep > 0)) {
219 fTrackEntering = kFALSE;
223 // New track position
224 Double_t d = fTrackStep / fTrackPtot;
225 fTrackX += fTrackPx * d;
226 fTrackY += fTrackPy * d;
227 fTrackZ += fTrackPz * d;
229 // Call the TRD step manager
234 //_____________________________________________________________________________
235 void AliTRDsimpleMC::TrackPosition(TLorentzVector& position) const
241 position[0] = fTrackX;
242 position[1] = fTrackY;
243 position[2] = fTrackZ;
247 //_____________________________________________________________________________
248 void AliTRDsimpleMC::TrackMomentum(TLorentzVector& momentum) const
254 momentum[0] = fTrackPx;
255 momentum[1] = fTrackPy;
256 momentum[2] = fTrackPz;
257 momentum[3] = fTrackEtot;
261 //_____________________________________________________________________________
262 Int_t AliTRDsimpleMC::VolId(const Text_t* volName) const
265 // Returns the volume IDs:
267 // 2 = amplification region
268 // 3 = drift chambers
273 if (strcmp(volName,"UL05") == 0) {
276 else if (strcmp(volName,"UL06") == 0) {
279 else if (strcmp(volName,"UCII") == 0) {
287 //_____________________________________________________________________________
288 Int_t AliTRDsimpleMC::CurrentVolID(Int_t& copyNo) const
291 // Check for the current volume
299 if ((fTrackX-fX0) < AliTRDgeometry::DrThick()) {
302 else if ((fTrackX-fX0) < (AliTRDgeometry::DrThick() +
303 AliTRDgeometry::AmThick())) {
311 //_____________________________________________________________________________
312 Int_t AliTRDsimpleMC::CurrentVolOffID(Int_t off, Int_t ©No) const
315 // Check for the current volume