]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDv1.cxx
Introducing Copyright include file
[u/mrichter/AliRoot.git] / TRD / AliTRDv1.cxx
1 ///////////////////////////////////////////////////////////////////////////////
2 //                                                                           //
3 //  Transition Radiation Detector version 1 -- coarse simulation             //
4 //  This version has two detector arms, leaving the space in front of the    //
5 //  HMPID and PHOS empty                                                     //
6 //                                                                           //
7 //Begin_Html
8 /*
9 <img src="picts/AliTRDv1Class.gif">
10 */
11 //End_Html
12 //                                                                           //
13 //                                                                           //
14 ///////////////////////////////////////////////////////////////////////////////
15
16 #include <TMath.h>
17 #include <TRandom.h>
18 #include <TVector.h>
19
20 #include "AliTRDv1.h"
21 #include "AliRun.h"
22 #include "AliMC.h"
23 #include "AliConst.h"
24  
25 ClassImp(AliTRDv1)
26
27 //_____________________________________________________________________________
28 AliTRDv1::AliTRDv1(const char *name, const char *title) 
29          :AliTRD(name, title) 
30 {
31   //
32   // Standard constructor for the Transition Radiation Detector version 1
33   //
34
35   fIdSens     = 0;
36   fHitsOn     = 0;
37
38   fIdSpace1   = 0;
39   fIdSpace2   = 0;
40   fIdSpace3   = 0;
41
42   fIdChamber1 = 0;
43   fIdChamber2 = 0;
44   fIdChamber3 = 0;
45
46 }
47  
48 //_____________________________________________________________________________
49 void AliTRDv1::CreateGeometry()
50 {
51   //
52   // Create the GEANT geometry for the Transition Radiation Detector - Version 1
53   // This version covers only part of the azimuth. 
54   //
55   // Author:  Christoph Blume (C.Blume@gsi.de) 20/07/99 
56   //
57
58   Float_t xpos, ypos, zpos;
59
60   // Check that FRAME is there otherwise we have no place where to put the TRD
61   AliModule* FRAME = gAlice->GetModule("FRAME");
62   if (!FRAME) return;
63
64   // Define the chambers
65   AliTRD::CreateGeometry();
66
67   // Position the the TRD-sectors only in one TRD-volume in the spaceframe
68   xpos     = 0.;
69   ypos     = 0.;
70   zpos     = 0.;
71   gMC->Gspos("TRD ",1,"BTR1",xpos,ypos,zpos,0,"ONLY");
72
73 }
74
75 //_____________________________________________________________________________
76 void AliTRDv1::CreateMaterials()
77 {
78   //
79   // Create materials for the Transition Radiation Detector version 1
80   //
81
82   AliTRD::CreateMaterials();
83
84 }
85
86 //_____________________________________________________________________________
87 void AliTRDv1::Init() 
88 {
89   //
90   // Initialise the Transition Radiation Detector after the 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 AliTRDv1::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 }