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