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"
61 //_____________________________________________________________________________
65 // Default constructor
89 //_____________________________________________________________________________
90 AliTRD::AliTRD(const char *name, const char *title)
91 : AliDetector(name,title)
94 // Standard constructor for the TRD
97 // Check that FRAME is there otherwise we have no place where to
99 AliModule* frame = gAlice->GetModule("FRAME");
101 Error("Ctor","TRD needs FRAME to be present\n");
105 // Define the TRD geometry according to the FRAME geometry
106 if (frame->IsVersion() == 0) {
107 // Geometry with hole
108 fGeometry = new AliTRDgeometryHole();
110 else if (frame->IsVersion() == 1) {
111 // Geometry without hole
112 fGeometry = new AliTRDgeometryFull();
115 Error("Ctor","Could not find valid FRAME version\n");
119 // Allocate the hit array
120 fHits = new TClonesArray("AliTRDhit" ,405);
121 gAlice->AddHitList(fHits);
123 // Allocate the digits array
126 // Allocate the rec point array
127 fRecPoints = new TObjArray(400);
142 SetMarkerColor(kWhite);
146 //_____________________________________________________________________________
147 AliTRD::AliTRD(const AliTRD &trd)
153 ((AliTRD &) trd).Copy(*this);
157 //_____________________________________________________________________________
185 //_____________________________________________________________________________
186 void AliTRD::AddCluster(Float_t *pos, Int_t det, Float_t amp
187 , Int_t *tracks, Float_t *sig, Int_t iType)
190 // Add a cluster for the TRD
193 AliTRDcluster *c = new AliTRDcluster();
196 c->AddTrackIndex(tracks);
200 c->SetSigmaY2(sig[0]);
201 c->SetSigmaZ2(sig[1]);
202 c->SetLocalTimeBin(((Int_t) pos[2]));
226 //_____________________________________________________________________________
227 void AliTRD::Hits2Digits()
232 if (!fLoader->TreeH()) fLoader->LoadHits("read");
235 AliTRDdigitizer *digitizer = new AliTRDdigitizer("TRDdigitizer"
236 ,"TRD digitizer class");
237 digitizer->SetDebug(GetDebug());
238 digitizer->SetEvent(gAlice->GetEvNumber());
241 digitizer->InitDetector();
244 digitizer->MakeDigits();
246 // Write the digits into the input file
248 if (!fLoader->TreeD()) fLoader->MakeTree("D");
249 if (digitizer->MakeBranch(fLoader->TreeD())) {
251 digitizer->WriteDigits();
253 // Save the digitizer class in the AliROOT
260 //_____________________________________________________________________________
261 void AliTRD::Hits2SDigits()
264 // Create summable digits
266 if (!fLoader->TreeH()) fLoader->LoadHits("read");
269 AliTRDdigitizer *digitizer = new AliTRDdigitizer("TRDdigitizer"
270 ,"TRD digitizer class");
271 digitizer->SetDebug(GetDebug());
273 // For the summable digits
274 digitizer->SetSDigits(kTRUE);
275 digitizer->SetEvent(gAlice->GetEvNumber());
278 digitizer->InitDetector();
280 // Create the TRD s-digits branch
281 digitizer->MakeDigits();
283 // Write the digits into the input file
284 if (!fLoader->TreeS()) fLoader->MakeTree("S");
286 if (digitizer->MakeBranch(fLoader->TreeS())) {
288 digitizer->WriteDigits();
290 // Save the digitizer class in the AliROOT
297 //_____________________________________________________________________________
298 void AliTRD::SDigits2Digits()
301 // Create final digits from summable digits
304 // Create the TRD digitizer
305 AliTRDdigitizer *digitizer = new AliTRDdigitizer("TRDdigitizer"
306 ,"TRD digitizer class");
307 digitizer->SetDebug(GetDebug());
310 digitizer->SetEvent(gAlice->GetEvNumber());
313 digitizer->InitDetector();
315 // Read the s-digits via digits manager
316 AliTRDdigitsManager *sdigitsManager = new AliTRDdigitsManager();
318 sdigitsManager->SetDebug(GetDebug());
319 sdigitsManager->SetSDigits(kTRUE);
320 sdigitsManager->CreateArrays();
322 if (!fLoader->TreeS())
323 if (fLoader->LoadSDigits("read"))
325 Error("SDigits2Digits","Error while reading SDigits for event %d",gAlice->GetEvNumber());
328 if (!fLoader->TreeS()) return;
330 sdigitsManager->ReadDigits(fLoader->TreeS());
332 // Add the s-digits to the input list
333 digitizer->AddSDigitsManager(sdigitsManager);
335 // Convert the s-digits to normal digits
336 digitizer->SDigits2Digits();
339 if (!fLoader->TreeD()) fLoader->MakeTree("D");
340 if (digitizer->MakeBranch(fLoader->TreeD())){
341 digitizer->WriteDigits();
346 //_____________________________________________________________________________
347 void AliTRD::AddHit(Int_t track, Int_t det, Float_t *hits, Int_t q
351 // Add a hit for the TRD
353 // The data structure is set according to fHitType:
354 // bit0: standard TClonesArray
355 // bit1: compressed trackHits structure
359 TClonesArray &lhits = *fHits;
360 new(lhits[fNhits++]) AliTRDhit(fIshunt,track,det,hits,q);
364 AddHit2(track,det,hits,q,inDrift);
369 //_____________________________________________________________________________
370 void AliTRD::BuildGeometry()
373 // Create the ROOT TNode geometry for the TRD
380 Float_t zmax1, zmax2;
384 const Int_t kColorTRD = 46;
386 // Find the top node alice
387 top = gAlice->GetGeometry()->GetNode("alice");
389 if (fDisplayType == 0) {
391 pgon = new TPGON("S_TRD","TRD","void",0,360,AliTRDgeometry::Nsect(),4);
392 rmin = AliTRDgeometry::Rmin();
393 rmax = AliTRDgeometry::Rmax();
394 pgon->DefineSection(0,-AliTRDgeometry::Zmax1(),rmax,rmax);
395 pgon->DefineSection(1,-AliTRDgeometry::Zmax2(),rmin,rmax);
396 pgon->DefineSection(2, AliTRDgeometry::Zmax2(),rmin,rmax);
397 pgon->DefineSection(3, AliTRDgeometry::Zmax1(),rmax,rmax);
399 node = new TNode("TRD","TRD","S_TRD",0,0,0,"");
400 node->SetLineColor(kColorTRD);
404 else if (fDisplayType == 1) {
408 Float_t slope = (AliTRDgeometry::Zmax1() - AliTRDgeometry::Zmax2())
409 / (AliTRDgeometry::Rmax() - AliTRDgeometry::Rmin());
411 rmin = AliTRDgeometry::Rmin() + AliTRDgeometry::CraHght();
412 rmax = rmin + AliTRDgeometry::CdrHght();
414 Float_t thickness = rmin - AliTRDgeometry::Rmin();
415 zmax2 = AliTRDgeometry::Zmax2() + slope * thickness;
416 zmax1 = zmax2 + slope * AliTRDgeometry::DrThick();
418 for (iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) {
420 sprintf(name,"S_TR1%d",iPlan);
421 pgon = new TPGON(name,"TRD","void",0,360,AliTRDgeometry::Nsect(),4);
422 pgon->DefineSection(0,-zmax1,rmax,rmax);
423 pgon->DefineSection(1,-zmax2,rmin,rmax);
424 pgon->DefineSection(2, zmax2,rmin,rmax);
425 pgon->DefineSection(3, zmax1,rmax,rmax);
427 node = new TNode("TRD","TRD",name,0,0,0,"");
428 node->SetLineColor(kColorTRD);
431 Float_t height = AliTRDgeometry::Cheight() + AliTRDgeometry::Cspace();
432 rmin = rmin + height;
433 rmax = rmax + height;
434 zmax1 = zmax1 + slope * height;
435 zmax2 = zmax2 + slope * height;
439 thickness += AliTRDgeometry::DrThick();
440 rmin = AliTRDgeometry::Rmin() + thickness;
441 rmax = rmin + AliTRDgeometry::AmThick();
442 zmax2 = AliTRDgeometry::Zmax2() + slope * thickness;
443 zmax1 = zmax2 + slope * AliTRDgeometry::AmThick();
445 for (iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) {
447 sprintf(name,"S_TR2%d",iPlan);
448 pgon = new TPGON(name,"TRD","void",0,360,AliTRDgeometry::Nsect(),4);
449 pgon->DefineSection(0,-zmax1,rmax,rmax);
450 pgon->DefineSection(1,-zmax2,rmin,rmax);
451 pgon->DefineSection(2, zmax2,rmin,rmax);
452 pgon->DefineSection(3, zmax1,rmax,rmax);
454 node = new TNode("TRD","TRD",name,0,0,0,"");
455 node->SetLineColor(kColorTRD);
458 Float_t height = AliTRDgeometry::Cheight() + AliTRDgeometry::Cspace();
459 rmin = rmin + height;
460 rmax = rmax + height;
461 zmax1 = zmax1 + slope * height;
462 zmax2 = zmax2 + slope * height;
470 //_____________________________________________________________________________
471 void AliTRD::Copy(TObject &trd)
477 ((AliTRD &) trd).fGasMix = fGasMix;
478 ((AliTRD &) trd).fGeometry = fGeometry;
479 ((AliTRD &) trd).fRecPoints = fRecPoints;
480 ((AliTRD &) trd).fNRecPoints = fNRecPoints;
481 ((AliTRD &) trd).fGasDensity = fGasDensity;
482 ((AliTRD &) trd).fFoilDensity = fFoilDensity;
483 ((AliTRD &) trd).fDrawTR = fDrawTR;
484 ((AliTRD &) trd).fDisplayType = fDisplayType;
485 ((AliTRD &) trd).fHitType = fHitType;
487 //AliDetector::Copy(trd);
491 //_____________________________________________________________________________
492 void AliTRD::CreateGeometry()
495 // Creates the volumes for the TRD chambers
498 // Check that FRAME is there otherwise we have no place where to put the TRD
499 AliModule* frame = gAlice->GetModule("FRAME");
501 printf(" The TRD needs the FRAME to be defined first\n");
505 fGeometry->CreateGeometry(fIdtmed->GetArray() - 1299);
509 //_____________________________________________________________________________
510 void AliTRD::CreateMaterials()
513 // Create the materials for the TRD
517 Int_t isxfld = gAlice->Field()->Integ();
518 Float_t sxmgmx = gAlice->Field()->Max();
520 // For polyethilene (CH2)
521 Float_t ape[2] = { 12., 1. };
522 Float_t zpe[2] = { 6., 1. };
523 Float_t wpe[2] = { 1., 2. };
526 // For mylar (C5H4O2)
527 Float_t amy[3] = { 12., 1., 16. };
528 Float_t zmy[3] = { 6., 1., 8. };
529 Float_t wmy[3] = { 5., 4., 2. };
533 Float_t aco[2] = { 12., 16. };
534 Float_t zco[2] = { 6., 8. };
535 Float_t wco[2] = { 1., 2. };
536 Float_t dco = 0.001977;
539 Float_t awa[2] = { 1., 16. };
540 Float_t zwa[2] = { 1., 8. };
541 Float_t wwa[2] = { 2., 1. };
544 // For isobutane (C4H10)
545 Float_t ais[2] = { 12., 1. };
546 Float_t zis[2] = { 6., 1. };
547 Float_t wis[2] = { 4., 10. };
548 Float_t dis = 0.00267;
550 // For plexiglas (C5H8O2)
551 Float_t apg[3] = { 12.011 , 1.0 , 15.9994 };
552 Float_t zpg[3] = { 6.0 , 1.0 , 8.0 };
553 Float_t wpg[3] = { 5.0 , 8.0 , 2.0 };
556 // For Xe/CO2-gas-mixture
557 // Xe-content of the Xe/CO2-mixture (85% / 15%)
559 // Xe-content of the Xe/Isobutane-mixture (97% / 3%)
561 Float_t dxe = .005858;
563 // General tracking parameter
564 Float_t tmaxfd = -10.;
565 Float_t stemax = -1e10;
566 Float_t deemax = -0.1;
567 Float_t epsil = 1e-4;
568 Float_t stmin = -0.001;
570 Float_t absl, radl, d, buf[1];
571 Float_t agm[2], zgm[2], wgm[2];
575 //////////////////////////////////////////////////////////////////////////
577 //////////////////////////////////////////////////////////////////////////
579 AliMaterial( 1, "Al" , 26.98, 13.0, 2.7 , 8.9 , 37.2);
580 AliMaterial( 2, "Air" , 14.61, 7.3, 0.001205, 30420.0 , 67500.0);
581 AliMaterial( 4, "Xe" , 131.29, 54.0, dxe , 1447.59, 0.0);
582 AliMaterial( 5, "Cu" , 63.54, 29.0, 8.96 , 1.43, 14.8);
583 AliMaterial( 6, "C" , 12.01, 6.0, 2.265 , 18.8 , 74.4);
584 AliMaterial(12, "G10" , 20.00, 10.0, 1.7 , 19.4 , 999.0);
585 AliMaterial(15, "Sn" , 118.71, 50.0, 7.31 , 1.21, 14.8);
586 AliMaterial(16, "Si" , 28.09, 14.0, 2.33 , 9.36, 37.2);
587 AliMaterial(17, "Epoxy", 17.75, 8.9, 1.8 , 21.82, 999.0);
590 AliMixture(3, "Polyethilene", ape, zpe, dpe, -2, wpe);
591 AliMixture(7, "Mylar", amy, zmy, dmy, -3, wmy);
592 AliMixture(8, "CO2", aco, zco, dco, -2, wco);
593 AliMixture(9, "Isobutane", ais, zis, dis, -2, wis);
594 AliMixture(13,"Water", awa, zwa, dwa, -2, wwa);
595 AliMixture(14,"Plexiglas", apg, zpg, dpg, -3, wpg);
600 // Get properties of Xe
601 gMC->Gfmate((*fIdmate)[4], namate, agm[0], zgm[0], d, radl, absl, buf, nbuf);
602 // Get properties of CO2
603 gMC->Gfmate((*fIdmate)[8], namate, agm[1], zgm[1], d, radl, absl, buf, nbuf);
604 // Create gas mixture
607 dgm1 = wgm[0] * dxe + wgm[1] * dco;
608 AliMixture(10, "Gas mixture 1", agm, zgm, dgm1, 2, wgm);
609 // Xe/Isobutane-mixture
610 // Get properties of Xe
611 gMC->Gfmate((*fIdmate)[4], namate, agm[0], zgm[0], d, radl, absl, buf, nbuf);
612 // Get properties of Isobutane
613 gMC->Gfmate((*fIdmate)[9], namate, agm[1], zgm[1], d, radl, absl, buf, nbuf);
614 // Create gas mixture
617 dgm2 = wgm[0] * dxe + wgm[1] * dis;
618 AliMixture(11, "Gas mixture 2", agm, zgm, dgm2, 2, wgm);
620 //////////////////////////////////////////////////////////////////////////
621 // Tracking Media Parameters
622 //////////////////////////////////////////////////////////////////////////
625 AliMedium(1, "Al Frame", 1, 0, isxfld, sxmgmx
626 , tmaxfd, stemax, deemax, epsil, stmin);
628 AliMedium(2, "Air", 2, 0, isxfld, sxmgmx
629 , tmaxfd, stemax, deemax, epsil, stmin);
631 AliMedium(3, "Radiator", 3, 0, isxfld, sxmgmx
632 , tmaxfd, stemax, deemax, epsil, stmin);
634 AliMedium(4, "Xe", 4, 1, isxfld, sxmgmx
635 , tmaxfd, stemax, deemax, epsil, stmin);
637 AliMedium(5, "Padplane", 5, 1, isxfld, sxmgmx
638 , tmaxfd, stemax, deemax, epsil, stmin);
640 AliMedium(6, "Readout", 1, 0, isxfld, sxmgmx
641 , tmaxfd, stemax, deemax, epsil, stmin);
643 AliMedium(7, "C Frame", 6, 0, isxfld, sxmgmx
644 , tmaxfd, stemax, deemax, epsil, stmin);
646 AliMedium(8, "Mylar", 7, 0, isxfld, sxmgmx
647 , tmaxfd, stemax, deemax, epsil, stmin);
649 // Gas-mixture (Xe/CO2)
650 AliMedium(9, "Gas-mix", 10, 1, isxfld, sxmgmx
651 , tmaxfd, stemax, deemax, epsil, stmin);
654 // Gas-mixture (Xe/Isobutane)
655 AliMedium(9, "Gas-mix", 11, 1, isxfld, sxmgmx
656 , tmaxfd, stemax, deemax, epsil, stmin);
658 // Nomex-honeycomb (use carbon for the time being)
659 AliMedium(10, "Nomex", 6, 0, isxfld, sxmgmx
660 , tmaxfd, stemax, deemax, epsil, stmin);
661 // Kapton foils (use Mylar for the time being)
662 AliMedium(11, "Kapton", 7, 0, isxfld, sxmgmx
663 , tmaxfd, stemax, deemax, epsil, stmin);
664 // Gas-filling of the radiator
665 AliMedium(12, "CO2", 8, 0, isxfld, sxmgmx
666 , tmaxfd, stemax, deemax, epsil, stmin);
668 AliMedium(13, "G10-plates",12, 0, isxfld, sxmgmx
669 , tmaxfd, stemax, deemax, epsil, stmin);
671 AliMedium(14, "Water", 13, 0, isxfld, sxmgmx
672 , tmaxfd, stemax, deemax, epsil, stmin);
673 // Rohacell (plexiglas) for the radiator
674 AliMedium(15, "Rohacell", 14, 0, isxfld, sxmgmx
675 , tmaxfd, stemax, deemax, epsil, stmin);
677 AliMedium(16, "MCM-Al" , 1, 0, isxfld, sxmgmx
678 , tmaxfd, stemax, deemax, epsil, stmin);
680 AliMedium(17, "MCM-Sn" , 15, 0, isxfld, sxmgmx
681 , tmaxfd, stemax, deemax, epsil, stmin);
683 AliMedium(18, "MCM-Cu" , 5, 0, isxfld, sxmgmx
684 , tmaxfd, stemax, deemax, epsil, stmin);
686 AliMedium(19, "MCM-G10" , 12, 0, isxfld, sxmgmx
687 , tmaxfd, stemax, deemax, epsil, stmin);
688 // Si in readout chips
689 AliMedium(20, "Chip-Si" , 16, 0, isxfld, sxmgmx
690 , tmaxfd, stemax, deemax, epsil, stmin);
691 // Epoxy in readout chips
692 AliMedium(21, "Chip-Ep" , 17, 0, isxfld, sxmgmx
693 , tmaxfd, stemax, deemax, epsil, stmin);
695 AliMedium(22, "Conn-PE" , 3, 0, isxfld, sxmgmx
696 , tmaxfd, stemax, deemax, epsil, stmin);
698 AliMedium(23, "Chip-Cu" , 5, 0, isxfld, sxmgmx
699 , tmaxfd, stemax, deemax, epsil, stmin);
700 // Al of cooling pipes
701 AliMedium(24, "Cooling" , 1, 0, isxfld, sxmgmx
702 , tmaxfd, stemax, deemax, epsil, stmin);
704 // Save the density values for the TRD absorbtion
713 //_____________________________________________________________________________
714 void AliTRD::DrawModule() const
717 // Draw a shaded view of the Transition Radiation Detector version 0
720 // Set everything unseen
721 gMC->Gsatt("*" ,"SEEN",-1);
723 // Set ALIC mother transparent
724 gMC->Gsatt("ALIC","SEEN", 0);
726 // Set the volumes visible
727 if (fGeometry->IsVersion() == 0) {
728 gMC->Gsatt("B071","SEEN", 0);
729 gMC->Gsatt("B074","SEEN", 0);
730 gMC->Gsatt("B075","SEEN", 0);
731 gMC->Gsatt("B077","SEEN", 0);
732 gMC->Gsatt("BTR1","SEEN", 0);
733 gMC->Gsatt("BTR2","SEEN", 0);
734 gMC->Gsatt("BTR3","SEEN", 0);
735 gMC->Gsatt("UTR1","SEEN", 0);
736 gMC->Gsatt("UTR2","SEEN", 0);
737 gMC->Gsatt("UTR3","SEEN", 0);
740 gMC->Gsatt("B071","SEEN", 0);
741 gMC->Gsatt("B074","SEEN", 0);
742 gMC->Gsatt("B075","SEEN", 0);
743 gMC->Gsatt("B077","SEEN", 0);
744 gMC->Gsatt("BTR1","SEEN", 0);
745 gMC->Gsatt("BTR2","SEEN", 0);
746 gMC->Gsatt("BTR3","SEEN", 0);
747 gMC->Gsatt("UTR1","SEEN", 0);
748 if (fGeometry->GetPHOShole())
749 gMC->Gsatt("UTR2","SEEN", 0);
750 if (fGeometry->GetRICHhole())
751 gMC->Gsatt("UTR3","SEEN", 0);
753 // gMC->Gsatt("UCII","SEEN", 0);
754 // gMC->Gsatt("UCIM","SEEN", 0);
755 // gMC->Gsatt("UCIO","SEEN", 0);
756 // gMC->Gsatt("UL02","SEEN", 1);
757 // gMC->Gsatt("UL05","SEEN", 1);
758 // gMC->Gsatt("UL06","SEEN", 1);
760 gMC->Gdopt("hide", "on");
761 gMC->Gdopt("shad", "on");
762 gMC->Gsatt("*", "fill", 7);
763 gMC->SetClipBox(".");
764 gMC->SetClipBox("*", 0, 2000, -2000, 2000, -2000, 2000);
766 gMC->Gdraw("alic", 40, 30, 0, 12, 9.4, .021, .021);
767 gMC->Gdhead(1111, "Transition Radiation Detector");
768 gMC->Gdman(18, 4, "MAN");
772 //_____________________________________________________________________________
773 Int_t AliTRD::DistancetoPrimitive(Int_t , Int_t ) const
776 // Distance between the mouse and the TRD detector on the screen
783 //_____________________________________________________________________________
787 // Initialize the TRD detector after the geometry has been created
793 printf("\n%s: ",ClassName());
794 for (i = 0; i < 35; i++) printf("*");
795 printf(" TRD_INIT ");
796 for (i = 0; i < 35; i++) printf("*");
800 if (fGeometry->IsVersion() == 0) {
801 printf("%s: Geometry for spaceframe with holes initialized\n",ClassName());
803 else if (fGeometry->IsVersion() == 1) {
804 printf("%s: Geometry for spaceframe without holes initialized\n",ClassName());
805 if (fGeometry->GetPHOShole())
806 printf("%s: Leave space in front of PHOS free\n",ClassName());
807 if (fGeometry->GetRICHhole())
808 printf("%s: Leave space in front of RICH free\n",ClassName());
812 printf("%s: Gas Mixture: 85%% Xe + 15%% CO2\n",ClassName());
815 printf("%s: Gas Mixture: 97%% Xe + 3%% Isobutane\n",ClassName());
820 //_____________________________________________________________________________
821 void AliTRD::LoadPoints(Int_t track)
824 // Store x, y, z of all hits in memory.
825 // Hit originating from TR photons are given a different color
829 // AliDetector::LoadPoints(track);
833 if ((fHits == 0) && (fTrackHits == 0)) return;
837 nhits = fHits->GetEntriesFast();
840 nhits = fTrackHits->GetEntriesFast();
842 if (nhits == 0) return;
844 Int_t tracks = gAlice->GetNtrack();
845 if (fPoints == 0) fPoints = new TObjArray(tracks);
849 Int_t *ntrkE = new Int_t[tracks];
850 Int_t *ntrkT = new Int_t[tracks];
851 Int_t *limiE = new Int_t[tracks];
852 Int_t *limiT = new Int_t[tracks];
853 Float_t **coorE = new Float_t*[tracks];
854 Float_t **coorT = new Float_t*[tracks];
855 for(Int_t i = 0; i < tracks; i++) {
864 AliTRDpoints *points = 0;
867 Int_t chunk = nhits / 4 + 1;
869 // Loop over all the hits and store their position
870 ahit = (AliTRDhit *) FirstHit(-1);
874 if (ahit->GetCharge() >= 0) {
876 trk = ahit->GetTrack();
877 if (ntrkE[trk] == limiE[trk]) {
878 // Initialise a new track
879 fp = new Float_t[3*(limiE[trk]+chunk)];
881 memcpy(fp,coorE[trk],sizeof(Float_t)*3*limiE[trk]);
882 delete [] coorE[trk];
890 fp[3*ntrkE[trk] ] = ahit->X();
891 fp[3*ntrkE[trk]+1] = ahit->Y();
892 fp[3*ntrkE[trk]+2] = ahit->Z();
897 else if ((ahit->GetCharge() < 0) && (fDrawTR)) {
899 trk = ahit->GetTrack();
900 if (ntrkT[trk] == limiT[trk]) {
901 // Initialise a new track
902 fp = new Float_t[3*(limiT[trk]+chunk)];
904 memcpy(fp,coorT[trk],sizeof(Float_t)*3*limiT[trk]);
905 delete [] coorT[trk];
913 fp[3*ntrkT[trk] ] = ahit->X();
914 fp[3*ntrkT[trk]+1] = ahit->Y();
915 fp[3*ntrkT[trk]+2] = ahit->Z();
920 ahit = (AliTRDhit *) NextHit();
924 for (trk = 0; trk < tracks; ++trk) {
926 if (ntrkE[trk] || ntrkT[trk]) {
928 points = new AliTRDpoints();
929 points->SetDetector(this);
930 points->SetParticle(trk);
932 // Set the dEdx points
934 points->SetMarkerColor(GetMarkerColor());
935 points->SetMarkerSize(GetMarkerSize());
936 points->SetPolyMarker(ntrkE[trk],coorE[trk],GetMarkerStyle());
937 delete [] coorE[trk];
941 // Set the TR photon points
943 points->SetTRpoints(ntrkT[trk],coorT[trk]);
944 delete [] coorT[trk];
948 fPoints->AddAt(points,trk);
963 //_____________________________________________________________________________
964 void AliTRD::MakeBranch(Option_t* option)
967 // Create Tree branches for the TRD digits.
970 Int_t buffersize = 4000;
971 Char_t branchname[15];
972 sprintf(branchname,"%s",GetName());
974 const char *cD = strstr(option,"D");
976 AliDetector::MakeBranch(option);
978 if (fDigits && gAlice->TreeD() && cD) {
979 MakeBranchInTree(gAlice->TreeD(),branchname,&fDigits,buffersize,0);
983 MakeBranch2(option,0);
988 //_____________________________________________________________________________
989 void AliTRD::ResetDigits()
992 // Reset number of digits and the digits array for this detector
996 if (fDigits) fDigits->Clear();
1000 //_____________________________________________________________________________
1001 void AliTRD::ResetRecPoints()
1004 // Reset number of reconstructed points and the point array
1009 Int_t nentr = fRecPoints->GetEntriesFast();
1010 for (Int_t i = 0; i < nentr; i++) delete fRecPoints->RemoveAt(i);
1015 //_____________________________________________________________________________
1016 void AliTRD::SetTreeAddress()
1019 // Set the branch addresses for the trees.
1022 Char_t branchname[15];
1024 if ( fLoader->TreeH() && (fHits == 0x0)) fHits = new TClonesArray("AliTRDhit",405);
1025 AliDetector::SetTreeAddress();
1028 TTree *treeR = fLoader->TreeR();
1031 sprintf(branchname,"%scluster",GetName());
1032 if (fRecPoints == 0x0) fRecPoints = new TObjArray(400);
1034 branch = treeR->GetBranch(branchname);
1036 branch->SetAddress(&fRecPoints);
1047 //_____________________________________________________________________________
1048 void AliTRD::SetGasMix(Int_t imix)
1051 // Defines the gas mixture (imix=0: Xe/Isobutane imix=1: Xe/CO2)
1054 if ((imix < 0) || (imix > 1)) {
1055 printf("Wrong input value: %d\n",imix);
1056 printf("Use standard setting\n");
1065 //_____________________________________________________________________________
1066 void AliTRD::SetPHOShole()
1069 // Selects a geometry with a hole in front of the PHOS
1072 fGeometry->SetPHOShole();
1076 //_____________________________________________________________________________
1077 void AliTRD::SetRICHhole()
1080 // Selects a geometry with a hole in front of the RICH
1083 fGeometry->SetRICHhole();
1087 //_____________________________________________________________________________
1088 AliTRD &AliTRD::operator=(const AliTRD &trd)
1091 // Assignment operator
1094 if (this != &trd) ((AliTRD &) trd).Copy(*this);
1099 //_____________________________________________________________________________
1100 void AliTRD::FinishPrimary()
1103 // Store the hits in the containers after all primaries are finished
1107 fTrackHits->FlushHitStack();
1112 //_____________________________________________________________________________
1113 void AliTRD::RemapTrackHitIDs(Int_t *map)
1116 // Remap the track IDs
1124 TClonesArray *arr = fTrackHits->GetArray();;
1125 for (Int_t i = 0; i < arr->GetEntriesFast(); i++){
1126 AliTrackHitsParamV2 *info = (AliTrackHitsParamV2 *) (arr->At(i));
1127 info->fTrackID = map[info->fTrackID];
1133 //_____________________________________________________________________________
1134 void AliTRD::ResetHits()
1140 AliDetector::ResetHits();
1142 fTrackHits->Clear();
1147 //_____________________________________________________________________________
1148 AliHit* AliTRD::FirstHit(Int_t track)
1151 // Return the first hit of a track
1155 return FirstHit2(track);
1158 return AliDetector::FirstHit(track);
1162 //_____________________________________________________________________________
1163 AliHit* AliTRD::NextHit()
1166 // Returns the next hit of a track
1173 return AliDetector::NextHit();
1177 //_____________________________________________________________________________
1178 AliHit* AliTRD::FirstHit2(Int_t track)
1181 // Initializes the hit iterator.
1182 // Returns the address of the first hit of a track.
1183 // If <track> >= 0 the track is read from disk,
1184 // while if <track> < 0 the first hit of the current
1185 // track is returned.
1189 gAlice->ResetHits();
1190 TreeH()->GetEvent(track);
1194 fTrackHits->First();
1195 return (AliHit*) fTrackHits->GetHit();
1203 //_____________________________________________________________________________
1204 AliHit* AliTRD::NextHit2()
1207 // Returns the next hit of the current track
1212 return (AliHit *) fTrackHits->GetHit();
1220 //_____________________________________________________________________________
1221 void AliTRD::MakeBranch2(Option_t *option, const char *file)
1224 // Create a new branch in the current Root tree.
1225 // The branch of fHits is automatically split.
1232 char branchname[10];
1233 sprintf(branchname,"%s2",GetName());
1235 // Get the pointer to the header
1236 const char *cH = strstr(option,"H");
1239 fTrackHits = new AliTRDtrackHits();
1243 if (fTrackHits && TreeH() && cH)
1245 TreeH()->Branch(branchname,"AliTRDtrackHits",&fTrackHits,fBufferSize,99);
1246 Info("MakeBranch2","Making Branch %s for trackhits",branchname);
1250 //_____________________________________________________________________________
1251 void AliTRD::SetTreeAddress2()
1254 // Set the branch address for the trackHits tree
1256 cout<<"AliTRD::SetTreeAddress2()"<<endl;
1259 char branchname[20];
1260 sprintf(branchname,"%s2",GetName());
1262 // Branch address for hit tree
1263 TTree *treeH = TreeH();
1264 if ((treeH) && (fHitType > 0)) {
1265 branch = treeH->GetBranch(branchname);
1268 branch->SetAddress(&fTrackHits);
1269 cout<<"Success"<<endl;
1273 cout<<"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"<<endl;
1274 cout<<"AliTRD::SetTreeAddress2() Can NOT get the branch "<<branchname<<endl;
1275 cout<<"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"<<endl;
1281 //_____________________________________________________________________________
1282 void AliTRD::AddHit2(Int_t track, Int_t det, Float_t *hits, Int_t q
1286 // Add a hit to the list
1292 Int_t primary = gAlice->GetPrimary(track);
1293 gAlice->Particle(primary)->SetBit(kKeepBit);
1298 gAlice->FlagTrack(track);
1301 if ((fTrackHits) && (fHitType > 0)) {
1302 fTrackHits->AddHitTRD(det,rtrack,hits[0],hits[1],hits[2],q,inDrift);