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 ///////////////////////////////////////////////////////////////////////////////
20 // Transition Radiation Detector //
21 // This class contains the basic functions for the Transition Radiation //
24 ///////////////////////////////////////////////////////////////////////////////
27 #include <Riostream.h>
30 #include <TGeometry.h>
31 #include <TLorentzVector.h>
35 #include <TParticle.h>
38 #include <TVirtualMC.h>
42 #include "AliLoader.h"
46 #include "AliTRDcluster.h"
47 #include "AliTRDclusterizer.h"
48 #include "AliTRDdigit.h"
49 #include "AliTRDdigitizer.h"
50 #include "AliTRDdigitsManager.h"
51 #include "AliTRDgeometryFull.h"
52 #include "AliTRDgeometryHole.h"
53 #include "AliTRDhit.h"
54 #include "AliTRDpoints.h"
55 #include "AliTRDrecPoint.h"
56 #include "AliTRDtrackHits.h"
57 #include "AliTrackReference.h"
62 //_____________________________________________________________________________
66 // Default constructor
90 //_____________________________________________________________________________
91 AliTRD::AliTRD(const char *name, const char *title)
92 : AliDetector(name,title)
95 // Standard constructor for the TRD
98 // Check that FRAME is there otherwise we have no place where to
100 AliModule* frame = gAlice->GetModule("FRAME");
102 Error("Ctor","TRD needs FRAME to be present\n");
106 // Define the TRD geometry according to the FRAME geometry
107 if (frame->IsVersion() == 0) {
108 // Geometry with hole
109 fGeometry = new AliTRDgeometryHole();
111 else if (frame->IsVersion() == 1) {
112 // Geometry without hole
113 fGeometry = new AliTRDgeometryFull();
116 Error("Ctor","Could not find valid FRAME version\n");
120 // Allocate the hit array
121 fHits = new TClonesArray("AliTRDhit" ,405);
122 gAlice->GetMCApp()->AddHitList(fHits);
124 // Allocate the digits array
127 // Allocate the rec point array
128 fRecPoints = new TObjArray(400);
143 SetMarkerColor(kWhite);
147 //_____________________________________________________________________________
148 AliTRD::AliTRD(const AliTRD &trd):AliDetector(trd)
154 ((AliTRD &) trd).Copy(*this);
158 //_____________________________________________________________________________
186 //_____________________________________________________________________________
187 void AliTRD::AddCluster(Float_t *pos, Int_t det, Float_t amp
188 , Int_t *tracks, Float_t *sig, Int_t iType)
191 // Add a cluster for the TRD
194 AliTRDcluster *c = new AliTRDcluster();
197 c->AddTrackIndex(tracks);
201 c->SetSigmaY2(sig[0]);
202 c->SetSigmaZ2(sig[1]);
203 c->SetLocalTimeBin(((Int_t) pos[2]));
227 //_____________________________________________________________________________
228 void AliTRD::Hits2Digits()
233 if (!fLoader->TreeH()) fLoader->LoadHits("read");
236 AliTRDdigitizer *digitizer = new AliTRDdigitizer("TRDdigitizer"
237 ,"TRD digitizer class");
238 digitizer->SetDebug(GetDebug());
239 digitizer->SetEvent(gAlice->GetEvNumber());
242 digitizer->InitDetector();
245 digitizer->MakeDigits();
247 // Write the digits into the input file
249 if (!fLoader->TreeD()) fLoader->MakeTree("D");
250 if (digitizer->MakeBranch(fLoader->TreeD())) {
252 digitizer->WriteDigits();
254 // Save the digitizer class in the AliROOT
261 //_____________________________________________________________________________
262 void AliTRD::Hits2SDigits()
265 // Create summable digits
267 if (!fLoader->TreeH()) fLoader->LoadHits("read");
270 AliTRDdigitizer *digitizer = new AliTRDdigitizer("TRDdigitizer"
271 ,"TRD digitizer class");
272 digitizer->SetDebug(GetDebug());
274 // For the summable digits
275 digitizer->SetSDigits(kTRUE);
276 digitizer->SetEvent(gAlice->GetEvNumber());
279 digitizer->InitDetector();
281 // Create the TRD s-digits branch
282 digitizer->MakeDigits();
284 // Write the digits into the input file
285 if (!fLoader->TreeS()) fLoader->MakeTree("S");
287 if (digitizer->MakeBranch(fLoader->TreeS())) {
289 digitizer->WriteDigits();
291 // Save the digitizer class in the AliROOT
298 //_____________________________________________________________________________
299 void AliTRD::SDigits2Digits()
302 // Create final digits from summable digits
305 // Create the TRD digitizer
306 AliTRDdigitizer *digitizer = new AliTRDdigitizer("TRDdigitizer"
307 ,"TRD digitizer class");
308 digitizer->SetDebug(GetDebug());
311 digitizer->SetEvent(gAlice->GetEvNumber());
314 digitizer->InitDetector();
316 // Read the s-digits via digits manager
317 AliTRDdigitsManager *sdigitsManager = new AliTRDdigitsManager();
319 sdigitsManager->SetDebug(GetDebug());
320 sdigitsManager->SetSDigits(kTRUE);
321 sdigitsManager->CreateArrays();
323 if (!fLoader->TreeS())
324 if (fLoader->LoadSDigits("read"))
326 Error("SDigits2Digits","Error while reading SDigits for event %d",gAlice->GetEvNumber());
329 if (!fLoader->TreeS()) return;
331 sdigitsManager->ReadDigits(fLoader->TreeS());
333 // Add the s-digits to the input list
334 digitizer->AddSDigitsManager(sdigitsManager);
336 // Convert the s-digits to normal digits
337 digitizer->SDigits2Digits();
340 if (!fLoader->TreeD()) fLoader->MakeTree("D");
341 if (digitizer->MakeBranch(fLoader->TreeD())){
342 digitizer->WriteDigits();
347 //_____________________________________________________________________________
348 void AliTRD::AddHit(Int_t track, Int_t det, Float_t *hits, Int_t q
352 // Add a hit for the TRD
354 // The data structure is set according to fHitType:
355 // bit0: standard TClonesArray
356 // bit1: compressed trackHits structure
360 TClonesArray &lhits = *fHits;
361 new(lhits[fNhits++]) AliTRDhit(fIshunt,track,det,hits,q);
365 AddHit2(track,det,hits,q,inDrift);
370 //_____________________________________________________________________________
371 void AliTRD::BuildGeometry()
374 // Create the ROOT TNode geometry for the TRD
381 Float_t zmax1, zmax2;
385 const Int_t kColorTRD = 46;
387 // Find the top node alice
388 top = gAlice->GetGeometry()->GetNode("alice");
390 if (fDisplayType == 0) {
392 pgon = new TPGON("S_TRD","TRD","void",0,360,AliTRDgeometry::Nsect(),4);
393 rmin = AliTRDgeometry::Rmin();
394 rmax = AliTRDgeometry::Rmax();
395 pgon->DefineSection(0,-AliTRDgeometry::Zmax1(),rmax,rmax);
396 pgon->DefineSection(1,-AliTRDgeometry::Zmax2(),rmin,rmax);
397 pgon->DefineSection(2, AliTRDgeometry::Zmax2(),rmin,rmax);
398 pgon->DefineSection(3, AliTRDgeometry::Zmax1(),rmax,rmax);
400 node = new TNode("TRD","TRD","S_TRD",0,0,0,"");
401 node->SetLineColor(kColorTRD);
405 else if (fDisplayType == 1) {
409 Float_t slope = (AliTRDgeometry::Zmax1() - AliTRDgeometry::Zmax2())
410 / (AliTRDgeometry::Rmax() - AliTRDgeometry::Rmin());
412 rmin = AliTRDgeometry::Rmin() + AliTRDgeometry::CraHght();
413 rmax = rmin + AliTRDgeometry::CdrHght();
415 Float_t thickness = rmin - AliTRDgeometry::Rmin();
416 zmax2 = AliTRDgeometry::Zmax2() + slope * thickness;
417 zmax1 = zmax2 + slope * AliTRDgeometry::DrThick();
419 for (iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) {
421 sprintf(name,"S_TR1%d",iPlan);
422 pgon = new TPGON(name,"TRD","void",0,360,AliTRDgeometry::Nsect(),4);
423 pgon->DefineSection(0,-zmax1,rmax,rmax);
424 pgon->DefineSection(1,-zmax2,rmin,rmax);
425 pgon->DefineSection(2, zmax2,rmin,rmax);
426 pgon->DefineSection(3, zmax1,rmax,rmax);
428 node = new TNode("TRD","TRD",name,0,0,0,"");
429 node->SetLineColor(kColorTRD);
432 Float_t height = AliTRDgeometry::Cheight() + AliTRDgeometry::Cspace();
433 rmin = rmin + height;
434 rmax = rmax + height;
435 zmax1 = zmax1 + slope * height;
436 zmax2 = zmax2 + slope * height;
440 thickness += AliTRDgeometry::DrThick();
441 rmin = AliTRDgeometry::Rmin() + thickness;
442 rmax = rmin + AliTRDgeometry::AmThick();
443 zmax2 = AliTRDgeometry::Zmax2() + slope * thickness;
444 zmax1 = zmax2 + slope * AliTRDgeometry::AmThick();
446 for (iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) {
448 sprintf(name,"S_TR2%d",iPlan);
449 pgon = new TPGON(name,"TRD","void",0,360,AliTRDgeometry::Nsect(),4);
450 pgon->DefineSection(0,-zmax1,rmax,rmax);
451 pgon->DefineSection(1,-zmax2,rmin,rmax);
452 pgon->DefineSection(2, zmax2,rmin,rmax);
453 pgon->DefineSection(3, zmax1,rmax,rmax);
455 node = new TNode("TRD","TRD",name,0,0,0,"");
456 node->SetLineColor(kColorTRD);
459 Float_t height = AliTRDgeometry::Cheight() + AliTRDgeometry::Cspace();
460 rmin = rmin + height;
461 rmax = rmax + height;
462 zmax1 = zmax1 + slope * height;
463 zmax2 = zmax2 + slope * height;
471 //_____________________________________________________________________________
472 void AliTRD::Copy(TObject &trd)
478 ((AliTRD &) trd).fGasMix = fGasMix;
479 ((AliTRD &) trd).fGeometry = fGeometry;
480 ((AliTRD &) trd).fRecPoints = fRecPoints;
481 ((AliTRD &) trd).fNRecPoints = fNRecPoints;
482 ((AliTRD &) trd).fGasDensity = fGasDensity;
483 ((AliTRD &) trd).fFoilDensity = fFoilDensity;
484 ((AliTRD &) trd).fDrawTR = fDrawTR;
485 ((AliTRD &) trd).fDisplayType = fDisplayType;
486 ((AliTRD &) trd).fHitType = fHitType;
488 //AliDetector::Copy(trd);
492 //_____________________________________________________________________________
493 void AliTRD::CreateGeometry()
496 // Creates the volumes for the TRD chambers
499 // Check that FRAME is there otherwise we have no place where to put the TRD
500 AliModule* frame = gAlice->GetModule("FRAME");
502 printf(" The TRD needs the FRAME to be defined first\n");
506 fGeometry->CreateGeometry(fIdtmed->GetArray() - 1299);
510 //_____________________________________________________________________________
511 void AliTRD::CreateMaterials()
514 // Create the materials for the TRD
518 Int_t isxfld = gAlice->Field()->Integ();
519 Float_t sxmgmx = gAlice->Field()->Max();
521 // For polyethilene (CH2)
522 Float_t ape[2] = { 12., 1. };
523 Float_t zpe[2] = { 6., 1. };
524 Float_t wpe[2] = { 1., 2. };
527 // For mylar (C5H4O2)
528 Float_t amy[3] = { 12., 1., 16. };
529 Float_t zmy[3] = { 6., 1., 8. };
530 Float_t wmy[3] = { 5., 4., 2. };
534 Float_t aco[2] = { 12., 16. };
535 Float_t zco[2] = { 6., 8. };
536 Float_t wco[2] = { 1., 2. };
537 Float_t dco = 0.001977;
540 Float_t awa[2] = { 1., 16. };
541 Float_t zwa[2] = { 1., 8. };
542 Float_t wwa[2] = { 2., 1. };
545 // For isobutane (C4H10)
546 Float_t ais[2] = { 12., 1. };
547 Float_t zis[2] = { 6., 1. };
548 Float_t wis[2] = { 4., 10. };
549 Float_t dis = 0.00267;
551 // For plexiglas (C5H8O2)
552 Float_t apg[3] = { 12.011 , 1.0 , 15.9994 };
553 Float_t zpg[3] = { 6.0 , 1.0 , 8.0 };
554 Float_t wpg[3] = { 5.0 , 8.0 , 2.0 };
557 // For Xe/CO2-gas-mixture
558 // Xe-content of the Xe/CO2-mixture (85% / 15%)
560 // Xe-content of the Xe/Isobutane-mixture (97% / 3%)
562 Float_t dxe = .005858;
564 // General tracking parameter
565 Float_t tmaxfd = -10.;
566 Float_t stemax = -1e10;
567 Float_t deemax = -0.1;
568 Float_t epsil = 1e-4;
569 Float_t stmin = -0.001;
571 Float_t absl, radl, d, buf[1];
572 Float_t agm[2], zgm[2], wgm[2];
576 //////////////////////////////////////////////////////////////////////////
578 //////////////////////////////////////////////////////////////////////////
580 AliMaterial( 1, "Al" , 26.98, 13.0, 2.7 , 8.9 , 37.2);
581 AliMaterial( 2, "Air" , 14.61, 7.3, 0.001205, 30420.0 , 67500.0);
582 AliMaterial( 4, "Xe" , 131.29, 54.0, dxe , 1447.59, 0.0);
583 AliMaterial( 5, "Cu" , 63.54, 29.0, 8.96 , 1.43, 14.8);
584 AliMaterial( 6, "C" , 12.01, 6.0, 2.265 , 18.8 , 74.4);
585 AliMaterial(12, "G10" , 20.00, 10.0, 1.7 , 19.4 , 999.0);
586 AliMaterial(15, "Sn" , 118.71, 50.0, 7.31 , 1.21, 14.8);
587 AliMaterial(16, "Si" , 28.09, 14.0, 2.33 , 9.36, 37.2);
588 AliMaterial(17, "Epoxy", 17.75, 8.9, 1.8 , 21.82, 999.0);
591 AliMixture(3, "Polyethilene", ape, zpe, dpe, -2, wpe);
592 AliMixture(7, "Mylar", amy, zmy, dmy, -3, wmy);
593 AliMixture(8, "CO2", aco, zco, dco, -2, wco);
594 AliMixture(9, "Isobutane", ais, zis, dis, -2, wis);
595 AliMixture(13,"Water", awa, zwa, dwa, -2, wwa);
596 AliMixture(14,"Plexiglas", apg, zpg, dpg, -3, wpg);
599 Char_t namate[21]="";
601 // Get properties of Xe
602 gMC->Gfmate((*fIdmate)[4], namate, agm[0], zgm[0], d, radl, absl, buf, nbuf);
603 // Get properties of CO2
604 gMC->Gfmate((*fIdmate)[8], namate, agm[1], zgm[1], d, radl, absl, buf, nbuf);
605 // Create gas mixture
608 dgm1 = wgm[0] * dxe + wgm[1] * dco;
609 AliMixture(10, "Gas mixture 1", agm, zgm, dgm1, 2, wgm);
610 // Xe/Isobutane-mixture
611 // Get properties of Xe
612 gMC->Gfmate((*fIdmate)[4], namate, agm[0], zgm[0], d, radl, absl, buf, nbuf);
613 // Get properties of Isobutane
614 gMC->Gfmate((*fIdmate)[9], namate, agm[1], zgm[1], d, radl, absl, buf, nbuf);
615 // Create gas mixture
618 dgm2 = wgm[0] * dxe + wgm[1] * dis;
619 AliMixture(11, "Gas mixture 2", agm, zgm, dgm2, 2, wgm);
621 //////////////////////////////////////////////////////////////////////////
622 // Tracking Media Parameters
623 //////////////////////////////////////////////////////////////////////////
626 AliMedium(1, "Al Frame", 1, 0, isxfld, sxmgmx
627 , tmaxfd, stemax, deemax, epsil, stmin);
629 AliMedium(2, "Air", 2, 0, isxfld, sxmgmx
630 , tmaxfd, stemax, deemax, epsil, stmin);
632 AliMedium(3, "Radiator", 3, 0, isxfld, sxmgmx
633 , tmaxfd, stemax, deemax, epsil, stmin);
635 AliMedium(4, "Xe", 4, 1, isxfld, sxmgmx
636 , tmaxfd, stemax, deemax, epsil, stmin);
638 AliMedium(5, "Padplane", 5, 1, isxfld, sxmgmx
639 , tmaxfd, stemax, deemax, epsil, stmin);
641 AliMedium(6, "Readout", 1, 0, isxfld, sxmgmx
642 , tmaxfd, stemax, deemax, epsil, stmin);
644 AliMedium(7, "C Frame", 6, 0, isxfld, sxmgmx
645 , tmaxfd, stemax, deemax, epsil, stmin);
647 AliMedium(8, "Mylar", 7, 0, isxfld, sxmgmx
648 , tmaxfd, stemax, deemax, epsil, stmin);
650 // Gas-mixture (Xe/CO2)
651 AliMedium(9, "Gas-mix", 10, 1, isxfld, sxmgmx
652 , tmaxfd, stemax, deemax, epsil, stmin);
655 // Gas-mixture (Xe/Isobutane)
656 AliMedium(9, "Gas-mix", 11, 1, isxfld, sxmgmx
657 , tmaxfd, stemax, deemax, epsil, stmin);
659 // Nomex-honeycomb (use carbon for the time being)
660 AliMedium(10, "Nomex", 6, 0, isxfld, sxmgmx
661 , tmaxfd, stemax, deemax, epsil, stmin);
662 // Kapton foils (use Mylar for the time being)
663 AliMedium(11, "Kapton", 7, 0, isxfld, sxmgmx
664 , tmaxfd, stemax, deemax, epsil, stmin);
665 // Gas-filling of the radiator
666 AliMedium(12, "CO2", 8, 0, isxfld, sxmgmx
667 , tmaxfd, stemax, deemax, epsil, stmin);
669 AliMedium(13, "G10-plates",12, 0, isxfld, sxmgmx
670 , tmaxfd, stemax, deemax, epsil, stmin);
672 AliMedium(14, "Water", 13, 0, isxfld, sxmgmx
673 , tmaxfd, stemax, deemax, epsil, stmin);
674 // Rohacell (plexiglas) for the radiator
675 AliMedium(15, "Rohacell", 14, 0, isxfld, sxmgmx
676 , tmaxfd, stemax, deemax, epsil, stmin);
678 AliMedium(16, "MCM-Al" , 1, 0, isxfld, sxmgmx
679 , tmaxfd, stemax, deemax, epsil, stmin);
681 AliMedium(17, "MCM-Sn" , 15, 0, isxfld, sxmgmx
682 , tmaxfd, stemax, deemax, epsil, stmin);
684 AliMedium(18, "MCM-Cu" , 5, 0, isxfld, sxmgmx
685 , tmaxfd, stemax, deemax, epsil, stmin);
687 AliMedium(19, "MCM-G10" , 12, 0, isxfld, sxmgmx
688 , tmaxfd, stemax, deemax, epsil, stmin);
689 // Si in readout chips
690 AliMedium(20, "Chip-Si" , 16, 0, isxfld, sxmgmx
691 , tmaxfd, stemax, deemax, epsil, stmin);
692 // Epoxy in readout chips
693 AliMedium(21, "Chip-Ep" , 17, 0, isxfld, sxmgmx
694 , tmaxfd, stemax, deemax, epsil, stmin);
696 AliMedium(22, "Conn-PE" , 3, 0, isxfld, sxmgmx
697 , tmaxfd, stemax, deemax, epsil, stmin);
699 AliMedium(23, "Chip-Cu" , 5, 0, isxfld, sxmgmx
700 , tmaxfd, stemax, deemax, epsil, stmin);
701 // Al of cooling pipes
702 AliMedium(24, "Cooling" , 1, 0, isxfld, sxmgmx
703 , tmaxfd, stemax, deemax, epsil, stmin);
705 AliMedium(25, "Serv-Cu" , 5, 0, isxfld, sxmgmx
706 , tmaxfd, stemax, deemax, epsil, stmin);
708 // Save the density values for the TRD absorbtion
717 //_____________________________________________________________________________
718 void AliTRD::DrawModule() const
721 // Draw a shaded view of the Transition Radiation Detector version 0
724 // Set everything unseen
725 gMC->Gsatt("*" ,"SEEN",-1);
727 // Set ALIC mother transparent
728 gMC->Gsatt("ALIC","SEEN", 0);
730 // Set the volumes visible
731 if (fGeometry->IsVersion() == 0) {
732 gMC->Gsatt("B071","SEEN", 0);
733 gMC->Gsatt("B074","SEEN", 0);
734 gMC->Gsatt("B075","SEEN", 0);
735 gMC->Gsatt("B077","SEEN", 0);
736 gMC->Gsatt("BTR1","SEEN", 0);
737 gMC->Gsatt("BTR2","SEEN", 0);
738 gMC->Gsatt("BTR3","SEEN", 0);
739 gMC->Gsatt("UTR1","SEEN", 0);
740 gMC->Gsatt("UTR2","SEEN", 0);
741 gMC->Gsatt("UTR3","SEEN", 0);
744 gMC->Gsatt("B071","SEEN", 0);
745 gMC->Gsatt("B074","SEEN", 0);
746 gMC->Gsatt("B075","SEEN", 0);
747 gMC->Gsatt("B077","SEEN", 0);
748 gMC->Gsatt("BTR1","SEEN", 0);
749 gMC->Gsatt("BTR2","SEEN", 0);
750 gMC->Gsatt("BTR3","SEEN", 0);
751 gMC->Gsatt("UTR1","SEEN", 0);
752 if (fGeometry->GetPHOShole())
753 gMC->Gsatt("UTR2","SEEN", 0);
754 if (fGeometry->GetRICHhole())
755 gMC->Gsatt("UTR3","SEEN", 0);
757 // gMC->Gsatt("UCII","SEEN", 0);
758 // gMC->Gsatt("UCIM","SEEN", 0);
759 // gMC->Gsatt("UCIO","SEEN", 0);
760 // gMC->Gsatt("UL02","SEEN", 1);
761 // gMC->Gsatt("UL05","SEEN", 1);
762 // gMC->Gsatt("UL06","SEEN", 1);
764 gMC->Gdopt("hide", "on");
765 gMC->Gdopt("shad", "on");
766 gMC->Gsatt("*", "fill", 7);
767 gMC->SetClipBox(".");
768 gMC->SetClipBox("*", 0, 2000, -2000, 2000, -2000, 2000);
770 gMC->Gdraw("alic", 40, 30, 0, 12, 9.4, .021, .021);
771 gMC->Gdhead(1111, "Transition Radiation Detector");
772 gMC->Gdman(18, 4, "MAN");
776 //_____________________________________________________________________________
777 Int_t AliTRD::DistancetoPrimitive(Int_t , Int_t ) const
780 // Distance between the mouse and the TRD detector on the screen
787 //_____________________________________________________________________________
791 // Initialize the TRD detector after the geometry has been created
797 printf("\n%s: ",ClassName());
798 for (i = 0; i < 35; i++) printf("*");
799 printf(" TRD_INIT ");
800 for (i = 0; i < 35; i++) printf("*");
804 if (fGeometry->IsVersion() == 0) {
805 printf("%s: Geometry for spaceframe with holes initialized\n",ClassName());
807 else if (fGeometry->IsVersion() == 1) {
808 printf("%s: Geometry for spaceframe without holes initialized\n",ClassName());
809 if (fGeometry->GetPHOShole())
810 printf("%s: Leave space in front of PHOS free\n",ClassName());
811 if (fGeometry->GetRICHhole())
812 printf("%s: Leave space in front of RICH free\n",ClassName());
816 printf("%s: Gas Mixture: 85%% Xe + 15%% CO2\n",ClassName());
819 printf("%s: Gas Mixture: 97%% Xe + 3%% Isobutane\n",ClassName());
824 //_____________________________________________________________________________
825 void AliTRD::LoadPoints(Int_t )
828 // Store x, y, z of all hits in memory.
829 // Hit originating from TR photons are given a different color
833 // AliDetector::LoadPoints(track);
837 if ((fHits == 0) && (fTrackHits == 0)) return;
841 nhits = fHits->GetEntriesFast();
844 nhits = fTrackHits->GetEntriesFast();
846 if (nhits == 0) return;
848 Int_t tracks = gAlice->GetMCApp()->GetNtrack();
849 if (fPoints == 0) fPoints = new TObjArray(tracks);
853 Int_t *ntrkE = new Int_t[tracks];
854 Int_t *ntrkT = new Int_t[tracks];
855 Int_t *limiE = new Int_t[tracks];
856 Int_t *limiT = new Int_t[tracks];
857 Float_t **coorE = new Float_t*[tracks];
858 Float_t **coorT = new Float_t*[tracks];
859 for(Int_t i = 0; i < tracks; i++) {
868 AliTRDpoints *points = 0;
871 Int_t chunk = nhits / 4 + 1;
873 // Loop over all the hits and store their position
874 ahit = (AliTRDhit *) FirstHit(-1);
878 if (ahit->GetCharge() >= 0) {
880 trk = ahit->GetTrack();
881 if (ntrkE[trk] == limiE[trk]) {
882 // Initialise a new track
883 fp = new Float_t[3*(limiE[trk]+chunk)];
885 memcpy(fp,coorE[trk],sizeof(Float_t)*3*limiE[trk]);
886 delete [] coorE[trk];
894 fp[3*ntrkE[trk] ] = ahit->X();
895 fp[3*ntrkE[trk]+1] = ahit->Y();
896 fp[3*ntrkE[trk]+2] = ahit->Z();
901 else if ((ahit->GetCharge() < 0) && (fDrawTR)) {
903 trk = ahit->GetTrack();
904 if (ntrkT[trk] == limiT[trk]) {
905 // Initialise a new track
906 fp = new Float_t[3*(limiT[trk]+chunk)];
908 memcpy(fp,coorT[trk],sizeof(Float_t)*3*limiT[trk]);
909 delete [] coorT[trk];
917 fp[3*ntrkT[trk] ] = ahit->X();
918 fp[3*ntrkT[trk]+1] = ahit->Y();
919 fp[3*ntrkT[trk]+2] = ahit->Z();
924 ahit = (AliTRDhit *) NextHit();
928 for (trk = 0; trk < tracks; ++trk) {
930 if (ntrkE[trk] || ntrkT[trk]) {
932 points = new AliTRDpoints();
933 points->SetDetector(this);
934 points->SetParticle(trk);
936 // Set the dEdx points
938 points->SetMarkerColor(GetMarkerColor());
939 points->SetMarkerSize(GetMarkerSize());
940 points->SetPolyMarker(ntrkE[trk],coorE[trk],GetMarkerStyle());
941 delete [] coorE[trk];
945 // Set the TR photon points
947 points->SetTRpoints(ntrkT[trk],coorT[trk]);
948 delete [] coorT[trk];
952 fPoints->AddAt(points,trk);
967 //_____________________________________________________________________________
968 void AliTRD::MakeBranch(Option_t* option)
971 // Create Tree branches for the TRD digits.
974 Int_t buffersize = 4000;
975 Char_t branchname[15];
976 sprintf(branchname,"%s",GetName());
978 const char *cD = strstr(option,"D");
980 AliDetector::MakeBranch(option);
982 if (fDigits && gAlice->TreeD() && cD) {
983 MakeBranchInTree(gAlice->TreeD(),branchname,&fDigits,buffersize,0);
987 MakeBranch2(option,0);
992 //_____________________________________________________________________________
993 void AliTRD::ResetDigits()
996 // Reset number of digits and the digits array for this detector
1000 if (fDigits) fDigits->Clear();
1004 //_____________________________________________________________________________
1005 void AliTRD::ResetRecPoints()
1008 // Reset number of reconstructed points and the point array
1013 Int_t nentr = fRecPoints->GetEntriesFast();
1014 for (Int_t i = 0; i < nentr; i++) delete fRecPoints->RemoveAt(i);
1019 //_____________________________________________________________________________
1020 void AliTRD::SetTreeAddress()
1023 // Set the branch addresses for the trees.
1026 Char_t branchname[15];
1028 if ( fLoader->TreeH() && (fHits == 0x0)) fHits = new TClonesArray("AliTRDhit",405);
1029 AliDetector::SetTreeAddress();
1032 TTree *treeR = fLoader->TreeR();
1035 sprintf(branchname,"%scluster",GetName());
1036 if (fRecPoints == 0x0) fRecPoints = new TObjArray(400);
1038 branch = treeR->GetBranch(branchname);
1040 branch->SetAddress(&fRecPoints);
1051 //_____________________________________________________________________________
1052 void AliTRD::SetGasMix(Int_t imix)
1055 // Defines the gas mixture (imix=0: Xe/Isobutane imix=1: Xe/CO2)
1058 if ((imix < 0) || (imix > 1)) {
1059 printf("Wrong input value: %d\n",imix);
1060 printf("Use standard setting\n");
1069 //_____________________________________________________________________________
1070 void AliTRD::SetPHOShole()
1073 // Selects a geometry with a hole in front of the PHOS
1076 fGeometry->SetPHOShole();
1080 //_____________________________________________________________________________
1081 void AliTRD::SetRICHhole()
1084 // Selects a geometry with a hole in front of the RICH
1087 fGeometry->SetRICHhole();
1091 //_____________________________________________________________________________
1092 AliTRD &AliTRD::operator=(const AliTRD &trd)
1095 // Assignment operator
1098 if (this != &trd) ((AliTRD &) trd).Copy(*this);
1103 //_____________________________________________________________________________
1104 void AliTRD::FinishPrimary()
1107 // Store the hits in the containers after all primaries are finished
1111 fTrackHits->FlushHitStack();
1116 //_____________________________________________________________________________
1117 void AliTRD::RemapTrackHitIDs(Int_t *map)
1120 // Remap the track IDs
1128 TClonesArray *arr = fTrackHits->GetArray();;
1129 for (Int_t i = 0; i < arr->GetEntriesFast(); i++){
1130 AliTrackHitsParamV2 *info = (AliTrackHitsParamV2 *) (arr->At(i));
1131 info->fTrackID = map[info->fTrackID];
1137 //_____________________________________________________________________________
1138 void AliTRD::ResetHits()
1144 AliDetector::ResetHits();
1146 fTrackHits->Clear();
1151 //_____________________________________________________________________________
1152 AliHit* AliTRD::FirstHit(Int_t track)
1155 // Return the first hit of a track
1159 return FirstHit2(track);
1162 return AliDetector::FirstHit(track);
1166 //_____________________________________________________________________________
1167 AliHit* AliTRD::NextHit()
1170 // Returns the next hit of a track
1177 return AliDetector::NextHit();
1181 //_____________________________________________________________________________
1182 AliHit* AliTRD::FirstHit2(Int_t track)
1185 // Initializes the hit iterator.
1186 // Returns the address of the first hit of a track.
1187 // If <track> >= 0 the track is read from disk,
1188 // while if <track> < 0 the first hit of the current
1189 // track is returned.
1193 gAlice->ResetHits();
1194 TreeH()->GetEvent(track);
1198 fTrackHits->First();
1199 return (AliHit*) fTrackHits->GetHit();
1207 //_____________________________________________________________________________
1208 AliHit* AliTRD::NextHit2()
1211 // Returns the next hit of the current track
1216 return (AliHit *) fTrackHits->GetHit();
1224 //_____________________________________________________________________________
1225 void AliTRD::MakeBranch2(Option_t *option, const char* )
1228 // Create a new branch in the current Root tree.
1229 // The branch of fHits is automatically split.
1236 char branchname[10];
1237 sprintf(branchname,"%s2",GetName());
1239 // Get the pointer to the header
1240 const char *cH = strstr(option,"H");
1243 fTrackHits = new AliTRDtrackHits();
1247 if (fTrackHits && TreeH() && cH)
1249 TreeH()->Branch(branchname,"AliTRDtrackHits",&fTrackHits,fBufferSize,99);
1250 Info("MakeBranch2","Making Branch %s for trackhits",branchname);
1254 //_____________________________________________________________________________
1255 void AliTRD::SetTreeAddress2()
1258 // Set the branch address for the trackHits tree
1260 if (GetDebug()) Info("SetTreeAddress2","");
1263 char branchname[20];
1264 sprintf(branchname,"%s2",GetName());
1266 // Branch address for hit tree
1267 TTree *treeH = TreeH();
1268 if ((treeH) && (fHitType > 0)) {
1269 branch = treeH->GetBranch(branchname);
1272 branch->SetAddress(&fTrackHits);
1274 Info("SetTreeAddress2","Success.");
1279 Info("SetTreeAddress2","Can NOT get the branch %s",branchname);
1285 //_____________________________________________________________________________
1286 void AliTRD::AddHit2(Int_t track, Int_t det, Float_t *hits, Int_t q
1290 // Add a hit to the list
1296 Int_t primary = gAlice->GetMCApp()->GetPrimary(track);
1297 gAlice->GetMCApp()->Particle(primary)->SetBit(kKeepBit);
1302 gAlice->GetMCApp()->FlagTrack(track);
1305 if ((fTrackHits) && (fHitType > 0)) {
1306 fTrackHits->AddHitTRD(det,rtrack,hits[0],hits[1],hits[2],q,inDrift);