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"
35 ClassImp(AliTRDsimpleMC)
37 //_____________________________________________________________________________
38 AliTRDsimpleMC::AliTRDsimpleMC()
41 // AliTRDsimpleMC default constructor
59 fTrackEntering = kFALSE;
66 //_____________________________________________________________________________
67 AliTRDsimpleMC::AliTRDsimpleMC(const char *name, const char *title)
68 :TVirtualMC(name,title,kFALSE)
71 // AliTRDsimpleMC default constructor
89 fTrackEntering = kFALSE;
96 //_____________________________________________________________________________
97 AliTRDsimpleMC::AliTRDsimpleMC(const AliTRDsimpleMC &m)
100 // AliTRDsimpleMC copy constructor
103 ((AliTRDsimpleMC &) m).Copy(*this);
107 //_____________________________________________________________________________
108 AliTRDsimpleMC::~AliTRDsimpleMC()
111 // AliTRDsimpleMC destructor
116 //_____________________________________________________________________________
117 AliTRDsimpleMC &AliTRDsimpleMC::operator=(const AliTRDsimpleMC &m)
120 // Assignment operator
123 if (this != &m) ((AliTRDsimpleMC &) m).Copy(*this);
128 //_____________________________________________________________________________
129 void AliTRDsimpleMC::Copy(TObject &m)
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;
154 //_____________________________________________________________________________
155 void AliTRDsimpleMC::NewTrack(Int_t iTrack, Int_t pdg
156 , Double_t px, Double_t py, Double_t pz)
159 // Starts a new track.
163 fPar = new AliTRDparameter("TRDparameter","Standard TRD parameter");
167 fTRD = (AliTRDv1 *) gAlice->GetDetector("TRD");
168 fX0 = fPar->GetTime0(0) - AliTRDgeometry::DrThick();
178 fTrackEntering = kTRUE;
182 fTrackMass = 5.11e-4;
186 fTrackMass = 0.13957;
190 printf("<AliTRDsimpleMC::NewTrack> PDG code %d not implemented\n",pdg);
194 Double_t pTot2 = px*px + py*py + pz*pz;
195 fTrackPtot = TMath::Sqrt(pTot2);
196 fTrackEtot = TMath::Sqrt(pTot2 + fTrackMass*fTrackMass);
205 gAlice->SetCurrentTrack(0);
209 //_____________________________________________________________________________
210 void AliTRDsimpleMC::ProcessEvent()
213 // Process one single track:
214 // - Determines the step size.
215 // - Calculates the track position
216 // - Calls TRD step manager.
219 // The stepsize from an exponential distribution
220 fTrackStep = gRandom->Exp(fMaxStep);
222 if ((fTrackEntering) && (fNStep > 0)) {
223 fTrackEntering = kFALSE;
227 // New track position
228 Double_t d = fTrackStep / fTrackPtot;
229 fTrackX += fTrackPx * d;
230 fTrackY += fTrackPy * d;
231 fTrackZ += fTrackPz * d;
233 // Call the TRD step manager
238 //_____________________________________________________________________________
239 void AliTRDsimpleMC::TrackPosition(TLorentzVector& position) const
245 position[0] = fTrackX;
246 position[1] = fTrackY;
247 position[2] = fTrackZ;
251 //_____________________________________________________________________________
252 void AliTRDsimpleMC::TrackPosition(Double_t &x, Double_t &y, Double_t &z) const
264 //_____________________________________________________________________________
265 void AliTRDsimpleMC::TrackMomentum(TLorentzVector& momentum) const
271 momentum[0] = fTrackPx;
272 momentum[1] = fTrackPy;
273 momentum[2] = fTrackPz;
274 momentum[3] = fTrackEtot;
278 //_____________________________________________________________________________
279 void AliTRDsimpleMC::TrackMomentum(Double_t &px, Double_t &py,
280 Double_t &pz, Double_t &et) const
293 //_____________________________________________________________________________
294 Int_t AliTRDsimpleMC::VolId(const Text_t* volName) const
297 // Returns the volume IDs:
299 // 2 = amplification region
300 // 3 = drift chambers
305 if (strcmp(volName,"UJ00") == 0) {
308 else if (strcmp(volName,"UK00") == 0) {
311 else if (strcmp(volName,"UC00") == 0) {
319 //_____________________________________________________________________________
320 Int_t AliTRDsimpleMC::CurrentVolID(Int_t& copyNo) const
323 // Check for the current volume
331 if ((fTrackX-fX0) < AliTRDgeometry::DrThick()) {
334 else if ((fTrackX-fX0) < (AliTRDgeometry::DrThick() +
335 AliTRDgeometry::AmThick())) {
343 //_____________________________________________________________________________
344 const char *AliTRDsimpleMC::CurrentVolName() const
347 // Check for the current volume
350 Char_t *volName = "UA00";
353 if ((fTrackX-fX0) < AliTRDgeometry::DrThick()) {
356 else if ((fTrackX-fX0) < (AliTRDgeometry::DrThick() +
357 AliTRDgeometry::AmThick())) {
365 //_____________________________________________________________________________
366 Int_t AliTRDsimpleMC::CurrentVolOffID(Int_t off, Int_t ©No) const
369 // Check for the current volume