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