]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRD.cxx
More details on installation pre-requisites
[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.14  1999/11/02 16:57:02  fca
19 Avoid non ansi warnings on HP compilers
20
21 Revision 1.13  1999/11/02 16:35:56  fca
22 New version of TRD introduced
23
24 Revision 1.12  1999/11/01 20:41:51  fca
25 Added protections against using the wrong version of FRAME
26
27 Revision 1.11  1999/09/29 09:24:34  fca
28 Introduction of the Copyright and cvs Log
29
30 */
31
32 ///////////////////////////////////////////////////////////////////////////////
33 //                                                                           //
34 //  Transition Radiation Detector                                            //
35 //  This class contains the basic functions for the Transition Radiation     //
36 //  Detector, as well as the geometry.                                       //
37 //  Functions specific to one particular geometry are contained in the       // 
38 //  derived classes.                                                         //
39 //                                                                           //
40 //Begin_Html
41 /*
42 <img src="picts/AliTRDClass.gif">
43 */
44 //End_Html
45 //                                                                           //
46 //                                                                           //
47 ///////////////////////////////////////////////////////////////////////////////
48
49 #include <stdlib.h>
50
51 #include <TMath.h>
52 #include <TNode.h>
53 #include <TPGON.h> 
54
55 #include "AliTRD.h"
56 #include "AliRun.h"
57 #include "AliConst.h"
58  
59 ClassImp(AliTRD)
60  
61 //_____________________________________________________________________________
62 AliTRD::AliTRD()
63 {
64   //
65   // Default constructor
66   //
67
68   Int_t iplan;
69
70   fIshunt      = 0;
71   fGasMix      = 0;
72   fHits        = 0;
73   fDigits      = 0;
74   fHole        = 0;
75
76   fClusters    = 0;
77   fNclusters   = 0;
78
79   // The chamber dimensions
80   for (iplan = 0; iplan < kNplan; iplan++) {
81     fClengthI[iplan]  = 0.;
82     fClengthM1[iplan] = 0.;
83     fClengthM2[iplan] = 0.;
84     fClengthO1[iplan] = 0.;
85     fClengthO2[iplan] = 0.;
86     fClengthO3[iplan] = 0.;
87     fCwidth[iplan]    = 0.;
88   }
89
90   for (iplan = 0; iplan < kNplan; iplan++) {
91     for (Int_t icham = 0; icham < kNcham; icham++) {
92       for (Int_t isect = 0; isect < kNsect; isect++) {
93         fRowMax[iplan][icham][isect] = 0;
94       }
95     }
96     fColMax[iplan] = 0;
97   }
98   fTimeMax       = 0;
99
100   fRowPadSize    = 0;
101   fColPadSize    = 0;
102   fTimeBinSize   = 0;
103
104 }
105  
106 //_____________________________________________________________________________
107 AliTRD::AliTRD(const char *name, const char *title)
108        : AliDetector(name,title)
109 {
110   //
111   // Standard constructor for the TRD
112   //
113
114   Int_t iplan;
115
116   // Check that FRAME is there otherwise we have no place where to
117   // put TRD
118   AliModule* FRAME=gAlice->GetModule("FRAME");
119   if (!FRAME) {
120     Error("Ctor","TRD needs FRAME to be present\n");
121     exit(1);
122   } 
123
124   // Define the TRD geometry according to the FRAME geometry
125   if (FRAME->IsVersion() == 0) 
126     // With hole
127     fHole = 1;
128   else 
129     // Without hole
130     fHole = 0; 
131
132   // Allocate the hit array
133   fHits      = new TClonesArray("AliTRDhit"    ,  405);
134
135   // Allocate the digits array
136   fDigits    = new TClonesArray("AliTRDdigit"  ,10000);
137
138   // Allocate the cluster array
139   fClusters  = new TClonesArray("AliTRDcluster",  400);
140   fNclusters = 0;
141    
142   fIshunt = 0;
143   fGasMix = 0;
144
145   // The chamber dimensions
146   for (iplan = 0; iplan < kNplan; iplan++) {
147     fClengthI[iplan]  = 0.;
148     fClengthM1[iplan] = 0.;
149     fClengthM2[iplan] = 0.;
150     fClengthO1[iplan] = 0.;
151     fClengthO2[iplan] = 0.;
152     fClengthO3[iplan] = 0.;
153     fCwidth[iplan]    = 0.;
154   }
155   
156   for (iplan = 0; iplan < kNplan; iplan++) {
157     for (Int_t icham = 0; icham < kNcham; icham++) {
158       for (Int_t isect = 0; isect < kNsect; isect++) {
159         fRowMax[iplan][icham][isect] = 0;
160       }
161     }
162     fColMax[iplan] = 0;
163   }
164   fTimeMax       = 0;
165
166   fRowPadSize    = 0;
167   fColPadSize    = 0;
168   fTimeBinSize   = 0;
169
170   SetMarkerColor(kWhite);   
171
172 }
173
174 //_____________________________________________________________________________
175 AliTRD::~AliTRD()
176 {
177   //
178   // TRD destructor
179   //
180
181   fIshunt = 0;
182
183   delete fHits;
184   delete fDigits;
185   delete fClusters;
186
187 }
188
189 //_____________________________________________________________________________
190 void AliTRD::AddCluster(Int_t *tracks, Int_t *clusters, Float_t *position)
191 {
192   //
193   // Add a cluster for the TRD
194   // 
195
196   TClonesArray &lclusters = *fClusters;
197   new(lclusters[fNclusters++]) AliTRDcluster(tracks,clusters,position);
198
199 }
200
201 //_____________________________________________________________________________
202 void AliTRD::AddDigit(Int_t *tracks, Int_t *digits)
203 {
204   //
205   // Add a digit for the TRD
206   //
207
208   TClonesArray &ldigits = *fDigits;
209   new(ldigits[fNdigits++]) AliTRDdigit(tracks,digits);
210
211 }
212
213 //_____________________________________________________________________________
214 void AliTRD::AddHit(Int_t track, Int_t *vol, Float_t *hits)
215 {
216   //
217   // Add a hit for the TRD
218   //
219
220   TClonesArray &lhits = *fHits;
221   new(lhits[fNhits++]) AliTRDhit(fIshunt,track,vol,hits);
222
223 }
224
225 //_____________________________________________________________________________
226 void AliTRD::BuildGeometry()
227 {
228   //
229   // Create the ROOT TNode geometry for the TRD
230   //
231
232   TNode *Node, *Top;
233   TPGON *pgon;
234   const Int_t kColorTRD = 46;
235   
236   // Find the top node alice
237   Top = gAlice->GetGeometry()->GetNode("alice");
238   
239   pgon = new TPGON("S_TRD","TRD","void",0,360,kNsect,4);
240   Float_t ff    = TMath::Cos(kDegrad * 180 / kNsect);
241   Float_t rrmin = kRmin / ff;
242   Float_t rrmax = kRmax / ff;
243   pgon->DefineSection(0,-kZmax1,rrmax,rrmax);
244   pgon->DefineSection(1,-kZmax2,rrmin,rrmax);
245   pgon->DefineSection(2, kZmax2,rrmin,rrmax);
246   pgon->DefineSection(3, kZmax1,rrmax,rrmax);
247   Top->cd();
248   Node = new TNode("TRD","TRD","S_TRD",0,0,0,"");
249   Node->SetLineColor(kColorTRD);
250   fNodes->Add(Node);
251
252 }
253  
254 //_____________________________________________________________________________
255 void AliTRD::CreateGeometry()
256 {
257   //
258   // Creates the volumes for the TRD chambers
259   //
260   // Author: Christoph Blume (C.Blume@gsi.de) 20/07/99
261   //
262   // The volumes:
263   //    TRD1-3     (Air)   --- The TRD mother volumes for one sector. 
264   //                           To be placed into the spaceframe.
265   //
266   //    UAFI(/M/O) (Al)    --- The aluminum frame of the inner(/middle/outer) chambers (readout)
267   //    UCFI(/M/O) (C)     --- The carbon frame of the inner(/middle/outer) chambers 
268   //                           (driftchamber + radiator)
269   //    UAII(/M/O) (Air)   --- The inner part of the readout of the inner(/middle/outer) chambers
270   //    UFII(/M/O) (Air)   --- The inner part of the chamner and radiator of the 
271   //                           inner(/middle/outer) chambers
272   //
273   // The material layers in one chamber:
274   //    UL01       (G10)   --- The gas seal of the radiator
275   //    UL02       (CO2)   --- The gas in the radiator
276   //    UL03       (PE)    --- The foil stack
277   //    UL04       (Mylar) --- Entrance window to the driftvolume and HV-cathode
278   //    UL05       (Xe)    --- The driftvolume
279   //    UL06       (Xe)    --- The amplification region
280   //    
281   //    UL07       (Cu)    --- The pad plane
282   //    UL08       (G10)   --- The Nomex honeycomb support structure
283   //    UL09       (Cu)    --- FEE and signal lines
284   //    UL10       (PE)    --- The cooling devices
285   //    UL11       (Water) --- The cooling water
286
287   // Check that FRAME is there otherwise we have no place where to put the TRD
288   AliModule* FRAME = gAlice->GetModule("FRAME");
289   if (!FRAME) return;
290
291   Int_t iplan;
292
293   const Int_t npar_trd = 4;
294   const Int_t npar_cha = 3;
295
296   Float_t par_dum[3];
297   Float_t par_trd[npar_trd];
298   Float_t par_cha[npar_cha];
299
300   Float_t xpos, ypos, zpos;
301
302   Int_t *idtmed = fIdtmed->GetArray() - 1299;
303
304   // The length of the inner chambers
305   for (iplan = 0; iplan < kNplan; iplan++) 
306     fClengthI[iplan] = 110.0;
307
308   // The length of the middle chambers
309   fClengthM1[0] = 123.5;
310   fClengthM1[1] = 131.0;
311   fClengthM1[2] = 138.5;
312   fClengthM1[3] = 146.0;
313   fClengthM1[4] = 153.0;
314   fClengthM1[5] = 160.5;
315
316   fClengthM2[0] = 123.5 - 7.0;
317   fClengthM2[1] = 131.0 - 7.0;
318   fClengthM2[2] = 138.5 - 7.0;
319   fClengthM2[3] = 146.0 - 7.0;
320   fClengthM2[4] = 153.0 - 7.0;
321   fClengthM2[5] = 160.4 - 7.0;
322
323   // The length of the outer chambers
324   fClengthO1[0] = 123.5;
325   fClengthO1[1] = 131.0;
326   fClengthO1[2] = 134.5;
327   fClengthO1[3] = 142.0;
328   fClengthO1[4] = 142.0;
329   fClengthO1[5] = 134.5;
330
331   fClengthO2[0] = 123.5;
332   fClengthO2[1] = 131.0;
333   fClengthO2[2] = 134.5;
334   fClengthO2[3] = 142.0;
335   fClengthO2[4] = 142.0;
336   fClengthO2[5] = 134.5;
337
338   fClengthO3[0] =  86.5;
339   fClengthO3[1] = 101.5;
340   fClengthO3[2] = 112.5;
341   fClengthO3[3] = 127.5;
342   fClengthO3[4] = 134.5;
343   fClengthO3[5] = 134.5;
344
345   // The width of the chambers
346   fCwidth[0]    =  99.6;
347   fCwidth[1]    = 104.1;
348   fCwidth[2]    = 108.5;
349   fCwidth[3]    = 112.9;
350   fCwidth[4]    = 117.4;
351   fCwidth[5]    = 121.8;
352
353   // The TRD mother volume for one sector (Air) (dimensions identical to BTR1)
354   par_trd[0] = kSwidth1/2.;
355   par_trd[1] = kSwidth2/2.;
356   par_trd[2] = kSlenTR1/2.;
357   par_trd[3] = kSheight/2.;
358   gMC->Gsvolu("TRD1","TRD1",idtmed[1302-1],par_trd,npar_trd);
359   
360   // The TRD mother volume for one sector (Air) (dimensions identical to BTR2 + BTR3).
361   // Only used for the geometry with holes.
362   if (fHole) {
363
364     par_trd[0] = kSwidth1/2.;
365     par_trd[1] = kSwidth2/2.;
366     par_trd[2] = kSlenTR2/2.;
367     par_trd[3] = kSheight/2.;
368     gMC->Gsvolu("TRD2","TRD1",idtmed[1302-1],par_trd,npar_trd);
369
370     par_trd[0] = kSwidth1/2.;
371     par_trd[1] = kSwidth2/2.;
372     par_trd[2] = kSlenTR3/2.;
373     par_trd[3] = kSheight/2.;
374     gMC->Gsvolu("TRD3","TRD1",idtmed[1302-1],par_trd,npar_trd);
375
376   }
377
378   // The aluminum frames - readout + electronics (Al)
379   // The inner chambers
380   gMC->Gsvolu("UAFI","BOX ",idtmed[1301-1],par_dum,0);
381   // The middle chambers
382   gMC->Gsvolu("UAFM","BOX ",idtmed[1301-1],par_dum,0);
383   // The outer chambers
384   gMC->Gsvolu("UAFO","BOX ",idtmed[1301-1],par_dum,0);
385
386   // The inner part of the aluminum frames (Air)
387   // The inner chambers
388   gMC->Gsvolu("UAII","BOX ",idtmed[1302-1],par_dum,0);
389   // The middle chambers
390   gMC->Gsvolu("UAIM","BOX ",idtmed[1302-1],par_dum,0);
391   // The outer chambers
392   gMC->Gsvolu("UAIO","BOX ",idtmed[1302-1],par_dum,0);
393
394   // The carbon frames - radiator + driftchamber (C)
395   // The inner chambers
396   gMC->Gsvolu("UCFI","BOX ",idtmed[1307-1],par_dum,0);
397   // The middle chambers
398   gMC->Gsvolu("UCFM","BOX ",idtmed[1307-1],par_dum,0);
399   // The outer chambers
400   gMC->Gsvolu("UCFO","BOX ",idtmed[1307-1],par_dum,0);
401
402   // The inner part of the carbon frames (Air)
403   // The inner chambers
404   gMC->Gsvolu("UCII","BOX ",idtmed[1302-1],par_dum,0);
405   // The middle chambers
406   gMC->Gsvolu("UCIM","BOX ",idtmed[1302-1],par_dum,0);
407   // The outer chambers
408   gMC->Gsvolu("UCIO","BOX ",idtmed[1302-1],par_dum,0);
409
410   // The material layers inside the chambers
411   par_cha[0] = -1.;
412   par_cha[1] = -1.;
413   // G10 layer (radiator seal)
414   par_cha[2] = kSeThick/2;
415   gMC->Gsvolu("UL01","BOX ",idtmed[1313-1],par_cha,npar_cha);
416   // CO2 layer (radiator)
417   par_cha[2] = kRaThick/2;
418   gMC->Gsvolu("UL02","BOX ",idtmed[1312-1],par_cha,npar_cha);
419   // PE layer (radiator)
420   par_cha[2] = kPeThick/2;
421   gMC->Gsvolu("UL03","BOX ",idtmed[1303-1],par_cha,npar_cha);
422   // Mylar layer (entrance window + HV cathode) 
423   par_cha[2] = kMyThick/2;
424   gMC->Gsvolu("UL04","BOX ",idtmed[1308-1],par_cha,npar_cha);
425   // Xe/Isobutane layer (drift volume, sensitive) 
426   par_cha[2] = kDrThick/2.;
427   gMC->Gsvolu("UL05","BOX ",idtmed[1309-1],par_cha,npar_cha);
428   // Xe/Isobutane layer (amplification volume, not sensitive)
429   par_cha[2] = kAmThick/2.;
430   gMC->Gsvolu("UL06","BOX ",idtmed[1309-1],par_cha,npar_cha);
431   
432   // Cu layer (pad plane)
433   par_cha[2] = kCuThick/2;
434   gMC->Gsvolu("UL07","BOX ",idtmed[1305-1],par_cha,npar_cha);
435   // G10 layer (support structure)
436   par_cha[2] = kSuThick/2;
437   gMC->Gsvolu("UL08","BOX ",idtmed[1313-1],par_cha,npar_cha);
438   // Cu layer (FEE + signal lines)
439   par_cha[2] = kFeThick/2;
440   gMC->Gsvolu("UL09","BOX ",idtmed[1305-1],par_cha,npar_cha);
441   // PE layer (cooling devices)
442   par_cha[2] = kCoThick/2;
443   gMC->Gsvolu("UL10","BOX ",idtmed[1303-1],par_cha,npar_cha);
444   // Water layer (cooling)
445   par_cha[2] = kWaThick/2;
446   gMC->Gsvolu("UL11","BOX ",idtmed[1314-1],par_cha,npar_cha);
447
448   // Position the layers in the chambers
449   xpos = 0;
450   ypos = 0;
451
452   // G10 layer (radiator seal)
453   zpos = kSeZpos;
454   gMC->Gspos("UL01",1,"UCII",xpos,ypos,zpos,0,"ONLY");
455   gMC->Gspos("UL01",2,"UCIM",xpos,ypos,zpos,0,"ONLY");
456   gMC->Gspos("UL01",3,"UCIO",xpos,ypos,zpos,0,"ONLY");
457   // CO2 layer (radiator)
458   zpos = kRaZpos;
459   gMC->Gspos("UL02",1,"UCII",xpos,ypos,zpos,0,"ONLY");
460   gMC->Gspos("UL02",2,"UCIM",xpos,ypos,zpos,0,"ONLY");
461   gMC->Gspos("UL02",3,"UCIO",xpos,ypos,zpos,0,"ONLY");
462   // PE layer (radiator)
463   zpos = 0;
464   gMC->Gspos("UL03",1,"UL02",xpos,ypos,zpos,0,"ONLY");
465   // Mylar layer (entrance window + HV cathode)   
466   zpos = kMyZpos;
467   gMC->Gspos("UL04",1,"UCII",xpos,ypos,zpos,0,"ONLY");
468   gMC->Gspos("UL04",2,"UCIM",xpos,ypos,zpos,0,"ONLY");
469   gMC->Gspos("UL04",3,"UCIO",xpos,ypos,zpos,0,"ONLY");
470   // Xe/Isobutane layer (drift volume) 
471   zpos = kDrZpos;
472   gMC->Gspos("UL05",1,"UCII",xpos,ypos,zpos,0,"ONLY");
473   gMC->Gspos("UL05",2,"UCIM",xpos,ypos,zpos,0,"ONLY");
474   gMC->Gspos("UL05",3,"UCIO",xpos,ypos,zpos,0,"ONLY");
475   // Xe/Isobutane layer (amplification volume)
476   zpos = kAmZpos;
477   gMC->Gspos("UL06",1,"UCII",xpos,ypos,zpos,0,"ONLY");
478   gMC->Gspos("UL06",2,"UCIM",xpos,ypos,zpos,0,"ONLY");
479   gMC->Gspos("UL06",3,"UCIO",xpos,ypos,zpos,0,"ONLY");
480
481   // Cu layer (pad plane)
482   zpos = kCuZpos;
483   gMC->Gspos("UL07",1,"UAII",xpos,ypos,zpos,0,"ONLY");
484   gMC->Gspos("UL07",2,"UAIM",xpos,ypos,zpos,0,"ONLY");
485   gMC->Gspos("UL07",3,"UAIO",xpos,ypos,zpos,0,"ONLY");
486   // G10 layer (support structure)
487   zpos = kSuZpos;
488   gMC->Gspos("UL08",1,"UAII",xpos,ypos,zpos,0,"ONLY");
489   gMC->Gspos("UL08",2,"UAIM",xpos,ypos,zpos,0,"ONLY");
490   gMC->Gspos("UL08",3,"UAIO",xpos,ypos,zpos,0,"ONLY");
491   // Cu layer (FEE + signal lines)
492   zpos = kFeZpos; 
493   gMC->Gspos("UL09",1,"UAII",xpos,ypos,zpos,0,"ONLY");
494   gMC->Gspos("UL09",2,"UAIM",xpos,ypos,zpos,0,"ONLY");
495   gMC->Gspos("UL09",3,"UAIO",xpos,ypos,zpos,0,"ONLY");
496   // PE layer (cooling devices)
497   zpos = kCoZpos;
498   gMC->Gspos("UL10",1,"UAII",xpos,ypos,zpos,0,"ONLY");
499   gMC->Gspos("UL10",2,"UAIM",xpos,ypos,zpos,0,"ONLY");
500   gMC->Gspos("UL10",3,"UAIO",xpos,ypos,zpos,0,"ONLY");
501   // Water layer (cooling)
502   zpos = kWaZpos;
503   gMC->Gspos("UL11",1,"UAII",xpos,ypos,zpos,0,"ONLY");
504   gMC->Gspos("UL11",1,"UAIM",xpos,ypos,zpos,0,"ONLY");
505   gMC->Gspos("UL11",1,"UAIO",xpos,ypos,zpos,0,"ONLY");
506
507   // Position the chambers in the TRD mother volume
508   for (iplan = 1; iplan <= kNplan; iplan++) {
509
510     // The inner chambers ---------------------------------------------------------------
511
512     // the aluminum frame
513     par_cha[0] = fCwidth[iplan-1]/2.;
514     par_cha[1] = fClengthI[iplan-1]/2.;
515     par_cha[2] = kCaframe/2.;
516     xpos       = 0.;
517     ypos       = 0.;
518     zpos       = kCheight - kCaframe/2. - kSheight/2. + (iplan-1) * (kCheight + kCspace);
519     gMC->Gsposp("UAFI",iplan       ,"TRD1",xpos,ypos,zpos,0,"MANY",par_cha,npar_cha);
520
521     // the inner part of the aluminum frame
522     par_cha[0] = fCwidth[iplan-1]/2.   - kCathick;
523     par_cha[1] = fClengthI[iplan-1]/2. - kCathick;
524     par_cha[2] = kCaframe/2.;
525     xpos       = 0.;
526     ypos       = 0.;
527     zpos       = kCheight - kCaframe/2. - kSheight/2. + (iplan-1) * (kCheight + kCspace);
528     gMC->Gsposp("UAII",iplan       ,"TRD1",xpos,ypos,zpos,0,"ONLY",par_cha,npar_cha);
529
530     // the carbon frame
531     par_cha[0] = fCwidth[iplan-1]/2.;
532     par_cha[1] = fClengthI[iplan-1]/2.;
533     par_cha[2] = kCcframe/2.;
534     xpos       = 0.;
535     ypos       = 0.;
536     zpos       = kCcframe/2.            - kSheight/2. + (iplan-1) * (kCheight + kCspace);
537     gMC->Gsposp("UCFI",iplan       ,"TRD1",xpos,ypos,zpos,0,"MANY",par_cha,npar_cha);
538
539     // the inner part of the carbon frame
540     par_cha[0] = fCwidth[iplan-1]/2.   - kCcthick;
541     par_cha[1] = fClengthI[iplan-1]/2. - kCcthick;
542     par_cha[2] = kCcframe/2.;
543     xpos       = 0.;
544     ypos       = 0.;
545     zpos       = kCcframe/2.            - kSheight/2. + (iplan-1) * (kCheight + kCspace);
546     gMC->Gsposp("UCII",iplan       ,"TRD1",xpos,ypos,zpos,0,"ONLY",par_cha,npar_cha);
547
548     // The middle chambers --------------------------------------------------------------
549
550     // the aluminum frame
551     par_cha[0] = fCwidth[iplan-1]/2.;
552     par_cha[1] = fClengthM1[iplan-1]/2.;
553     par_cha[2] = kCaframe/2.;
554     xpos       = 0.;
555     ypos       = fClengthI[iplan-1]/2.  + fClengthM1[iplan-1]/2.;
556     zpos       = kCheight - kCaframe/2. - kSheight/2. + (iplan-1) * (kCheight + kCspace);
557     gMC->Gsposp("UAFM",iplan         ,"TRD1",xpos, ypos,zpos,0,"MANY",par_cha,npar_cha);
558     gMC->Gsposp("UAFM",iplan+  kNplan,"TRD1",xpos,-ypos,zpos,0,"MANY",par_cha,npar_cha);
559
560     // the inner part of the aluminum frame
561     par_cha[0] = fCwidth[iplan-1]/2.    - kCathick;
562     par_cha[1] = fClengthM1[iplan-1]/2. - kCathick;
563     par_cha[2] = kCaframe/2.;
564     xpos       = 0.;
565     ypos       = fClengthI[iplan-1]/2.  + fClengthM1[iplan-1]/2.;
566     zpos       = kCheight - kCaframe/2. - kSheight/2. + (iplan-1) * (kCheight + kCspace);
567     gMC->Gsposp("UAIM",iplan         ,"TRD1",xpos, ypos,zpos,0,"ONLY",par_cha,npar_cha);
568     gMC->Gsposp("UAIM",iplan+  kNplan,"TRD1",xpos,-ypos,zpos,0,"ONLY",par_cha,npar_cha);
569
570     // the carbon frame
571     par_cha[0] = fCwidth[iplan-1]/2.;
572     par_cha[1] = fClengthM1[iplan-1]/2.;
573     par_cha[2] = kCcframe/2.;
574     xpos       = 0.;
575     ypos       = fClengthI[iplan-1]/2. + fClengthM1[iplan-1]/2.;
576     zpos       = kCcframe/2.           - kSheight/2. + (iplan-1) * (kCheight + kCspace);
577     gMC->Gsposp("UCFM",iplan         ,"TRD1",xpos, ypos,zpos,0,"MANY",par_cha,npar_cha);
578     gMC->Gsposp("UCFM",iplan+  kNplan,"TRD1",xpos,-ypos,zpos,0,"MANY",par_cha,npar_cha);
579
580     // the inner part of the carbon frame
581     par_cha[0] = fCwidth[iplan-1]/2.    - kCcthick;
582     par_cha[1] = fClengthM1[iplan-1]/2. - kCcthick;
583     par_cha[2] = kCcframe/2.;
584     xpos       = 0.;
585     ypos       = fClengthI[iplan-1]/2. + fClengthM1[iplan-1]/2.;
586     zpos       = kCcframe/2.           - kSheight/2. + (iplan-1) * (kCheight + kCspace);
587     gMC->Gsposp("UCIM",iplan         ,"TRD1",xpos, ypos,zpos,0,"ONLY",par_cha,npar_cha);
588     gMC->Gsposp("UCIM",iplan+  kNplan,"TRD1",xpos,-ypos,zpos,0,"ONLY",par_cha,npar_cha);
589
590     // Only for the geometry with holes
591     if (fHole) {
592
593       // the aluminum frame
594       par_cha[0] = fCwidth[iplan-1]/2.;
595       par_cha[1] = fClengthM2[iplan-1]/2.;
596       par_cha[2] = kCaframe/2.;
597       xpos       = 0.;
598       ypos       = fClengthM2[iplan-1]/2. - kSlenTR2/2.;
599       zpos       = kCheight - kCaframe/2. - kSheight/2. + (iplan-1) * (kCheight + kCspace);
600       gMC->Gsposp("UAFM",iplan+2*kNplan,"TRD2",xpos, ypos,zpos,0,"MANY",par_cha,npar_cha);
601
602       // the inner part of the aluminum frame
603       par_cha[0] = fCwidth[iplan-1]/2.    - kCathick;
604       par_cha[1] = fClengthM2[iplan-1]/2. - kCathick;
605       par_cha[2] = kCaframe/2.;
606       xpos       = 0.;
607       ypos       = fClengthM2[iplan-1]/2. - kSlenTR2/2.;
608       zpos       = kCheight - kCaframe/2. - kSheight/2. + (iplan-1) * (kCheight + kCspace);
609       gMC->Gsposp("UAIM",iplan+2*kNplan,"TRD2",xpos, ypos,zpos,0,"ONLY",par_cha,npar_cha);
610
611       // the carbon frame
612       par_cha[0] = fCwidth[iplan-1]/2.;
613       par_cha[1] = fClengthM2[iplan-1]/2.;
614       par_cha[2] = kCcframe/2.;
615       xpos       = 0.;
616       ypos       = fClengthM2[iplan-1]/2. - kSlenTR2/2.;
617       zpos       = kCcframe/2.            - kSheight/2. + (iplan-1) * (kCheight + kCspace);
618       gMC->Gsposp("UCFM",iplan+2*kNplan,"TRD2",xpos, ypos,zpos,0,"MANY",par_cha,npar_cha);
619
620       // the inner part of the carbon frame
621       par_cha[0] = fCwidth[iplan-1]/2.    - kCcthick;
622       par_cha[1] = fClengthM2[iplan-1]/2. - kCcthick;
623       par_cha[2] = kCcframe/2.;
624       xpos       = 0.;
625       ypos       = fClengthM2[iplan-1]/2. - kSlenTR2/2.;
626       zpos       = kCcframe/2.            - kSheight/2. + (iplan-1) * (kCheight + kCspace);
627       gMC->Gsposp("UCIM",iplan+2*kNplan,"TRD2",xpos, ypos,zpos,0,"ONLY",par_cha,npar_cha);
628       
629     }
630
631     // The outer chambers ---------------------------------------------------------------
632
633     // the aluminum frame
634     par_cha[0] = fCwidth[iplan-1]/2.;
635     par_cha[1] = fClengthO1[iplan-1]/2.;
636     par_cha[2] = kCaframe/2.;
637     xpos       = 0.;
638     ypos       = fClengthI[iplan-1]/2. + fClengthM1[iplan-1]    + fClengthO1[iplan-1]/2.;
639     zpos       = kCheight - kCaframe/2. - kSheight/2. + (iplan-1) * (kCheight + kCspace);
640     gMC->Gsposp("UAFO",iplan         ,"TRD1",xpos, ypos,zpos,0,"MANY",par_cha,npar_cha);
641     gMC->Gsposp("UAFO",iplan+  kNplan,"TRD1",xpos,-ypos,zpos,0,"MANY",par_cha,npar_cha);
642
643     // the inner part of the aluminum frame
644     par_cha[0] = fCwidth[iplan-1]/2.    - kCathick;
645     par_cha[1] = fClengthO1[iplan-1]/2. - kCathick;
646     par_cha[2] = kCaframe/2.;
647     xpos       = 0.;
648     ypos       = fClengthI[iplan-1]/2. + fClengthM1[iplan-1]    + fClengthO1[iplan-1]/2.;
649     zpos       = kCheight - kCaframe/2. - kSheight/2. + (iplan-1) * (kCheight + kCspace);
650     gMC->Gsposp("UAIO",iplan         ,"TRD1",xpos, ypos,zpos,0,"ONLY",par_cha,npar_cha);
651     gMC->Gsposp("UAIO",iplan+  kNplan,"TRD1",xpos,-ypos,zpos,0,"ONLY",par_cha,npar_cha);
652
653     // the carbon frame
654     par_cha[0] = fCwidth[iplan-1]/2.;
655     par_cha[1] = fClengthO1[iplan-1]/2.;
656     par_cha[2] = kCcframe/2.;
657     xpos       = 0.;
658     ypos       = fClengthI[iplan-1]/2. + fClengthM1[iplan-1]    + fClengthO1[iplan-1]/2.;
659     zpos       = kCcframe/2.           - kSheight/2. + (iplan-1) * (kCheight + kCspace);
660     gMC->Gsposp("UCFO",iplan,         "TRD1",xpos, ypos,zpos,0,"MANY",par_cha,npar_cha);
661     gMC->Gsposp("UCFO",iplan+  kNplan,"TRD1",xpos,-ypos,zpos,0,"MANY",par_cha,npar_cha);
662
663     // the inner part of the carbon frame
664     par_cha[0] = fCwidth[iplan-1]/2.    - kCcthick;
665     par_cha[1] = fClengthO1[iplan-1]/2. - kCcthick;
666     par_cha[2] = kCcframe/2.;
667     xpos       = 0.;
668     ypos       = fClengthI[iplan-1]/2. + fClengthM1[iplan-1]    + fClengthO1[iplan-1]/2.;
669     zpos       = kCcframe/2.           - kSheight/2. + (iplan-1) * (kCheight + kCspace);
670     gMC->Gsposp("UCIO",iplan         ,"TRD1",xpos, ypos,zpos,0,"ONLY",par_cha,npar_cha);
671     gMC->Gsposp("UCIO",iplan+  kNplan,"TRD1",xpos,-ypos,zpos,0,"ONLY",par_cha,npar_cha);
672
673     // Only for the geometry with holes
674     if (fHole) {
675
676       // the aluminum frame
677       par_cha[0] = fCwidth[iplan-1]/2.;
678       par_cha[1] = fClengthO2[iplan-1]/2.;
679       par_cha[2] = kCaframe/2.;
680       xpos       = 0.;
681       ypos       = fClengthM2[iplan-1]    + fClengthO2[iplan-1]/2. - kSlenTR2/2.;
682       zpos       = kCheight - kCaframe/2. - kSheight/2. + (iplan-1) * (kCheight + kCspace);
683       gMC->Gsposp("UAFO",iplan+2*kNplan,"TRD2",xpos, ypos,zpos,0,"MANY",par_cha,npar_cha);
684
685       // the inner part of the aluminum frame
686       par_cha[0] = fCwidth[iplan-1]/2.    - kCathick;
687       par_cha[1] = fClengthO2[iplan-1]/2. - kCathick;
688       par_cha[2] = kCaframe/2.;
689       xpos       = 0.;
690       ypos       = fClengthM2[iplan-1]    + fClengthO2[iplan-1]/2. - kSlenTR2/2.;
691       zpos       = kCheight - kCaframe/2. - kSheight/2. + (iplan-1) * (kCheight + kCspace);
692       gMC->Gsposp("UAIO",iplan+2*kNplan,"TRD2",xpos, ypos,zpos,0,"ONLY",par_cha,npar_cha);
693
694       // the carbon frame
695       par_cha[0] = fCwidth[iplan-1]/2.;
696       par_cha[1] = fClengthO2[iplan-1]/2.;
697       par_cha[2] = kCcframe/2.;
698       xpos       = 0.;
699       ypos       = fClengthM2[iplan-1]    + fClengthO2[iplan-1]/2. - kSlenTR2/2.;
700       zpos       = kCcframe/2.            - kSheight/2. + (iplan-1) * (kCheight + kCspace);
701       gMC->Gsposp("UCFO",iplan+2*kNplan,"TRD2",xpos, ypos,zpos,0,"MANY",par_cha,npar_cha);
702
703       // the inner part of the carbon frame
704       par_cha[0] = fCwidth[iplan-1]/2.    - kCcthick;
705       par_cha[1] = fClengthO2[iplan-1]/2. - kCcthick;
706       par_cha[2] = kCcframe/2.;
707       xpos       = 0.;
708       ypos       = fClengthM2[iplan-1]    + fClengthO2[iplan-1]/2. - kSlenTR2/2.;
709       zpos       = kCcframe/2.            - kSheight/2. + (iplan-1) * (kCheight + kCspace);
710       gMC->Gsposp("UCIO",iplan+2*kNplan,"TRD2",xpos, ypos,zpos,0,"ONLY",par_cha,npar_cha);
711
712       // the aluminum frame
713       par_cha[0] = fCwidth[iplan-1]/2.;
714       par_cha[1] = fClengthO3[iplan-1]/2.;
715       par_cha[2] = kCaframe/2.;
716       xpos       = 0.;
717       ypos       = fClengthO3[iplan-1]/2. - kSlenTR3/2.;
718       zpos       = kCheight - kCaframe/2. - kSheight/2. + (iplan-1) * (kCheight + kCspace);
719       gMC->Gsposp("UAFO",iplan+4*kNplan,"TRD3",xpos, ypos,zpos,0,"MANY",par_cha,npar_cha);
720
721       // the inner part of the aluminum frame
722       par_cha[0] = fCwidth[iplan-1]/2.    - kCathick;
723       par_cha[1] = fClengthO3[iplan-1]/2. - kCathick;
724       par_cha[2] = kCaframe/2.;
725       xpos       = 0.;
726       ypos       = fClengthO3[iplan-1]/2. - kSlenTR3/2.;
727       zpos       = kCheight - kCaframe/2. - kSheight/2. + (iplan-1) * (kCheight + kCspace);
728       gMC->Gsposp("UAIO",iplan+4*kNplan,"TRD3",xpos, ypos,zpos,0,"ONLY",par_cha,npar_cha);
729
730       // the carbon frame
731       par_cha[0] = fCwidth[iplan-1]/2.;
732       par_cha[1] = fClengthO3[iplan-1]/2.;
733       par_cha[2] = kCcframe/2.;
734       xpos       = 0.;
735       ypos       = fClengthO3[iplan-1]/2. - kSlenTR3/2.;
736       zpos       = kCcframe/2.            - kSheight/2. + (iplan-1) * (kCheight + kCspace);
737       gMC->Gsposp("UCFO",iplan+4*kNplan,"TRD3",xpos, ypos,zpos,0,"MANY",par_cha,npar_cha);
738
739       // the inner part of the carbon frame
740       par_cha[0] = fCwidth[iplan-1]/2.    - kCcthick;
741       par_cha[1] = fClengthO3[iplan-1]/2. - kCcthick;
742       par_cha[2] = kCcframe/2.;
743       xpos       = 0.;
744       ypos       = fClengthO3[iplan-1]/2. - kSlenTR3/2.;
745       zpos       = kCcframe/2.            - kSheight/2. + (iplan-1) * (kCheight + kCspace);
746       gMC->Gsposp("UCIO",iplan+4*kNplan,"TRD3",xpos, ypos,zpos,0,"ONLY",par_cha,npar_cha);
747
748     }
749
750   }
751
752   if (fHole) {
753     xpos     = 0.;
754     ypos     = 0.;
755     zpos     = 0.;
756     gMC->Gspos("TRD1",1,"BTR1",xpos,ypos,zpos,0,"ONLY");
757     gMC->Gspos("TRD2",1,"BTR2",xpos,ypos,zpos,0,"ONLY");
758     gMC->Gspos("TRD3",1,"BTR3",xpos,ypos,zpos,0,"ONLY");
759   }
760   else {
761     xpos     = 0.;
762     ypos     = 0.;
763     zpos     = 0.;
764     gMC->Gspos("TRD1",1,"BTR1",xpos,ypos,zpos,0,"ONLY");
765     gMC->Gspos("TRD1",2,"BTR2",xpos,ypos,zpos,0,"ONLY");
766     gMC->Gspos("TRD1",3,"BTR3",xpos,ypos,zpos,0,"ONLY");
767   }
768
769 }
770  
771 //_____________________________________________________________________________
772 void AliTRD::CreateMaterials()
773 {
774   //
775   // Create the materials for the TRD
776   // Origin Y.Foka
777   //
778
779   Int_t   ISXFLD = gAlice->Field()->Integ();
780   Float_t SXMGMX = gAlice->Field()->Max();
781   
782   // For polyethilene (CH2) 
783   Float_t ape[2] = { 12., 1. };
784   Float_t zpe[2] = {  6., 1. };
785   Float_t wpe[2] = {  1., 2. };
786   Float_t dpe    = 0.95;
787
788   // For mylar (C5H4O2) 
789   Float_t amy[3] = { 12., 1., 16. };
790   Float_t zmy[3] = {  6., 1.,  8. };
791   Float_t wmy[3] = {  5., 4.,  2. };
792   Float_t dmy    = 1.39;
793
794   // For CO2 
795   Float_t aco[2] = { 12., 16. };
796   Float_t zco[2] = {  6.,  8. };
797   Float_t wco[2] = {  1.,  2. };
798   Float_t dco    = 0.001977;
799
800   // For water
801   Float_t awa[2] = {  1., 16. };
802   Float_t zwa[2] = {  1.,  8. };
803   Float_t wwa[2] = {  2.,  1. };
804   Float_t dwa    = 1.0;
805
806   // For isobutane (C4H10)
807   Float_t ais[2] = { 12.,  1. };
808   Float_t zis[2] = {  6.,  1. };
809   Float_t wis[2] = {  4., 10. };
810   Float_t dis    = 0.00267;
811
812   // For Xe/CO2-gas-mixture 
813   // Xe-content of the Xe/CO2-mixture (90% / 10%) 
814   Float_t fxc    = .90;
815   // Xe-content of the Xe/Isobutane-mixture (97% / 3%) 
816   Float_t fxi    = .97;
817   Float_t dxe    = .005858;
818   
819   // General tracking parameter
820   Float_t tmaxfd = -10.;
821   Float_t stemax = -1e10;
822   Float_t deemax = -0.1;
823   Float_t epsil  =  1e-4;
824   Float_t stmin  = -0.001;
825   
826   Float_t absl, radl, d, buf[1];
827   Float_t agm[2], dgm, zgm[2], wgm[2];
828   Int_t   nbuf;
829   
830   //////////////////////////////////////////////////////////////////////////
831   //     Define Materials 
832   //////////////////////////////////////////////////////////////////////////
833
834   AliMaterial( 1, "Al $",  26.98, 13.0, 2.7     ,     8.9 ,    37.2);
835   AliMaterial( 2, "Air$",  14.61,  7.3, 0.001205, 30420.0 , 67500.0);
836   AliMaterial( 4, "Xe $", 131.29, 54.0, dxe     ,  1447.59,     0.0);
837   AliMaterial( 5, "Cu $",  63.54, 29.0, 8.96    ,     1.43,    14.8);
838   AliMaterial( 6, "C  $",  12.01,  6.0, 2.265   ,    18.8 ,    74.4);
839   AliMaterial(12, "G10$",  20.00, 10.0, 1.7     ,    19.4 ,   999.0);
840
841   // Mixtures 
842   AliMixture(3, "Polyethilene$",   ape, zpe, dpe, -2, wpe);
843   AliMixture(7, "Mylar$",          amy, zmy, dmy, -3, wmy);
844   AliMixture(8, "CO2$",            aco, zco, dco, -2, wco);
845   AliMixture(9, "Isobutane$",      ais, zis, dis, -2, wis);
846   AliMixture(13,"Water$",          awa, zwa, dwa, -2, wwa);
847
848   // Gas mixtures
849   Char_t namate[21];
850   // Xe/CO2-mixture
851   // Get properties of Xe 
852   gMC->Gfmate((*fIdmate)[4], namate, agm[0], zgm[0], d, radl, absl, buf, nbuf);
853   // Get properties of CO2 
854   gMC->Gfmate((*fIdmate)[8], namate, agm[1], zgm[1], d, radl, absl, buf, nbuf);
855   // Create gas mixture 
856   wgm[0] = fxc;
857   wgm[1] = 1. - fxc;
858   dgm    = wgm[0] * dxe + wgm[1] * dco;
859   AliMixture(10, "Gas mixture 1$", agm, zgm, dgm,  2, wgm);
860   // Xe/Isobutane-mixture
861   // Get properties of Xe 
862   gMC->Gfmate((*fIdmate)[4], namate, agm[0], zgm[0], d, radl, absl, buf, nbuf);
863   // Get properties of Isobutane
864   gMC->Gfmate((*fIdmate)[9], namate, agm[1], zgm[1], d, radl, absl, buf, nbuf);
865   // Create gas mixture 
866   wgm[0] = fxi;
867   wgm[1] = 1. - fxi;
868   dgm    = wgm[0] * dxe + wgm[1] * dis;
869   AliMixture(11, "Gas mixture 2$", agm, zgm, dgm,  2, wgm);
870  
871   //////////////////////////////////////////////////////////////////////////
872   //     Tracking Media Parameters 
873   //////////////////////////////////////////////////////////////////////////
874
875   // Al Frame 
876   AliMedium(1, "Al Frame$",   1, 0, ISXFLD, SXMGMX
877                 , tmaxfd, stemax, deemax, epsil, stmin);
878   // Air 
879   AliMedium(2, "Air$",        2, 0, ISXFLD, SXMGMX
880                 , tmaxfd, stemax, deemax, epsil, stmin);
881   // Polyethilene 
882   AliMedium(3, "Radiator$",   3, 0, ISXFLD, SXMGMX
883                 , tmaxfd, stemax, deemax, epsil, stmin);
884   // Xe 
885   AliMedium(4, "Xe$",         4, 1, ISXFLD, SXMGMX
886                 , tmaxfd, stemax, deemax, epsil, stmin);
887   // Cu pads 
888   AliMedium(5, "Padplane$",   5, 1, ISXFLD, SXMGMX
889                 , tmaxfd, stemax, deemax, epsil, stmin);
890   // Fee + cables 
891   AliMedium(6, "Readout$",    1, 0, ISXFLD, SXMGMX
892                 , tmaxfd, stemax, deemax, epsil, stmin);
893   // C frame 
894   AliMedium(7, "C Frame$",    6, 0, ISXFLD, SXMGMX
895                 , tmaxfd, stemax, deemax, epsil, stmin);
896   // Mylar foils 
897   AliMedium(8, "Mylar$",      7, 0, ISXFLD, SXMGMX
898                 , tmaxfd, stemax, deemax, epsil, stmin);
899   if (fGasMix == 1) {
900     // Gas-mixture (Xe/CO2) 
901     AliMedium(9, "Gas-mix$",   10, 1, ISXFLD, SXMGMX
902                   , tmaxfd, stemax, deemax, epsil, stmin);
903   }
904   else {
905     // Gas-mixture (Xe/Isobutane) 
906     AliMedium(9, "Gas-mix$",   11, 1, ISXFLD, SXMGMX
907                   , tmaxfd, stemax, deemax, epsil, stmin);
908   }
909   // Nomex-honeycomb (use carbon for the time being) 
910   AliMedium(10, "Nomex$",      6, 0, ISXFLD, SXMGMX
911                 , tmaxfd, stemax, deemax, epsil, stmin);
912   // Kapton foils (use Mylar for the time being) 
913   AliMedium(11, "Kapton$",     7, 0, ISXFLD, SXMGMX
914                 , tmaxfd, stemax, deemax, epsil, stmin);
915   // Gas-filling of the radiator 
916   AliMedium(12, "CO2$",        8, 0, ISXFLD, SXMGMX
917                 , tmaxfd, stemax, deemax, epsil, stmin);
918   // G10-plates
919   AliMedium(13, "G10-plates$",12, 0, ISXFLD, SXMGMX
920                 , tmaxfd, stemax, deemax, epsil, stmin);
921   // Cooling water
922   AliMedium(14, "Water$",     13, 0, ISXFLD, SXMGMX
923                 , tmaxfd, stemax, deemax, epsil, stmin);
924
925 }
926
927 //_____________________________________________________________________________
928 void AliTRD::DrawModule()
929 {
930   //
931   // Draw a shaded view of the Transition Radiation Detector version 0
932   //
933
934   // Set everything unseen
935   gMC->Gsatt("*"   ,"SEEN",-1);
936   
937   // Set ALIC mother transparent
938   gMC->Gsatt("ALIC","SEEN", 0);
939   
940   // Set the volumes visible
941   if (fHole) {
942     gMC->Gsatt("B071","SEEN", 0);
943     gMC->Gsatt("B074","SEEN", 0);
944     gMC->Gsatt("B075","SEEN", 0);
945     gMC->Gsatt("B077","SEEN", 0);
946     gMC->Gsatt("BTR1","SEEN", 0);
947     gMC->Gsatt("BTR2","SEEN", 0);
948     gMC->Gsatt("BTR3","SEEN", 0);
949     gMC->Gsatt("TRD1","SEEN", 0);
950     gMC->Gsatt("TRD2","SEEN", 0);
951     gMC->Gsatt("TRD3","SEEN", 0);
952   }
953   else {
954     gMC->Gsatt("B071","SEEN", 0);
955     gMC->Gsatt("B074","SEEN", 0);
956     gMC->Gsatt("B075","SEEN", 0);
957     gMC->Gsatt("B077","SEEN", 0);
958     gMC->Gsatt("BTR1","SEEN", 0);
959     gMC->Gsatt("BTR2","SEEN", 0);
960     gMC->Gsatt("BTR3","SEEN", 0);
961     gMC->Gsatt("TRD1","SEEN", 0);
962   }
963   gMC->Gsatt("UCII","SEEN", 0);
964   gMC->Gsatt("UCIM","SEEN", 0);
965   gMC->Gsatt("UCIO","SEEN", 0);
966   gMC->Gsatt("UL02","SEEN", 1);
967   gMC->Gsatt("UL05","SEEN", 1);
968   gMC->Gsatt("UL06","SEEN", 1);
969   
970   gMC->Gdopt("hide", "on");
971   gMC->Gdopt("shad", "on");
972   gMC->Gsatt("*", "fill", 7);
973   gMC->SetClipBox(".");
974   gMC->SetClipBox("*", 0, 2000, -2000, 2000, -2000, 2000);
975   gMC->DefaultRange();
976   gMC->Gdraw("alic", 40, 30, 0, 12, 9.4, .021, .021);
977   gMC->Gdhead(1111, "Transition Radiation Detector");
978   gMC->Gdman(18, 4, "MAN");
979
980 }
981
982 //_____________________________________________________________________________
983 Int_t AliTRD::DistancetoPrimitive(Int_t , Int_t )
984 {
985   //
986   // Distance between the mouse and the TRD detector on the screen
987   // Dummy routine
988   
989   return 9999;
990
991 }
992  
993 //_____________________________________________________________________________
994 void AliTRD::Init()
995 {
996   //
997   // Initialise the TRD detector after the geometry has been created
998   //
999
1000   Int_t i;
1001   Int_t iplan;
1002   
1003   printf("\n");
1004   for(i=0;i<35;i++) printf("*");
1005   printf(" TRD_INIT ");
1006   for(i=0;i<35;i++) printf("*");
1007   printf("\n");
1008   
1009   // Here the TRD initialisation code (if any!)
1010   if (fGasMix == 1) 
1011     printf("          Gas Mixture: 90%% Xe + 10%% CO2\n");
1012   else
1013     printf("          Gas Mixture: 97%% Xe + 3%% Isobutane\n");
1014
1015   if (fHole)
1016     printf("          Geometry with holes\n");
1017   else
1018     printf("          Full geometry\n");
1019
1020   // The default pad dimensions
1021   if (!(fRowPadSize))  fRowPadSize  = 4.5;
1022   if (!(fColPadSize))  fColPadSize  = 1.0;
1023   if (!(fTimeBinSize)) fTimeBinSize = 0.1;
1024
1025   // The maximum number of pads
1026   // and the position of pad 0,0,0 
1027   // 
1028   // chambers seen from the top:
1029   //     +----------------------------+
1030   //     |                            |
1031   //     |                            |     ^
1032   //     |                            | rphi|
1033   //     |                            |     |
1034   //     |0                           |     | 
1035   //     +----------------------------+     +------>
1036   //                                             z 
1037   // chambers seen from the side:           ^
1038   //     +----------------------------+ time|
1039   //     |                            |     |
1040   //     |0                           |     |
1041   //     +----------------------------+     +------>
1042   //                                             z
1043   //                                             
1044   for (iplan = 0; iplan < kNplan; iplan++) {
1045
1046     // The pad row (z-direction)
1047     for (Int_t isect = 0; isect < kNsect; isect++) {
1048       Float_t clengthI = fClengthI[iplan];
1049       Float_t clengthM = fClengthM1[iplan];
1050       Float_t clengthO = fClengthO1[iplan];
1051       if (fHole) {
1052         switch (isect) {
1053         case 12:
1054         case 13:
1055         case 14:
1056         case 15:
1057         case 16:
1058           clengthM = fClengthM2[iplan];
1059           clengthO = fClengthO2[iplan];
1060           break;
1061         case 4:
1062         case 5:
1063         case 6:
1064           clengthO = fClengthO3[iplan];
1065           break;
1066         };
1067       }
1068       fRowMax[iplan][0][isect] = 1 + TMath::Nint((clengthO - 2. * kCcthick) 
1069                                                            / fRowPadSize - 0.5);
1070       fRowMax[iplan][1][isect] = 1 + TMath::Nint((clengthM - 2. * kCcthick) 
1071                                                            / fRowPadSize - 0.5);
1072       fRowMax[iplan][2][isect] = 1 + TMath::Nint((clengthI - 2. * kCcthick) 
1073                                                            / fRowPadSize - 0.5);
1074       fRowMax[iplan][3][isect] = 1 + TMath::Nint((clengthM - 2. * kCcthick) 
1075                                                            / fRowPadSize - 0.5);
1076       fRowMax[iplan][4][isect] = 1 + TMath::Nint((clengthO - 2. * kCcthick) 
1077                                                            / fRowPadSize - 0.5);
1078       fRow0[iplan][0][isect]   = -clengthI/2. - clengthM - clengthO + kCcthick; 
1079       fRow0[iplan][1][isect]   = -clengthI/2. - clengthM            + kCcthick;
1080       fRow0[iplan][2][isect]   = -clengthI/2.                       + kCcthick;
1081       fRow0[iplan][3][isect]   =  clengthI/2.                       + kCcthick; 
1082       fRow0[iplan][4][isect]   =  clengthI/2. + clengthM            + kCcthick; 
1083     }
1084
1085     // The pad column (rphi-direction)  
1086     fColMax[iplan]    = 1 + TMath::Nint((fCwidth[iplan] - 2. * kCcthick) 
1087                                                         / fColPadSize - 0.5);
1088     fCol0[iplan]      = -fCwidth[iplan]/2. + kCcthick;
1089
1090   }
1091
1092   // The time bucket
1093   fTimeMax = 1 + TMath::Nint(kDrThick / fTimeBinSize - 0.5);
1094   for (iplan = 0; iplan < kNplan; iplan++) {
1095     fTime0[iplan]   = kRmin + kCcframe/2. + kDrZpos - 0.5 * kDrThick
1096                             + iplan * (kCheight + kCspace);
1097   } 
1098
1099 }
1100
1101 //_____________________________________________________________________________
1102 void AliTRD::MakeBranch(Option_t* option)
1103 {
1104   //
1105   // Create Tree branches for the TRD digits and cluster.
1106   //
1107
1108   Int_t  buffersize = 4000;
1109   Char_t branchname[15];
1110
1111   AliDetector::MakeBranch(option);
1112
1113   Char_t *D = strstr(option,"D");
1114   sprintf(branchname,"%s",GetName());
1115   if (fDigits   && gAlice->TreeD() && D) {
1116     gAlice->TreeD()->Branch(branchname,&fDigits,  buffersize);
1117     printf("* AliTRD::MakeBranch * Making Branch %s for digits in TreeD\n",branchname);
1118   }
1119
1120   sprintf(branchname,"%scluster",GetName());
1121   if (fClusters && gAlice->TreeD() && D) {
1122     gAlice->TreeD()->Branch(branchname,&fClusters,buffersize);
1123     printf("* AliTRD::MakeBranch * Making Branch %s for cluster in TreeD\n",branchname);
1124   }
1125
1126 }
1127
1128 //_____________________________________________________________________________
1129 void AliTRD::SetTreeAddress()
1130 {
1131   //
1132   // Set the branch addresses for the trees.
1133   //
1134
1135   Char_t branchname[15];
1136
1137   AliDetector::SetTreeAddress();
1138
1139   TBranch *branch;
1140   TTree   *treeD = gAlice->TreeD();
1141
1142   if (treeD) {
1143     sprintf(branchname,"%scluster",GetName());    
1144     if (fClusters) {
1145       branch = treeD->GetBranch(branchname);
1146       if (branch) branch->SetAddress(&fClusters);
1147     }
1148   }
1149
1150 }
1151
1152 //_____________________________________________________________________________
1153 void AliTRD::SetGasMix(Int_t imix)
1154 {
1155   //
1156   // Defines the gas mixture (imix=0:  Xe/Isobutane imix=1: Xe/CO2)
1157   //
1158   
1159   if ((imix < 0) || (imix > 1)) {
1160     printf("Wrong input value: %d\n",imix);
1161     printf("Use standard setting\n");
1162     fGasMix = 0;
1163     return;
1164   }
1165
1166   fGasMix = imix;
1167
1168 }
1169
1170 //______________________________________________________________________________
1171 void AliTRD::Streamer(TBuffer &R__b)
1172 {
1173    // Stream an object of class AliTRD.
1174
1175    if (R__b.IsReading()) {
1176       Version_t R__v = R__b.ReadVersion(); if (R__v) { }
1177       AliDetector::Streamer(R__b);
1178       R__b >> fGasMix;
1179       R__b.ReadStaticArray(fClengthI);
1180       R__b.ReadStaticArray(fClengthM1);
1181       R__b.ReadStaticArray(fClengthM2);
1182       R__b.ReadStaticArray(fClengthO1);
1183       R__b.ReadStaticArray(fClengthO2);
1184       R__b.ReadStaticArray(fClengthO3);
1185       R__b.ReadStaticArray(fCwidth);
1186       R__b.ReadStaticArray((int*)fRowMax);
1187       R__b.ReadStaticArray(fColMax);
1188       R__b >> fTimeMax;
1189       R__b.ReadStaticArray((float*)fRow0);
1190       R__b.ReadStaticArray(fCol0);
1191       R__b.ReadStaticArray(fTime0);
1192       R__b >> fRowPadSize;
1193       R__b >> fColPadSize;
1194       R__b >> fTimeBinSize;
1195       R__b >> fHole;
1196       // Stream the pointers but not the TClonesArray
1197       R__b >> fClusters;     // diff
1198       //R__b >> fNclusters;
1199    } else {
1200       R__b.WriteVersion(AliTRD::IsA());
1201       AliDetector::Streamer(R__b);
1202       R__b << fGasMix;
1203       R__b.WriteArray(fClengthI, 6);
1204       R__b.WriteArray(fClengthM1, 6);
1205       R__b.WriteArray(fClengthM2, 6);
1206       R__b.WriteArray(fClengthO1, 6);
1207       R__b.WriteArray(fClengthO2, 6);
1208       R__b.WriteArray(fClengthO3, 6);
1209       R__b.WriteArray(fCwidth, 6);
1210       R__b.WriteArray((int*)fRowMax, 540);
1211       R__b.WriteArray(fColMax, 6);
1212       R__b << fTimeMax;
1213       R__b.WriteArray((float*)fRow0, 540);
1214       R__b.WriteArray(fCol0, 6);
1215       R__b.WriteArray(fTime0, 6);
1216       R__b << fRowPadSize;
1217       R__b << fColPadSize;
1218       R__b << fTimeBinSize;
1219       R__b << fHole;
1220       // Stream the pointers but not the TClonesArrays
1221       R__b << fClusters;     // diff
1222       //R__b << fNclusters;
1223    }
1224
1225 }
1226
1227 ClassImp(AliTRDhit)
1228  
1229 //_____________________________________________________________________________
1230 AliTRDhit::AliTRDhit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits)
1231           :AliHit(shunt, track)
1232 {
1233   //
1234   // Create a TRD hit
1235   //
1236
1237   // Store volume hierarchy
1238   fSector  = vol[0]; 
1239   fChamber = vol[1];
1240   fPlane   = vol[2];
1241   
1242   // Store position and charge
1243   fX       = hits[0];
1244   fY       = hits[1];
1245   fZ       = hits[2];
1246   fQ       = hits[3];
1247
1248 }
1249
1250 ClassImp(AliTRDdigit)
1251
1252 //_____________________________________________________________________________
1253 AliTRDdigit::AliTRDdigit(Int_t *tracks, Int_t *digits)
1254             :AliDigit(tracks)
1255 {
1256   //
1257   // Create a TRD digit
1258   //
1259
1260   // Store the volume hierarchy
1261   fSector  = digits[0];
1262   fChamber = digits[1];
1263   fPlane   = digits[2];
1264
1265   // Store the row, pad, and time bucket number
1266   fRow     = digits[3];
1267   fCol     = digits[4];
1268   fTime    = digits[5];
1269
1270   // Store the signal amplitude
1271   fSignal  = digits[6];
1272
1273 }
1274
1275 ClassImp(AliTRDcluster)
1276
1277 //_____________________________________________________________________________
1278 AliTRDcluster::AliTRDcluster(Int_t *tracks, Int_t *cluster, Float_t* position)
1279               :TObject()
1280 {
1281   //
1282   // Create a TRD cluster
1283   //
1284
1285   fSector    = cluster[0];
1286   fChamber   = cluster[1];
1287   fPlane     = cluster[2];
1288
1289   fTimeSlice = cluster[3];
1290   fEnergy    = cluster[4];
1291
1292   fX         = position[0];
1293   fY         = position[1];
1294   fZ         = position[2];
1295
1296   fTracks[0] = tracks[0];
1297   fTracks[1] = tracks[1];
1298   fTracks[2] = tracks[2];
1299
1300 }
1301