1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Revision 1.37 2002/03/25 20:01:49 cblume
19 Introduce parameter class
21 Revision 1.36 2002/02/11 14:25:27 cblume
22 Geometry update, compressed hit structure
24 Revision 1.35 2001/11/14 12:08:44 cblume
25 Remove unneccessary header files
27 Revision 1.34 2001/11/14 10:50:45 cblume
28 Changes in digits IO. Add merging of summable digits
30 Revision 1.33 2001/11/06 17:19:41 cblume
31 Add detailed geometry and simple simulator
33 Revision 1.32 2001/10/08 06:57:33 hristov
34 Branches for TRD digits are created only during the digitisation
36 Revision 1.31 2001/08/30 09:30:30 hristov
37 The split level of branches is set to 99
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)
42 Revision 1.29 2001/05/21 16:45:47 hristov
43 Last minute changes (C.Blume)
45 Revision 1.28 2001/05/16 14:57:27 alibrary
46 New files for folders and Stack
48 Revision 1.27 2001/05/08 07:05:02 hristov
49 Loop variable declared once (HP, Sun)
51 Revision 1.26 2001/05/07 08:03:22 cblume
52 Generate also hits in the amplification region
54 Revision 1.25 2001/03/13 09:30:35 cblume
55 Update of digitization. Moved digit branch definition to AliTRD
57 Revision 1.24 2001/01/26 19:56:49 hristov
58 Major upgrade of AliRoot code
60 Revision 1.23 2000/11/01 14:53:20 cblume
61 Merge with TRD-develop
63 Revision 1.17.2.6 2000/10/15 23:29:08 cblume
64 Introduced more detailed geometry for the display
66 Revision 1.17.2.5 2000/10/06 16:49:46 cblume
69 Revision 1.17.2.4 2000/10/04 16:34:57 cblume
70 Replace include files by forward declarations
72 Revision 1.17.2.3 2000/09/22 14:45:17 cblume
73 Included changes for the tracking
75 Revision 1.17.2.2 2000/09/18 13:25:13 cblume
76 Included LoadPoints() method to display the TR photons
78 Revision 1.22 2000/10/02 21:28:19 fca
79 Removal of useless dependecies via forward declarations
81 Revision 1.21 2000/06/09 11:10:07 cblume
82 Compiler warnings and coding conventions, next round
84 Revision 1.20 2000/06/08 18:32:57 cblume
85 Make code compliant to coding conventions
87 Revision 1.19 2000/06/07 16:25:37 cblume
88 Try to remove compiler warnings on Sun and HP
90 Revision 1.18 2000/05/08 16:17:27 cblume
93 Revision 1.21 2000/06/09 11:10:07 cblume
94 Compiler warnings and coding conventions, next round
96 Revision 1.20 2000/06/08 18:32:57 cblume
97 Make code compliant to coding conventions
99 Revision 1.19 2000/06/07 16:25:37 cblume
100 Try to remove compiler warnings on Sun and HP
102 Revision 1.18 2000/05/08 16:17:27 cblume
105 Revision 1.17.2.1 2000/05/08 14:28:59 cblume
106 Introduced SetPHOShole() and SetRICHhole(). AliTRDrecPoint container is now a TObjArray
108 Revision 1.17 2000/02/28 19:10:26 cblume
109 Include the new TRD classes
111 Revision 1.16.2.2 2000/02/28 17:53:24 cblume
112 Introduce TRD geometry classes
114 Revision 1.16.2.1 2000/02/28 17:04:19 cblume
115 Include functions and data members for AliTRDrecPoint
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
120 Revision 1.15 1999/11/02 17:04:25 fca
121 Small syntax change for HP compiler
123 Revision 1.14 1999/11/02 16:57:02 fca
124 Avoid non ansi warnings on HP compilers
126 Revision 1.13 1999/11/02 16:35:56 fca
127 New version of TRD introduced
129 Revision 1.12 1999/11/01 20:41:51 fca
130 Added protections against using the wrong version of FRAME
132 Revision 1.11 1999/09/29 09:24:34 fca
133 Introduction of the Copyright and cvs Log
137 ///////////////////////////////////////////////////////////////////////////////
139 // Transition Radiation Detector //
140 // This class contains the basic functions for the Transition Radiation //
143 ///////////////////////////////////////////////////////////////////////////////
146 #include <iostream.h>
150 #include <TGeometry.h>
155 #include <TParticle.h>
158 #include "AliConst.h"
159 #include "AliDigit.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"
178 //_____________________________________________________________________________
182 // Default constructor
206 //_____________________________________________________________________________
207 AliTRD::AliTRD(const char *name, const char *title)
208 : AliDetector(name,title)
211 // Standard constructor for the TRD
214 // Check that FRAME is there otherwise we have no place where to
216 AliModule* frame = gAlice->GetModule("FRAME");
218 Error("Ctor","TRD needs FRAME to be present\n");
222 // Define the TRD geometry according to the FRAME geometry
223 if (frame->IsVersion() == 0) {
224 // Geometry with hole
225 fGeometry = new AliTRDgeometryHole();
227 else if (frame->IsVersion() == 1) {
228 // Geometry without hole
229 fGeometry = new AliTRDgeometryFull();
232 Error("Ctor","Could not find valid FRAME version\n");
236 // Allocate the hit array
237 fHits = new TClonesArray("AliTRDhit" ,405);
238 gAlice->AddHitList(fHits);
240 // Allocate the digits array
243 // Allocate the rec point array
244 fRecPoints = new TObjArray(400);
259 SetMarkerColor(kWhite);
263 //_____________________________________________________________________________
264 AliTRD::AliTRD(const AliTRD &trd)
270 ((AliTRD &) trd).Copy(*this);
274 //_____________________________________________________________________________
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)
307 // Add a cluster for the TRD
310 Int_t pla = fGeometry->GetPlane(det);
311 Int_t cha = fGeometry->GetChamber(det);
312 Int_t sec = fGeometry->GetSector(det);
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);
321 AliTRDcluster *c = new AliTRDcluster();
324 c->AddTrackIndex(tracks);
328 c->SetLocalTimeBin(((Int_t) pos[2]));
329 c->SetY(col0 + padCol * colSize);
330 c->SetZ(row0 + padRow * rowSize);
332 c->SetSigmaY2((sigmaY2 + 1./12.) * colSize*colSize);
333 c->SetSigmaZ2(rowSize * rowSize / 12.);
357 //_____________________________________________________________________________
358 void AliTRD::Hits2Digits()
364 AliTRDdigitizer *digitizer = new AliTRDdigitizer("TRDdigitizer"
365 ,"TRD digitizer class");
366 digitizer->SetDebug(GetDebug());
367 digitizer->SetEvent(gAlice->GetEvNumber());
370 digitizer->InitDetector();
373 digitizer->MakeDigits();
375 // Write the digits into the input file
376 if (digitizer->MakeBranch(fDigitsFile)) {
378 digitizer->WriteDigits();
380 // Save the digitizer class in the AliROOT
387 //_____________________________________________________________________________
388 void AliTRD::Hits2SDigits()
391 // Create summable digits
394 AliTRDdigitizer *digitizer = new AliTRDdigitizer("TRDdigitizer"
395 ,"TRD digitizer class");
396 digitizer->SetDebug(GetDebug());
398 // For the summable digits
399 digitizer->SetSDigits(kTRUE);
400 digitizer->SetEvent(gAlice->GetEvNumber());
403 digitizer->InitDetector();
405 // Create the TRD s-digits branch
406 digitizer->MakeDigits();
408 // Write the digits into the input file
409 if (digitizer->MakeBranch(fDigitsFile)) {
411 digitizer->WriteDigits();
413 // Save the digitizer class in the AliROOT
420 //_____________________________________________________________________________
421 void AliTRD::SDigits2Digits()
424 // Create final digits from summable digits
427 // Create the TRD digitizer
428 AliTRDdigitizer *digitizer = new AliTRDdigitizer("TRDdigitizer"
429 ,"TRD digitizer class");
430 digitizer->SetDebug(GetDebug());
433 digitizer->SetEvent(gAlice->GetEvNumber());
436 digitizer->InitDetector();
438 // Read the s-digits via digits manager
439 AliTRDdigitsManager *sdigitsManager = new AliTRDdigitsManager();
440 sdigitsManager->SetDebug(GetDebug());
441 sdigitsManager->SetSDigits(kTRUE);
443 sdigitsManager->Open(fDigitsFile);
445 sdigitsManager->CreateArrays();
446 sdigitsManager->ReadDigits();
448 // Add the s-digits to the input list
449 digitizer->AddSDigitsManager(sdigitsManager);
451 // Convert the s-digits to normal digits
452 digitizer->SDigits2Digits();
455 if (digitizer->MakeBranch(fDigitsFile)) {
457 digitizer->WriteDigits();
463 //_____________________________________________________________________________
464 void AliTRD::AddHit(Int_t track, Int_t det, Float_t *hits, Int_t q
468 // Add a hit for the TRD
470 // The data structure is set according to fHitType:
471 // bit0: standard TClonesArray
472 // bit1: compressed trackHits structure
476 TClonesArray &lhits = *fHits;
477 new(lhits[fNhits++]) AliTRDhit(fIshunt,track,det,hits,q);
481 AddHit2(track,det,hits,q,inDrift);
486 //_____________________________________________________________________________
487 void AliTRD::BuildGeometry()
490 // Create the ROOT TNode geometry for the TRD
497 Float_t zmax1, zmax2;
501 const Int_t kColorTRD = 46;
503 // Find the top node alice
504 top = gAlice->GetGeometry()->GetNode("alice");
506 if (fDisplayType == 0) {
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);
516 node = new TNode("TRD","TRD","S_TRD",0,0,0,"");
517 node->SetLineColor(kColorTRD);
521 else if (fDisplayType == 1) {
525 Float_t slope = (AliTRDgeometry::Zmax1() - AliTRDgeometry::Zmax2())
526 / (AliTRDgeometry::Rmax() - AliTRDgeometry::Rmin());
528 rmin = AliTRDgeometry::Rmin() + AliTRDgeometry::CraHght();
529 rmax = rmin + AliTRDgeometry::CdrHght();
531 Float_t thickness = rmin - AliTRDgeometry::Rmin();
532 zmax2 = AliTRDgeometry::Zmax2() + slope * thickness;
533 zmax1 = zmax2 + slope * AliTRDgeometry::DrThick();
535 for (iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) {
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);
544 node = new TNode("TRD","TRD",name,0,0,0,"");
545 node->SetLineColor(kColorTRD);
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;
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();
562 for (iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) {
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);
571 node = new TNode("TRD","TRD",name,0,0,0,"");
572 node->SetLineColor(kColorTRD);
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;
587 //_____________________________________________________________________________
588 void AliTRD::Copy(TObject &trd)
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;
604 //AliDetector::Copy(trd);
608 //_____________________________________________________________________________
609 void AliTRD::CreateGeometry()
612 // Creates the volumes for the TRD chambers
615 // Check that FRAME is there otherwise we have no place where to put the TRD
616 AliModule* frame = gAlice->GetModule("FRAME");
618 printf(" The TRD needs the FRAME to be defined first\n");
622 fGeometry->CreateGeometry(fIdtmed->GetArray() - 1299);
626 //_____________________________________________________________________________
627 void AliTRD::CreateMaterials()
630 // Create the materials for the TRD
634 Int_t isxfld = gAlice->Field()->Integ();
635 Float_t sxmgmx = gAlice->Field()->Max();
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. };
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. };
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;
656 Float_t awa[2] = { 1., 16. };
657 Float_t zwa[2] = { 1., 8. };
658 Float_t wwa[2] = { 2., 1. };
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;
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 };
673 // For Xe/CO2-gas-mixture
674 // Xe-content of the Xe/CO2-mixture (85% / 15%)
676 // Xe-content of the Xe/Isobutane-mixture (97% / 3%)
678 Float_t dxe = .005858;
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;
687 Float_t absl, radl, d, buf[1];
688 Float_t agm[2], zgm[2], wgm[2];
692 //////////////////////////////////////////////////////////////////////////
694 //////////////////////////////////////////////////////////////////////////
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);
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);
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
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
734 dgm2 = wgm[0] * dxe + wgm[1] * dis;
735 AliMixture(11, "Gas mixture 2", agm, zgm, dgm2, 2, wgm);
737 //////////////////////////////////////////////////////////////////////////
738 // Tracking Media Parameters
739 //////////////////////////////////////////////////////////////////////////
742 AliMedium(1, "Al Frame", 1, 0, isxfld, sxmgmx
743 , tmaxfd, stemax, deemax, epsil, stmin);
745 AliMedium(2, "Air", 2, 0, isxfld, sxmgmx
746 , tmaxfd, stemax, deemax, epsil, stmin);
748 AliMedium(3, "Radiator", 3, 0, isxfld, sxmgmx
749 , tmaxfd, stemax, deemax, epsil, stmin);
751 AliMedium(4, "Xe", 4, 1, isxfld, sxmgmx
752 , tmaxfd, stemax, deemax, epsil, stmin);
754 AliMedium(5, "Padplane", 5, 1, isxfld, sxmgmx
755 , tmaxfd, stemax, deemax, epsil, stmin);
757 AliMedium(6, "Readout", 1, 0, isxfld, sxmgmx
758 , tmaxfd, stemax, deemax, epsil, stmin);
760 AliMedium(7, "C Frame", 6, 0, isxfld, sxmgmx
761 , tmaxfd, stemax, deemax, epsil, stmin);
763 AliMedium(8, "Mylar", 7, 0, isxfld, sxmgmx
764 , tmaxfd, stemax, deemax, epsil, stmin);
766 // Gas-mixture (Xe/CO2)
767 AliMedium(9, "Gas-mix", 10, 1, isxfld, sxmgmx
768 , tmaxfd, stemax, deemax, epsil, stmin);
771 // Gas-mixture (Xe/Isobutane)
772 AliMedium(9, "Gas-mix", 11, 1, isxfld, sxmgmx
773 , tmaxfd, stemax, deemax, epsil, stmin);
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);
785 AliMedium(13, "G10-plates",12, 0, isxfld, sxmgmx
786 , tmaxfd, stemax, deemax, epsil, stmin);
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);
794 AliMedium(16, "MCM-Al" , 1, 0, isxfld, sxmgmx
795 , tmaxfd, stemax, deemax, epsil, stmin);
797 AliMedium(17, "MCM-Sn" , 15, 0, isxfld, sxmgmx
798 , tmaxfd, stemax, deemax, epsil, stmin);
800 AliMedium(18, "MCM-Cu" , 5, 0, isxfld, sxmgmx
801 , tmaxfd, stemax, deemax, epsil, stmin);
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);
812 AliMedium(22, "Conn-PE" , 3, 0, isxfld, sxmgmx
813 , tmaxfd, stemax, deemax, epsil, stmin);
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);
821 // Save the density values for the TRD absorbtion
830 //_____________________________________________________________________________
831 void AliTRD::DrawModule() const
834 // Draw a shaded view of the Transition Radiation Detector version 0
837 // Set everything unseen
838 gMC->Gsatt("*" ,"SEEN",-1);
840 // Set ALIC mother transparent
841 gMC->Gsatt("ALIC","SEEN", 0);
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);
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);
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);
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);
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");
889 //_____________________________________________________________________________
890 Int_t AliTRD::DistancetoPrimitive(Int_t , Int_t ) const
893 // Distance between the mouse and the TRD detector on the screen
900 //_____________________________________________________________________________
904 // Initialize the TRD detector after the geometry has been created
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("*");
917 if (fGeometry->IsVersion() == 0) {
918 printf("%s: Geometry for spaceframe with holes initialized\n",ClassName());
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());
929 printf("%s: Gas Mixture: 85%% Xe + 15%% CO2\n",ClassName());
932 printf("%s: Gas Mixture: 97%% Xe + 3%% Isobutane\n",ClassName());
937 //_____________________________________________________________________________
938 void AliTRD::LoadPoints(Int_t track)
941 // Store x, y, z of all hits in memory.
942 // Hit originating from TR photons are given a different color
946 // AliDetector::LoadPoints(track);
950 if ((fHits == 0) && (fTrackHits == 0)) return;
954 nhits = fHits->GetEntriesFast();
957 nhits = fTrackHits->GetEntriesFast();
959 if (nhits == 0) return;
961 Int_t tracks = gAlice->GetNtrack();
962 if (fPoints == 0) fPoints = new TObjArray(tracks);
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++) {
981 AliTRDpoints *points = 0;
984 Int_t chunk = nhits / 4 + 1;
986 // Loop over all the hits and store their position
987 ahit = (AliTRDhit *) FirstHit(-1);
991 if (ahit->GetCharge() >= 0) {
993 trk = ahit->GetTrack();
994 if (ntrkE[trk] == limiE[trk]) {
995 // Initialise a new track
996 fp = new Float_t[3*(limiE[trk]+chunk)];
998 memcpy(fp,coorE[trk],sizeof(Float_t)*3*limiE[trk]);
999 delete [] coorE[trk];
1001 limiE[trk] += chunk;
1007 fp[3*ntrkE[trk] ] = ahit->X();
1008 fp[3*ntrkE[trk]+1] = ahit->Y();
1009 fp[3*ntrkE[trk]+2] = ahit->Z();
1014 else if ((ahit->GetCharge() < 0) && (fDrawTR)) {
1016 trk = ahit->GetTrack();
1017 if (ntrkT[trk] == limiT[trk]) {
1018 // Initialise a new track
1019 fp = new Float_t[3*(limiT[trk]+chunk)];
1021 memcpy(fp,coorT[trk],sizeof(Float_t)*3*limiT[trk]);
1022 delete [] coorT[trk];
1024 limiT[trk] += chunk;
1030 fp[3*ntrkT[trk] ] = ahit->X();
1031 fp[3*ntrkT[trk]+1] = ahit->Y();
1032 fp[3*ntrkT[trk]+2] = ahit->Z();
1037 ahit = (AliTRDhit *) NextHit();
1041 for (trk = 0; trk < tracks; ++trk) {
1043 if (ntrkE[trk] || ntrkT[trk]) {
1045 points = new AliTRDpoints();
1046 points->SetDetector(this);
1047 points->SetParticle(trk);
1049 // Set the dEdx points
1051 points->SetMarkerColor(GetMarkerColor());
1052 points->SetMarkerSize(GetMarkerSize());
1053 points->SetPolyMarker(ntrkE[trk],coorE[trk],GetMarkerStyle());
1054 delete [] coorE[trk];
1058 // Set the TR photon points
1060 points->SetTRpoints(ntrkT[trk],coorT[trk]);
1061 delete [] coorT[trk];
1065 fPoints->AddAt(points,trk);
1080 //_____________________________________________________________________________
1081 void AliTRD::MakeBranch(Option_t* option, const char *file)
1084 // Create Tree branches for the TRD digits.
1087 Int_t buffersize = 4000;
1088 Char_t branchname[15];
1089 sprintf(branchname,"%s",GetName());
1091 const char *cD = strstr(option,"D");
1093 AliDetector::MakeBranch(option,file);
1095 if (fDigits && gAlice->TreeD() && cD) {
1096 MakeBranchInTree(gAlice->TreeD(),branchname,&fDigits,buffersize,file);
1100 MakeBranch2(option,file);
1105 //_____________________________________________________________________________
1106 void AliTRD::ResetDigits()
1109 // Reset number of digits and the digits array for this detector
1113 if (fDigits) fDigits->Clear();
1117 //_____________________________________________________________________________
1118 void AliTRD::ResetRecPoints()
1121 // Reset number of reconstructed points and the point array
1126 Int_t nentr = fRecPoints->GetEntriesFast();
1127 for (Int_t i = 0; i < nentr; i++) delete fRecPoints->RemoveAt(i);
1132 //_____________________________________________________________________________
1133 void AliTRD::SetTreeAddress()
1136 // Set the branch addresses for the trees.
1139 Char_t branchname[15];
1141 AliDetector::SetTreeAddress();
1144 TTree *treeR = gAlice->TreeR();
1147 sprintf(branchname,"%scluster",GetName());
1149 branch = treeR->GetBranch(branchname);
1151 branch->SetAddress(&fRecPoints);
1162 //_____________________________________________________________________________
1163 void AliTRD::SetGasMix(Int_t imix)
1166 // Defines the gas mixture (imix=0: Xe/Isobutane imix=1: Xe/CO2)
1169 if ((imix < 0) || (imix > 1)) {
1170 printf("Wrong input value: %d\n",imix);
1171 printf("Use standard setting\n");
1180 //_____________________________________________________________________________
1181 void AliTRD::SetPHOShole()
1184 // Selects a geometry with a hole in front of the PHOS
1187 fGeometry->SetPHOShole();
1191 //_____________________________________________________________________________
1192 void AliTRD::SetRICHhole()
1195 // Selects a geometry with a hole in front of the RICH
1198 fGeometry->SetRICHhole();
1202 //_____________________________________________________________________________
1203 AliTRD &AliTRD::operator=(const AliTRD &trd)
1206 // Assignment operator
1209 if (this != &trd) ((AliTRD &) trd).Copy(*this);
1214 //_____________________________________________________________________________
1215 void AliTRD::FinishPrimary()
1218 // Store the hits in the containers after all primaries are finished
1222 fTrackHits->FlushHitStack();
1227 //_____________________________________________________________________________
1228 void AliTRD::RemapTrackHitIDs(Int_t *map)
1231 // Remap the track IDs
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];
1248 //_____________________________________________________________________________
1249 void AliTRD::ResetHits()
1255 AliDetector::ResetHits();
1257 fTrackHits->Clear();
1262 //_____________________________________________________________________________
1263 AliHit* AliTRD::FirstHit(Int_t track)
1266 // Return the first hit of a track
1270 return FirstHit2(track);
1273 return AliDetector::FirstHit(track);
1277 //_____________________________________________________________________________
1278 AliHit* AliTRD::NextHit()
1281 // Returns the next hit of a track
1288 return AliDetector::NextHit();
1292 //_____________________________________________________________________________
1293 AliHit* AliTRD::FirstHit2(Int_t track)
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.
1304 gAlice->ResetHits();
1305 gAlice->TreeH()->GetEvent(track);
1309 fTrackHits->First();
1310 return (AliHit*) fTrackHits->GetHit();
1318 //_____________________________________________________________________________
1319 AliHit* AliTRD::NextHit2()
1322 // Returns the next hit of the current track
1327 return (AliHit *) fTrackHits->GetHit();
1335 //_____________________________________________________________________________
1336 void AliTRD::MakeBranch2(Option_t *option, const char *file)
1339 // Create a new branch in the current Root tree.
1340 // The branch of fHits is automatically split.
1347 char branchname[10];
1348 sprintf(branchname,"%s2",GetName());
1350 // Get the pointer to the header
1351 const char *cH = strstr(option,"H");
1354 fTrackHits = new AliTRDtrackHits();
1357 if (fTrackHits && gAlice->TreeH() && cH) {
1359 gAlice->TreeH()->Branch(branchname,"AliTRDtrackHits"
1363 if (GetDebug() > 1) {
1364 printf("<AliTRD::MakeBranch2> Making Branch %s for trackhits\n"
1368 const char kFolder[] = "RunMC/Event/Data";
1371 printf("<AliTRD::MakeBranch2> %15s: Publishing %s to %s\n"
1372 ,ClassName(),branchname,kFolder);
1375 Publish(kFolder,&fTrackHits,branchname);
1378 TBranch *b = gAlice->TreeH()->GetBranch(branchname);
1379 TDirectory *wd = gDirectory;
1381 TIter next(b->GetListOfBranches());
1382 while ((b = (TBranch*) next())) {
1386 if (GetDebug() > 1) {
1387 printf("<AliTRD::MakeBranch2> Diverting branch %s to file %s\n"
1396 //_____________________________________________________________________________
1397 void AliTRD::SetTreeAddress2()
1400 // Set the branch address for the trackHits tree
1405 char branchname[20];
1407 sprintf(branchname,"%s2",GetName());
1409 // Branch address for hit tree
1410 TTree *treeH = gAlice->TreeH();
1411 if ((treeH) && (fHitType > 0)) {
1412 branch = treeH->GetBranch(branchname);
1414 branch->SetAddress(&fTrackHits);
1420 //_____________________________________________________________________________
1421 void AliTRD::AddHit2(Int_t track, Int_t det, Float_t *hits, Int_t q
1425 // Add a hit to the list
1431 Int_t primary = gAlice->GetPrimary(track);
1432 gAlice->Particle(primary)->SetBit(kKeepBit);
1437 gAlice->FlagTrack(track);
1440 if ((fTrackHits) && (fHitType > 0)) {
1441 fTrackHits->AddHitTRD(det,rtrack,hits[0],hits[1],hits[2],q,inDrift);