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.36.6.2 2002/07/24 10:09:30 alibrary
21 Revision 1.40 2002/06/13 08:11:56 cblume
22 Add the track references
24 Revision 1.39 2002/06/12 09:54:35 cblume
25 Update of tracking code provided by Sergei
27 Revision 1.38 2002/03/28 14:59:07 cblume
30 Revision 1.37 2002/03/25 20:01:49 cblume
31 Introduce parameter class
33 Revision 1.36 2002/02/11 14:25:27 cblume
34 Geometry update, compressed hit structure
36 Revision 1.35 2001/11/14 12:08:44 cblume
37 Remove unneccessary header files
39 Revision 1.34 2001/11/14 10:50:45 cblume
40 Changes in digits IO. Add merging of summable digits
42 Revision 1.33 2001/11/06 17:19:41 cblume
43 Add detailed geometry and simple simulator
45 Revision 1.32 2001/10/08 06:57:33 hristov
46 Branches for TRD digits are created only during the digitisation
48 Revision 1.31 2001/08/30 09:30:30 hristov
49 The split level of branches is set to 99
51 Revision 1.30 2001/05/28 17:07:58 hristov
52 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)
54 Revision 1.29 2001/05/21 16:45:47 hristov
55 Last minute changes (C.Blume)
57 Revision 1.28 2001/05/16 14:57:27 alibrary
58 New files for folders and Stack
60 Revision 1.27 2001/05/08 07:05:02 hristov
61 Loop variable declared once (HP, Sun)
63 Revision 1.26 2001/05/07 08:03:22 cblume
64 Generate also hits in the amplification region
66 Revision 1.25 2001/03/13 09:30:35 cblume
67 Update of digitization. Moved digit branch definition to AliTRD
69 Revision 1.24 2001/01/26 19:56:49 hristov
70 Major upgrade of AliRoot code
72 Revision 1.23 2000/11/01 14:53:20 cblume
73 Merge with TRD-develop
75 Revision 1.17.2.6 2000/10/15 23:29:08 cblume
76 Introduced more detailed geometry for the display
78 Revision 1.17.2.5 2000/10/06 16:49:46 cblume
81 Revision 1.17.2.4 2000/10/04 16:34:57 cblume
82 Replace include files by forward declarations
84 Revision 1.17.2.3 2000/09/22 14:45:17 cblume
85 Included changes for the tracking
87 Revision 1.17.2.2 2000/09/18 13:25:13 cblume
88 Included LoadPoints() method to display the TR photons
90 Revision 1.22 2000/10/02 21:28:19 fca
91 Removal of useless dependecies via forward declarations
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.21 2000/06/09 11:10:07 cblume
106 Compiler warnings and coding conventions, next round
108 Revision 1.20 2000/06/08 18:32:57 cblume
109 Make code compliant to coding conventions
111 Revision 1.19 2000/06/07 16:25:37 cblume
112 Try to remove compiler warnings on Sun and HP
114 Revision 1.18 2000/05/08 16:17:27 cblume
117 Revision 1.17.2.1 2000/05/08 14:28:59 cblume
118 Introduced SetPHOShole() and SetRICHhole(). AliTRDrecPoint container is now a TObjArray
120 Revision 1.17 2000/02/28 19:10:26 cblume
121 Include the new TRD classes
123 Revision 1.16.2.2 2000/02/28 17:53:24 cblume
124 Introduce TRD geometry classes
126 Revision 1.16.2.1 2000/02/28 17:04:19 cblume
127 Include functions and data members for AliTRDrecPoint
129 Revision 1.16 2000/01/19 17:17:35 fca
130 Introducing a list of lists of hits -- more hits allowed for detector now
132 Revision 1.15 1999/11/02 17:04:25 fca
133 Small syntax change for HP compiler
135 Revision 1.14 1999/11/02 16:57:02 fca
136 Avoid non ansi warnings on HP compilers
138 Revision 1.13 1999/11/02 16:35:56 fca
139 New version of TRD introduced
141 Revision 1.12 1999/11/01 20:41:51 fca
142 Added protections against using the wrong version of FRAME
144 Revision 1.11 1999/09/29 09:24:34 fca
145 Introduction of the Copyright and cvs Log
149 ///////////////////////////////////////////////////////////////////////////////
151 // Transition Radiation Detector //
152 // This class contains the basic functions for the Transition Radiation //
155 ///////////////////////////////////////////////////////////////////////////////
158 #include <iostream.h>
162 #include <TGeometry.h>
167 #include <TParticle.h>
168 #include <TLorentzVector.h>
171 #include "AliConst.h"
172 #include "AliDigit.h"
175 #include "AliTrackReference.h"
178 #include "AliTRDhit.h"
179 #include "AliTRDpoints.h"
180 #include "AliTRDdigit.h"
181 #include "AliTRDdigitizer.h"
182 #include "AliTRDclusterizer.h"
183 #include "AliTRDgeometryHole.h"
184 #include "AliTRDgeometryFull.h"
185 #include "AliTRDrecPoint.h"
186 #include "AliTRDcluster.h"
187 #include "AliTRDdigitsManager.h"
188 #include "AliTRDtrackHits.h"
192 //_____________________________________________________________________________
196 // Default constructor
220 //_____________________________________________________________________________
221 AliTRD::AliTRD(const char *name, const char *title)
222 : AliDetector(name,title)
225 // Standard constructor for the TRD
228 // Check that FRAME is there otherwise we have no place where to
230 AliModule* frame = gAlice->GetModule("FRAME");
232 Error("Ctor","TRD needs FRAME to be present\n");
236 // Define the TRD geometry according to the FRAME geometry
237 if (frame->IsVersion() == 0) {
238 // Geometry with hole
239 fGeometry = new AliTRDgeometryHole();
241 else if (frame->IsVersion() == 1) {
242 // Geometry without hole
243 fGeometry = new AliTRDgeometryFull();
246 Error("Ctor","Could not find valid FRAME version\n");
250 // Allocate the hit array
251 fHits = new TClonesArray("AliTRDhit" ,405);
252 gAlice->AddHitList(fHits);
254 // Allocate the digits array
257 // Allocate the rec point array
258 fRecPoints = new TObjArray(400);
273 SetMarkerColor(kWhite);
277 //_____________________________________________________________________________
278 AliTRD::AliTRD(const AliTRD &trd)
284 ((AliTRD &) trd).Copy(*this);
288 //_____________________________________________________________________________
316 //_____________________________________________________________________________
317 void AliTRD::AddCluster(Float_t *pos, Int_t det, Float_t amp
318 , Int_t *tracks, Float_t *sig, Int_t iType)
321 // Add a cluster for the TRD
324 AliTRDcluster *c = new AliTRDcluster();
327 c->AddTrackIndex(tracks);
331 c->SetSigmaY2(sig[0]);
332 c->SetSigmaZ2(sig[1]);
333 c->SetLocalTimeBin(((Int_t) pos[2]));
357 //_____________________________________________________________________________
358 void AliTRD::AddTrackReference(Int_t label, TLorentzVector p, TLorentzVector x)
361 // Add a trackrefernce to the list
364 if (!fTrackReferences) {
365 Error("AddTrackReference","Container fTrackRefernce not active\n");
369 Int_t nref = fTrackReferences->GetEntriesFast();
370 TClonesArray &lref = *fTrackReferences;
371 AliTrackReference * ref = new(lref[nref]) AliTrackReference();
372 ref->SetMomentum(p[0],p[1],p[2]);
373 ref->SetPosition(x[0],x[1],x[2]);
374 ref->SetTrack(label);
378 //_____________________________________________________________________________
379 void AliTRD::Hits2Digits()
385 AliTRDdigitizer *digitizer = new AliTRDdigitizer("TRDdigitizer"
386 ,"TRD digitizer class");
387 digitizer->SetDebug(GetDebug());
388 digitizer->SetEvent(gAlice->GetEvNumber());
391 digitizer->InitDetector();
394 digitizer->MakeDigits();
396 // Write the digits into the input file
397 if (digitizer->MakeBranch(fDigitsFile)) {
399 digitizer->WriteDigits();
401 // Save the digitizer class in the AliROOT
408 //_____________________________________________________________________________
409 void AliTRD::Hits2SDigits()
412 // Create summable digits
415 AliTRDdigitizer *digitizer = new AliTRDdigitizer("TRDdigitizer"
416 ,"TRD digitizer class");
417 digitizer->SetDebug(GetDebug());
419 // For the summable digits
420 digitizer->SetSDigits(kTRUE);
421 digitizer->SetEvent(gAlice->GetEvNumber());
424 digitizer->InitDetector();
426 // Create the TRD s-digits branch
427 digitizer->MakeDigits();
429 // Write the digits into the input file
430 if (digitizer->MakeBranch(fDigitsFile)) {
432 digitizer->WriteDigits();
434 // Save the digitizer class in the AliROOT
441 //_____________________________________________________________________________
442 void AliTRD::SDigits2Digits()
445 // Create final digits from summable digits
448 // Create the TRD digitizer
449 AliTRDdigitizer *digitizer = new AliTRDdigitizer("TRDdigitizer"
450 ,"TRD digitizer class");
451 digitizer->SetDebug(GetDebug());
454 digitizer->SetEvent(gAlice->GetEvNumber());
457 digitizer->InitDetector();
459 // Read the s-digits via digits manager
460 AliTRDdigitsManager *sdigitsManager = new AliTRDdigitsManager();
461 sdigitsManager->SetDebug(GetDebug());
462 sdigitsManager->SetSDigits(kTRUE);
464 sdigitsManager->Open(fDigitsFile);
466 sdigitsManager->CreateArrays();
467 sdigitsManager->ReadDigits();
469 // Add the s-digits to the input list
470 digitizer->AddSDigitsManager(sdigitsManager);
472 // Convert the s-digits to normal digits
473 digitizer->SDigits2Digits();
476 if (digitizer->MakeBranch(fDigitsFile)) {
478 digitizer->WriteDigits();
484 //_____________________________________________________________________________
485 void AliTRD::AddHit(Int_t track, Int_t det, Float_t *hits, Int_t q
489 // Add a hit for the TRD
491 // The data structure is set according to fHitType:
492 // bit0: standard TClonesArray
493 // bit1: compressed trackHits structure
497 TClonesArray &lhits = *fHits;
498 new(lhits[fNhits++]) AliTRDhit(fIshunt,track,det,hits,q);
502 AddHit2(track,det,hits,q,inDrift);
507 //_____________________________________________________________________________
508 void AliTRD::BuildGeometry()
511 // Create the ROOT TNode geometry for the TRD
518 Float_t zmax1, zmax2;
522 const Int_t kColorTRD = 46;
524 // Find the top node alice
525 top = gAlice->GetGeometry()->GetNode("alice");
527 if (fDisplayType == 0) {
529 pgon = new TPGON("S_TRD","TRD","void",0,360,AliTRDgeometry::Nsect(),4);
530 rmin = AliTRDgeometry::Rmin();
531 rmax = AliTRDgeometry::Rmax();
532 pgon->DefineSection(0,-AliTRDgeometry::Zmax1(),rmax,rmax);
533 pgon->DefineSection(1,-AliTRDgeometry::Zmax2(),rmin,rmax);
534 pgon->DefineSection(2, AliTRDgeometry::Zmax2(),rmin,rmax);
535 pgon->DefineSection(3, AliTRDgeometry::Zmax1(),rmax,rmax);
537 node = new TNode("TRD","TRD","S_TRD",0,0,0,"");
538 node->SetLineColor(kColorTRD);
542 else if (fDisplayType == 1) {
546 Float_t slope = (AliTRDgeometry::Zmax1() - AliTRDgeometry::Zmax2())
547 / (AliTRDgeometry::Rmax() - AliTRDgeometry::Rmin());
549 rmin = AliTRDgeometry::Rmin() + AliTRDgeometry::CraHght();
550 rmax = rmin + AliTRDgeometry::CdrHght();
552 Float_t thickness = rmin - AliTRDgeometry::Rmin();
553 zmax2 = AliTRDgeometry::Zmax2() + slope * thickness;
554 zmax1 = zmax2 + slope * AliTRDgeometry::DrThick();
556 for (iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) {
558 sprintf(name,"S_TR1%d",iPlan);
559 pgon = new TPGON(name,"TRD","void",0,360,AliTRDgeometry::Nsect(),4);
560 pgon->DefineSection(0,-zmax1,rmax,rmax);
561 pgon->DefineSection(1,-zmax2,rmin,rmax);
562 pgon->DefineSection(2, zmax2,rmin,rmax);
563 pgon->DefineSection(3, zmax1,rmax,rmax);
565 node = new TNode("TRD","TRD",name,0,0,0,"");
566 node->SetLineColor(kColorTRD);
569 Float_t height = AliTRDgeometry::Cheight() + AliTRDgeometry::Cspace();
570 rmin = rmin + height;
571 rmax = rmax + height;
572 zmax1 = zmax1 + slope * height;
573 zmax2 = zmax2 + slope * height;
577 thickness += AliTRDgeometry::DrThick();
578 rmin = AliTRDgeometry::Rmin() + thickness;
579 rmax = rmin + AliTRDgeometry::AmThick();
580 zmax2 = AliTRDgeometry::Zmax2() + slope * thickness;
581 zmax1 = zmax2 + slope * AliTRDgeometry::AmThick();
583 for (iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) {
585 sprintf(name,"S_TR2%d",iPlan);
586 pgon = new TPGON(name,"TRD","void",0,360,AliTRDgeometry::Nsect(),4);
587 pgon->DefineSection(0,-zmax1,rmax,rmax);
588 pgon->DefineSection(1,-zmax2,rmin,rmax);
589 pgon->DefineSection(2, zmax2,rmin,rmax);
590 pgon->DefineSection(3, zmax1,rmax,rmax);
592 node = new TNode("TRD","TRD",name,0,0,0,"");
593 node->SetLineColor(kColorTRD);
596 Float_t height = AliTRDgeometry::Cheight() + AliTRDgeometry::Cspace();
597 rmin = rmin + height;
598 rmax = rmax + height;
599 zmax1 = zmax1 + slope * height;
600 zmax2 = zmax2 + slope * height;
608 //_____________________________________________________________________________
609 void AliTRD::Copy(TObject &trd)
615 ((AliTRD &) trd).fGasMix = fGasMix;
616 ((AliTRD &) trd).fGeometry = fGeometry;
617 ((AliTRD &) trd).fRecPoints = fRecPoints;
618 ((AliTRD &) trd).fNRecPoints = fNRecPoints;
619 ((AliTRD &) trd).fGasDensity = fGasDensity;
620 ((AliTRD &) trd).fFoilDensity = fFoilDensity;
621 ((AliTRD &) trd).fDrawTR = fDrawTR;
622 ((AliTRD &) trd).fDisplayType = fDisplayType;
623 ((AliTRD &) trd).fHitType = fHitType;
625 //AliDetector::Copy(trd);
629 //_____________________________________________________________________________
630 void AliTRD::CreateGeometry()
633 // Creates the volumes for the TRD chambers
636 // Check that FRAME is there otherwise we have no place where to put the TRD
637 AliModule* frame = gAlice->GetModule("FRAME");
639 printf(" The TRD needs the FRAME to be defined first\n");
643 fGeometry->CreateGeometry(fIdtmed->GetArray() - 1299);
647 //_____________________________________________________________________________
648 void AliTRD::CreateMaterials()
651 // Create the materials for the TRD
655 Int_t isxfld = gAlice->Field()->Integ();
656 Float_t sxmgmx = gAlice->Field()->Max();
658 // For polyethilene (CH2)
659 Float_t ape[2] = { 12., 1. };
660 Float_t zpe[2] = { 6., 1. };
661 Float_t wpe[2] = { 1., 2. };
664 // For mylar (C5H4O2)
665 Float_t amy[3] = { 12., 1., 16. };
666 Float_t zmy[3] = { 6., 1., 8. };
667 Float_t wmy[3] = { 5., 4., 2. };
671 Float_t aco[2] = { 12., 16. };
672 Float_t zco[2] = { 6., 8. };
673 Float_t wco[2] = { 1., 2. };
674 Float_t dco = 0.001977;
677 Float_t awa[2] = { 1., 16. };
678 Float_t zwa[2] = { 1., 8. };
679 Float_t wwa[2] = { 2., 1. };
682 // For isobutane (C4H10)
683 Float_t ais[2] = { 12., 1. };
684 Float_t zis[2] = { 6., 1. };
685 Float_t wis[2] = { 4., 10. };
686 Float_t dis = 0.00267;
688 // For plexiglas (C5H8O2)
689 Float_t apg[3] = { 12.011 , 1.0 , 15.9994 };
690 Float_t zpg[3] = { 6.0 , 1.0 , 8.0 };
691 Float_t wpg[3] = { 5.0 , 8.0 , 2.0 };
694 // For Xe/CO2-gas-mixture
695 // Xe-content of the Xe/CO2-mixture (85% / 15%)
697 // Xe-content of the Xe/Isobutane-mixture (97% / 3%)
699 Float_t dxe = .005858;
701 // General tracking parameter
702 Float_t tmaxfd = -10.;
703 Float_t stemax = -1e10;
704 Float_t deemax = -0.1;
705 Float_t epsil = 1e-4;
706 Float_t stmin = -0.001;
708 Float_t absl, radl, d, buf[1];
709 Float_t agm[2], zgm[2], wgm[2];
713 //////////////////////////////////////////////////////////////////////////
715 //////////////////////////////////////////////////////////////////////////
717 AliMaterial( 1, "Al" , 26.98, 13.0, 2.7 , 8.9 , 37.2);
718 AliMaterial( 2, "Air" , 14.61, 7.3, 0.001205, 30420.0 , 67500.0);
719 AliMaterial( 4, "Xe" , 131.29, 54.0, dxe , 1447.59, 0.0);
720 AliMaterial( 5, "Cu" , 63.54, 29.0, 8.96 , 1.43, 14.8);
721 AliMaterial( 6, "C" , 12.01, 6.0, 2.265 , 18.8 , 74.4);
722 AliMaterial(12, "G10" , 20.00, 10.0, 1.7 , 19.4 , 999.0);
723 AliMaterial(15, "Sn" , 118.71, 50.0, 7.31 , 1.21, 14.8);
724 AliMaterial(16, "Si" , 28.09, 14.0, 2.33 , 9.36, 37.2);
725 AliMaterial(17, "Epoxy", 17.75, 8.9, 1.8 , 21.82, 999.0);
728 AliMixture(3, "Polyethilene", ape, zpe, dpe, -2, wpe);
729 AliMixture(7, "Mylar", amy, zmy, dmy, -3, wmy);
730 AliMixture(8, "CO2", aco, zco, dco, -2, wco);
731 AliMixture(9, "Isobutane", ais, zis, dis, -2, wis);
732 AliMixture(13,"Water", awa, zwa, dwa, -2, wwa);
733 AliMixture(14,"Plexiglas", apg, zpg, dpg, -3, wpg);
738 // Get properties of Xe
739 gMC->Gfmate((*fIdmate)[4], namate, agm[0], zgm[0], d, radl, absl, buf, nbuf);
740 // Get properties of CO2
741 gMC->Gfmate((*fIdmate)[8], namate, agm[1], zgm[1], d, radl, absl, buf, nbuf);
742 // Create gas mixture
745 dgm1 = wgm[0] * dxe + wgm[1] * dco;
746 AliMixture(10, "Gas mixture 1", agm, zgm, dgm1, 2, wgm);
747 // Xe/Isobutane-mixture
748 // Get properties of Xe
749 gMC->Gfmate((*fIdmate)[4], namate, agm[0], zgm[0], d, radl, absl, buf, nbuf);
750 // Get properties of Isobutane
751 gMC->Gfmate((*fIdmate)[9], namate, agm[1], zgm[1], d, radl, absl, buf, nbuf);
752 // Create gas mixture
755 dgm2 = wgm[0] * dxe + wgm[1] * dis;
756 AliMixture(11, "Gas mixture 2", agm, zgm, dgm2, 2, wgm);
758 //////////////////////////////////////////////////////////////////////////
759 // Tracking Media Parameters
760 //////////////////////////////////////////////////////////////////////////
763 AliMedium(1, "Al Frame", 1, 0, isxfld, sxmgmx
764 , tmaxfd, stemax, deemax, epsil, stmin);
766 AliMedium(2, "Air", 2, 0, isxfld, sxmgmx
767 , tmaxfd, stemax, deemax, epsil, stmin);
769 AliMedium(3, "Radiator", 3, 0, isxfld, sxmgmx
770 , tmaxfd, stemax, deemax, epsil, stmin);
772 AliMedium(4, "Xe", 4, 1, isxfld, sxmgmx
773 , tmaxfd, stemax, deemax, epsil, stmin);
775 AliMedium(5, "Padplane", 5, 1, isxfld, sxmgmx
776 , tmaxfd, stemax, deemax, epsil, stmin);
778 AliMedium(6, "Readout", 1, 0, isxfld, sxmgmx
779 , tmaxfd, stemax, deemax, epsil, stmin);
781 AliMedium(7, "C Frame", 6, 0, isxfld, sxmgmx
782 , tmaxfd, stemax, deemax, epsil, stmin);
784 AliMedium(8, "Mylar", 7, 0, isxfld, sxmgmx
785 , tmaxfd, stemax, deemax, epsil, stmin);
787 // Gas-mixture (Xe/CO2)
788 AliMedium(9, "Gas-mix", 10, 1, isxfld, sxmgmx
789 , tmaxfd, stemax, deemax, epsil, stmin);
792 // Gas-mixture (Xe/Isobutane)
793 AliMedium(9, "Gas-mix", 11, 1, isxfld, sxmgmx
794 , tmaxfd, stemax, deemax, epsil, stmin);
796 // Nomex-honeycomb (use carbon for the time being)
797 AliMedium(10, "Nomex", 6, 0, isxfld, sxmgmx
798 , tmaxfd, stemax, deemax, epsil, stmin);
799 // Kapton foils (use Mylar for the time being)
800 AliMedium(11, "Kapton", 7, 0, isxfld, sxmgmx
801 , tmaxfd, stemax, deemax, epsil, stmin);
802 // Gas-filling of the radiator
803 AliMedium(12, "CO2", 8, 0, isxfld, sxmgmx
804 , tmaxfd, stemax, deemax, epsil, stmin);
806 AliMedium(13, "G10-plates",12, 0, isxfld, sxmgmx
807 , tmaxfd, stemax, deemax, epsil, stmin);
809 AliMedium(14, "Water", 13, 0, isxfld, sxmgmx
810 , tmaxfd, stemax, deemax, epsil, stmin);
811 // Rohacell (plexiglas) for the radiator
812 AliMedium(15, "Rohacell", 14, 0, isxfld, sxmgmx
813 , tmaxfd, stemax, deemax, epsil, stmin);
815 AliMedium(16, "MCM-Al" , 1, 0, isxfld, sxmgmx
816 , tmaxfd, stemax, deemax, epsil, stmin);
818 AliMedium(17, "MCM-Sn" , 15, 0, isxfld, sxmgmx
819 , tmaxfd, stemax, deemax, epsil, stmin);
821 AliMedium(18, "MCM-Cu" , 5, 0, isxfld, sxmgmx
822 , tmaxfd, stemax, deemax, epsil, stmin);
824 AliMedium(19, "MCM-G10" , 12, 0, isxfld, sxmgmx
825 , tmaxfd, stemax, deemax, epsil, stmin);
826 // Si in readout chips
827 AliMedium(20, "Chip-Si" , 16, 0, isxfld, sxmgmx
828 , tmaxfd, stemax, deemax, epsil, stmin);
829 // Epoxy in readout chips
830 AliMedium(21, "Chip-Ep" , 17, 0, isxfld, sxmgmx
831 , tmaxfd, stemax, deemax, epsil, stmin);
833 AliMedium(22, "Conn-PE" , 3, 0, isxfld, sxmgmx
834 , tmaxfd, stemax, deemax, epsil, stmin);
836 AliMedium(23, "Chip-Cu" , 5, 0, isxfld, sxmgmx
837 , tmaxfd, stemax, deemax, epsil, stmin);
838 // Al of cooling pipes
839 AliMedium(24, "Cooling" , 1, 0, isxfld, sxmgmx
840 , tmaxfd, stemax, deemax, epsil, stmin);
842 // Save the density values for the TRD absorbtion
851 //_____________________________________________________________________________
852 void AliTRD::DrawModule() const
855 // Draw a shaded view of the Transition Radiation Detector version 0
858 // Set everything unseen
859 gMC->Gsatt("*" ,"SEEN",-1);
861 // Set ALIC mother transparent
862 gMC->Gsatt("ALIC","SEEN", 0);
864 // Set the volumes visible
865 if (fGeometry->IsVersion() == 0) {
866 gMC->Gsatt("B071","SEEN", 0);
867 gMC->Gsatt("B074","SEEN", 0);
868 gMC->Gsatt("B075","SEEN", 0);
869 gMC->Gsatt("B077","SEEN", 0);
870 gMC->Gsatt("BTR1","SEEN", 0);
871 gMC->Gsatt("BTR2","SEEN", 0);
872 gMC->Gsatt("BTR3","SEEN", 0);
873 gMC->Gsatt("UTR1","SEEN", 0);
874 gMC->Gsatt("UTR2","SEEN", 0);
875 gMC->Gsatt("UTR3","SEEN", 0);
878 gMC->Gsatt("B071","SEEN", 0);
879 gMC->Gsatt("B074","SEEN", 0);
880 gMC->Gsatt("B075","SEEN", 0);
881 gMC->Gsatt("B077","SEEN", 0);
882 gMC->Gsatt("BTR1","SEEN", 0);
883 gMC->Gsatt("BTR2","SEEN", 0);
884 gMC->Gsatt("BTR3","SEEN", 0);
885 gMC->Gsatt("UTR1","SEEN", 0);
886 if (fGeometry->GetPHOShole())
887 gMC->Gsatt("UTR2","SEEN", 0);
888 if (fGeometry->GetRICHhole())
889 gMC->Gsatt("UTR3","SEEN", 0);
891 // gMC->Gsatt("UCII","SEEN", 0);
892 // gMC->Gsatt("UCIM","SEEN", 0);
893 // gMC->Gsatt("UCIO","SEEN", 0);
894 // gMC->Gsatt("UL02","SEEN", 1);
895 // gMC->Gsatt("UL05","SEEN", 1);
896 // gMC->Gsatt("UL06","SEEN", 1);
898 gMC->Gdopt("hide", "on");
899 gMC->Gdopt("shad", "on");
900 gMC->Gsatt("*", "fill", 7);
901 gMC->SetClipBox(".");
902 gMC->SetClipBox("*", 0, 2000, -2000, 2000, -2000, 2000);
904 gMC->Gdraw("alic", 40, 30, 0, 12, 9.4, .021, .021);
905 gMC->Gdhead(1111, "Transition Radiation Detector");
906 gMC->Gdman(18, 4, "MAN");
910 //_____________________________________________________________________________
911 Int_t AliTRD::DistancetoPrimitive(Int_t , Int_t ) const
914 // Distance between the mouse and the TRD detector on the screen
921 //_____________________________________________________________________________
925 // Initialize the TRD detector after the geometry has been created
931 printf("\n%s: ",ClassName());
932 for (i = 0; i < 35; i++) printf("*");
933 printf(" TRD_INIT ");
934 for (i = 0; i < 35; i++) printf("*");
938 if (fGeometry->IsVersion() == 0) {
939 printf("%s: Geometry for spaceframe with holes initialized\n",ClassName());
941 else if (fGeometry->IsVersion() == 1) {
942 printf("%s: Geometry for spaceframe without holes initialized\n",ClassName());
943 if (fGeometry->GetPHOShole())
944 printf("%s: Leave space in front of PHOS free\n",ClassName());
945 if (fGeometry->GetRICHhole())
946 printf("%s: Leave space in front of RICH free\n",ClassName());
950 printf("%s: Gas Mixture: 85%% Xe + 15%% CO2\n",ClassName());
953 printf("%s: Gas Mixture: 97%% Xe + 3%% Isobutane\n",ClassName());
958 //_____________________________________________________________________________
959 void AliTRD::LoadPoints(Int_t track)
962 // Store x, y, z of all hits in memory.
963 // Hit originating from TR photons are given a different color
967 // AliDetector::LoadPoints(track);
971 if ((fHits == 0) && (fTrackHits == 0)) return;
975 nhits = fHits->GetEntriesFast();
978 nhits = fTrackHits->GetEntriesFast();
980 if (nhits == 0) return;
982 Int_t tracks = gAlice->GetNtrack();
983 if (fPoints == 0) fPoints = new TObjArray(tracks);
987 Int_t *ntrkE = new Int_t[tracks];
988 Int_t *ntrkT = new Int_t[tracks];
989 Int_t *limiE = new Int_t[tracks];
990 Int_t *limiT = new Int_t[tracks];
991 Float_t **coorE = new Float_t*[tracks];
992 Float_t **coorT = new Float_t*[tracks];
993 for(Int_t i = 0; i < tracks; i++) {
1002 AliTRDpoints *points = 0;
1005 Int_t chunk = nhits / 4 + 1;
1007 // Loop over all the hits and store their position
1008 ahit = (AliTRDhit *) FirstHit(-1);
1012 if (ahit->GetCharge() >= 0) {
1014 trk = ahit->GetTrack();
1015 if (ntrkE[trk] == limiE[trk]) {
1016 // Initialise a new track
1017 fp = new Float_t[3*(limiE[trk]+chunk)];
1019 memcpy(fp,coorE[trk],sizeof(Float_t)*3*limiE[trk]);
1020 delete [] coorE[trk];
1022 limiE[trk] += chunk;
1028 fp[3*ntrkE[trk] ] = ahit->X();
1029 fp[3*ntrkE[trk]+1] = ahit->Y();
1030 fp[3*ntrkE[trk]+2] = ahit->Z();
1035 else if ((ahit->GetCharge() < 0) && (fDrawTR)) {
1037 trk = ahit->GetTrack();
1038 if (ntrkT[trk] == limiT[trk]) {
1039 // Initialise a new track
1040 fp = new Float_t[3*(limiT[trk]+chunk)];
1042 memcpy(fp,coorT[trk],sizeof(Float_t)*3*limiT[trk]);
1043 delete [] coorT[trk];
1045 limiT[trk] += chunk;
1051 fp[3*ntrkT[trk] ] = ahit->X();
1052 fp[3*ntrkT[trk]+1] = ahit->Y();
1053 fp[3*ntrkT[trk]+2] = ahit->Z();
1058 ahit = (AliTRDhit *) NextHit();
1062 for (trk = 0; trk < tracks; ++trk) {
1064 if (ntrkE[trk] || ntrkT[trk]) {
1066 points = new AliTRDpoints();
1067 points->SetDetector(this);
1068 points->SetParticle(trk);
1070 // Set the dEdx points
1072 points->SetMarkerColor(GetMarkerColor());
1073 points->SetMarkerSize(GetMarkerSize());
1074 points->SetPolyMarker(ntrkE[trk],coorE[trk],GetMarkerStyle());
1075 delete [] coorE[trk];
1079 // Set the TR photon points
1081 points->SetTRpoints(ntrkT[trk],coorT[trk]);
1082 delete [] coorT[trk];
1086 fPoints->AddAt(points,trk);
1101 //_____________________________________________________________________________
1102 void AliTRD::MakeBranch(Option_t* option, const char *file)
1105 // Create Tree branches for the TRD digits.
1108 Int_t buffersize = 4000;
1109 Char_t branchname[15];
1110 sprintf(branchname,"%s",GetName());
1112 const char *cD = strstr(option,"D");
1114 AliDetector::MakeBranch(option,file);
1116 if (fDigits && gAlice->TreeD() && cD) {
1117 MakeBranchInTree(gAlice->TreeD(),branchname,&fDigits,buffersize,file);
1121 MakeBranch2(option,file);
1126 //_____________________________________________________________________________
1127 void AliTRD::ResetDigits()
1130 // Reset number of digits and the digits array for this detector
1134 if (fDigits) fDigits->Clear();
1138 //_____________________________________________________________________________
1139 void AliTRD::ResetRecPoints()
1142 // Reset number of reconstructed points and the point array
1147 Int_t nentr = fRecPoints->GetEntriesFast();
1148 for (Int_t i = 0; i < nentr; i++) delete fRecPoints->RemoveAt(i);
1153 //_____________________________________________________________________________
1154 void AliTRD::SetTreeAddress()
1157 // Set the branch addresses for the trees.
1160 Char_t branchname[15];
1162 AliDetector::SetTreeAddress();
1165 TTree *treeR = gAlice->TreeR();
1168 sprintf(branchname,"%scluster",GetName());
1170 branch = treeR->GetBranch(branchname);
1172 branch->SetAddress(&fRecPoints);
1183 //_____________________________________________________________________________
1184 void AliTRD::SetGasMix(Int_t imix)
1187 // Defines the gas mixture (imix=0: Xe/Isobutane imix=1: Xe/CO2)
1190 if ((imix < 0) || (imix > 1)) {
1191 printf("Wrong input value: %d\n",imix);
1192 printf("Use standard setting\n");
1201 //_____________________________________________________________________________
1202 void AliTRD::SetPHOShole()
1205 // Selects a geometry with a hole in front of the PHOS
1208 fGeometry->SetPHOShole();
1212 //_____________________________________________________________________________
1213 void AliTRD::SetRICHhole()
1216 // Selects a geometry with a hole in front of the RICH
1219 fGeometry->SetRICHhole();
1223 //_____________________________________________________________________________
1224 AliTRD &AliTRD::operator=(const AliTRD &trd)
1227 // Assignment operator
1230 if (this != &trd) ((AliTRD &) trd).Copy(*this);
1235 //_____________________________________________________________________________
1236 void AliTRD::FinishPrimary()
1239 // Store the hits in the containers after all primaries are finished
1243 fTrackHits->FlushHitStack();
1248 //_____________________________________________________________________________
1249 void AliTRD::RemapTrackHitIDs(Int_t *map)
1252 // Remap the track IDs
1260 TClonesArray *arr = fTrackHits->GetArray();;
1261 for (Int_t i = 0; i < arr->GetEntriesFast(); i++){
1262 AliTrackHitsParamV2 *info = (AliTrackHitsParamV2 *) (arr->At(i));
1263 info->fTrackID = map[info->fTrackID];
1269 //_____________________________________________________________________________
1270 void AliTRD::ResetHits()
1276 AliDetector::ResetHits();
1278 fTrackHits->Clear();
1283 //_____________________________________________________________________________
1284 AliHit* AliTRD::FirstHit(Int_t track)
1287 // Return the first hit of a track
1291 return FirstHit2(track);
1294 return AliDetector::FirstHit(track);
1298 //_____________________________________________________________________________
1299 AliHit* AliTRD::NextHit()
1302 // Returns the next hit of a track
1309 return AliDetector::NextHit();
1313 //_____________________________________________________________________________
1314 AliHit* AliTRD::FirstHit2(Int_t track)
1317 // Initializes the hit iterator.
1318 // Returns the address of the first hit of a track.
1319 // If <track> >= 0 the track is read from disk,
1320 // while if <track> < 0 the first hit of the current
1321 // track is returned.
1325 gAlice->ResetHits();
1326 gAlice->TreeH()->GetEvent(track);
1330 fTrackHits->First();
1331 return (AliHit*) fTrackHits->GetHit();
1339 //_____________________________________________________________________________
1340 AliHit* AliTRD::NextHit2()
1343 // Returns the next hit of the current track
1348 return (AliHit *) fTrackHits->GetHit();
1356 //_____________________________________________________________________________
1357 void AliTRD::MakeBranch2(Option_t *option, const char *file)
1360 // Create a new branch in the current Root tree.
1361 // The branch of fHits is automatically split.
1368 char branchname[10];
1369 sprintf(branchname,"%s2",GetName());
1371 // Get the pointer to the header
1372 const char *cH = strstr(option,"H");
1375 fTrackHits = new AliTRDtrackHits();
1378 if (fTrackHits && gAlice->TreeH() && cH) {
1380 gAlice->TreeH()->Branch(branchname,"AliTRDtrackHits"
1384 if (GetDebug() > 1) {
1385 printf("<AliTRD::MakeBranch2> Making Branch %s for trackhits\n"
1389 const char kFolder[] = "RunMC/Event/Data";
1392 printf("<AliTRD::MakeBranch2> %15s: Publishing %s to %s\n"
1393 ,ClassName(),branchname,kFolder);
1396 Publish(kFolder,&fTrackHits,branchname);
1399 TBranch *b = gAlice->TreeH()->GetBranch(branchname);
1400 TDirectory *wd = gDirectory;
1402 TIter next(b->GetListOfBranches());
1403 while ((b = (TBranch*) next())) {
1407 if (GetDebug() > 1) {
1408 printf("<AliTRD::MakeBranch2> Diverting branch %s to file %s\n"
1417 //_____________________________________________________________________________
1418 void AliTRD::SetTreeAddress2()
1421 // Set the branch address for the trackHits tree
1426 char branchname[20];
1428 sprintf(branchname,"%s2",GetName());
1430 // Branch address for hit tree
1431 TTree *treeH = gAlice->TreeH();
1432 if ((treeH) && (fHitType > 0)) {
1433 branch = treeH->GetBranch(branchname);
1435 branch->SetAddress(&fTrackHits);
1441 //_____________________________________________________________________________
1442 void AliTRD::AddHit2(Int_t track, Int_t det, Float_t *hits, Int_t q
1446 // Add a hit to the list
1452 Int_t primary = gAlice->GetPrimary(track);
1453 gAlice->Particle(primary)->SetBit(kKeepBit);
1458 gAlice->FlagTrack(track);
1461 if ((fTrackHits) && (fHitType > 0)) {
1462 fTrackHits->AddHitTRD(det,rtrack,hits[0],hits[1],hits[2],q,inDrift);