]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRD.cxx
Major upgrade of AliRoot code
[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.23  2000/11/01 14:53:20  cblume
19 Merge with TRD-develop
20
21
22 Revision 1.17.2.6  2000/10/15 23:29:08  cblume
23 Introduced more detailed geometry for the display
24
25 Revision 1.17.2.5  2000/10/06 16:49:46  cblume
26 Made Getters const
27
28 Revision 1.17.2.4  2000/10/04 16:34:57  cblume
29 Replace include files by forward declarations
30
31 Revision 1.17.2.3  2000/09/22 14:45:17  cblume
32 Included changes for the tracking
33
34 Revision 1.17.2.2  2000/09/18 13:25:13  cblume
35 Included LoadPoints() method to display the TR photons
36
37 Revision 1.22  2000/10/02 21:28:19  fca
38 Removal of useless dependecies via forward declarations
39
40 Revision 1.21  2000/06/09 11:10:07  cblume
41 Compiler warnings and coding conventions, next round
42
43 Revision 1.20  2000/06/08 18:32:57  cblume
44 Make code compliant to coding conventions
45
46 Revision 1.19  2000/06/07 16:25:37  cblume
47 Try to remove compiler warnings on Sun and HP
48
49 Revision 1.18  2000/05/08 16:17:27  cblume
50 Merge TRD-develop
51
52 Revision 1.21  2000/06/09 11:10:07  cblume
53 Compiler warnings and coding conventions, next round
54
55 Revision 1.20  2000/06/08 18:32:57  cblume
56 Make code compliant to coding conventions
57
58 Revision 1.19  2000/06/07 16:25:37  cblume
59 Try to remove compiler warnings on Sun and HP
60
61 Revision 1.18  2000/05/08 16:17:27  cblume
62 Merge TRD-develop
63
64 Revision 1.17.2.1  2000/05/08 14:28:59  cblume
65 Introduced SetPHOShole() and SetRICHhole(). AliTRDrecPoint container is now a TObjArray
66
67 Revision 1.17  2000/02/28 19:10:26  cblume
68 Include the new TRD classes
69
70 Revision 1.16.2.2  2000/02/28 17:53:24  cblume
71 Introduce TRD geometry classes
72
73 Revision 1.16.2.1  2000/02/28 17:04:19  cblume
74 Include functions and data members for AliTRDrecPoint
75
76 Revision 1.16  2000/01/19 17:17:35  fca
77 Introducing a list of lists of hits -- more hits allowed for detector now
78
79 Revision 1.15  1999/11/02 17:04:25  fca
80 Small syntax change for HP compiler
81
82 Revision 1.14  1999/11/02 16:57:02  fca
83 Avoid non ansi warnings on HP compilers
84
85 Revision 1.13  1999/11/02 16:35:56  fca
86 New version of TRD introduced
87
88 Revision 1.12  1999/11/01 20:41:51  fca
89 Added protections against using the wrong version of FRAME
90
91 Revision 1.11  1999/09/29 09:24:34  fca
92 Introduction of the Copyright and cvs Log
93
94 */
95
96 ///////////////////////////////////////////////////////////////////////////////
97 //                                                                           //
98 //  Transition Radiation Detector                                            //
99 //  This class contains the basic functions for the Transition Radiation     //
100 //  Detector.                                                                //
101 //                                                                           //
102 ///////////////////////////////////////////////////////////////////////////////
103
104 #include <stdlib.h>
105 #include <iostream.h>
106
107 #include <TMath.h>
108 #include <TNode.h>
109 #include <TGeometry.h>
110 #include <TTree.h>                                                              
111 #include <TPGON.h> 
112
113 #include "AliRun.h"
114 #include "AliConst.h"
115 #include "AliDigit.h"
116 #include "AliMagF.h"
117 #include "AliMC.h"                                                              
118  
119 #include "AliTRD.h"
120 #include "AliTRDhit.h"
121 #include "AliTRDpoints.h"
122 #include "AliTRDdigit.h"
123 #include "AliTRDdigitizer.h"
124 #include "AliTRDclusterizer.h"
125 #include "AliTRDgeometryHole.h"
126 #include "AliTRDgeometryFull.h"
127 #include "AliTRDrecPoint.h"
128 #include "AliTRDdigitsManager.h"
129
130 ClassImp(AliTRD)
131  
132 //_____________________________________________________________________________
133 AliTRD::AliTRD()
134 {
135   //
136   // Default constructor
137   //
138
139   fIshunt      = 0;
140   fGasMix      = 0;
141   fHits        = 0;
142   fDigits      = 0;
143
144   fRecPoints   = 0;
145   fNRecPoints  = 0;
146
147   fGeometry    = 0;
148
149   fGasDensity  = 0;
150   fFoilDensity = 0;
151
152   fDrawTR      = 0;
153   fDisplayType = 0; 
154
155 }
156  
157 //_____________________________________________________________________________
158 AliTRD::AliTRD(const char *name, const char *title)
159        : AliDetector(name,title)
160 {
161   //
162   // Standard constructor for the TRD
163   //
164
165   // Check that FRAME is there otherwise we have no place where to
166   // put TRD
167   AliModule* frame = gAlice->GetModule("FRAME");
168   if (!frame) {
169     Error("Ctor","TRD needs FRAME to be present\n");
170     exit(1);
171   } 
172
173   // Define the TRD geometry according to the FRAME geometry
174   if      (frame->IsVersion() == 0) {
175     // Geometry with hole
176     fGeometry = new AliTRDgeometryHole();
177   }
178   else if (frame->IsVersion() == 1) {
179     // Geometry without hole
180     fGeometry = new AliTRDgeometryFull();
181   }
182   else {
183     Error("Ctor","Could not find valid FRAME version\n");
184     exit(1);
185   }
186
187   // Allocate the hit array
188   fHits        = new TClonesArray("AliTRDhit"     ,405);
189   gAlice->AddHitList(fHits);
190
191   // Allocate the digits array
192   fDigits      = 0;
193
194   // Allocate the rec point array
195   fRecPoints   = new TObjArray(400);
196   fNRecPoints  = 0;
197    
198   fIshunt      = 0;
199   fGasMix      = 0;
200
201   fGasDensity  = 0;
202   fFoilDensity = 0;
203
204   fDrawTR      = 0;
205   fDisplayType = 0;
206
207   SetMarkerColor(kWhite);   
208
209 }
210
211 //_____________________________________________________________________________
212 AliTRD::AliTRD(const AliTRD &trd)
213 {
214   //
215   // Copy constructor
216   //
217
218   ((AliTRD &) trd).Copy(*this);
219
220 }
221
222 //_____________________________________________________________________________
223 AliTRD::~AliTRD()
224 {
225   //
226   // TRD destructor
227   //
228
229   fIshunt = 0;
230
231   delete fGeometry;
232   delete fHits;
233   delete fRecPoints;
234
235 }
236
237 //_____________________________________________________________________________
238 void AliTRD::AddRecPoint(Float_t *pos, Int_t *digits, Int_t det, Float_t amp
239                        , Int_t *tracks)
240 {
241   //
242   // Add a reconstructed point for the TRD
243   //
244
245   AliTRDrecPoint *recPoint = new AliTRDrecPoint();
246   TVector3        posVec(pos[0],pos[1],pos[2]);
247   recPoint->SetLocalPosition(posVec);
248   recPoint->SetDetector(det);
249   recPoint->SetEnergy(amp);
250   for (Int_t iDigit = 0; iDigit < 3; iDigit++) {
251     recPoint->AddDigit(digits[iDigit]);
252   }
253
254   recPoint->AddTrackIndex(tracks);
255
256   recPoint->SetTrackingYZ(0.,0.);  // variance values set inside
257   fRecPoints->Add(recPoint);
258
259 }
260 //___________________________________________
261 void AliTRD::SDigits2Digits()
262 {
263   //
264   // Create digits
265   //
266   AliTRDdigitizer *Digitizer = new AliTRDdigitizer("digitizer","TRD digitizer class");
267
268   // Set the parameter
269   Digitizer->SetDiffusion();
270   Digitizer->SetVerbose(1);
271   
272   //Digitizer->SetExB();
273   //Digitizer->SetElAttach();
274   //Digitizer->SetAttachProb();
275
276   Digitizer->InitDetector();
277     
278   // Create the digits
279   Digitizer->MakeDigits();
280   cout<<"After MakeDigits"<<endl;
281   
282   // Write the digits into the input file
283   if (Digitizer->Digits()->MakeBranch(fDigitsFile))
284   {
285     Digitizer->WriteDigits();
286     cout<<"After write digits"<<endl;
287
288     // Save the digitizer class in the AliROOT 
289     Digitizer->Write();
290     cout<<"After write digitizer"<<endl;
291   }
292 }
293
294 //_____________________________________________________________________________
295 void AliTRD::AddDigit(Int_t *digits, Int_t *amp)
296 {
297   //
298   // Add a digit for the TRD
299   //
300
301   TClonesArray &ldigits = *fDigits;
302   new(ldigits[fNdigits++]) AliTRDdigit(kFALSE,digits,amp);
303
304 }
305
306 //_____________________________________________________________________________
307 void AliTRD::AddHit(Int_t track, Int_t det, Float_t *hits, Int_t q)
308 {
309   //
310   // Add a hit for the TRD
311   //
312
313   TClonesArray &lhits = *fHits;
314   new(lhits[fNhits++]) AliTRDhit(fIshunt,track,det,hits,q);
315
316 }
317
318 //_____________________________________________________________________________
319 void AliTRD::BuildGeometry()
320 {
321   //
322   // Create the ROOT TNode geometry for the TRD
323   //
324
325   TNode *node, *top;
326   TPGON *pgon;
327
328   Float_t rmin, rmax;
329   Float_t zmax1, zmax2;
330  
331   const Int_t kColorTRD = 46;
332   
333   // Find the top node alice
334   top = gAlice->GetGeometry()->GetNode("alice");
335   
336   switch (fDisplayType) {
337
338   case 0:
339
340     pgon = new TPGON("S_TRD","TRD","void",0,360,AliTRDgeometry::Nsect(),4);
341     rmin = AliTRDgeometry::Rmin();
342     rmax = AliTRDgeometry::Rmax();
343     pgon->DefineSection(0,-AliTRDgeometry::Zmax1(),rmax,rmax);
344     pgon->DefineSection(1,-AliTRDgeometry::Zmax2(),rmin,rmax);
345     pgon->DefineSection(2, AliTRDgeometry::Zmax2(),rmin,rmax);
346     pgon->DefineSection(3, AliTRDgeometry::Zmax1(),rmax,rmax);
347     top->cd();
348     node = new TNode("TRD","TRD","S_TRD",0,0,0,"");
349     node->SetLineColor(kColorTRD);
350     fNodes->Add(node);
351
352     break;
353
354   case 1:
355
356     Float_t slope = (AliTRDgeometry::Zmax1() - AliTRDgeometry::Zmax2())
357                   / (AliTRDgeometry::Rmax()  - AliTRDgeometry::Rmin());
358
359     rmin  = AliTRDgeometry::Rmin() + AliTRDgeometry::RaThick();
360     rmax  = rmin + AliTRDgeometry::DrThick();
361     zmax2 = AliTRDgeometry::Zmax2() + slope * AliTRDgeometry::RaThick();
362     zmax1 = zmax2 + slope * AliTRDgeometry::DrThick();
363     Char_t name[7];
364
365     for (Int_t iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) {
366
367       sprintf(name,"S_TRD%d",iPlan);
368       pgon  = new TPGON(name,"TRD","void",0,360,AliTRDgeometry::Nsect(),4);
369       pgon->DefineSection(0,-zmax1,rmax,rmax);
370       pgon->DefineSection(1,-zmax2,rmin,rmax);
371       pgon->DefineSection(2, zmax2,rmin,rmax);
372       pgon->DefineSection(3, zmax1,rmax,rmax);
373       top->cd();
374       node = new TNode("TRD","TRD",name,0,0,0,"");
375       node->SetLineColor(kColorTRD);
376       fNodes->Add(node);
377
378       Float_t height = AliTRDgeometry::Cheight() + AliTRDgeometry::Cspace(); 
379       rmin  = rmin  + height;
380       rmax  = rmax  + height;
381       zmax1 = zmax1 + slope * height;
382       zmax2 = zmax2 + slope * height;
383
384     }
385
386     break;
387
388   };
389
390 }
391  
392 //_____________________________________________________________________________
393 void AliTRD::Copy(TObject &trd)
394 {
395   //
396   // Copy function
397   //
398
399   ((AliTRD &) trd).fGasMix      = fGasMix;
400   ((AliTRD &) trd).fGeometry    = fGeometry;       
401   ((AliTRD &) trd).fRecPoints   = fRecPoints;
402   ((AliTRD &) trd).fNRecPoints  = fNRecPoints;
403   ((AliTRD &) trd).fGasDensity  = fGasDensity;
404   ((AliTRD &) trd).fFoilDensity = fFoilDensity;
405   ((AliTRD &) trd).fDrawTR      = fDrawTR;
406   ((AliTRD &) trd).fDisplayType = fDisplayType;
407
408   //AliDetector::Copy(trd);
409
410 }
411
412 //_____________________________________________________________________________
413 void AliTRD::CreateGeometry()
414 {
415   //
416   // Creates the volumes for the TRD chambers
417   //
418
419   // Check that FRAME is there otherwise we have no place where to put the TRD
420   AliModule* frame = gAlice->GetModule("FRAME");
421   if (!frame) {
422     printf(" The TRD needs the FRAME to be defined first\n");
423     return;
424   }
425
426   fGeometry->CreateGeometry(fIdtmed->GetArray() - 1299);
427
428 }
429  
430 //_____________________________________________________________________________
431 void AliTRD::CreateMaterials()
432 {
433   //
434   // Create the materials for the TRD
435   // Origin Y.Foka
436   //
437
438   Int_t   isxfld = gAlice->Field()->Integ();
439   Float_t sxmgmx = gAlice->Field()->Max();
440   
441   // For polyethilene (CH2) 
442   Float_t ape[2] = { 12., 1. };
443   Float_t zpe[2] = {  6., 1. };
444   Float_t wpe[2] = {  1., 2. };
445   Float_t dpe    = 0.95;
446
447   // For mylar (C5H4O2) 
448   Float_t amy[3] = { 12., 1., 16. };
449   Float_t zmy[3] = {  6., 1.,  8. };
450   Float_t wmy[3] = {  5., 4.,  2. };
451   Float_t dmy    = 1.39;
452
453   // For CO2 
454   Float_t aco[2] = { 12., 16. };
455   Float_t zco[2] = {  6.,  8. };
456   Float_t wco[2] = {  1.,  2. };
457   Float_t dco    = 0.001977;
458
459   // For water
460   Float_t awa[2] = {  1., 16. };
461   Float_t zwa[2] = {  1.,  8. };
462   Float_t wwa[2] = {  2.,  1. };
463   Float_t dwa    = 1.0;
464
465   // For isobutane (C4H10)
466   Float_t ais[2] = { 12.,  1. };
467   Float_t zis[2] = {  6.,  1. };
468   Float_t wis[2] = {  4., 10. };
469   Float_t dis    = 0.00267;
470
471   // For Xe/CO2-gas-mixture 
472   // Xe-content of the Xe/CO2-mixture (90% / 10%) 
473   Float_t fxc    = .90;
474   // Xe-content of the Xe/Isobutane-mixture (97% / 3%) 
475   Float_t fxi    = .97;
476   Float_t dxe    = .005858;
477   
478   // General tracking parameter
479   Float_t tmaxfd = -10.;
480   Float_t stemax = -1e10;
481   Float_t deemax = -0.1;
482   Float_t epsil  =  1e-4;
483   Float_t stmin  = -0.001;
484   
485   Float_t absl, radl, d, buf[1];
486   Float_t agm[2], zgm[2], wgm[2];
487   Float_t dgm1, dgm2;
488   Int_t   nbuf;
489   
490   //////////////////////////////////////////////////////////////////////////
491   //     Define Materials 
492   //////////////////////////////////////////////////////////////////////////
493
494   AliMaterial( 1, "Al $",  26.98, 13.0, 2.7     ,     8.9 ,    37.2);
495   AliMaterial( 2, "Air$",  14.61,  7.3, 0.001205, 30420.0 , 67500.0);
496   AliMaterial( 4, "Xe $", 131.29, 54.0, dxe     ,  1447.59,     0.0);
497   AliMaterial( 5, "Cu $",  63.54, 29.0, 8.96    ,     1.43,    14.8);
498   AliMaterial( 6, "C  $",  12.01,  6.0, 2.265   ,    18.8 ,    74.4);
499   AliMaterial(12, "G10$",  20.00, 10.0, 1.7     ,    19.4 ,   999.0);
500
501   // Mixtures 
502   AliMixture(3, "Polyethilene$",   ape, zpe, dpe, -2, wpe);
503   AliMixture(7, "Mylar$",          amy, zmy, dmy, -3, wmy);
504   AliMixture(8, "CO2$",            aco, zco, dco, -2, wco);
505   AliMixture(9, "Isobutane$",      ais, zis, dis, -2, wis);
506   AliMixture(13,"Water$",          awa, zwa, dwa, -2, wwa);
507
508   // Gas mixtures
509   Char_t namate[21];
510   // Xe/CO2-mixture
511   // Get properties of Xe 
512   gMC->Gfmate((*fIdmate)[4], namate, agm[0], zgm[0], d, radl, absl, buf, nbuf);
513   // Get properties of CO2 
514   gMC->Gfmate((*fIdmate)[8], namate, agm[1], zgm[1], d, radl, absl, buf, nbuf);
515   // Create gas mixture 
516   wgm[0] = fxc;
517   wgm[1] = 1. - fxc;
518   dgm1   = wgm[0] * dxe + wgm[1] * dco;
519   AliMixture(10, "Gas mixture 1$", agm, zgm, dgm1,  2, wgm);
520   // Xe/Isobutane-mixture
521   // Get properties of Xe 
522   gMC->Gfmate((*fIdmate)[4], namate, agm[0], zgm[0], d, radl, absl, buf, nbuf);
523   // Get properties of Isobutane
524   gMC->Gfmate((*fIdmate)[9], namate, agm[1], zgm[1], d, radl, absl, buf, nbuf);
525   // Create gas mixture 
526   wgm[0] = fxi;
527   wgm[1] = 1. - fxi;
528   dgm2   = wgm[0] * dxe + wgm[1] * dis;
529   AliMixture(11, "Gas mixture 2$", agm, zgm, dgm2,  2, wgm);
530  
531   //////////////////////////////////////////////////////////////////////////
532   //     Tracking Media Parameters 
533   //////////////////////////////////////////////////////////////////////////
534
535   // Al Frame 
536   AliMedium(1, "Al Frame$",   1, 0, isxfld, sxmgmx
537                 , tmaxfd, stemax, deemax, epsil, stmin);
538   // Air 
539   AliMedium(2, "Air$",        2, 0, isxfld, sxmgmx
540                 , tmaxfd, stemax, deemax, epsil, stmin);
541   // Polyethilene 
542   AliMedium(3, "Radiator$",   3, 0, isxfld, sxmgmx
543                 , tmaxfd, stemax, deemax, epsil, stmin);
544   // Xe 
545   AliMedium(4, "Xe$",         4, 1, isxfld, sxmgmx
546                 , tmaxfd, stemax, deemax, epsil, stmin);
547   // Cu pads 
548   AliMedium(5, "Padplane$",   5, 1, isxfld, sxmgmx
549                 , tmaxfd, stemax, deemax, epsil, stmin);
550   // Fee + cables 
551   AliMedium(6, "Readout$",    1, 0, isxfld, sxmgmx
552                 , tmaxfd, stemax, deemax, epsil, stmin);
553   // C frame 
554   AliMedium(7, "C Frame$",    6, 0, isxfld, sxmgmx
555                 , tmaxfd, stemax, deemax, epsil, stmin);
556   // Mylar foils 
557   AliMedium(8, "Mylar$",      7, 0, isxfld, sxmgmx
558                 , tmaxfd, stemax, deemax, epsil, stmin);
559   if (fGasMix == 1) {
560     // Gas-mixture (Xe/CO2) 
561     AliMedium(9, "Gas-mix$",   10, 1, isxfld, sxmgmx
562                   , tmaxfd, stemax, deemax, epsil, stmin);
563   }
564   else {
565     // Gas-mixture (Xe/Isobutane) 
566     AliMedium(9, "Gas-mix$",   11, 1, isxfld, sxmgmx
567                   , tmaxfd, stemax, deemax, epsil, stmin);
568   }
569   // Nomex-honeycomb (use carbon for the time being) 
570   AliMedium(10, "Nomex$",      6, 0, isxfld, sxmgmx
571                 , tmaxfd, stemax, deemax, epsil, stmin);
572   // Kapton foils (use Mylar for the time being) 
573   AliMedium(11, "Kapton$",     7, 0, isxfld, sxmgmx
574                 , tmaxfd, stemax, deemax, epsil, stmin);
575   // Gas-filling of the radiator 
576   AliMedium(12, "CO2$",        8, 0, isxfld, sxmgmx
577                 , tmaxfd, stemax, deemax, epsil, stmin);
578   // G10-plates
579   AliMedium(13, "G10-plates$",12, 0, isxfld, sxmgmx
580                 , tmaxfd, stemax, deemax, epsil, stmin);
581   // Cooling water
582   AliMedium(14, "Water$",     13, 0, isxfld, sxmgmx
583                 , tmaxfd, stemax, deemax, epsil, stmin);
584
585   // Save the density values for the TRD absorbtion
586   fFoilDensity = dmy;
587   if (fGasMix == 1)
588     fGasDensity = dgm1;
589   else
590     fGasDensity = dgm2;
591
592 }
593
594 //_____________________________________________________________________________
595 void AliTRD::DrawModule()
596 {
597   //
598   // Draw a shaded view of the Transition Radiation Detector version 0
599   //
600
601   // Set everything unseen
602   gMC->Gsatt("*"   ,"SEEN",-1);
603   
604   // Set ALIC mother transparent
605   gMC->Gsatt("ALIC","SEEN", 0);
606   
607   // Set the volumes visible
608   if (fGeometry->IsVersion() == 0) {
609     gMC->Gsatt("B071","SEEN", 0);
610     gMC->Gsatt("B074","SEEN", 0);
611     gMC->Gsatt("B075","SEEN", 0);
612     gMC->Gsatt("B077","SEEN", 0);
613     gMC->Gsatt("BTR1","SEEN", 0);
614     gMC->Gsatt("BTR2","SEEN", 0);
615     gMC->Gsatt("BTR3","SEEN", 0);
616     gMC->Gsatt("TRD1","SEEN", 0);
617     gMC->Gsatt("TRD2","SEEN", 0);
618     gMC->Gsatt("TRD3","SEEN", 0);
619   }
620   else {
621     gMC->Gsatt("B071","SEEN", 0);
622     gMC->Gsatt("B074","SEEN", 0);
623     gMC->Gsatt("B075","SEEN", 0);
624     gMC->Gsatt("B077","SEEN", 0);
625     gMC->Gsatt("BTR1","SEEN", 0);
626     gMC->Gsatt("BTR2","SEEN", 0);
627     gMC->Gsatt("BTR3","SEEN", 0);
628     gMC->Gsatt("TRD1","SEEN", 0);
629     if (fGeometry->GetPHOShole())
630       gMC->Gsatt("TRD2","SEEN", 0);
631     if (fGeometry->GetRICHhole())
632       gMC->Gsatt("TRD3","SEEN", 0);
633   }
634   gMC->Gsatt("UCII","SEEN", 0);
635   gMC->Gsatt("UCIM","SEEN", 0);
636   gMC->Gsatt("UCIO","SEEN", 0);
637   gMC->Gsatt("UL02","SEEN", 1);
638   gMC->Gsatt("UL05","SEEN", 1);
639   gMC->Gsatt("UL06","SEEN", 1);
640   
641   gMC->Gdopt("hide", "on");
642   gMC->Gdopt("shad", "on");
643   gMC->Gsatt("*", "fill", 7);
644   gMC->SetClipBox(".");
645   gMC->SetClipBox("*", 0, 2000, -2000, 2000, -2000, 2000);
646   gMC->DefaultRange();
647   gMC->Gdraw("alic", 40, 30, 0, 12, 9.4, .021, .021);
648   gMC->Gdhead(1111, "Transition Radiation Detector");
649   gMC->Gdman(18, 4, "MAN");
650
651 }
652
653 //_____________________________________________________________________________
654 Int_t AliTRD::DistancetoPrimitive(Int_t , Int_t )
655 {
656   //
657   // Distance between the mouse and the TRD detector on the screen
658   // Dummy routine
659   
660   return 9999;
661
662 }
663  
664 //_____________________________________________________________________________
665 void AliTRD::Init()
666 {
667   //
668   // Initialize the TRD detector after the geometry has been created
669   //
670
671   Int_t i;
672
673   printf("\n");
674   for (i = 0; i < 35; i++) printf("*");
675   printf(" TRD_INIT ");
676   for (i = 0; i < 35; i++) printf("*");
677   printf("\n");
678   printf("\n");
679
680   if      (fGeometry->IsVersion() == 0) {
681     printf("          Geometry for spaceframe with holes initialized.\n\n");
682   }
683   else if (fGeometry->IsVersion() == 1) {
684     printf("          Geometry for spaceframe without holes initialized.\n");
685     if (fGeometry->GetPHOShole())
686       printf("          Leave space in front of PHOS free.\n");
687     if (fGeometry->GetRICHhole())
688       printf("          Leave space in front of RICH free.\n");
689     printf("\n");
690   }
691
692   if (fGasMix == 1)
693     printf("          Gas Mixture: 90%% Xe + 10%% CO2\n\n");
694   else
695     printf("          Gas Mixture: 97%% Xe + 3%% Isobutane\n\n");
696
697 }
698
699 //_____________________________________________________________________________
700 void AliTRD::LoadPoints(Int_t track)
701 {
702   //
703   // Store x, y, z of all hits in memory.
704   // Hit originating from TR photons are given a different color
705   //
706
707   if (!fDrawTR) {
708     AliDetector::LoadPoints(track);
709     return;
710   }
711
712   if (fHits == 0) return;
713
714   Int_t nhits  = fHits->GetEntriesFast();
715   if (nhits == 0) return;
716
717   Int_t tracks = gAlice->GetNtrack();
718   if (fPoints == 0) fPoints = new TObjArray(tracks);
719
720   AliTRDhit *ahit;
721   
722   Int_t    *ntrkE = new Int_t[tracks];
723   Int_t    *ntrkT = new Int_t[tracks];
724   Int_t    *limiE = new Int_t[tracks];
725   Int_t    *limiT = new Int_t[tracks];
726   Float_t **coorE = new Float_t*[tracks];
727   Float_t **coorT = new Float_t*[tracks];
728   for(Int_t i = 0; i < tracks; i++) {
729     ntrkE[i] = 0;
730     ntrkT[i] = 0;
731     coorE[i] = 0;
732     coorT[i] = 0;
733     limiE[i] = 0;
734     limiT[i] = 0;
735   }
736   
737   AliTRDpoints  *points = 0;
738   Float_t       *fp     = 0;
739   Int_t          trk;
740   Int_t          chunk  = nhits / 4 + 1;
741
742   // Loop over all the hits and store their position
743   for (Int_t hit = 0; hit < nhits; hit++) {
744
745     ahit = (AliTRDhit *) fHits->UncheckedAt(hit);
746
747     // dEdx hits
748     if (ahit->GetCharge() >= 0) {
749
750       trk = ahit->GetTrack();
751       if (ntrkE[trk] == limiE[trk]) {
752         // Initialise a new track
753         fp = new Float_t[3*(limiE[trk]+chunk)];
754         if (coorE[trk]) {
755           memcpy(fp,coorE[trk],sizeof(Float_t)*3*limiE[trk]);
756           delete [] coorE[trk];
757         }
758         limiE[trk] += chunk;
759         coorE[trk]  = fp;
760       } 
761       else {
762         fp = coorE[trk];
763       }
764       fp[3*ntrkE[trk]  ] = ahit->X();
765       fp[3*ntrkE[trk]+1] = ahit->Y();
766       fp[3*ntrkE[trk]+2] = ahit->Z();
767       ntrkE[trk]++;
768
769     }
770     // TR photon hits
771     else {
772
773       trk = ahit->GetTrack();
774       if (ntrkT[trk] == limiT[trk]) {
775         // Initialise a new track
776         fp = new Float_t[3*(limiT[trk]+chunk)];
777         if (coorT[trk]) {
778           memcpy(fp,coorT[trk],sizeof(Float_t)*3*limiT[trk]);
779           delete [] coorT[trk];
780         }
781         limiT[trk] += chunk;
782         coorT[trk]  = fp;
783       } 
784       else {
785         fp = coorT[trk];
786       }
787       fp[3*ntrkT[trk]  ] = ahit->X();
788       fp[3*ntrkT[trk]+1] = ahit->Y();
789       fp[3*ntrkT[trk]+2] = ahit->Z();
790       ntrkT[trk]++;
791
792     }
793
794   }
795
796   for (trk = 0; trk < tracks; ++trk) {
797
798     if (ntrkE[trk] || ntrkT[trk]) {
799
800       points = new AliTRDpoints();
801       points->SetDetector(this);
802       points->SetParticle(trk);
803
804       // Set the dEdx points
805       if (ntrkE[trk]) {
806         points->SetMarkerColor(GetMarkerColor());
807         points->SetMarkerSize(GetMarkerSize());
808         points->SetPolyMarker(ntrkE[trk],coorE[trk],GetMarkerStyle());
809         delete [] coorE[trk];
810         coorE[trk] = 0;
811       }
812
813       // Set the TR photon points
814       if (ntrkT[trk]) {
815         points->SetTRpoints(ntrkT[trk],coorT[trk]);
816         delete [] coorT[trk];
817         coorT[trk] = 0;
818       }
819
820       fPoints->AddAt(points,trk);
821
822     }
823
824   }
825
826   delete [] coorE;
827   delete [] coorT;
828   delete [] ntrkE;
829   delete [] ntrkT;
830   delete [] limiE;
831   delete [] limiT;
832
833 }
834
835 //_____________________________________________________________________________
836 void AliTRD::MakeBranch(Option_t* option, char *file)
837 {
838   //
839   // Create Tree branches for the TRD digits and cluster.
840   //
841
842   //Int_t  buffersize = 4000;
843   //Char_t branchname[15];
844
845   AliDetector::MakeBranch(option,file);
846
847   //Char_t *r = strstr(option,"R");
848   //sprintf(branchname,"%srecPoints",GetName());
849   //if (fRecPoints && gAlice->TreeR() && r) {
850   //  MakeBranchInTree(gAlice->TreeR(), 
851   //                  branchname, &fRecPoints,buffersize, file) ;
852   //}
853
854 }
855
856 //_____________________________________________________________________________
857 void AliTRD::ResetRecPoints()
858 {
859   //
860   // Reset number of reconstructed points and the point array
861   //
862
863   if(fRecPoints) {
864     fNRecPoints = 0;
865     Int_t nentr = fRecPoints->GetEntriesFast();
866     for(Int_t i = 0; i < nentr; i++) delete fRecPoints->RemoveAt(i);
867   }
868
869 }
870
871 //_____________________________________________________________________________
872 void AliTRD::SetTreeAddress()
873 {
874   //
875   // Set the branch addresses for the trees.
876   //
877
878   Char_t branchname[15];
879
880   AliDetector::SetTreeAddress();
881
882   TBranch *branch;
883   TTree   *treeR = gAlice->TreeR();
884
885   if (treeR) {
886     sprintf(branchname,"%srecPoints",GetName());
887     if (fRecPoints) {
888       branch = treeR->GetBranch(branchname);
889       if (branch) {
890         branch->SetAddress(&fRecPoints);
891       }
892     }
893   }
894
895 }
896
897 //_____________________________________________________________________________
898 void AliTRD::SetGasMix(Int_t imix)
899 {
900   //
901   // Defines the gas mixture (imix=0:  Xe/Isobutane imix=1: Xe/CO2)
902   //
903   
904   if ((imix < 0) || (imix > 1)) {
905     printf("Wrong input value: %d\n",imix);
906     printf("Use standard setting\n");
907     fGasMix = 0;
908     return;
909   }
910
911   fGasMix = imix;
912
913 }
914
915 //_____________________________________________________________________________
916 void AliTRD::SetPHOShole()
917 {
918   //
919   // Selects a geometry with a hole in front of the PHOS
920   //
921
922   fGeometry->SetPHOShole();
923
924 }
925
926 //_____________________________________________________________________________
927 void AliTRD::SetRICHhole()
928 {
929   //
930   // Selects a geometry with a hole in front of the RICH
931   //
932
933   fGeometry->SetRICHhole();
934
935 }
936
937 //_____________________________________________________________________________
938 AliTRD &AliTRD::operator=(const AliTRD &trd)
939 {
940   //
941   // Assignment operator
942   //
943
944   if (this != &trd) ((AliTRD &) trd).Copy(*this);
945   return *this;
946
947 }