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