Variable number of modules introduced
[u/mrichter/AliRoot.git] / TRD / AliTRD.cxx
CommitLineData
fe4da5cc 1///////////////////////////////////////////////////////////////////////////////
2// //
3// Transition Radiation Detector //
4// This class contains the basic functions for the Transition Radiation //
5// detector. Functions specific to one particular geometry are //
6// contained in the derived classes //
7// //
8//Begin_Html
9/*
1439f98e 10<img src="picts/AliTRDClass.gif">
fe4da5cc 11*/
12//End_Html
13// //
14// //
15///////////////////////////////////////////////////////////////////////////////
16
17#include <TMath.h>
fe4da5cc 18#include <TNode.h>
fe4da5cc 19#include <TPGON.h>
20
fe4da5cc 21#include "AliTRD.h"
22#include "AliRun.h"
fe4da5cc 23
d3f347ff 24#include "AliConst.h"
fe4da5cc 25
26ClassImp(AliTRD)
27
28//_____________________________________________________________________________
29AliTRD::AliTRD()
30{
31 //
32 // Default constructor
33 //
d3f347ff 34 fIshunt = 0;
35 fGasMix = 0;
36 fSensSelect = 0;
37 fSensPlane = 0;
38 fSensChamber = 0;
39 fSensSector = 0;
fe4da5cc 40}
41
42//_____________________________________________________________________________
43AliTRD::AliTRD(const char *name, const char *title)
44 : AliDetector(name,title)
45{
46 //
47 // Standard constructor for the TRD
48 //
49
50 //
51 // Allocate the hit array
52
53 fHits = new TClonesArray("AliTRDhit", 405);
54
d3f347ff 55 fIshunt = 0;
56 fGasMix = 0;
57 fSensSelect = 0;
58 fSensPlane = 0;
59 fSensChamber = 0;
60 fSensSector = 0;
fe4da5cc 61
62 SetMarkerColor(kWhite);
63}
64
65//_____________________________________________________________________________
66void AliTRD::AddHit(Int_t track, Int_t *vol, Float_t *hits)
67{
68 //
69 // Add a hit for the TRD
70 //
71 TClonesArray &lhits = *fHits;
72 new(lhits[fNhits++]) AliTRDhit(fIshunt,track,vol,hits);
73}
74
75//_____________________________________________________________________________
76void AliTRD::BuildGeometry()
77{
78 //
79 // Create the ROOT TNode geometry for the TRD
80 //
81 TNode *Node, *Top;
82 TPGON *pgon;
83 const Int_t kColorTRD = 46;
d3f347ff 84
fe4da5cc 85 // Find the top node alice
86 Top=gAlice->GetGeometry()->GetNode("alice");
d3f347ff 87
88 pgon = new TPGON("S_TRD","TRD","void",0,360,nsect,4);
89 Float_t ff = TMath::Cos(kDegrad * 180 / nsect);
90 Float_t rrmin = rmin / ff;
91 Float_t rrmax = rmax / ff;
92 pgon->DefineSection(0,-zmax1,rrmax,rrmax);
93 pgon->DefineSection(1,-zmax2,rrmin,rrmax);
94 pgon->DefineSection(2, zmax2,rrmin,rrmax);
95 pgon->DefineSection(3, zmax1,rrmax,rrmax);
fe4da5cc 96 Top->cd();
97 Node = new TNode("TRD","TRD","S_TRD",0,0,0,"");
98 Node->SetLineColor(kColorTRD);
99 fNodes->Add(Node);
d3f347ff 100
fe4da5cc 101}
102
103//_____________________________________________________________________________
104void AliTRD::CreateMaterials()
105{
d3f347ff 106
fe4da5cc 107 //
108 // Create the materials for the TRD
109 // Origin Y.Foka
110 //
111
112 AliMC* pMC = AliMC::GetMC();
113
114 Int_t ISXFLD = gAlice->Field()->Integ();
115 Float_t SXMGMX = gAlice->Field()->Max();
116
d3f347ff 117 // For polyethilene (CH2)
118 Float_t ape[2] = { 12., 1. };
119 Float_t zpe[2] = { 6., 1. };
120 Float_t wpe[2] = { 1., 2. };
121 Float_t dpe = 0.95;
122
123 // For mylar (C5H4O2)
124 Float_t amy[3] = { 12., 1., 16. };
125 Float_t zmy[3] = { 6., 1., 8. };
126 Float_t wmy[3] = { 5., 4., 2. };
fe4da5cc 127 Float_t dmy = 1.39;
d3f347ff 128
129 // For CO2
130 Float_t aco[2] = { 12., 16. };
131 Float_t zco[2] = { 6., 8. };
132 Float_t wco[2] = { 1., 2. };
133 Float_t dco = 0.001977;
134
135 // For water
136 Float_t awa[2] = { 1., 16. };
137 Float_t zwa[2] = { 1., 8. };
138 Float_t wwa[2] = { 2., 1. };
139 Float_t dwa = 1.0;
140
141 // For isobutane (C4H10)
142 Float_t ais[2] = { 12., 1. };
143 Float_t zis[2] = { 6., 1. };
144 Float_t wis[2] = { 4., 10. };
145 Float_t dis = 0.00267;
146
147 // For Xe/CO2-gas-mixture
148 // Xe-content of the Xe/CO2-mixture (90% / 10%)
149 Float_t fxc = .90;
150 // Xe-content of the Xe/Isobutane-mixture (97% / 3%)
151 Float_t fxi = .97;
fe4da5cc 152 Float_t dxe = .005858;
153
d3f347ff 154 // General tracking parameter
fe4da5cc 155 Float_t tmaxfd = -10.;
156 Float_t stemax = -1e10;
d3f347ff 157 Float_t deemax = -0.1;
158 Float_t epsil = 1e-4;
159 Float_t stmin = -0.001;
fe4da5cc 160
161 Float_t absl, radl, d, buf[1];
162 Float_t agm[2], dgm, zgm[2], wgm[2];
d3f347ff 163 Int_t nbuf;
fe4da5cc 164
d3f347ff 165 //////////////////////////////////////////////////////////////////////////
fe4da5cc 166 // Define Materials
d3f347ff 167 //////////////////////////////////////////////////////////////////////////
168
169 AliMaterial( 1, "Al $", 26.98, 13.0, 2.7 , 8.9 , 37.2);
170 AliMaterial( 2, "Air$", 14.61, 7.3, 0.001205, 30420.0 , 67500.0);
171 AliMaterial( 4, "Xe $", 131.29, 54.0, dxe , 1447.59, 0.0);
172 AliMaterial( 5, "Cu $", 63.54, 29.0, 8.96 , 1.43, 14.8);
173 AliMaterial( 6, "C $", 12.01, 6.0, 2.265 , 18.8 , 74.4);
174 AliMaterial(12, "G10$", 20.00, 10.0, 1.7 , 19.4 , 999.0);
175
176 // Mixtures
177 AliMixture(3, "Polyethilene$", ape, zpe, dpe, -2, wpe);
178 AliMixture(7, "Mylar$", amy, zmy, dmy, -3, wmy);
179 AliMixture(8, "CO2$", aco, zco, dco, -2, wco);
180 AliMixture(9, "Isobutane$", ais, zis, dis, -2, wis);
181 AliMixture(13, "Water$" , awa, zwa, dwa, -2, wwa);
182
183 // Gas mixtures
fe4da5cc 184 char namate[21];
d3f347ff 185 // Xe/CO2-mixture
186 // Get properties of Xe
fe4da5cc 187 pMC->Gfmate((*fIdmate)[4], namate, agm[0], zgm[0], d, radl, absl, buf, nbuf);
d3f347ff 188 // Get properties of CO2
fe4da5cc 189 pMC->Gfmate((*fIdmate)[8], namate, agm[1], zgm[1], d, radl, absl, buf, nbuf);
d3f347ff 190 // Create gas mixture
191 wgm[0] = fxc;
192 wgm[1] = 1. - fxc;
fe4da5cc 193 dgm = wgm[0] * dxe + wgm[1] * dco;
d3f347ff 194 AliMixture(10, "Gas mixture 1$", agm, zgm, dgm, 2, wgm);
195 // Xe/Isobutane-mixture
196 // Get properties of Xe
197 pMC->Gfmate((*fIdmate)[4], namate, agm[0], zgm[0], d, radl, absl, buf, nbuf);
198 // Get properties of Isobutane
199 pMC->Gfmate((*fIdmate)[9], namate, agm[1], zgm[1], d, radl, absl, buf, nbuf);
200 // Create gas mixture
201 wgm[0] = fxi;
202 wgm[1] = 1. - fxi;
203 dgm = wgm[0] * dxe + wgm[1] * dis;
204 AliMixture(11, "Gas mixture 2$", agm, zgm, dgm, 2, wgm);
205
206 //////////////////////////////////////////////////////////////////////////
fe4da5cc 207 // Tracking Media Parameters
d3f347ff 208 //////////////////////////////////////////////////////////////////////////
209
210 // Al Frame
ad51aeb0 211 AliMedium(1, "Al Frame$", 1, 0, ISXFLD, SXMGMX
d3f347ff 212 , tmaxfd, stemax, deemax, epsil, stmin);
213 // Air
ad51aeb0 214 AliMedium(2, "Air$", 2, 0, ISXFLD, SXMGMX
d3f347ff 215 , tmaxfd, stemax, deemax, epsil, stmin);
216 // Polyethilene
ad51aeb0 217 AliMedium(3, "Radiator$", 3, 0, ISXFLD, SXMGMX
d3f347ff 218 , tmaxfd, stemax, deemax, epsil, stmin);
219 // Xe
ad51aeb0 220 AliMedium(4, "Xe$", 4, 1, ISXFLD, SXMGMX
d3f347ff 221 , tmaxfd, stemax, deemax, epsil, stmin);
222 // Cu pads
ad51aeb0 223 AliMedium(5, "Padplane$", 5, 1, ISXFLD, SXMGMX
d3f347ff 224 , tmaxfd, stemax, deemax, epsil, stmin);
225 // Fee + cables
ad51aeb0 226 AliMedium(6, "Readout$", 1, 0, ISXFLD, SXMGMX
d3f347ff 227 , tmaxfd, stemax, deemax, epsil, stmin);
228 // C frame
ad51aeb0 229 AliMedium(7, "C Frame$", 6, 0, ISXFLD, SXMGMX
d3f347ff 230 , tmaxfd, stemax, deemax, epsil, stmin);
231 // Mylar foils
ad51aeb0 232 AliMedium(8, "Mylar$", 7, 0, ISXFLD, SXMGMX
d3f347ff 233 , tmaxfd, stemax, deemax, epsil, stmin);
234 if (fGasMix == 1) {
235 // Gas-mixture (Xe/CO2)
ad51aeb0 236 AliMedium(9, "Gas-mix$", 10, 1, ISXFLD, SXMGMX
d3f347ff 237 , tmaxfd, stemax, deemax, epsil, stmin);
238 }
239 else {
240 // Gas-mixture (Xe/Isobutane)
ad51aeb0 241 AliMedium(9, "Gas-mix$", 11, 1, ISXFLD, SXMGMX
d3f347ff 242 , tmaxfd, stemax, deemax, epsil, stmin);
243 }
244 // Nomex-honeycomb (use carbon for the time being)
ad51aeb0 245 AliMedium(10, "Nomex$", 6, 0, ISXFLD, SXMGMX
d3f347ff 246 , tmaxfd, stemax, deemax, epsil, stmin);
247 // Kapton foils (use Mylar for the time being)
ad51aeb0 248 AliMedium(11, "Kapton$", 7, 0, ISXFLD, SXMGMX
d3f347ff 249 , tmaxfd, stemax, deemax, epsil, stmin);
250 // Gas-filling of the radiator
ad51aeb0 251 AliMedium(12, "CO2$", 8, 0, ISXFLD, SXMGMX
d3f347ff 252 , tmaxfd, stemax, deemax, epsil, stmin);
253 // G10-plates
ad51aeb0 254 AliMedium(13, "G10-plates$",12, 0, ISXFLD, SXMGMX
d3f347ff 255 , tmaxfd, stemax, deemax, epsil, stmin);
256 // Cooling water
ad51aeb0 257 AliMedium(14, "Water$", 13, 0, ISXFLD, SXMGMX
d3f347ff 258 , tmaxfd, stemax, deemax, epsil, stmin);
259
fe4da5cc 260}
261
262//_____________________________________________________________________________
263Int_t AliTRD::DistancetoPrimitive(Int_t , Int_t )
264{
265 //
266 // Distance between the mouse and the TRD detector on the screen
267 // Dummy routine
268 //
269 return 9999;
270}
271
272//_____________________________________________________________________________
273void AliTRD::Init()
274{
275 //
276 // Initialise the TRD detector after the geometry has been created
277 //
278 Int_t i;
279 //
280 printf("\n");
281 for(i=0;i<35;i++) printf("*");
282 printf(" TRD_INIT ");
283 for(i=0;i<35;i++) printf("*");
284 printf("\n");
d3f347ff 285
fe4da5cc 286 // Here the TRD initialisation code (if any!)
d3f347ff 287 if (fGasMix == 1)
288 printf(" Gas Mixture: 90%% Xe + 10%% CO2\n");
289 else
290 printf(" Gas Mixture: 97%% Xe + 3%% Isobutane\n");
291 if (fSensPlane)
292 printf(" Only plane %d is sensitive\n",fSensPlane);
293 if (fSensChamber)
294 printf(" Only chamber %d is sensitive\n",fSensChamber);
295 if (fSensSector)
296 printf(" Only sector %d is sensitive\n",fSensSector);
297
fe4da5cc 298 for(i=0;i<80;i++) printf("*");
299 printf("\n");
300}
301
d3f347ff 302//_____________________________________________________________________________
b060c36f 303void AliTRD::SetGasMix(Int_t imix)
d3f347ff 304{
305
306 if ((imix < 0) || (imix > 1)) {
307 printf("Wrong input value: %d\n",imix);
308 printf("Use standard setting\n");
309 fGasMix = 0;
310 return;
311 }
312
313 fGasMix = imix;
314
315}
316
317//_____________________________________________________________________________
b060c36f 318void AliTRD::SetSensPlane(Int_t iplane)
d3f347ff 319{
320
321 if ((iplane < 0) || (iplane > 6)) {
322 printf("Wrong input value: %d\n",iplane);
323 printf("Use standard setting\n");
324 fSensPlane = 0;
325 fSensSelect = 0;
326 return;
327 }
328
329 fSensSelect = 1;
330 fSensPlane = iplane;
331
332}
333
334//_____________________________________________________________________________
b060c36f 335void AliTRD::SetSensChamber(Int_t ichamber)
d3f347ff 336{
337
338 if ((ichamber < 0) || (ichamber > 5)) {
339 printf("Wrong input value: %d\n",ichamber);
340 printf("Use standard setting\n");
341 fSensChamber = 0;
342 fSensSelect = 0;
343 return;
344 }
345
346 fSensSelect = 1;
347 fSensChamber = ichamber;
348
349}
350
351//_____________________________________________________________________________
b060c36f 352void AliTRD::SetSensSector(Int_t isector)
d3f347ff 353{
354
355 if ((isector < 0) || (isector > 18)) {
356 printf("Wrong input value: %d\n",isector);
357 printf("Use standard setting\n");
358 fSensSector = 0;
359 fSensSelect = 0;
360 return;
361 }
362
363 fSensSelect = 1;
364 fSensSector = isector;
365
366}
367
fe4da5cc 368ClassImp(AliTRDhit)
369
370//_____________________________________________________________________________
371AliTRDhit::AliTRDhit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits):
372 AliHit(shunt, track)
373{
374 //
375 // Create a TRD hit
376 //
377
378 //
379 // Store volume hierarchy
380 fSector = vol[0];
381 fChamber = vol[1];
382 fPlane = vol[2];
383 //
384 // Store position and charge
385 fX = hits[0];
386 fY = hits[1];
387 fZ = hits[2];
388 fQ = hits[3];
389}