]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDv0.cxx
New TRD version now inserted in the space frame
[u/mrichter/AliRoot.git] / TRD / AliTRDv0.cxx
1 ///////////////////////////////////////////////////////////////////////////////
2 //                                                                           //
3 //  Transition Radiation Detector version 0 -- coarse simulation             //
4 //                                                                           //
5 //Begin_Html
6 /*
7 <img src="picts/AliTRDv0Class.gif">
8 */
9 //End_Html
10 //                                                                           //
11 //                                                                           //
12 ///////////////////////////////////////////////////////////////////////////////
13
14 #include <TMath.h>
15 #include <TRandom.h>
16 #include <TVector.h>
17
18 #include "AliTRDv0.h"
19 #include "AliRun.h"
20 #include "AliMC.h"
21 #include "AliConst.h"
22   
23 ClassImp(AliTRDv0)
24
25 //_____________________________________________________________________________
26 AliTRDv0::AliTRDv0(const char *name, const char *title) 
27          :AliTRD(name, title) 
28 {
29   //
30   // Standard constructor for Transition Radiation Detector version 0
31   //
32
33   fIdSens     = 0;
34   fHitsOn     = 0;
35
36   fIdSpace1   = 0;
37   fIdSpace2   = 0;
38   fIdSpace3   = 0;
39
40   fIdChamber1 = 0;
41   fIdChamber2 = 0;
42   fIdChamber3 = 0;
43
44 }
45  
46 //_____________________________________________________________________________
47 void AliTRDv0::CreateGeometry()
48 {
49   //
50   // Create the GEANT geometry for the Transition Radiation Detector - Version 0
51   // This version covers the full azimuth. 
52   //
53   // Author:  Christoph Blume (C.Blume@gsi.de) 20/07/99 
54   //
55
56   Float_t xpos, ypos, zpos;
57
58   // Check that FRAME is there otherwise we have no place where to put the TRD
59   AliModule* FRAME = gAlice->GetModule("FRAME");
60   if (!FRAME) return;
61
62   // Define the chambers
63   AliTRD::CreateGeometry();
64
65   // Position the the TRD-sectors in all TRD-volumes in the spaceframe
66   xpos     = 0.;
67   ypos     = 0.;
68   zpos     = 0.;
69   gMC->Gspos("TRD ",1,"BTR1",xpos,ypos,zpos,0,"ONLY");
70   gMC->Gspos("TRD ",2,"BTR2",xpos,ypos,zpos,0,"ONLY");
71   gMC->Gspos("TRD ",3,"BTR3",xpos,ypos,zpos,0,"ONLY");
72
73 }
74
75 //_____________________________________________________________________________
76 void AliTRDv0::CreateMaterials()
77 {
78   //
79   // Create materials for the Transition Radiation Detector
80   //
81
82   AliTRD::CreateMaterials();
83
84 }
85
86 //_____________________________________________________________________________
87 void AliTRDv0::Init() 
88 {
89   //
90   // Initialise Transition Radiation Detector after geometry is built
91   //
92
93   AliTRD::Init();
94
95   for (Int_t i = 0; i < 80; i++) printf("*");
96   printf("\n");
97   
98   // Identifier of the sensitive volume (amplification region)
99   fIdSens     = gMC->VolId("UL06");
100
101   // Identifier of the TRD-spaceframe volumina
102   fIdSpace1   = gMC->VolId("B028");
103   fIdSpace2   = gMC->VolId("B029");
104   fIdSpace3   = gMC->VolId("B030");
105
106   // Identifier of the TRD-driftchambers
107   fIdChamber1 = gMC->VolId("UCIO");
108   fIdChamber2 = gMC->VolId("UCIM");
109   fIdChamber3 = gMC->VolId("UCII");
110
111 }
112
113 //_____________________________________________________________________________
114 void AliTRDv0::StepManager()
115 {
116   //
117   // Procedure called at every step in the TRD
118   // Fast simulator. If switched on, a hit is produced when a track
119   // crosses the border between amplification region and pad plane.
120   //
121
122   Int_t   vol[3]; 
123   Int_t   iIdSens, icSens; 
124   Int_t   iIdSpace, icSpace;
125   Int_t   iIdChamber, icChamber;
126
127   Int_t   secMap1[10] = {  3,  7,  8,  9, 10, 11,  2,  1, 18, 17 };
128   Int_t   secMap2[ 5] = { 16, 15, 14, 13, 12 };
129   Int_t   secMap3[ 3] = {  5,  6,  4 };
130
131   Float_t hits[4];
132
133   TLorentzVector p;
134   TClonesArray  &lhits = *fHits;
135
136   // Writing out hits enabled?
137   if (!(fHitsOn)) return;
138
139   // Use only charged tracks and count them only once per volume
140   if (gMC->TrackCharge()    && 
141       gMC->IsTrackExiting()) {
142     
143     // Check on sensitive volume
144     iIdSens = gMC->CurrentVolID(icSens);
145     if (iIdSens == fIdSens) { 
146
147       gMC->TrackPosition(p);
148       for (Int_t i = 0; i < 3; i++) hits[i] = p[i];
149       // No charge created
150       hits[3] = 0;
151
152       iIdSpace   = gMC->CurrentVolOffID(4,icSpace  );
153       iIdChamber = gMC->CurrentVolOffID(1,icChamber);
154
155       // The sector number
156       if      (iIdSpace == fIdSpace1) 
157         vol[0] = secMap1[icSpace-1];
158       else if (iIdSpace == fIdSpace2) 
159         vol[0] = secMap2[icSpace-1];
160       else if (iIdSpace == fIdSpace3) 
161         vol[0] = secMap3[icSpace-1];
162
163       // The chamber number 
164       //   1: outer left
165       //   2: middle left
166       //   3: inner
167       //   4: middle right
168       //   5: outer right
169       if      (iIdChamber == fIdChamber1)
170         vol[1] = (hits[2] < 0 ? 1 : 5);
171       else if (iIdChamber == fIdChamber2)       
172         vol[1] = (hits[2] < 0 ? 2 : 4);
173       else if (iIdChamber == fIdChamber3)       
174         vol[1] = 3;
175
176       // The plane number
177       vol[2] = icChamber - TMath::Nint((Float_t) (icChamber / 7)) * 6;
178
179       new(lhits[fNhits++]) AliTRDhit(fIshunt,gAlice->CurrentTrack(),vol,hits);
180
181     }
182
183   }  
184
185 }