]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRD.cxx
Added protections against using the wrong version of FRAME
[u/mrichter/AliRoot.git] / TRD / AliTRD.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 Revision 1.11  1999/09/29 09:24:34  fca
19 Introduction of the Copyright and cvs Log
20
21 */
22
23 ///////////////////////////////////////////////////////////////////////////////
24 //                                                                           //
25 //  Transition Radiation Detector                                            //
26 //  This class contains the basic functions for the Transition Radiation     //
27 //  detector. Functions specific to one particular geometry are              //
28 //  contained in the derived classes                                         //
29 //                                                                           //
30 //Begin_Html
31 /*
32 <img src="picts/AliTRDClass.gif">
33 */
34 //End_Html
35 //                                                                           //
36 //                                                                           //
37 ///////////////////////////////////////////////////////////////////////////////
38
39 #include <TMath.h>
40 #include <TNode.h>
41 #include <TPGON.h> 
42
43 #include "AliTRD.h"
44 #include "AliRun.h"
45
46 #include "AliConst.h"
47  
48 ClassImp(AliTRD)
49  
50 //_____________________________________________________________________________
51 AliTRD::AliTRD()
52 {
53   //
54   // Default constructor
55   //
56
57   fIshunt      = 0;
58   fGasMix      = 0;
59   fHits        = 0;
60   fDigits      = 0;
61
62   // The chamber dimensions
63   for (Int_t iplan = 0; iplan < kNplan; iplan++) {
64     fClengthI[iplan] = 0.;
65     fClengthM[iplan] = 0.;
66     fClengthO[iplan] = 0.;
67   }
68
69 }
70  
71 //_____________________________________________________________________________
72 AliTRD::AliTRD(const char *name, const char *title)
73        : AliDetector(name,title)
74 {
75   //
76   // Standard constructor for the TRD
77   //
78
79   // Allocate the hit array
80   fHits   = new TClonesArray("AliTRDhit",  405);
81
82   // Allocate the digits array
83   fDigits = new TClonesArray("AliTRDdigit",10000);
84    
85   fIshunt = 0;
86   fGasMix = 0;
87
88   // The chamber dimensions
89   for (Int_t iplan = 0; iplan < kNplan; iplan++) {
90     fClengthI[iplan] = 0.;
91     fClengthM[iplan] = 0.;
92     fClengthO[iplan] = 0.;
93     fCwidth[iplan]   = 0.;
94   }
95   
96   SetMarkerColor(kWhite);   
97
98 }
99
100 //_____________________________________________________________________________
101 AliTRD::~AliTRD()
102 {
103   //
104   // TRD destructor
105   //
106
107   fIshunt = 0;
108
109   delete fHits;
110   delete fDigits;
111
112 }
113
114 //_____________________________________________________________________________
115 void AliTRD::AddDigit(Int_t *tracks, Int_t *digits)
116 {
117   //
118   // Add a digit for the TRD
119   //
120
121   TClonesArray &ldigits = *fDigits;
122   new(ldigits[fNdigits++]) AliTRDdigit(tracks,digits);
123
124 }
125
126 //_____________________________________________________________________________
127 void AliTRD::AddHit(Int_t track, Int_t *vol, Float_t *hits)
128 {
129   //
130   // Add a hit for the TRD
131   //
132
133   TClonesArray &lhits = *fHits;
134   new(lhits[fNhits++]) AliTRDhit(fIshunt,track,vol,hits);
135
136 }
137
138 //_____________________________________________________________________________
139 void AliTRD::BuildGeometry()
140 {
141   //
142   // Create the ROOT TNode geometry for the TRD
143   //
144
145   TNode *Node, *Top;
146   TPGON *pgon;
147   const Int_t kColorTRD = 46;
148   
149   // Find the top node alice
150   Top = gAlice->GetGeometry()->GetNode("alice");
151   
152   pgon = new TPGON("S_TRD","TRD","void",0,360,kNsect,4);
153   Float_t ff    = TMath::Cos(kDegrad * 180 / kNsect);
154   Float_t rrmin = kRmin / ff;
155   Float_t rrmax = kRmax / ff;
156   pgon->DefineSection(0,-kZmax1,rrmax,rrmax);
157   pgon->DefineSection(1,-kZmax2,rrmin,rrmax);
158   pgon->DefineSection(2, kZmax2,rrmin,rrmax);
159   pgon->DefineSection(3, kZmax1,rrmax,rrmax);
160   Top->cd();
161   Node = new TNode("TRD","TRD","S_TRD",0,0,0,"");
162   Node->SetLineColor(kColorTRD);
163   fNodes->Add(Node);
164
165 }
166  
167 //_____________________________________________________________________________
168 void AliTRD::CreateGeometry()
169 {
170   //
171   // Creates the volumes for the TRD chambers
172   //
173   // Author: Christoph Blume (C.Blume@gsi.de) 20/07/99
174   //
175   // The volumes:
176   //    TRD        (Air)   --- The TRD mother volume for one sector. 
177   //                           To be placed into the spaceframe.
178   //
179   //    UAFI(/M/O) (Al)    --- The aluminum frame of the inner(/middle/outer) chambers (readout)
180   //    UCFI(/M/O) (C)     --- The carbon frame of the inner(/middle/outer) chambers 
181   //                           (driftchamber + radiator)
182   //    UAII(/M/O) (Air)   --- The inner part of the readout of the inner(/middle/outer) chambers
183   //    UFII(/M/O) (Air)   --- The inner part of the chamner and radiator of the 
184   //                           inner(/middle/outer) chambers
185   //
186   // The material layers in one chamber:
187   //    UL01       (G10)   --- The gas seal of the radiator
188   //    UL02       (CO2)   --- The gas in the radiator
189   //    UL03       (PE)    --- The foil stack
190   //    UL04       (Mylar) --- Entrance window to the driftvolume and HV-cathode
191   //    UL05       (Xe)    --- The driftvolume
192   //    UL06       (Xe)    --- The amplification region
193   //    
194   //    UL07       (Cu)    --- The pad plane
195   //    UL08       (G10)   --- The Nomex honeycomb support structure
196   //    UL09       (Cu)    --- FEE and signal lines
197   //    UL10       (PE)    --- The cooling devices
198   //    UL11       (Water) --- The cooling water
199
200   // Check that FRAME is there otherwise we have no place where to put the TRD
201   AliModule* FRAME = gAlice->GetModule("FRAME");
202   if (!FRAME) return;
203
204   const Int_t npar_trd = 4;
205   const Int_t npar_cha = 3;
206
207   Float_t par_dum[3];
208   Float_t par_trd[npar_trd];
209   Float_t par_cha[npar_cha];
210   Int_t iplan;
211
212   Float_t xpos, ypos, zpos;
213
214   Int_t *idtmed = fIdtmed->GetArray()-1299;
215
216   // The length of the inner chambers
217   for (iplan = 0; iplan < kNplan; iplan++) fClengthI[iplan] = 110.0;
218   // The length of the middle chambers
219   fClengthM[0] = 123.5;
220   fClengthM[1] = 131.0;
221   fClengthM[2] = 138.5;
222   fClengthM[3] = 146.0;
223   fClengthM[4] = 153.0;
224   fClengthM[5] = 160.5;
225   // The length of the outer chambers
226   fClengthO[0] = 123.5;
227   fClengthO[1] = 131.0;
228   fClengthO[2] = 134.5;
229   fClengthO[3] = 142.0;
230   fClengthO[4] = 142.0;
231   fClengthO[5] = 134.5;
232
233   // The width of the chambers
234   fCwidth[0] =  99.6;
235   fCwidth[1] = 104.1;
236   fCwidth[2] = 108.5;
237   fCwidth[3] = 112.9;
238   fCwidth[4] = 117.4;
239   fCwidth[5] = 121.8;
240
241   // The TRD mother volume for one sector (Air) (dimensions identical to BTR1-3)
242   par_trd[0] = kSwidth1/2.;
243   par_trd[1] = kSwidth2/2.;
244   par_trd[2] = kSlength/2.;
245   par_trd[3] = kSheight/2.;
246   gMC->Gsvolu("TRD ","TRD1",idtmed[1302-1],par_trd,npar_trd);
247
248   // The aluminum frames - readout + electronics (Al)
249   // The inner chambers
250   gMC->Gsvolu("UAFI","BOX ",idtmed[1301-1],par_dum,0);
251   // The middle chambers
252   gMC->Gsvolu("UAFM","BOX ",idtmed[1301-1],par_dum,0);
253   // The outer chambers
254   gMC->Gsvolu("UAFO","BOX ",idtmed[1301-1],par_dum,0);
255
256   // The inner part of the aluminum frames (Air)
257   // The inner chambers
258   gMC->Gsvolu("UAII","BOX ",idtmed[1302-1],par_dum,0);
259   // The middle chambers
260   gMC->Gsvolu("UAIM","BOX ",idtmed[1302-1],par_dum,0);
261   // The outer chambers
262   gMC->Gsvolu("UAIO","BOX ",idtmed[1302-1],par_dum,0);
263
264   // The carbon frames - radiator + driftchamber (C)
265   // The inner chambers
266   gMC->Gsvolu("UCFI","BOX ",idtmed[1307-1],par_dum,0);
267   // The middle chambers
268   gMC->Gsvolu("UCFM","BOX ",idtmed[1307-1],par_dum,0);
269   // The outer chambers
270   gMC->Gsvolu("UCFO","BOX ",idtmed[1307-1],par_dum,0);
271
272   // The inner part of the carbon frames (Air)
273   // The inner chambers
274   gMC->Gsvolu("UCII","BOX ",idtmed[1302-1],par_dum,0);
275   // The middle chambers
276   gMC->Gsvolu("UCIM","BOX ",idtmed[1302-1],par_dum,0);
277   // The outer chambers
278   gMC->Gsvolu("UCIO","BOX ",idtmed[1302-1],par_dum,0);
279
280   // The material layers inside the chambers
281   par_cha[0] = -1.;
282   par_cha[1] = -1.;
283   // G10 layer (radiator seal)
284   par_cha[2] = kSeThick/2;
285   gMC->Gsvolu("UL01","BOX ",idtmed[1313-1],par_cha,npar_cha);
286   // CO2 layer (radiator)
287   par_cha[2] = kRaThick/2;
288   gMC->Gsvolu("UL02","BOX ",idtmed[1312-1],par_cha,npar_cha);
289   // PE layer (radiator)
290   par_cha[2] = kPeThick/2;
291   gMC->Gsvolu("UL03","BOX ",idtmed[1303-1],par_cha,npar_cha);
292   // Mylar layer (entrance window + HV cathode) 
293   par_cha[2] = kMyThick/2;
294   gMC->Gsvolu("UL04","BOX ",idtmed[1308-1],par_cha,npar_cha);
295   // Xe/Isobutane layer (drift volume, sensitive) 
296   par_cha[2] = kDrThick/2.;
297   gMC->Gsvolu("UL05","BOX ",idtmed[1309-1],par_cha,npar_cha);
298   // Xe/Isobutane layer (amplification volume, not sensitive)
299   par_cha[2] = kAmThick/2.;
300   gMC->Gsvolu("UL06","BOX ",idtmed[1309-1],par_cha,npar_cha);
301   
302   // Cu layer (pad plane)
303   par_cha[2] = kCuThick/2;
304   gMC->Gsvolu("UL07","BOX ",idtmed[1305-1],par_cha,npar_cha);
305   // G10 layer (support structure)
306   par_cha[2] = kSuThick/2;
307   gMC->Gsvolu("UL08","BOX ",idtmed[1313-1],par_cha,npar_cha);
308   // Cu layer (FEE + signal lines)
309   par_cha[2] = kFeThick/2;
310   gMC->Gsvolu("UL09","BOX ",idtmed[1305-1],par_cha,npar_cha);
311   // PE layer (cooling devices)
312   par_cha[2] = kCoThick/2;
313   gMC->Gsvolu("UL10","BOX ",idtmed[1303-1],par_cha,npar_cha);
314   // Water layer (cooling)
315   par_cha[2] = kWaThick/2;
316   gMC->Gsvolu("UL11","BOX ",idtmed[1314-1],par_cha,npar_cha);
317
318   // Position the layers in the chambers
319   xpos = 0;
320   ypos = 0;
321
322   // G10 layer (radiator seal)
323   zpos = kSeZpos;
324   gMC->Gspos("UL01",1,"UCII",xpos,ypos,zpos,0,"ONLY");
325   gMC->Gspos("UL01",2,"UCIM",xpos,ypos,zpos,0,"ONLY");
326   gMC->Gspos("UL01",3,"UCIO",xpos,ypos,zpos,0,"ONLY");
327   // CO2 layer (radiator)
328   zpos = kRaZpos;
329   gMC->Gspos("UL02",1,"UCII",xpos,ypos,zpos,0,"ONLY");
330   gMC->Gspos("UL02",2,"UCIM",xpos,ypos,zpos,0,"ONLY");
331   gMC->Gspos("UL02",3,"UCIO",xpos,ypos,zpos,0,"ONLY");
332   // PE layer (radiator)
333   zpos = 0;
334   gMC->Gspos("UL03",1,"UL02",xpos,ypos,zpos,0,"ONLY");
335   // Mylar layer (entrance window + HV cathode)   
336   zpos = kMyZpos;
337   gMC->Gspos("UL04",1,"UCII",xpos,ypos,zpos,0,"ONLY");
338   gMC->Gspos("UL04",2,"UCIM",xpos,ypos,zpos,0,"ONLY");
339   gMC->Gspos("UL04",3,"UCIO",xpos,ypos,zpos,0,"ONLY");
340   // Xe/Isobutane layer (drift volume) 
341   zpos = kDrZpos;
342   gMC->Gspos("UL05",1,"UCII",xpos,ypos,zpos,0,"ONLY");
343   gMC->Gspos("UL05",2,"UCIM",xpos,ypos,zpos,0,"ONLY");
344   gMC->Gspos("UL05",3,"UCIO",xpos,ypos,zpos,0,"ONLY");
345   // Xe/Isobutane layer (amplification volume)
346   zpos = kAmZpos;
347   gMC->Gspos("UL06",1,"UCII",xpos,ypos,zpos,0,"ONLY");
348   gMC->Gspos("UL06",2,"UCIM",xpos,ypos,zpos,0,"ONLY");
349   gMC->Gspos("UL06",3,"UCIO",xpos,ypos,zpos,0,"ONLY");
350
351   // Cu layer (pad plane)
352   zpos = kCuZpos;
353   gMC->Gspos("UL07",1,"UAII",xpos,ypos,zpos,0,"ONLY");
354   gMC->Gspos("UL07",2,"UAIM",xpos,ypos,zpos,0,"ONLY");
355   gMC->Gspos("UL07",3,"UAIO",xpos,ypos,zpos,0,"ONLY");
356   // G10 layer (support structure)
357   zpos = kSuZpos;
358   gMC->Gspos("UL08",1,"UAII",xpos,ypos,zpos,0,"ONLY");
359   gMC->Gspos("UL08",2,"UAIM",xpos,ypos,zpos,0,"ONLY");
360   gMC->Gspos("UL08",3,"UAIO",xpos,ypos,zpos,0,"ONLY");
361   // Cu layer (FEE + signal lines)
362   zpos = kFeZpos; 
363   gMC->Gspos("UL09",1,"UAII",xpos,ypos,zpos,0,"ONLY");
364   gMC->Gspos("UL09",2,"UAIM",xpos,ypos,zpos,0,"ONLY");
365   gMC->Gspos("UL09",3,"UAIO",xpos,ypos,zpos,0,"ONLY");
366   // PE layer (cooling devices)
367   zpos = kCoZpos;
368   gMC->Gspos("UL10",1,"UAII",xpos,ypos,zpos,0,"ONLY");
369   gMC->Gspos("UL10",2,"UAIM",xpos,ypos,zpos,0,"ONLY");
370   gMC->Gspos("UL10",3,"UAIO",xpos,ypos,zpos,0,"ONLY");
371   // Water layer (cooling)
372   zpos = kWaZpos;
373   gMC->Gspos("UL11",1,"UAII",xpos,ypos,zpos,0,"ONLY");
374   gMC->Gspos("UL11",1,"UAIM",xpos,ypos,zpos,0,"ONLY");
375   gMC->Gspos("UL11",1,"UAIO",xpos,ypos,zpos,0,"ONLY");
376
377   // Position the chambers in the TRD mother volume
378   for (iplan = 1; iplan <= kNplan; iplan++) {
379
380     // The inner chambers ---------------------------------------------------------------
381
382     // the aluminum frame
383     //par_cha[0] = kSwidth1/2. + (iplan-1) * kCwidcha/2.;
384     par_cha[0] = fCwidth[iplan-1]/2.;
385     par_cha[1] = fClengthI[iplan-1]/2.;
386     par_cha[2] = kCaframe/2.;
387     xpos       = 0.;
388     ypos       = 0.;
389     zpos       = kCheight - kCaframe/2. - kSheight/2. + (iplan-1) * (kCheight + kCspace);
390     gMC->Gsposp("UAFI",iplan       ,"TRD ",xpos,ypos,zpos,0,"MANY",par_cha,npar_cha);
391
392     // the inner part of the aluminum frame
393     //par_cha[0] = kSwidth1/2. + (iplan-1) * kCwidcha/2. - kCathick;
394     par_cha[0] = fCwidth[iplan-1]/2.   - kCathick;
395     par_cha[1] = fClengthI[iplan-1]/2. - kCathick;
396     par_cha[2] = kCaframe/2.;
397     xpos       = 0.;
398     ypos       = 0.;
399     zpos       = kCheight - kCaframe/2. - kSheight/2. + (iplan-1) * (kCheight + kCspace);
400     gMC->Gsposp("UAII",iplan       ,"TRD ",xpos,ypos,zpos,0,"ONLY",par_cha,npar_cha);
401
402     // the carbon frame
403     //par_cha[0] = kSwidth1/2. + (iplan-1) * kCwidcha/2.;
404     par_cha[0] = fCwidth[iplan-1]/2.;
405     par_cha[1] = fClengthI[iplan-1]/2.;
406     par_cha[2] = kCcframe/2.;
407     xpos       = 0.;
408     ypos       = 0.;
409     zpos       = kCcframe/2.            - kSheight/2. + (iplan-1) * (kCheight + kCspace);
410     gMC->Gsposp("UCFI",iplan       ,"TRD ",xpos,ypos,zpos,0,"MANY",par_cha,npar_cha);
411
412     // the inner part of the carbon frame
413     //par_cha[0] = kSwidth1/2. + (iplan-1) * kCwidcha/2. - kCcthick;
414     par_cha[0] = fCwidth[iplan-1]/2.   - kCcthick;
415     par_cha[1] = fClengthI[iplan-1]/2. - kCcthick;
416     par_cha[2] = kCcframe/2.;
417     xpos       = 0.;
418     ypos       = 0.;
419     zpos       = kCcframe/2.            - kSheight/2. + (iplan-1) * (kCheight + kCspace);
420     gMC->Gsposp("UCII",iplan       ,"TRD ",xpos,ypos,zpos,0,"ONLY",par_cha,npar_cha);
421
422     // The middle chambers --------------------------------------------------------------
423
424     // the aluminum frame
425     //par_cha[0] = kSwidth1/2. + (iplan-1) * kCwidcha/2.;
426     par_cha[0] = fCwidth[iplan-1]/2.;
427     par_cha[1] = fClengthM[iplan-1]/2.;
428     par_cha[2] = kCaframe/2.;
429     xpos       = 0.;
430     ypos       = fClengthI[iplan-1]/2. + fClengthM[iplan-1]/2.;
431     zpos       = kCheight - kCaframe/2. - kSheight/2. + (iplan-1) * (kCheight + kCspace);
432     gMC->Gsposp("UAFM",iplan       ,"TRD ",xpos, ypos,zpos,0,"MANY",par_cha,npar_cha);
433     gMC->Gsposp("UAFM",iplan+kNplan,"TRD ",xpos,-ypos,zpos,0,"MANY",par_cha,npar_cha);
434
435     // the inner part of the aluminum frame
436     //par_cha[0] = kSwidth1/2. + (iplan-1) * kCwidcha/2. - kCathick;
437     par_cha[0] = fCwidth[iplan-1]/2.   - kCathick;
438     par_cha[1] = fClengthM[iplan-1]/2. - kCathick;
439     par_cha[2] = kCaframe/2.;
440     xpos       = 0.;
441     ypos       = fClengthI[iplan-1]/2. + fClengthM[iplan-1]/2.;
442     zpos       = kCheight - kCaframe/2. - kSheight/2. + (iplan-1) * (kCheight + kCspace);
443     gMC->Gsposp("UAIM",iplan       ,"TRD ",xpos, ypos,zpos,0,"ONLY",par_cha,npar_cha);
444     gMC->Gsposp("UAIM",iplan+kNplan,"TRD ",xpos,-ypos,zpos,0,"ONLY",par_cha,npar_cha);
445
446     // the carbon frame
447     //par_cha[0] = kSwidth1/2. + (iplan-1) * kCwidcha/2.;
448     par_cha[0] = fCwidth[iplan-1]/2.;
449     par_cha[1] = fClengthM[iplan-1]/2.;
450     par_cha[2] = kCcframe/2.;
451     xpos       = 0.;
452     ypos       = fClengthI[iplan-1]/2. + fClengthM[iplan-1]/2.;
453     zpos       = kCcframe/2.            - kSheight/2. + (iplan-1) * (kCheight + kCspace);
454     gMC->Gsposp("UCFM",iplan,       "TRD ",xpos, ypos,zpos,0,"MANY",par_cha,npar_cha);
455     gMC->Gsposp("UCFM",iplan+kNplan,"TRD ",xpos,-ypos,zpos,0,"MANY",par_cha,npar_cha);
456
457     // the inner part of the carbon frame
458     //par_cha[0] = kSwidth1/2. + (iplan-1) * kCwidcha/2. - kCcthick;
459     par_cha[0] = fCwidth[iplan-1]/2.   - kCcthick;
460     par_cha[1] = fClengthM[iplan-1]/2. - kCcthick;
461     par_cha[2] = kCcframe/2.;
462     xpos       = 0.;
463     ypos       = fClengthI[iplan-1]/2. + fClengthM[iplan-1]/2.;
464     zpos       = kCcframe/2.            - kSheight/2. + (iplan-1) * (kCheight + kCspace);
465     gMC->Gsposp("UCIM",iplan       ,"TRD ",xpos, ypos,zpos,0,"ONLY",par_cha,npar_cha);
466     gMC->Gsposp("UCIM",iplan+kNplan,"TRD ",xpos,-ypos,zpos,0,"ONLY",par_cha,npar_cha);
467
468     // The outer chambers ---------------------------------------------------------------
469
470     // the aluminum frame
471     //par_cha[0] = kSwidth1/2. + (iplan-1) * kCwidcha/2.;
472     par_cha[0] = fCwidth[iplan-1]/2.;
473     par_cha[1] = fClengthO[iplan-1]/2.;
474     par_cha[2] = kCaframe/2.;
475     xpos       = 0.;
476     ypos       = fClengthI[iplan-1]/2. + fClengthM[iplan-1]    + fClengthO[iplan-1]/2.;
477     zpos       = kCheight - kCaframe/2. - kSheight/2. + (iplan-1) * (kCheight + kCspace);
478     gMC->Gsposp("UAFO",iplan       ,"TRD ",xpos, ypos,zpos,0,"MANY",par_cha,npar_cha);
479     gMC->Gsposp("UAFO",iplan+kNplan,"TRD ",xpos,-ypos,zpos,0,"MANY",par_cha,npar_cha);
480
481     // the inner part of the aluminum frame
482     //par_cha[0] = kSwidth1/2. + (iplan-1) * kCwidcha/2. - kCathick;
483     par_cha[0] = fCwidth[iplan-1]/2.   - kCathick;
484     par_cha[1] = fClengthO[iplan-1]/2.  - kCathick;
485     par_cha[2] = kCaframe/2.;
486     xpos       = 0.;
487     ypos       = fClengthI[iplan-1]/2. + fClengthM[iplan-1]    + fClengthO[iplan-1]/2.;
488     zpos       = kCheight - kCaframe/2. - kSheight/2. + (iplan-1) * (kCheight + kCspace);
489     gMC->Gsposp("UAIO",iplan       ,"TRD ",xpos, ypos,zpos,0,"ONLY",par_cha,npar_cha);
490     gMC->Gsposp("UAIO",iplan+kNplan,"TRD ",xpos,-ypos,zpos,0,"ONLY",par_cha,npar_cha);
491
492     // the carbon frame
493     //par_cha[0] = kSwidth1/2. + (iplan-1) * kCwidcha/2.;
494     par_cha[0] = fCwidth[iplan-1]/2.;
495     par_cha[1] = fClengthO[iplan-1]/2.;
496     par_cha[2] = kCcframe/2.;
497     xpos       = 0.;
498     ypos       = fClengthI[iplan-1]/2. + fClengthM[iplan-1]    + fClengthO[iplan-1]/2.;
499     zpos       = kCcframe/2.            - kSheight/2. + (iplan-1) * (kCheight + kCspace);
500     gMC->Gsposp("UCFO",iplan,       "TRD ",xpos, ypos,zpos,0,"MANY",par_cha,npar_cha);
501     gMC->Gsposp("UCFO",iplan+kNplan,"TRD ",xpos,-ypos,zpos,0,"MANY",par_cha,npar_cha);
502
503     // the inner part of the carbon frame
504     //par_cha[0] = kSwidth1/2. + (iplan-1) * kCwidcha/2. - kCcthick;
505     par_cha[0] = fCwidth[iplan-1]/2.   - kCcthick;
506     par_cha[1] = fClengthO[iplan-1]/2. - kCcthick;
507     par_cha[2] = kCcframe/2.;
508     xpos       = 0.;
509     ypos       = fClengthI[iplan-1]/2. + fClengthM[iplan-1]    + fClengthO[iplan-1]/2.;
510     zpos       = kCcframe/2.            - kSheight/2. + (iplan-1) * (kCheight + kCspace);
511     gMC->Gsposp("UCIO",iplan       ,"TRD ",xpos, ypos,zpos,0,"ONLY",par_cha,npar_cha);
512     gMC->Gsposp("UCIO",iplan+kNplan,"TRD ",xpos,-ypos,zpos,0,"ONLY",par_cha,npar_cha);
513
514   }
515
516 }
517  
518 //_____________________________________________________________________________
519 void AliTRD::CreateMaterials()
520 {
521   //
522   // Create the materials for the TRD
523   // Origin Y.Foka
524   //
525
526   Int_t   ISXFLD = gAlice->Field()->Integ();
527   Float_t SXMGMX = gAlice->Field()->Max();
528   
529   // For polyethilene (CH2) 
530   Float_t ape[2] = { 12., 1. };
531   Float_t zpe[2] = {  6., 1. };
532   Float_t wpe[2] = {  1., 2. };
533   Float_t dpe    = 0.95;
534
535   // For mylar (C5H4O2) 
536   Float_t amy[3] = { 12., 1., 16. };
537   Float_t zmy[3] = {  6., 1.,  8. };
538   Float_t wmy[3] = {  5., 4.,  2. };
539   Float_t dmy    = 1.39;
540
541   // For CO2 
542   Float_t aco[2] = { 12., 16. };
543   Float_t zco[2] = {  6.,  8. };
544   Float_t wco[2] = {  1.,  2. };
545   Float_t dco    = 0.001977;
546
547   // For water
548   Float_t awa[2] = {  1., 16. };
549   Float_t zwa[2] = {  1.,  8. };
550   Float_t wwa[2] = {  2.,  1. };
551   Float_t dwa    = 1.0;
552
553   // For isobutane (C4H10)
554   Float_t ais[2] = { 12.,  1. };
555   Float_t zis[2] = {  6.,  1. };
556   Float_t wis[2] = {  4., 10. };
557   Float_t dis    = 0.00267;
558
559   // For Xe/CO2-gas-mixture 
560   // Xe-content of the Xe/CO2-mixture (90% / 10%) 
561   Float_t fxc    = .90;
562   // Xe-content of the Xe/Isobutane-mixture (97% / 3%) 
563   Float_t fxi    = .97;
564   Float_t dxe    = .005858;
565   
566   // General tracking parameter
567   Float_t tmaxfd = -10.;
568   Float_t stemax = -1e10;
569   Float_t deemax = -0.1;
570   Float_t epsil  =  1e-4;
571   Float_t stmin  = -0.001;
572   
573   Float_t absl, radl, d, buf[1];
574   Float_t agm[2], dgm, zgm[2], wgm[2];
575   Int_t   nbuf;
576   
577   //////////////////////////////////////////////////////////////////////////
578   //     Define Materials 
579   //////////////////////////////////////////////////////////////////////////
580
581   AliMaterial( 1, "Al $",  26.98, 13.0, 2.7     ,     8.9 ,    37.2);
582   AliMaterial( 2, "Air$",  14.61,  7.3, 0.001205, 30420.0 , 67500.0);
583   AliMaterial( 4, "Xe $", 131.29, 54.0, dxe     ,  1447.59,     0.0);
584   AliMaterial( 5, "Cu $",  63.54, 29.0, 8.96    ,     1.43,    14.8);
585   AliMaterial( 6, "C  $",  12.01,  6.0, 2.265   ,    18.8 ,    74.4);
586   AliMaterial(12, "G10$",  20.00, 10.0, 1.7     ,    19.4 ,   999.0);
587
588   // Mixtures 
589   AliMixture(3, "Polyethilene$",   ape, zpe, dpe, -2, wpe);
590   AliMixture(7, "Mylar$",          amy, zmy, dmy, -3, wmy);
591   AliMixture(8, "CO2$",            aco, zco, dco, -2, wco);
592   AliMixture(9, "Isobutane$",      ais, zis, dis, -2, wis);
593   AliMixture(13,"Water$",          awa, zwa, dwa, -2, wwa);
594
595   // Gas mixtures
596   Char_t namate[21];
597   // Xe/CO2-mixture
598   // Get properties of Xe 
599   gMC->Gfmate((*fIdmate)[4], namate, agm[0], zgm[0], d, radl, absl, buf, nbuf);
600   // Get properties of CO2 
601   gMC->Gfmate((*fIdmate)[8], namate, agm[1], zgm[1], d, radl, absl, buf, nbuf);
602   // Create gas mixture 
603   wgm[0] = fxc;
604   wgm[1] = 1. - fxc;
605   dgm    = wgm[0] * dxe + wgm[1] * dco;
606   AliMixture(10, "Gas mixture 1$", agm, zgm, dgm,  2, wgm);
607   // Xe/Isobutane-mixture
608   // Get properties of Xe 
609   gMC->Gfmate((*fIdmate)[4], namate, agm[0], zgm[0], d, radl, absl, buf, nbuf);
610   // Get properties of Isobutane
611   gMC->Gfmate((*fIdmate)[9], namate, agm[1], zgm[1], d, radl, absl, buf, nbuf);
612   // Create gas mixture 
613   wgm[0] = fxi;
614   wgm[1] = 1. - fxi;
615   dgm    = wgm[0] * dxe + wgm[1] * dis;
616   AliMixture(11, "Gas mixture 2$", agm, zgm, dgm,  2, wgm);
617  
618   //////////////////////////////////////////////////////////////////////////
619   //     Tracking Media Parameters 
620   //////////////////////////////////////////////////////////////////////////
621
622   // Al Frame 
623   AliMedium(1, "Al Frame$",   1, 0, ISXFLD, SXMGMX
624                 , tmaxfd, stemax, deemax, epsil, stmin);
625   // Air 
626   AliMedium(2, "Air$",        2, 0, ISXFLD, SXMGMX
627                 , tmaxfd, stemax, deemax, epsil, stmin);
628   // Polyethilene 
629   AliMedium(3, "Radiator$",   3, 0, ISXFLD, SXMGMX
630                 , tmaxfd, stemax, deemax, epsil, stmin);
631   // Xe 
632   AliMedium(4, "Xe$",         4, 1, ISXFLD, SXMGMX
633                 , tmaxfd, stemax, deemax, epsil, stmin);
634   // Cu pads 
635   AliMedium(5, "Padplane$",   5, 1, ISXFLD, SXMGMX
636                 , tmaxfd, stemax, deemax, epsil, stmin);
637   // Fee + cables 
638   AliMedium(6, "Readout$",    1, 0, ISXFLD, SXMGMX
639                 , tmaxfd, stemax, deemax, epsil, stmin);
640   // C frame 
641   AliMedium(7, "C Frame$",    6, 0, ISXFLD, SXMGMX
642                 , tmaxfd, stemax, deemax, epsil, stmin);
643   // Mylar foils 
644   AliMedium(8, "Mylar$",      7, 0, ISXFLD, SXMGMX
645                 , tmaxfd, stemax, deemax, epsil, stmin);
646   if (fGasMix == 1) {
647     // Gas-mixture (Xe/CO2) 
648     AliMedium(9, "Gas-mix$",   10, 1, ISXFLD, SXMGMX
649                   , tmaxfd, stemax, deemax, epsil, stmin);
650   }
651   else {
652     // Gas-mixture (Xe/Isobutane) 
653     AliMedium(9, "Gas-mix$",   11, 1, ISXFLD, SXMGMX
654                   , tmaxfd, stemax, deemax, epsil, stmin);
655   }
656   // Nomex-honeycomb (use carbon for the time being) 
657   AliMedium(10, "Nomex$",      6, 0, ISXFLD, SXMGMX
658                 , tmaxfd, stemax, deemax, epsil, stmin);
659   // Kapton foils (use Mylar for the time being) 
660   AliMedium(11, "Kapton$",     7, 0, ISXFLD, SXMGMX
661                 , tmaxfd, stemax, deemax, epsil, stmin);
662   // Gas-filling of the radiator 
663   AliMedium(12, "CO2$",        8, 0, ISXFLD, SXMGMX
664                 , tmaxfd, stemax, deemax, epsil, stmin);
665   // G10-plates
666   AliMedium(13, "G10-plates$",12, 0, ISXFLD, SXMGMX
667                 , tmaxfd, stemax, deemax, epsil, stmin);
668   // Cooling water
669   AliMedium(14, "Water$",     13, 0, ISXFLD, SXMGMX
670                 , tmaxfd, stemax, deemax, epsil, stmin);
671
672 }
673
674 //_____________________________________________________________________________
675 void AliTRD::DrawModule()
676 {
677   //
678   // Draw a shaded view of the Transition Radiation Detector version 0
679   //
680
681   // Set everything unseen
682   gMC->Gsatt("*"   ,"SEEN",-1);
683   
684   // Set ALIC mother transparent
685   gMC->Gsatt("ALIC","SEEN", 0);
686   
687   // Set the volumes visible
688   gMC->Gsatt("B032","SEEN", 0);
689   gMC->Gsatt("B028","SEEN", 0);
690   gMC->Gsatt("B029","SEEN", 0);
691   gMC->Gsatt("B030","SEEN", 0);
692   gMC->Gsatt("BTR1","SEEN", 0);
693   gMC->Gsatt("BTR2","SEEN", 0);
694   gMC->Gsatt("BTR3","SEEN", 0);
695   gMC->Gsatt("TRD" ,"SEEN", 0);
696   gMC->Gsatt("UCII","SEEN", 0);
697   gMC->Gsatt("UCIM","SEEN", 0);
698   gMC->Gsatt("UCIO","SEEN", 0);
699   gMC->Gsatt("UL02","SEEN", 1);
700   gMC->Gsatt("UL05","SEEN", 1);
701   gMC->Gsatt("UL06","SEEN", 1);
702   
703   gMC->Gdopt("hide", "on");
704   gMC->Gdopt("shad", "on");
705   gMC->Gsatt("*", "fill", 7);
706   gMC->SetClipBox(".");
707   gMC->SetClipBox("*", 0, 2000, -2000, 2000, -2000, 2000);
708   gMC->DefaultRange();
709   gMC->Gdraw("alic", 40, 30, 0, 12, 9.4, .021, .021);
710   gMC->Gdhead(1111, "Transition Radiation Detector");
711   gMC->Gdman(18, 4, "MAN");
712
713 }
714
715 //_____________________________________________________________________________
716 Int_t AliTRD::DistancetoPrimitive(Int_t , Int_t )
717 {
718   //
719   // Distance between the mouse and the TRD detector on the screen
720   // Dummy routine
721   
722   return 9999;
723
724 }
725  
726 //_____________________________________________________________________________
727 void AliTRD::Init()
728 {
729   //
730   // Initialise the TRD detector after the geometry has been created
731   //
732
733   // Here the TRD initialisation code (if any!)
734   if (fGasMix == 1) 
735     printf("          Gas Mixture: 90%% Xe + 10%% CO2\n");
736   else
737     printf("          Gas Mixture: 97%% Xe + 3%% Isobutane\n");
738
739 }
740
741 //_____________________________________________________________________________
742 void AliTRD::SetGasMix(Int_t imix)
743 {
744   //
745   // Defines the gas mixture (imix=0:  Xe/Isobutane imix=1: Xe/CO2)
746   //
747   
748   if ((imix < 0) || (imix > 1)) {
749     printf("Wrong input value: %d\n",imix);
750     printf("Use standard setting\n");
751     fGasMix = 0;
752     return;
753   }
754
755   fGasMix = imix;
756
757 }
758
759 ClassImp(AliTRDhit)
760  
761 //_____________________________________________________________________________
762 AliTRDhit::AliTRDhit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits):
763   AliHit(shunt, track)
764 {
765   //
766   // Create a TRD hit
767   //
768
769   // Store volume hierarchy
770   fSector  = vol[0]; 
771   fChamber = vol[1];
772   fPlane   = vol[2];
773   
774   // Store position and charge
775   fX       = hits[0];
776   fY       = hits[1];
777   fZ       = hits[2];
778   fQ       = hits[3];
779
780 }
781
782 ClassImp(AliTRDdigit)
783
784 //_____________________________________________________________________________
785 AliTRDdigit::AliTRDdigit(Int_t *tracks, Int_t *digits)
786             :AliDigit(tracks)
787 {
788   //
789   // Create a TRD digit
790   //
791
792   // Store the volume hierarchy
793   fSector  = digits[0];
794   fChamber = digits[1];
795   fPlane   = digits[2];
796
797   // Store the row, pad, and time bucket number
798   fRow     = digits[3];
799   fCol     = digits[4];
800   fTime    = digits[5];
801
802   // Store the signal amplitude
803   fSignal  = digits[6];
804
805 }