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 Revision 1.5 2003/01/07 09:03:52 alibrary
19 New TrackMomentum and Position without LorentzVectors
21 Revision 1.4 2002/11/21 22:38:47 alibrary
22 Removing AliMC and AliMCProcess
24 Revision 1.3 2002/10/14 14:57:44 hristov
25 Merging the VirtualMC branch to the main development branch (HEAD)
27 Revision 1.1.8.1 2002/07/24 10:09:31 alibrary
30 Revision 1.2 2002/06/12 09:54:35 cblume
31 Update of tracking code provided by Sergei
33 Revision 1.1 2001/11/06 17:19:41 cblume
34 Add detailed geometry and simple simulator
38 ///////////////////////////////////////////////////////////////////////////////
40 // Simple TRD Monte Carlo class //
42 ///////////////////////////////////////////////////////////////////////////////
46 #include <TLorentzVector.h>
50 #include "AliTRDsimpleMC.h"
51 #include "AliTRDgeometry.h"
53 #include "AliTRDparameter.h"
55 ClassImp(AliTRDsimpleMC)
57 //_____________________________________________________________________________
58 AliTRDsimpleMC::AliTRDsimpleMC()
61 // AliTRDsimpleMC default constructor
79 fTrackEntering = kFALSE;
86 //_____________________________________________________________________________
87 AliTRDsimpleMC::AliTRDsimpleMC(const char *name, const char *title)
88 :TVirtualMC(name,title)
91 // AliTRDsimpleMC default constructor
109 fTrackEntering = kFALSE;
116 //_____________________________________________________________________________
117 AliTRDsimpleMC::AliTRDsimpleMC(const AliTRDsimpleMC &m)
120 // AliTRDsimpleMC copy constructor
123 ((AliTRDsimpleMC &) m).Copy(*this);
127 //_____________________________________________________________________________
128 AliTRDsimpleMC::~AliTRDsimpleMC()
131 // AliTRDsimpleMC destructor
136 //_____________________________________________________________________________
137 AliTRDsimpleMC &AliTRDsimpleMC::operator=(const AliTRDsimpleMC &m)
140 // Assignment operator
143 if (this != &m) ((AliTRDsimpleMC &) m).Copy(*this);
148 //_____________________________________________________________________________
149 void AliTRDsimpleMC::Copy(TObject &m)
155 ((AliTRDsimpleMC &) m).fMaxStep = fMaxStep;
156 ((AliTRDsimpleMC &) m).fNStep = fNStep;
157 ((AliTRDsimpleMC &) m).fTrack = fTrack;
158 ((AliTRDsimpleMC &) m).fTrackPx = fTrackPx;
159 ((AliTRDsimpleMC &) m).fTrackPy = fTrackPy;
160 ((AliTRDsimpleMC &) m).fTrackPz = fTrackPz;
161 ((AliTRDsimpleMC &) m).fTrackPtot = fTrackPtot;
162 ((AliTRDsimpleMC &) m).fTrackEtot = fTrackEtot;
163 ((AliTRDsimpleMC &) m).fTrackX = fTrackX;
164 ((AliTRDsimpleMC &) m).fTrackY = fTrackY;
165 ((AliTRDsimpleMC &) m).fTrackZ = fTrackZ;
166 ((AliTRDsimpleMC &) m).fTrackStep = fTrackStep;
167 ((AliTRDsimpleMC &) m).fTrackPid = fTrackPid;
168 ((AliTRDsimpleMC &) m).fTrackCharge = fTrackCharge;
169 ((AliTRDsimpleMC &) m).fTrackMass = fTrackMass;
170 ((AliTRDsimpleMC &) m).fTrackEntering = fTrackEntering;
174 //_____________________________________________________________________________
175 void AliTRDsimpleMC::NewTrack(Int_t iTrack, Int_t pdg
176 , Double_t px, Double_t py, Double_t pz)
179 // Starts a new track.
183 fPar = new AliTRDparameter("TRDparameter","Standard TRD parameter");
187 fTRD = (AliTRDv1 *) gAlice->GetDetector("TRD");
188 fX0 = fPar->GetTime0(0) - AliTRDgeometry::DrThick();
198 fTrackEntering = kTRUE;
202 fTrackMass = 5.11e-4;
206 fTrackMass = 0.13957;
210 printf("<AliTRDsimpleMC::NewTrack> PDG code %d not implemented\n",pdg);
214 Double_t pTot2 = px*px + py*py + pz*pz;
215 fTrackPtot = TMath::Sqrt(pTot2);
216 fTrackEtot = TMath::Sqrt(pTot2 + fTrackMass*fTrackMass);
225 gAlice->SetCurrentTrack(0);
229 //_____________________________________________________________________________
230 void AliTRDsimpleMC::ProcessEvent()
233 // Process one single track:
234 // - Determines the step size.
235 // - Calculates the track position
236 // - Calls TRD step manager.
239 // The stepsize from an exponential distribution
240 fTrackStep = gRandom->Exp(fMaxStep);
242 if ((fTrackEntering) && (fNStep > 0)) {
243 fTrackEntering = kFALSE;
247 // New track position
248 Double_t d = fTrackStep / fTrackPtot;
249 fTrackX += fTrackPx * d;
250 fTrackY += fTrackPy * d;
251 fTrackZ += fTrackPz * d;
253 // Call the TRD step manager
258 //_____________________________________________________________________________
259 void AliTRDsimpleMC::TrackPosition(TLorentzVector& position) const
265 position[0] = fTrackX;
266 position[1] = fTrackY;
267 position[2] = fTrackZ;
271 //_____________________________________________________________________________
272 void AliTRDsimpleMC::TrackPosition(Double_t &x, Double_t &y, Double_t &z) const
284 //_____________________________________________________________________________
285 void AliTRDsimpleMC::TrackMomentum(TLorentzVector& momentum) const
291 momentum[0] = fTrackPx;
292 momentum[1] = fTrackPy;
293 momentum[2] = fTrackPz;
294 momentum[3] = fTrackEtot;
298 //_____________________________________________________________________________
299 void AliTRDsimpleMC::TrackMomentum(Double_t &px, Double_t &py, Double_t &pz, Double_t &etot) const
312 //_____________________________________________________________________________
313 Int_t AliTRDsimpleMC::VolId(const Text_t* volName) const
316 // Returns the volume IDs:
318 // 2 = amplification region
319 // 3 = drift chambers
324 if (strcmp(volName,"UJ00") == 0) {
327 else if (strcmp(volName,"UK00") == 0) {
330 else if (strcmp(volName,"UC00") == 0) {
338 //_____________________________________________________________________________
339 Int_t AliTRDsimpleMC::CurrentVolID(Int_t& copyNo) const
342 // Check for the current volume
350 if ((fTrackX-fX0) < AliTRDgeometry::DrThick()) {
353 else if ((fTrackX-fX0) < (AliTRDgeometry::DrThick() +
354 AliTRDgeometry::AmThick())) {
362 //_____________________________________________________________________________
363 const char *AliTRDsimpleMC::CurrentVolName() const
366 // Check for the current volume
369 Char_t *volName = "UA00";
372 if ((fTrackX-fX0) < AliTRDgeometry::DrThick()) {
375 else if ((fTrackX-fX0) < (AliTRDgeometry::DrThick() +
376 AliTRDgeometry::AmThick())) {
384 //_____________________________________________________________________________
385 Int_t AliTRDsimpleMC::CurrentVolOffID(Int_t off, Int_t ©No) const
388 // Check for the current volume