]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRD.cxx
Coding conventions
[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.37  2002/03/25 20:01:49  cblume
19 Introduce parameter class
20
21 Revision 1.36  2002/02/11 14:25:27  cblume
22 Geometry update, compressed hit structure
23
24 Revision 1.35  2001/11/14 12:08:44  cblume
25 Remove unneccessary header files
26
27 Revision 1.34  2001/11/14 10:50:45  cblume
28 Changes in digits IO. Add merging of summable digits
29
30 Revision 1.33  2001/11/06 17:19:41  cblume
31 Add detailed geometry and simple simulator
32
33 Revision 1.32  2001/10/08 06:57:33  hristov
34 Branches for  TRD digits are created only during the digitisation
35
36 Revision 1.31  2001/08/30 09:30:30  hristov
37 The split level of branches is set to 99
38
39 Revision 1.30  2001/05/28 17:07:58  hristov
40 Last minute changes; ExB correction in AliTRDclusterizerV1; taking into account of material in G10 TEC frames and material between TEC planes (C.Blume,S.Sedykh)
41
42 Revision 1.29  2001/05/21 16:45:47  hristov
43 Last minute changes (C.Blume)
44
45 Revision 1.28  2001/05/16 14:57:27  alibrary
46 New files for folders and Stack
47
48 Revision 1.27  2001/05/08 07:05:02  hristov
49 Loop variable declared once (HP, Sun)
50
51 Revision 1.26  2001/05/07 08:03:22  cblume
52 Generate also hits in the amplification region
53
54 Revision 1.25  2001/03/13 09:30:35  cblume
55 Update of digitization. Moved digit branch definition to AliTRD
56
57 Revision 1.24  2001/01/26 19:56:49  hristov
58 Major upgrade of AliRoot code
59
60 Revision 1.23  2000/11/01 14:53:20  cblume
61 Merge with TRD-develop
62
63 Revision 1.17.2.6  2000/10/15 23:29:08  cblume
64 Introduced more detailed geometry for the display
65
66 Revision 1.17.2.5  2000/10/06 16:49:46  cblume
67 Made Getters const
68
69 Revision 1.17.2.4  2000/10/04 16:34:57  cblume
70 Replace include files by forward declarations
71
72 Revision 1.17.2.3  2000/09/22 14:45:17  cblume
73 Included changes for the tracking
74
75 Revision 1.17.2.2  2000/09/18 13:25:13  cblume
76 Included LoadPoints() method to display the TR photons
77
78 Revision 1.22  2000/10/02 21:28:19  fca
79 Removal of useless dependecies via forward declarations
80
81 Revision 1.21  2000/06/09 11:10:07  cblume
82 Compiler warnings and coding conventions, next round
83
84 Revision 1.20  2000/06/08 18:32:57  cblume
85 Make code compliant to coding conventions
86
87 Revision 1.19  2000/06/07 16:25:37  cblume
88 Try to remove compiler warnings on Sun and HP
89
90 Revision 1.18  2000/05/08 16:17:27  cblume
91 Merge TRD-develop
92
93 Revision 1.21  2000/06/09 11:10:07  cblume
94 Compiler warnings and coding conventions, next round
95
96 Revision 1.20  2000/06/08 18:32:57  cblume
97 Make code compliant to coding conventions
98
99 Revision 1.19  2000/06/07 16:25:37  cblume
100 Try to remove compiler warnings on Sun and HP
101
102 Revision 1.18  2000/05/08 16:17:27  cblume
103 Merge TRD-develop
104
105 Revision 1.17.2.1  2000/05/08 14:28:59  cblume
106 Introduced SetPHOShole() and SetRICHhole(). AliTRDrecPoint container is now a TObjArray
107
108 Revision 1.17  2000/02/28 19:10:26  cblume
109 Include the new TRD classes
110
111 Revision 1.16.2.2  2000/02/28 17:53:24  cblume
112 Introduce TRD geometry classes
113
114 Revision 1.16.2.1  2000/02/28 17:04:19  cblume
115 Include functions and data members for AliTRDrecPoint
116
117 Revision 1.16  2000/01/19 17:17:35  fca
118 Introducing a list of lists of hits -- more hits allowed for detector now
119
120 Revision 1.15  1999/11/02 17:04:25  fca
121 Small syntax change for HP compiler
122
123 Revision 1.14  1999/11/02 16:57:02  fca
124 Avoid non ansi warnings on HP compilers
125
126 Revision 1.13  1999/11/02 16:35:56  fca
127 New version of TRD introduced
128
129 Revision 1.12  1999/11/01 20:41:51  fca
130 Added protections against using the wrong version of FRAME
131
132 Revision 1.11  1999/09/29 09:24:34  fca
133 Introduction of the Copyright and cvs Log
134
135 */
136
137 ///////////////////////////////////////////////////////////////////////////////
138 //                                                                           //
139 //  Transition Radiation Detector                                            //
140 //  This class contains the basic functions for the Transition Radiation     //
141 //  Detector.                                                                //
142 //                                                                           //
143 ///////////////////////////////////////////////////////////////////////////////
144
145 #include <stdlib.h>
146 #include <iostream.h>
147
148 #include <TMath.h>
149 #include <TNode.h>
150 #include <TGeometry.h>
151 #include <TTree.h>                                                              
152 #include <TPGON.h> 
153 #include <TFile.h>
154 #include <TROOT.h>
155 #include <TParticle.h>
156
157 #include "AliRun.h"
158 #include "AliConst.h"
159 #include "AliDigit.h"
160 #include "AliMagF.h"
161 #include "AliMC.h"                                                              
162  
163 #include "AliTRD.h"
164 #include "AliTRDhit.h"
165 #include "AliTRDpoints.h"
166 #include "AliTRDdigit.h"
167 #include "AliTRDdigitizer.h"
168 #include "AliTRDclusterizer.h"
169 #include "AliTRDgeometryHole.h"
170 #include "AliTRDgeometryFull.h"
171 #include "AliTRDrecPoint.h"
172 #include "AliTRDcluster.h"
173 #include "AliTRDdigitsManager.h"
174 #include "AliTRDtrackHits.h"  
175
176 ClassImp(AliTRD)
177  
178 //_____________________________________________________________________________
179 AliTRD::AliTRD()
180 {
181   //
182   // Default constructor
183   //
184
185   fIshunt        = 0;
186   fGasMix        = 0;
187   fHits          = 0;
188   fDigits        = 0;
189
190   fRecPoints     = 0;
191   fNRecPoints    = 0;
192
193   fGeometry      = 0;
194
195   fGasDensity    = 0;
196   fFoilDensity   = 0;
197
198   fDrawTR        = 0;
199   fDisplayType   = 0;
200  
201   fTrackHits     = 0; 
202   fHitType       = 0; 
203
204 }
205  
206 //_____________________________________________________________________________
207 AliTRD::AliTRD(const char *name, const char *title)
208        : AliDetector(name,title)
209 {
210   //
211   // Standard constructor for the TRD
212   //
213
214   // Check that FRAME is there otherwise we have no place where to
215   // put TRD
216   AliModule* frame = gAlice->GetModule("FRAME");
217   if (!frame) {
218     Error("Ctor","TRD needs FRAME to be present\n");
219     exit(1);
220   } 
221
222   // Define the TRD geometry according to the FRAME geometry
223   if      (frame->IsVersion() == 0) {
224     // Geometry with hole
225     fGeometry = new AliTRDgeometryHole();
226   }
227   else if (frame->IsVersion() == 1) {
228     // Geometry without hole
229     fGeometry = new AliTRDgeometryFull();
230   }
231   else {
232     Error("Ctor","Could not find valid FRAME version\n");
233     exit(1);
234   }
235
236   // Allocate the hit array
237   fHits           = new TClonesArray("AliTRDhit"     ,405);
238   gAlice->AddHitList(fHits);
239
240   // Allocate the digits array
241   fDigits         = 0;
242
243   // Allocate the rec point array
244   fRecPoints     = new TObjArray(400);
245   fNRecPoints    = 0;
246    
247   fIshunt        = 0;
248   fGasMix        = 1;
249
250   fGasDensity    = 0;
251   fFoilDensity   = 0;
252
253   fDrawTR        = 0;
254   fDisplayType   = 0;
255
256   fTrackHits     = 0;
257   fHitType       = 2;
258
259   SetMarkerColor(kWhite);   
260
261 }
262
263 //_____________________________________________________________________________
264 AliTRD::AliTRD(const AliTRD &trd)
265 {
266   //
267   // Copy constructor
268   //
269
270   ((AliTRD &) trd).Copy(*this);
271
272 }
273
274 //_____________________________________________________________________________
275 AliTRD::~AliTRD()
276 {
277   //
278   // TRD destructor
279   //
280
281   fIshunt = 0;
282
283   if (fGeometry) {
284     delete fGeometry;
285     fGeometry  = 0;
286   }
287   if (fHits) {
288     delete fHits;
289     fHits      = 0;
290   }
291   if (fRecPoints) {
292     delete fRecPoints;
293     fRecPoints = 0;
294   }
295   if (fTrackHits) {
296     delete fTrackHits;
297     fTrackHits = 0;
298   }
299
300 }
301
302 //_____________________________________________________________________________
303 void AliTRD::AddCluster(Float_t *pos, Int_t *digits, Int_t det, Float_t amp
304                        , Int_t *tracks, Float_t sigmaY2, Int_t iType)
305 {
306   //
307   // Add a cluster for the TRD
308   //
309
310   Int_t   pla = fGeometry->GetPlane(det);
311   Int_t   cha = fGeometry->GetChamber(det);
312   Int_t   sec = fGeometry->GetSector(det);
313
314   Float_t padRow  = pos[0]; 
315   Float_t padCol  = pos[1]; 
316   Float_t row0    = fGeometry->GetRow0(pla,cha,sec);
317   Float_t col0    = fGeometry->GetCol0(pla);
318   Float_t rowSize = fGeometry->GetRowPadSize(pla,cha,sec);
319   Float_t colSize = fGeometry->GetColPadSize(pla);
320
321   AliTRDcluster *c = new AliTRDcluster();
322
323   c->SetDetector(det);
324   c->AddTrackIndex(tracks);
325
326   c->SetQ(amp);
327
328   c->SetLocalTimeBin(((Int_t) pos[2]));
329   c->SetY(col0 + padCol * colSize);
330   c->SetZ(row0 + padRow * rowSize);
331   
332   c->SetSigmaY2((sigmaY2 + 1./12.) * colSize*colSize);   
333   c->SetSigmaZ2(rowSize * rowSize / 12.);
334
335   switch (iType) {
336   case 0:
337     c->Set2pad();
338     break;
339   case 1:
340     c->Set3pad();
341     break;
342   case 2:
343     c->Set4pad();
344     break;
345   case 3:
346     c->Set5pad();
347     break;
348   case 4:
349     c->SetLarge();
350     break;
351   };
352
353   fRecPoints->Add(c);
354
355 }
356
357 //_____________________________________________________________________________
358 void AliTRD::Hits2Digits()
359 {
360   //
361   // Create digits
362   //
363
364   AliTRDdigitizer *digitizer = new AliTRDdigitizer("TRDdigitizer"
365                                                   ,"TRD digitizer class");
366   digitizer->SetDebug(GetDebug());
367   digitizer->SetEvent(gAlice->GetEvNumber());
368
369   // Initialization
370   digitizer->InitDetector();
371     
372   // Create the digits
373   digitizer->MakeDigits();
374   
375   // Write the digits into the input file
376   if (digitizer->MakeBranch(fDigitsFile)) {
377
378     digitizer->WriteDigits();
379
380     // Save the digitizer class in the AliROOT 
381     digitizer->Write();
382
383   }
384
385 }
386
387 //_____________________________________________________________________________
388 void AliTRD::Hits2SDigits()
389 {
390   //
391   // Create summable digits
392   //
393
394   AliTRDdigitizer *digitizer = new AliTRDdigitizer("TRDdigitizer"
395                                                   ,"TRD digitizer class");
396   digitizer->SetDebug(GetDebug());
397
398   // For the summable digits
399   digitizer->SetSDigits(kTRUE);
400   digitizer->SetEvent(gAlice->GetEvNumber());
401
402   // Initialization
403   digitizer->InitDetector();
404     
405   // Create the TRD s-digits branch
406   digitizer->MakeDigits();
407   
408   // Write the digits into the input file
409   if (digitizer->MakeBranch(fDigitsFile)) {
410
411     digitizer->WriteDigits();
412
413     // Save the digitizer class in the AliROOT 
414     digitizer->Write();
415
416   }
417
418 }
419
420 //_____________________________________________________________________________
421 void AliTRD::SDigits2Digits()
422 {
423   //
424   // Create final digits from summable digits
425   //
426
427    // Create the TRD digitizer
428   AliTRDdigitizer *digitizer = new AliTRDdigitizer("TRDdigitizer"
429                                                   ,"TRD digitizer class");  
430   digitizer->SetDebug(GetDebug());
431
432   // Set the parameter
433   digitizer->SetEvent(gAlice->GetEvNumber());
434
435   // Initialization
436   digitizer->InitDetector();
437
438   // Read the s-digits via digits manager
439   AliTRDdigitsManager *sdigitsManager = new AliTRDdigitsManager();
440   sdigitsManager->SetDebug(GetDebug());
441   sdigitsManager->SetSDigits(kTRUE);
442   if (fDigitsFile) {
443     sdigitsManager->Open(fDigitsFile);
444   }
445   sdigitsManager->CreateArrays();
446   sdigitsManager->ReadDigits();
447
448   // Add the s-digits to the input list 
449   digitizer->AddSDigitsManager(sdigitsManager);
450
451   // Convert the s-digits to normal digits
452   digitizer->SDigits2Digits();
453
454   // Store the digits
455   if (digitizer->MakeBranch(fDigitsFile)) {
456
457     digitizer->WriteDigits();
458
459   }
460
461 }
462
463 //_____________________________________________________________________________
464 void AliTRD::AddHit(Int_t track, Int_t det, Float_t *hits, Int_t q
465                   , Bool_t inDrift)
466 {
467   //
468   // Add a hit for the TRD
469   // 
470   // The data structure is set according to fHitType:
471   //   bit0: standard TClonesArray
472   //   bit1: compressed trackHits structure
473   //
474
475   if (fHitType & 1) {
476     TClonesArray &lhits = *fHits;
477     new(lhits[fNhits++]) AliTRDhit(fIshunt,track,det,hits,q);
478   }
479
480   if (fHitType > 1) {
481     AddHit2(track,det,hits,q,inDrift);
482   }
483
484 }
485
486 //_____________________________________________________________________________
487 void AliTRD::BuildGeometry()
488 {
489   //
490   // Create the ROOT TNode geometry for the TRD
491   //
492
493   TNode *node, *top;
494   TPGON *pgon;
495
496   Float_t rmin, rmax;
497   Float_t zmax1, zmax2;
498
499   Int_t   iPlan;
500  
501   const Int_t kColorTRD = 46;
502   
503   // Find the top node alice
504   top = gAlice->GetGeometry()->GetNode("alice");
505   
506   if      (fDisplayType == 0) {
507
508     pgon = new TPGON("S_TRD","TRD","void",0,360,AliTRDgeometry::Nsect(),4);
509     rmin = AliTRDgeometry::Rmin();
510     rmax = AliTRDgeometry::Rmax();
511     pgon->DefineSection(0,-AliTRDgeometry::Zmax1(),rmax,rmax);
512     pgon->DefineSection(1,-AliTRDgeometry::Zmax2(),rmin,rmax);
513     pgon->DefineSection(2, AliTRDgeometry::Zmax2(),rmin,rmax);
514     pgon->DefineSection(3, AliTRDgeometry::Zmax1(),rmax,rmax);
515     top->cd();
516     node = new TNode("TRD","TRD","S_TRD",0,0,0,"");
517     node->SetLineColor(kColorTRD);
518     fNodes->Add(node);
519
520   }
521   else if (fDisplayType == 1) {
522
523     Char_t name[7];
524
525     Float_t slope = (AliTRDgeometry::Zmax1() - AliTRDgeometry::Zmax2())
526                   / (AliTRDgeometry::Rmax()  - AliTRDgeometry::Rmin());
527
528     rmin  = AliTRDgeometry::Rmin() + AliTRDgeometry::CraHght();
529     rmax  = rmin                   + AliTRDgeometry::CdrHght();
530
531     Float_t thickness = rmin - AliTRDgeometry::Rmin();
532     zmax2 = AliTRDgeometry::Zmax2() + slope * thickness;
533     zmax1 = zmax2 + slope * AliTRDgeometry::DrThick();
534
535     for (iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) {
536
537       sprintf(name,"S_TR1%d",iPlan);
538       pgon  = new TPGON(name,"TRD","void",0,360,AliTRDgeometry::Nsect(),4);
539       pgon->DefineSection(0,-zmax1,rmax,rmax);
540       pgon->DefineSection(1,-zmax2,rmin,rmax);
541       pgon->DefineSection(2, zmax2,rmin,rmax);
542       pgon->DefineSection(3, zmax1,rmax,rmax);
543       top->cd();
544       node = new TNode("TRD","TRD",name,0,0,0,"");
545       node->SetLineColor(kColorTRD);
546       fNodes->Add(node);
547
548       Float_t height = AliTRDgeometry::Cheight() + AliTRDgeometry::Cspace(); 
549       rmin  = rmin  + height;
550       rmax  = rmax  + height;
551       zmax1 = zmax1 + slope * height;
552       zmax2 = zmax2 + slope * height;
553
554     }
555
556     thickness += AliTRDgeometry::DrThick();
557     rmin  = AliTRDgeometry::Rmin() + thickness;
558     rmax  = rmin + AliTRDgeometry::AmThick();
559     zmax2 = AliTRDgeometry::Zmax2() + slope * thickness;
560     zmax1 = zmax2 + slope * AliTRDgeometry::AmThick();
561
562     for (iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) {
563
564       sprintf(name,"S_TR2%d",iPlan);
565       pgon  = new TPGON(name,"TRD","void",0,360,AliTRDgeometry::Nsect(),4);
566       pgon->DefineSection(0,-zmax1,rmax,rmax);
567       pgon->DefineSection(1,-zmax2,rmin,rmax);
568       pgon->DefineSection(2, zmax2,rmin,rmax);
569       pgon->DefineSection(3, zmax1,rmax,rmax);
570       top->cd();
571       node = new TNode("TRD","TRD",name,0,0,0,"");
572       node->SetLineColor(kColorTRD);
573       fNodes->Add(node);
574
575       Float_t height = AliTRDgeometry::Cheight() + AliTRDgeometry::Cspace(); 
576       rmin  = rmin  + height;
577       rmax  = rmax  + height;
578       zmax1 = zmax1 + slope * height;
579       zmax2 = zmax2 + slope * height;
580
581     }
582
583   }
584
585 }
586  
587 //_____________________________________________________________________________
588 void AliTRD::Copy(TObject &trd)
589 {
590   //
591   // Copy function
592   //
593
594   ((AliTRD &) trd).fGasMix      = fGasMix;
595   ((AliTRD &) trd).fGeometry    = fGeometry;       
596   ((AliTRD &) trd).fRecPoints   = fRecPoints;
597   ((AliTRD &) trd).fNRecPoints  = fNRecPoints;
598   ((AliTRD &) trd).fGasDensity  = fGasDensity;
599   ((AliTRD &) trd).fFoilDensity = fFoilDensity;
600   ((AliTRD &) trd).fDrawTR      = fDrawTR;
601   ((AliTRD &) trd).fDisplayType = fDisplayType;
602   ((AliTRD &) trd).fHitType     = fHitType;
603
604   //AliDetector::Copy(trd);
605
606 }
607
608 //_____________________________________________________________________________
609 void AliTRD::CreateGeometry()
610 {
611   //
612   // Creates the volumes for the TRD chambers
613   //
614
615   // Check that FRAME is there otherwise we have no place where to put the TRD
616   AliModule* frame = gAlice->GetModule("FRAME");
617   if (!frame) {
618     printf(" The TRD needs the FRAME to be defined first\n");
619     return;
620   }
621
622   fGeometry->CreateGeometry(fIdtmed->GetArray() - 1299);
623
624 }
625  
626 //_____________________________________________________________________________
627 void AliTRD::CreateMaterials()
628 {
629   //
630   // Create the materials for the TRD
631   // Origin Y.Foka
632   //
633
634   Int_t   isxfld = gAlice->Field()->Integ();
635   Float_t sxmgmx = gAlice->Field()->Max();
636   
637   // For polyethilene (CH2) 
638   Float_t ape[2] = { 12., 1. };
639   Float_t zpe[2] = {  6., 1. };
640   Float_t wpe[2] = {  1., 2. };
641   Float_t dpe    = 0.95;
642
643   // For mylar (C5H4O2) 
644   Float_t amy[3] = { 12., 1., 16. };
645   Float_t zmy[3] = {  6., 1.,  8. };
646   Float_t wmy[3] = {  5., 4.,  2. };
647   Float_t dmy    = 1.39;
648
649   // For CO2 
650   Float_t aco[2] = { 12., 16. };
651   Float_t zco[2] = {  6.,  8. };
652   Float_t wco[2] = {  1.,  2. };
653   Float_t dco    = 0.001977;
654
655   // For water
656   Float_t awa[2] = {  1., 16. };
657   Float_t zwa[2] = {  1.,  8. };
658   Float_t wwa[2] = {  2.,  1. };
659   Float_t dwa    = 1.0;
660
661   // For isobutane (C4H10)
662   Float_t ais[2] = { 12.,  1. };
663   Float_t zis[2] = {  6.,  1. };
664   Float_t wis[2] = {  4., 10. };
665   Float_t dis    = 0.00267;
666
667   // For plexiglas (C5H8O2)
668   Float_t apg[3] = { 12.011 ,  1.0    , 15.9994 };
669   Float_t zpg[3] = {  6.0   ,  1.0    ,  8.0    };
670   Float_t wpg[3] = {  5.0   ,  8.0    ,  2.0    };
671   Float_t dpg    = 1.18; 
672
673   // For Xe/CO2-gas-mixture 
674   // Xe-content of the Xe/CO2-mixture (85% / 15%) 
675   Float_t fxc    = .85;
676   // Xe-content of the Xe/Isobutane-mixture (97% / 3%) 
677   Float_t fxi    = .97;
678   Float_t dxe    = .005858;
679   
680   // General tracking parameter
681   Float_t tmaxfd = -10.;
682   Float_t stemax = -1e10;
683   Float_t deemax = -0.1;
684   Float_t epsil  =  1e-4;
685   Float_t stmin  = -0.001;
686   
687   Float_t absl, radl, d, buf[1];
688   Float_t agm[2], zgm[2], wgm[2];
689   Float_t dgm1, dgm2;
690   Int_t   nbuf;
691   
692   //////////////////////////////////////////////////////////////////////////
693   //     Define Materials 
694   //////////////////////////////////////////////////////////////////////////
695
696   AliMaterial( 1, "Al"   ,  26.98, 13.0, 2.7     ,     8.9 ,    37.2);
697   AliMaterial( 2, "Air"  ,  14.61,  7.3, 0.001205, 30420.0 , 67500.0);
698   AliMaterial( 4, "Xe"   , 131.29, 54.0, dxe     ,  1447.59,     0.0);
699   AliMaterial( 5, "Cu"   ,  63.54, 29.0, 8.96    ,     1.43,    14.8);
700   AliMaterial( 6, "C"    ,  12.01,  6.0, 2.265   ,    18.8 ,    74.4);
701   AliMaterial(12, "G10"  ,  20.00, 10.0, 1.7     ,    19.4 ,   999.0);
702   AliMaterial(15, "Sn"   , 118.71, 50.0, 7.31    ,     1.21,    14.8);
703   AliMaterial(16, "Si"   ,  28.09, 14.0, 2.33    ,     9.36,    37.2);
704   AliMaterial(17, "Epoxy",  17.75,  8.9, 1.8     ,    21.82,   999.0);
705
706   // Mixtures 
707   AliMixture(3, "Polyethilene",   ape, zpe, dpe, -2, wpe);
708   AliMixture(7, "Mylar",          amy, zmy, dmy, -3, wmy);
709   AliMixture(8, "CO2",            aco, zco, dco, -2, wco);
710   AliMixture(9, "Isobutane",      ais, zis, dis, -2, wis);
711   AliMixture(13,"Water",          awa, zwa, dwa, -2, wwa);
712   AliMixture(14,"Plexiglas",      apg, zpg, dpg, -3, wpg);
713
714   // Gas mixtures
715   Char_t namate[21];
716   // Xe/CO2-mixture
717   // Get properties of Xe 
718   gMC->Gfmate((*fIdmate)[4], namate, agm[0], zgm[0], d, radl, absl, buf, nbuf);
719   // Get properties of CO2 
720   gMC->Gfmate((*fIdmate)[8], namate, agm[1], zgm[1], d, radl, absl, buf, nbuf);
721   // Create gas mixture 
722   wgm[0] = fxc;
723   wgm[1] = 1. - fxc;
724   dgm1   = wgm[0] * dxe + wgm[1] * dco;
725   AliMixture(10, "Gas mixture 1", agm, zgm, dgm1,  2, wgm);
726   // Xe/Isobutane-mixture
727   // Get properties of Xe 
728   gMC->Gfmate((*fIdmate)[4], namate, agm[0], zgm[0], d, radl, absl, buf, nbuf);
729   // Get properties of Isobutane
730   gMC->Gfmate((*fIdmate)[9], namate, agm[1], zgm[1], d, radl, absl, buf, nbuf);
731   // Create gas mixture 
732   wgm[0] = fxi;
733   wgm[1] = 1. - fxi;
734   dgm2   = wgm[0] * dxe + wgm[1] * dis;
735   AliMixture(11, "Gas mixture 2", agm, zgm, dgm2,  2, wgm);
736  
737   //////////////////////////////////////////////////////////////////////////
738   //     Tracking Media Parameters 
739   //////////////////////////////////////////////////////////////////////////
740
741   // Al Frame 
742   AliMedium(1, "Al Frame",   1, 0, isxfld, sxmgmx
743                 , tmaxfd, stemax, deemax, epsil, stmin);
744   // Air 
745   AliMedium(2, "Air",        2, 0, isxfld, sxmgmx
746                 , tmaxfd, stemax, deemax, epsil, stmin);
747   // Polyethilene 
748   AliMedium(3, "Radiator",   3, 0, isxfld, sxmgmx
749                 , tmaxfd, stemax, deemax, epsil, stmin);
750   // Xe 
751   AliMedium(4, "Xe",         4, 1, isxfld, sxmgmx
752                 , tmaxfd, stemax, deemax, epsil, stmin);
753   // Cu pads 
754   AliMedium(5, "Padplane",   5, 1, isxfld, sxmgmx
755                 , tmaxfd, stemax, deemax, epsil, stmin);
756   // Fee + cables 
757   AliMedium(6, "Readout",    1, 0, isxfld, sxmgmx
758                 , tmaxfd, stemax, deemax, epsil, stmin);
759   // C frame 
760   AliMedium(7, "C Frame",    6, 0, isxfld, sxmgmx
761                 , tmaxfd, stemax, deemax, epsil, stmin);
762   // Mylar foils 
763   AliMedium(8, "Mylar",      7, 0, isxfld, sxmgmx
764                 , tmaxfd, stemax, deemax, epsil, stmin);
765   if (fGasMix == 1) {
766     // Gas-mixture (Xe/CO2) 
767     AliMedium(9, "Gas-mix",   10, 1, isxfld, sxmgmx
768                   , tmaxfd, stemax, deemax, epsil, stmin);
769   }
770   else {
771     // Gas-mixture (Xe/Isobutane) 
772     AliMedium(9, "Gas-mix",   11, 1, isxfld, sxmgmx
773                   , tmaxfd, stemax, deemax, epsil, stmin);
774   }
775   // Nomex-honeycomb (use carbon for the time being) 
776   AliMedium(10, "Nomex",      6, 0, isxfld, sxmgmx
777                 , tmaxfd, stemax, deemax, epsil, stmin);
778   // Kapton foils (use Mylar for the time being) 
779   AliMedium(11, "Kapton",     7, 0, isxfld, sxmgmx
780                 , tmaxfd, stemax, deemax, epsil, stmin);
781   // Gas-filling of the radiator 
782   AliMedium(12, "CO2",        8, 0, isxfld, sxmgmx
783                 , tmaxfd, stemax, deemax, epsil, stmin);
784   // G10-plates
785   AliMedium(13, "G10-plates",12, 0, isxfld, sxmgmx
786                 , tmaxfd, stemax, deemax, epsil, stmin);
787   // Cooling water
788   AliMedium(14, "Water",     13, 0, isxfld, sxmgmx
789                 , tmaxfd, stemax, deemax, epsil, stmin);
790   // Rohacell (plexiglas) for the radiator
791   AliMedium(15, "Rohacell",  14, 0, isxfld, sxmgmx
792                 , tmaxfd, stemax, deemax, epsil, stmin);
793   // Al layer in MCMs
794   AliMedium(16, "MCM-Al"  ,   1, 0, isxfld, sxmgmx
795                 , tmaxfd, stemax, deemax, epsil, stmin);
796   // Sn layer in MCMs
797   AliMedium(17, "MCM-Sn"  ,  15, 0, isxfld, sxmgmx
798                 , tmaxfd, stemax, deemax, epsil, stmin);
799   // Cu layer in MCMs
800   AliMedium(18, "MCM-Cu"  ,   5, 0, isxfld, sxmgmx
801                 , tmaxfd, stemax, deemax, epsil, stmin);
802   // G10 layer in MCMs
803   AliMedium(19, "MCM-G10" ,  12, 0, isxfld, sxmgmx
804                 , tmaxfd, stemax, deemax, epsil, stmin);
805   // Si in readout chips
806   AliMedium(20, "Chip-Si" ,  16, 0, isxfld, sxmgmx
807                 , tmaxfd, stemax, deemax, epsil, stmin);
808   // Epoxy in readout chips
809   AliMedium(21, "Chip-Ep" ,  17, 0, isxfld, sxmgmx
810                 , tmaxfd, stemax, deemax, epsil, stmin);
811   // PE in connectors
812   AliMedium(22, "Conn-PE" ,   3, 0, isxfld, sxmgmx
813                 , tmaxfd, stemax, deemax, epsil, stmin);
814   // Cu in connectors
815   AliMedium(23, "Chip-Cu" ,   5, 0, isxfld, sxmgmx
816                 , tmaxfd, stemax, deemax, epsil, stmin);
817   // Al of cooling pipes
818   AliMedium(24, "Cooling" ,   1, 0, isxfld, sxmgmx
819                 , tmaxfd, stemax, deemax, epsil, stmin);
820
821   // Save the density values for the TRD absorbtion
822   fFoilDensity = dmy;
823   if (fGasMix == 1)
824     fGasDensity = dgm1;
825   else
826     fGasDensity = dgm2;
827
828 }
829
830 //_____________________________________________________________________________
831 void AliTRD::DrawModule() const
832 {
833   //
834   // Draw a shaded view of the Transition Radiation Detector version 0
835   //
836
837   // Set everything unseen
838   gMC->Gsatt("*"   ,"SEEN",-1);
839   
840   // Set ALIC mother transparent
841   gMC->Gsatt("ALIC","SEEN", 0);
842   
843   // Set the volumes visible
844   if (fGeometry->IsVersion() == 0) {
845     gMC->Gsatt("B071","SEEN", 0);
846     gMC->Gsatt("B074","SEEN", 0);
847     gMC->Gsatt("B075","SEEN", 0);
848     gMC->Gsatt("B077","SEEN", 0);
849     gMC->Gsatt("BTR1","SEEN", 0);
850     gMC->Gsatt("BTR2","SEEN", 0);
851     gMC->Gsatt("BTR3","SEEN", 0);
852     gMC->Gsatt("UTR1","SEEN", 0);
853     gMC->Gsatt("UTR2","SEEN", 0);
854     gMC->Gsatt("UTR3","SEEN", 0);
855   }
856   else {
857     gMC->Gsatt("B071","SEEN", 0);
858     gMC->Gsatt("B074","SEEN", 0);
859     gMC->Gsatt("B075","SEEN", 0);
860     gMC->Gsatt("B077","SEEN", 0);
861     gMC->Gsatt("BTR1","SEEN", 0);
862     gMC->Gsatt("BTR2","SEEN", 0);
863     gMC->Gsatt("BTR3","SEEN", 0);
864     gMC->Gsatt("UTR1","SEEN", 0);
865     if (fGeometry->GetPHOShole())
866       gMC->Gsatt("UTR2","SEEN", 0);
867     if (fGeometry->GetRICHhole())
868       gMC->Gsatt("UTR3","SEEN", 0);
869   }
870 //   gMC->Gsatt("UCII","SEEN", 0);
871 //   gMC->Gsatt("UCIM","SEEN", 0);
872 //   gMC->Gsatt("UCIO","SEEN", 0);
873 //   gMC->Gsatt("UL02","SEEN", 1);
874 //   gMC->Gsatt("UL05","SEEN", 1);
875 //   gMC->Gsatt("UL06","SEEN", 1);
876   
877   gMC->Gdopt("hide", "on");
878   gMC->Gdopt("shad", "on");
879   gMC->Gsatt("*", "fill", 7);
880   gMC->SetClipBox(".");
881   gMC->SetClipBox("*", 0, 2000, -2000, 2000, -2000, 2000);
882   gMC->DefaultRange();
883   gMC->Gdraw("alic", 40, 30, 0, 12, 9.4, .021, .021);
884   gMC->Gdhead(1111, "Transition Radiation Detector");
885   gMC->Gdman(18, 4, "MAN");
886
887 }
888
889 //_____________________________________________________________________________
890 Int_t AliTRD::DistancetoPrimitive(Int_t , Int_t ) const
891 {
892   //
893   // Distance between the mouse and the TRD detector on the screen
894   // Dummy routine
895   
896   return 9999;
897
898 }
899  
900 //_____________________________________________________________________________
901 void AliTRD::Init()
902 {
903   //
904   // Initialize the TRD detector after the geometry has been created
905   //
906
907   Int_t i;
908
909   if (fDebug) {
910     printf("\n%s: ",ClassName());
911     for (i = 0; i < 35; i++) printf("*");
912     printf(" TRD_INIT ");
913     for (i = 0; i < 35; i++) printf("*");
914     printf("\n");
915   }
916
917   if      (fGeometry->IsVersion() == 0) {
918     printf("%s: Geometry for spaceframe with holes initialized\n",ClassName());
919   }
920   else if (fGeometry->IsVersion() == 1) {
921     printf("%s: Geometry for spaceframe without holes initialized\n",ClassName());
922     if (fGeometry->GetPHOShole())
923       printf("%s: Leave space in front of PHOS free\n",ClassName());
924     if (fGeometry->GetRICHhole())
925       printf("%s: Leave space in front of RICH free\n",ClassName());
926   }
927   
928   if (fGasMix == 1) {
929     printf("%s: Gas Mixture: 85%% Xe + 15%% CO2\n",ClassName());
930   }
931   else {
932     printf("%s: Gas Mixture: 97%% Xe + 3%% Isobutane\n",ClassName());
933   }
934
935 }
936
937 //_____________________________________________________________________________
938 void AliTRD::LoadPoints(Int_t track)
939 {
940   //
941   // Store x, y, z of all hits in memory.
942   // Hit originating from TR photons are given a different color
943   //
944
945   //if (!fDrawTR) {
946   //  AliDetector::LoadPoints(track);
947   //  return;
948   //}
949
950   if ((fHits == 0) && (fTrackHits == 0)) return;
951
952   Int_t nhits;
953   if (fHitType < 2) {
954     nhits = fHits->GetEntriesFast();
955   }
956   else {
957     nhits = fTrackHits->GetEntriesFast();
958   } 
959   if (nhits == 0) return;
960
961   Int_t tracks = gAlice->GetNtrack();
962   if (fPoints == 0) fPoints = new TObjArray(tracks);
963
964   AliTRDhit *ahit;
965   
966   Int_t    *ntrkE = new Int_t[tracks];
967   Int_t    *ntrkT = new Int_t[tracks];
968   Int_t    *limiE = new Int_t[tracks];
969   Int_t    *limiT = new Int_t[tracks];
970   Float_t **coorE = new Float_t*[tracks];
971   Float_t **coorT = new Float_t*[tracks];
972   for(Int_t i = 0; i < tracks; i++) {
973     ntrkE[i] = 0;
974     ntrkT[i] = 0;
975     coorE[i] = 0;
976     coorT[i] = 0;
977     limiE[i] = 0;
978     limiT[i] = 0;
979   }
980   
981   AliTRDpoints *points = 0;
982   Float_t      *fp     = 0;
983   Int_t         trk;
984   Int_t         chunk  = nhits / 4 + 1;
985
986   // Loop over all the hits and store their position
987   ahit = (AliTRDhit *) FirstHit(-1);
988   while (ahit) {
989
990     // dEdx hits
991     if (ahit->GetCharge() >= 0) {
992
993       trk = ahit->GetTrack();
994       if (ntrkE[trk] == limiE[trk]) {
995         // Initialise a new track
996         fp = new Float_t[3*(limiE[trk]+chunk)];
997         if (coorE[trk]) {
998           memcpy(fp,coorE[trk],sizeof(Float_t)*3*limiE[trk]);
999           delete [] coorE[trk];
1000         }
1001         limiE[trk] += chunk;
1002         coorE[trk]  = fp;
1003       } 
1004       else {
1005         fp = coorE[trk];
1006       }
1007       fp[3*ntrkE[trk]  ] = ahit->X();
1008       fp[3*ntrkE[trk]+1] = ahit->Y();
1009       fp[3*ntrkE[trk]+2] = ahit->Z();
1010       ntrkE[trk]++;
1011
1012     }
1013     // TR photon hits
1014     else if ((ahit->GetCharge() < 0) && (fDrawTR)) {
1015
1016       trk = ahit->GetTrack();
1017       if (ntrkT[trk] == limiT[trk]) {
1018         // Initialise a new track
1019         fp = new Float_t[3*(limiT[trk]+chunk)];
1020         if (coorT[trk]) {
1021           memcpy(fp,coorT[trk],sizeof(Float_t)*3*limiT[trk]);
1022           delete [] coorT[trk];
1023         }
1024         limiT[trk] += chunk;
1025         coorT[trk]  = fp;
1026       } 
1027       else {
1028         fp = coorT[trk];
1029       }
1030       fp[3*ntrkT[trk]  ] = ahit->X();
1031       fp[3*ntrkT[trk]+1] = ahit->Y();
1032       fp[3*ntrkT[trk]+2] = ahit->Z();
1033       ntrkT[trk]++;
1034
1035     }
1036
1037     ahit = (AliTRDhit *) NextHit();
1038
1039   }
1040
1041   for (trk = 0; trk < tracks; ++trk) {
1042
1043     if (ntrkE[trk] || ntrkT[trk]) {
1044
1045       points = new AliTRDpoints();
1046       points->SetDetector(this);
1047       points->SetParticle(trk);
1048
1049       // Set the dEdx points
1050       if (ntrkE[trk]) {
1051         points->SetMarkerColor(GetMarkerColor());
1052         points->SetMarkerSize(GetMarkerSize());
1053         points->SetPolyMarker(ntrkE[trk],coorE[trk],GetMarkerStyle());
1054         delete [] coorE[trk];
1055         coorE[trk] = 0;
1056       }
1057
1058       // Set the TR photon points
1059       if (ntrkT[trk]) {
1060         points->SetTRpoints(ntrkT[trk],coorT[trk]);
1061         delete [] coorT[trk];
1062         coorT[trk] = 0;
1063       }
1064
1065       fPoints->AddAt(points,trk);
1066
1067     }
1068
1069   }
1070
1071   delete [] coorE;
1072   delete [] coorT;
1073   delete [] ntrkE;
1074   delete [] ntrkT;
1075   delete [] limiE;
1076   delete [] limiT;
1077
1078 }
1079
1080 //_____________________________________________________________________________
1081 void AliTRD::MakeBranch(Option_t* option, const char *file)
1082 {
1083   //
1084   // Create Tree branches for the TRD digits.
1085   //
1086
1087   Int_t  buffersize = 4000;
1088   Char_t branchname[15];
1089   sprintf(branchname,"%s",GetName());
1090
1091   const char *cD = strstr(option,"D");
1092
1093   AliDetector::MakeBranch(option,file);
1094
1095   if (fDigits && gAlice->TreeD() && cD) {
1096     MakeBranchInTree(gAlice->TreeD(),branchname,&fDigits,buffersize,file);
1097   }     
1098
1099   if (fHitType > 1) {
1100     MakeBranch2(option,file); 
1101   }
1102
1103 }
1104
1105 //_____________________________________________________________________________
1106 void AliTRD::ResetDigits()
1107 {
1108   //
1109   // Reset number of digits and the digits array for this detector
1110   //
1111
1112   fNdigits = 0;
1113   if (fDigits) fDigits->Clear();
1114
1115 }
1116
1117 //_____________________________________________________________________________
1118 void AliTRD::ResetRecPoints()
1119 {
1120   //
1121   // Reset number of reconstructed points and the point array
1122   //
1123
1124   if (fRecPoints) {
1125     fNRecPoints = 0;
1126     Int_t nentr = fRecPoints->GetEntriesFast();
1127     for (Int_t i = 0; i < nentr; i++) delete fRecPoints->RemoveAt(i);
1128   }
1129
1130 }
1131
1132 //_____________________________________________________________________________
1133 void AliTRD::SetTreeAddress()
1134 {
1135   //
1136   // Set the branch addresses for the trees.
1137   //
1138
1139   Char_t branchname[15];
1140
1141   AliDetector::SetTreeAddress();
1142
1143   TBranch *branch;
1144   TTree   *treeR = gAlice->TreeR();
1145
1146   if (treeR) {
1147     sprintf(branchname,"%scluster",GetName());
1148     if (fRecPoints) {
1149       branch = treeR->GetBranch(branchname);
1150       if (branch) {
1151         branch->SetAddress(&fRecPoints);
1152       }
1153     }
1154   }
1155
1156   if (fHitType > 0) {
1157     SetTreeAddress2();    
1158   }
1159
1160 }
1161
1162 //_____________________________________________________________________________
1163 void AliTRD::SetGasMix(Int_t imix)
1164 {
1165   //
1166   // Defines the gas mixture (imix=0:  Xe/Isobutane imix=1: Xe/CO2)
1167   //
1168   
1169   if ((imix < 0) || (imix > 1)) {
1170     printf("Wrong input value: %d\n",imix);
1171     printf("Use standard setting\n");
1172     fGasMix = 1;
1173     return;
1174   }
1175
1176   fGasMix = imix;
1177
1178 }
1179
1180 //_____________________________________________________________________________
1181 void AliTRD::SetPHOShole()
1182 {
1183   //
1184   // Selects a geometry with a hole in front of the PHOS
1185   //
1186
1187   fGeometry->SetPHOShole();
1188
1189 }
1190
1191 //_____________________________________________________________________________
1192 void AliTRD::SetRICHhole()
1193 {
1194   //
1195   // Selects a geometry with a hole in front of the RICH
1196   //
1197
1198   fGeometry->SetRICHhole();
1199
1200 }
1201
1202 //_____________________________________________________________________________
1203 AliTRD &AliTRD::operator=(const AliTRD &trd)
1204 {
1205   //
1206   // Assignment operator
1207   //
1208
1209   if (this != &trd) ((AliTRD &) trd).Copy(*this);
1210   return *this;
1211
1212
1213
1214 //_____________________________________________________________________________
1215 void AliTRD::FinishPrimary()
1216 {
1217   //
1218   // Store the hits in the containers after all primaries are finished
1219   //
1220
1221   if (fTrackHits) { 
1222     fTrackHits->FlushHitStack();
1223   }
1224
1225 }
1226
1227 //_____________________________________________________________________________
1228 void AliTRD::RemapTrackHitIDs(Int_t *map)
1229 {
1230   //
1231   // Remap the track IDs
1232   //
1233
1234   if (!fTrackHits) {
1235     return;
1236   }
1237
1238   if (fTrackHits) {
1239     TClonesArray *arr = fTrackHits->GetArray();;
1240     for (Int_t i = 0; i < arr->GetEntriesFast(); i++){
1241       AliTrackHitsParamV2 *info = (AliTrackHitsParamV2 *) (arr->At(i));
1242       info->fTrackID = map[info->fTrackID];
1243     }
1244   }
1245
1246 }
1247
1248 //_____________________________________________________________________________
1249 void AliTRD::ResetHits()
1250 {
1251   //
1252   // Reset the hits
1253   //
1254
1255   AliDetector::ResetHits();
1256   if (fTrackHits) {
1257     fTrackHits->Clear();
1258   }
1259
1260 }
1261
1262 //_____________________________________________________________________________
1263 AliHit* AliTRD::FirstHit(Int_t track)
1264 {
1265   //
1266   // Return the first hit of a track
1267   //
1268
1269   if (fHitType > 1) {
1270     return FirstHit2(track);
1271   }
1272
1273   return AliDetector::FirstHit(track);
1274
1275 }
1276
1277 //_____________________________________________________________________________
1278 AliHit* AliTRD::NextHit()
1279 {
1280   //
1281   // Returns the next hit of a track
1282   //
1283
1284   if (fHitType > 1) {
1285     return NextHit2();
1286   }
1287
1288   return AliDetector::NextHit();
1289
1290 }
1291
1292 //_____________________________________________________________________________
1293 AliHit* AliTRD::FirstHit2(Int_t track) 
1294 {
1295   //
1296   // Initializes the hit iterator.
1297   // Returns the address of the first hit of a track.
1298   // If <track> >= 0 the track is read from disk,
1299   // while if <track> < 0 the first hit of the current
1300   // track is returned.
1301   //
1302
1303   if (track >= 0) {
1304     gAlice->ResetHits();
1305     gAlice->TreeH()->GetEvent(track);
1306   }
1307   
1308   if (fTrackHits) {
1309     fTrackHits->First();
1310     return (AliHit*) fTrackHits->GetHit();
1311   }
1312   else {
1313     return 0;
1314   }
1315
1316 }
1317
1318 //_____________________________________________________________________________
1319 AliHit* AliTRD::NextHit2()
1320 {
1321   //
1322   // Returns the next hit of the current track
1323   //
1324
1325   if (fTrackHits) {
1326     fTrackHits->Next();
1327     return (AliHit *) fTrackHits->GetHit();
1328   }
1329   else {
1330     return 0;
1331   }
1332
1333 }
1334
1335 //_____________________________________________________________________________
1336 void AliTRD::MakeBranch2(Option_t *option, const char *file)
1337 {
1338   //
1339   // Create a new branch in the current Root tree.
1340   // The branch of fHits is automatically split.
1341   //
1342
1343   if (fHitType < 2) {
1344     return;
1345   }
1346
1347   char branchname[10];
1348   sprintf(branchname,"%s2",GetName());
1349
1350   // Get the pointer to the header
1351   const char *cH = strstr(option,"H");
1352  
1353   if (!fTrackHits) {
1354     fTrackHits = new AliTRDtrackHits();
1355   }
1356
1357   if (fTrackHits && gAlice->TreeH() && cH) {
1358
1359     gAlice->TreeH()->Branch(branchname,"AliTRDtrackHits"
1360                                       ,&fTrackHits
1361                                       ,fBufferSize,99);
1362
1363     if (GetDebug() > 1) {
1364       printf("<AliTRD::MakeBranch2> Making Branch %s for trackhits\n"
1365             ,branchname);
1366     }
1367
1368     const char kFolder[] = "RunMC/Event/Data";
1369
1370     if (GetDebug()) {
1371       printf("<AliTRD::MakeBranch2> %15s: Publishing %s to %s\n"
1372             ,ClassName(),branchname,kFolder);
1373     }
1374
1375     Publish(kFolder,&fTrackHits,branchname);
1376
1377     if (file) {
1378       TBranch *b = gAlice->TreeH()->GetBranch(branchname);
1379       TDirectory *wd = gDirectory;
1380       b->SetFile(file);
1381       TIter next(b->GetListOfBranches());
1382       while ((b = (TBranch*) next())) {
1383         b->SetFile(file);
1384       }
1385       wd->cd();
1386       if (GetDebug() > 1) {
1387         printf("<AliTRD::MakeBranch2> Diverting branch %s to file %s\n"
1388               ,branchname,file);
1389       }
1390     }
1391
1392   }
1393
1394 }
1395
1396 //_____________________________________________________________________________
1397 void AliTRD::SetTreeAddress2()
1398 {
1399   //
1400   // Set the branch address for the trackHits tree
1401   //
1402
1403   TBranch *branch;
1404
1405   char branchname[20];
1406
1407   sprintf(branchname,"%s2",GetName());
1408   
1409   // Branch address for hit tree
1410   TTree *treeH = gAlice->TreeH();
1411   if ((treeH) && (fHitType > 0)) {
1412     branch = treeH->GetBranch(branchname);
1413     if (branch) {
1414       branch->SetAddress(&fTrackHits);
1415     }
1416   }
1417
1418 }
1419
1420 //_____________________________________________________________________________
1421 void AliTRD::AddHit2(Int_t track, Int_t det, Float_t *hits, Int_t q
1422                    , Bool_t inDrift)
1423 {
1424   //
1425   // Add a hit to the list
1426   //
1427
1428   Int_t rtrack;
1429
1430   if (fIshunt) {
1431     Int_t primary = gAlice->GetPrimary(track);
1432     gAlice->Particle(primary)->SetBit(kKeepBit);
1433     rtrack = primary;
1434   } 
1435   else {
1436     rtrack = track;
1437     gAlice->FlagTrack(track);
1438   }
1439
1440   if ((fTrackHits) && (fHitType > 0)) {
1441     fTrackHits->AddHitTRD(det,rtrack,hits[0],hits[1],hits[2],q,inDrift);
1442   }
1443
1444 }
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783