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