]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDv0.cxx
Transition to NewIO
[u/mrichter/AliRoot.git] / TRD / AliTRDv0.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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  **************************************************************************/
15
16 /* $Id$ */
17
18 ///////////////////////////////////////////////////////////////////////////////
19 //                                                                           //
20 //  Transition Radiation Detector version 0 -- fast simulator                //
21 //                                                                           //
22 //Begin_Html
23 /*
24 <img src="picts/AliTRDfullClass.gif">
25 */
26 //End_Html
27 //                                                                           //
28 //                                                                           //
29 ///////////////////////////////////////////////////////////////////////////////
30
31 #include <stdlib.h> 
32
33 #include <TLorentzVector.h>
34 #include <TMath.h>
35 #include <TRandom.h>
36 #include <TVector.h> 
37 #include <TVirtualMC.h>
38
39 #include "AliConst.h"
40 #include "AliRun.h"
41 #include "AliTRDgeometry.h"
42 #include "AliTRDhit.h"
43 #include "AliTRDv0.h"
44
45 ClassImp(AliTRDv0)
46   
47 //_____________________________________________________________________________
48 AliTRDv0::AliTRDv0():AliTRD() 
49 {
50   //
51   // AliTRDv0 default constructor
52   //
53
54   fHitsOn     = 0;
55
56 }
57
58 //_____________________________________________________________________________
59 AliTRDv0::AliTRDv0(const char *name, const char *title) 
60          :AliTRD(name, title) 
61 {
62   //
63   // Standard constructor for Transition Radiation Detector version 0
64   //
65
66   fHitsOn     = 0;
67
68 }
69
70 //_____________________________________________________________________________
71 AliTRDv0::~AliTRDv0()
72 {
73   //
74   // AliTRDv0 destructor
75   //
76
77 }
78
79 //_____________________________________________________________________________
80 void AliTRDv0::CreateGeometry()
81 {
82   //
83   // Create the GEANT geometry for the Transition Radiation Detector - Version 0
84   // This version covers the full azimuth. 
85   //
86
87   // Check that FRAME is there otherwise we have no place where to put the TRD
88   AliModule* frame = gAlice->GetModule("FRAME");
89   if (!frame) return;
90
91   // Define the chambers
92   AliTRD::CreateGeometry();
93
94 }
95
96 //_____________________________________________________________________________
97 void AliTRDv0::CreateMaterials()
98 {
99   //
100   // Create materials for the Transition Radiation Detector
101   //
102
103   AliTRD::CreateMaterials();
104
105 }
106
107 //_____________________________________________________________________________
108 void AliTRDv0::Init() 
109 {
110   //
111   // Initialize Transition Radiation Detector after geometry is built
112   //
113
114   AliTRD::Init();
115
116   printf("          Fast simulator\n\n");
117   for (Int_t i = 0; i < 80; i++) printf("*");
118   printf("\n");
119   
120 }
121
122 //_____________________________________________________________________________
123 void AliTRDv0::StepManager()
124 {
125   //
126   // Procedure called at every step in the TRD
127   // Fast simulator. If switched on, a hit is produced when a track
128   // crosses the border between amplification region and pad plane.
129   //
130
131   Int_t   pla = 0; 
132   Int_t   cha = 0;
133   Int_t   sec = 0; 
134
135   Float_t hits[3];
136   Int_t   det;
137
138   TLorentzVector p;
139
140   // Use pad plane as sensitive volume
141   TString  cIdSens = "L";
142   TString  cIdCurrent;
143   Char_t   cIdChamber[3];
144            cIdChamber[2] = 0;
145
146   const Int_t kNplan = AliTRDgeometry::Nplan();
147
148   // Writing out hits enabled?
149   if (!(fHitsOn)) return;
150
151   // Use only charged tracks and count them only once per volume
152   if (gMC->TrackCharge()    && 
153       gMC->IsTrackEntering()) {
154     
155     // Check on sensitive volume
156     cIdCurrent = gMC->CurrentVolName();
157     if (cIdSens == cIdCurrent[1]) {
158
159       gMC->TrackPosition(p);
160       for (Int_t i = 0; i < 3; i++) hits[i] = p[i];
161
162       // The sector number (0 - 17)
163       // The numbering goes clockwise and starts at y = 0
164       Float_t phi = kRaddeg*TMath::ATan2(hits[0],hits[1]);
165       if (phi < 90.) 
166         phi = phi + 270.;
167       else
168         phi = phi -  90.;
169       sec = ((Int_t) (phi / 20));
170
171       // The plane and chamber number
172       cIdChamber[0] = cIdCurrent[2];
173       cIdChamber[1] = cIdCurrent[3];
174       Int_t idChamber = atoi(cIdChamber);
175       cha = ((Int_t) idChamber / kNplan);
176       pla = ((Int_t) idChamber % kNplan);
177       det = fGeometry->GetDetector(pla,cha,sec);
178
179       AddHit(gAlice->CurrentTrack(),det,hits,0,kTRUE);       
180
181     }
182
183   }  
184
185 }