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 AliTRDdigitizer *digitizer = new AliTRDdigitizer("TRDdigitizer"
234 ,"TRD digitizer class");
235 digitizer->SetDebug(GetDebug());
238 digitizer->InitDetector();
240 if (!fLoader->TreeH()) fLoader->LoadHits("read");
241 fLoader->LoadDigits("recreate");
242 AliRunLoader* runLoader = fLoader->GetRunLoader();
244 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
245 digitizer->Open(runLoader->GetFileName().Data(), iEvent);
246 digitizer->MakeDigits();
247 digitizer->WriteDigits();
250 fLoader->UnloadHits();
251 fLoader->UnloadDigits();
254 //_____________________________________________________________________________
255 void AliTRD::Hits2SDigits()
258 // Create summable digits
260 AliTRDdigitizer *digitizer = new AliTRDdigitizer("TRDdigitizer"
261 ,"TRD digitizer class");
262 // For the summable digits
263 digitizer->SetSDigits(kTRUE);
264 digitizer->SetDebug(GetDebug());
267 digitizer->InitDetector();
269 if (!fLoader->TreeH()) fLoader->LoadHits("read");
270 fLoader->LoadSDigits("recreate");
271 AliRunLoader* runLoader = fLoader->GetRunLoader();
273 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
274 digitizer->Open(runLoader->GetFileName().Data(), iEvent);
275 digitizer->MakeDigits();
276 digitizer->WriteDigits();
279 fLoader->UnloadHits();
280 fLoader->UnloadSDigits();
283 //_____________________________________________________________________________
284 AliDigitizer* AliTRD::CreateDigitizer(AliRunDigitizer* manager)
286 return new AliTRDdigitizer(manager);
289 //_____________________________________________________________________________
290 void AliTRD::SDigits2Digits()
293 // Create final digits from summable digits
296 // Create the TRD digitizer
297 AliTRDdigitizer *digitizer = new AliTRDdigitizer("TRDdigitizer"
298 ,"TRD digitizer class");
299 digitizer->SetDebug(GetDebug());
302 digitizer->SetEvent(gAlice->GetEvNumber());
305 digitizer->InitDetector();
307 // Read the s-digits via digits manager
308 AliTRDdigitsManager *sdigitsManager = new AliTRDdigitsManager();
310 sdigitsManager->SetDebug(GetDebug());
311 sdigitsManager->SetSDigits(kTRUE);
312 sdigitsManager->CreateArrays();
314 if (!fLoader->TreeS())
315 if (fLoader->LoadSDigits("read"))
317 Error("SDigits2Digits","Error while reading SDigits for event %d",gAlice->GetEvNumber());
320 if (!fLoader->TreeS()) return;
322 sdigitsManager->ReadDigits(fLoader->TreeS());
324 // Add the s-digits to the input list
325 digitizer->AddSDigitsManager(sdigitsManager);
327 // Convert the s-digits to normal digits
328 digitizer->SDigits2Digits();
331 if (!fLoader->TreeD()) fLoader->MakeTree("D");
332 if (digitizer->MakeBranch(fLoader->TreeD())){
333 digitizer->WriteDigits();
338 //_____________________________________________________________________________
339 void AliTRD::AddHit(Int_t track, Int_t det, Float_t *hits, Int_t q
343 // Add a hit for the TRD
345 // The data structure is set according to fHitType:
346 // bit0: standard TClonesArray
347 // bit1: compressed trackHits structure
351 TClonesArray &lhits = *fHits;
352 new(lhits[fNhits++]) AliTRDhit(fIshunt,track,det,hits,q);
356 AddHit2(track,det,hits,q,inDrift);
361 //_____________________________________________________________________________
362 void AliTRD::BuildGeometry()
365 // Create the ROOT TNode geometry for the TRD
372 Float_t zmax1, zmax2;
376 const Int_t kColorTRD = 46;
378 // Find the top node alice
379 top = gAlice->GetGeometry()->GetNode("alice");
381 if (fDisplayType == 0) {
383 pgon = new TPGON("S_TRD","TRD","void",0,360,AliTRDgeometry::Nsect(),4);
384 rmin = AliTRDgeometry::Rmin();
385 rmax = AliTRDgeometry::Rmax();
386 pgon->DefineSection(0,-AliTRDgeometry::Zmax1(),rmax,rmax);
387 pgon->DefineSection(1,-AliTRDgeometry::Zmax2(),rmin,rmax);
388 pgon->DefineSection(2, AliTRDgeometry::Zmax2(),rmin,rmax);
389 pgon->DefineSection(3, AliTRDgeometry::Zmax1(),rmax,rmax);
391 node = new TNode("TRD","TRD","S_TRD",0,0,0,"");
392 node->SetLineColor(kColorTRD);
396 else if (fDisplayType == 1) {
400 Float_t slope = (AliTRDgeometry::Zmax1() - AliTRDgeometry::Zmax2())
401 / (AliTRDgeometry::Rmax() - AliTRDgeometry::Rmin());
403 rmin = AliTRDgeometry::Rmin() + AliTRDgeometry::CraHght();
404 rmax = rmin + AliTRDgeometry::CdrHght();
406 Float_t thickness = rmin - AliTRDgeometry::Rmin();
407 zmax2 = AliTRDgeometry::Zmax2() + slope * thickness;
408 zmax1 = zmax2 + slope * AliTRDgeometry::DrThick();
410 for (iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) {
412 sprintf(name,"S_TR1%d",iPlan);
413 pgon = new TPGON(name,"TRD","void",0,360,AliTRDgeometry::Nsect(),4);
414 pgon->DefineSection(0,-zmax1,rmax,rmax);
415 pgon->DefineSection(1,-zmax2,rmin,rmax);
416 pgon->DefineSection(2, zmax2,rmin,rmax);
417 pgon->DefineSection(3, zmax1,rmax,rmax);
419 node = new TNode("TRD","TRD",name,0,0,0,"");
420 node->SetLineColor(kColorTRD);
423 Float_t height = AliTRDgeometry::Cheight() + AliTRDgeometry::Cspace();
424 rmin = rmin + height;
425 rmax = rmax + height;
426 zmax1 = zmax1 + slope * height;
427 zmax2 = zmax2 + slope * height;
431 thickness += AliTRDgeometry::DrThick();
432 rmin = AliTRDgeometry::Rmin() + thickness;
433 rmax = rmin + AliTRDgeometry::AmThick();
434 zmax2 = AliTRDgeometry::Zmax2() + slope * thickness;
435 zmax1 = zmax2 + slope * AliTRDgeometry::AmThick();
437 for (iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) {
439 sprintf(name,"S_TR2%d",iPlan);
440 pgon = new TPGON(name,"TRD","void",0,360,AliTRDgeometry::Nsect(),4);
441 pgon->DefineSection(0,-zmax1,rmax,rmax);
442 pgon->DefineSection(1,-zmax2,rmin,rmax);
443 pgon->DefineSection(2, zmax2,rmin,rmax);
444 pgon->DefineSection(3, zmax1,rmax,rmax);
446 node = new TNode("TRD","TRD",name,0,0,0,"");
447 node->SetLineColor(kColorTRD);
450 Float_t height = AliTRDgeometry::Cheight() + AliTRDgeometry::Cspace();
451 rmin = rmin + height;
452 rmax = rmax + height;
453 zmax1 = zmax1 + slope * height;
454 zmax2 = zmax2 + slope * height;
462 //_____________________________________________________________________________
463 void AliTRD::Copy(TObject &trd)
469 ((AliTRD &) trd).fGasMix = fGasMix;
470 ((AliTRD &) trd).fGeometry = fGeometry;
471 ((AliTRD &) trd).fRecPoints = fRecPoints;
472 ((AliTRD &) trd).fNRecPoints = fNRecPoints;
473 ((AliTRD &) trd).fGasDensity = fGasDensity;
474 ((AliTRD &) trd).fFoilDensity = fFoilDensity;
475 ((AliTRD &) trd).fDrawTR = fDrawTR;
476 ((AliTRD &) trd).fDisplayType = fDisplayType;
477 ((AliTRD &) trd).fHitType = fHitType;
479 //AliDetector::Copy(trd);
483 //_____________________________________________________________________________
484 void AliTRD::CreateGeometry()
487 // Creates the volumes for the TRD chambers
490 // Check that FRAME is there otherwise we have no place where to put the TRD
491 AliModule* frame = gAlice->GetModule("FRAME");
493 printf(" The TRD needs the FRAME to be defined first\n");
497 fGeometry->CreateGeometry(fIdtmed->GetArray() - 1299);
501 //_____________________________________________________________________________
502 void AliTRD::CreateMaterials()
505 // Create the materials for the TRD
509 Int_t isxfld = gAlice->Field()->Integ();
510 Float_t sxmgmx = gAlice->Field()->Max();
512 // For polyethilene (CH2)
513 Float_t ape[2] = { 12., 1. };
514 Float_t zpe[2] = { 6., 1. };
515 Float_t wpe[2] = { 1., 2. };
518 // For mylar (C5H4O2)
519 Float_t amy[3] = { 12., 1., 16. };
520 Float_t zmy[3] = { 6., 1., 8. };
521 Float_t wmy[3] = { 5., 4., 2. };
525 Float_t aco[2] = { 12., 16. };
526 Float_t zco[2] = { 6., 8. };
527 Float_t wco[2] = { 1., 2. };
528 Float_t dco = 0.001977;
531 Float_t awa[2] = { 1., 16. };
532 Float_t zwa[2] = { 1., 8. };
533 Float_t wwa[2] = { 2., 1. };
536 // For isobutane (C4H10)
537 Float_t ais[2] = { 12., 1. };
538 Float_t zis[2] = { 6., 1. };
539 Float_t wis[2] = { 4., 10. };
540 Float_t dis = 0.00267;
542 // For plexiglas (C5H8O2)
543 Float_t apg[3] = { 12.011 , 1.0 , 15.9994 };
544 Float_t zpg[3] = { 6.0 , 1.0 , 8.0 };
545 Float_t wpg[3] = { 5.0 , 8.0 , 2.0 };
548 // For Xe/CO2-gas-mixture
549 // Xe-content of the Xe/CO2-mixture (85% / 15%)
551 // Xe-content of the Xe/Isobutane-mixture (97% / 3%)
553 Float_t dxe = .005858;
555 // General tracking parameter
556 Float_t tmaxfd = -10.;
557 Float_t stemax = -1e10;
558 Float_t deemax = -0.1;
559 Float_t epsil = 1e-4;
560 Float_t stmin = -0.001;
562 Float_t absl, radl, d, buf[1];
563 Float_t agm[2], zgm[2], wgm[2];
567 //////////////////////////////////////////////////////////////////////////
569 //////////////////////////////////////////////////////////////////////////
571 AliMaterial( 1, "Al" , 26.98, 13.0, 2.7 , 8.9 , 37.2);
572 AliMaterial( 2, "Air" , 14.61, 7.3, 0.001205, 30420.0 , 67500.0);
573 AliMaterial( 4, "Xe" , 131.29, 54.0, dxe , 1447.59, 0.0);
574 AliMaterial( 5, "Cu" , 63.54, 29.0, 8.96 , 1.43, 14.8);
575 AliMaterial( 6, "C" , 12.01, 6.0, 2.265 , 18.8 , 74.4);
576 AliMaterial(12, "G10" , 20.00, 10.0, 1.7 , 19.4 , 999.0);
577 AliMaterial(15, "Sn" , 118.71, 50.0, 7.31 , 1.21, 14.8);
578 AliMaterial(16, "Si" , 28.09, 14.0, 2.33 , 9.36, 37.2);
579 AliMaterial(17, "Epoxy", 17.75, 8.9, 1.8 , 21.82, 999.0);
582 AliMixture(3, "Polyethilene", ape, zpe, dpe, -2, wpe);
583 AliMixture(7, "Mylar", amy, zmy, dmy, -3, wmy);
584 AliMixture(8, "CO2", aco, zco, dco, -2, wco);
585 AliMixture(9, "Isobutane", ais, zis, dis, -2, wis);
586 AliMixture(13,"Water", awa, zwa, dwa, -2, wwa);
587 AliMixture(14,"Plexiglas", apg, zpg, dpg, -3, wpg);
590 Char_t namate[21]="";
592 // Get properties of Xe
593 gMC->Gfmate((*fIdmate)[4], namate, agm[0], zgm[0], d, radl, absl, buf, nbuf);
594 // Get properties of CO2
595 gMC->Gfmate((*fIdmate)[8], namate, agm[1], zgm[1], d, radl, absl, buf, nbuf);
596 // Create gas mixture
599 dgm1 = wgm[0] * dxe + wgm[1] * dco;
600 AliMixture(10, "Gas mixture 1", agm, zgm, dgm1, 2, wgm);
601 // Xe/Isobutane-mixture
602 // Get properties of Xe
603 gMC->Gfmate((*fIdmate)[4], namate, agm[0], zgm[0], d, radl, absl, buf, nbuf);
604 // Get properties of Isobutane
605 gMC->Gfmate((*fIdmate)[9], namate, agm[1], zgm[1], d, radl, absl, buf, nbuf);
606 // Create gas mixture
609 dgm2 = wgm[0] * dxe + wgm[1] * dis;
610 AliMixture(11, "Gas mixture 2", agm, zgm, dgm2, 2, wgm);
612 //////////////////////////////////////////////////////////////////////////
613 // Tracking Media Parameters
614 //////////////////////////////////////////////////////////////////////////
617 AliMedium(1, "Al Frame", 1, 0, isxfld, sxmgmx
618 , tmaxfd, stemax, deemax, epsil, stmin);
620 AliMedium(2, "Air", 2, 0, isxfld, sxmgmx
621 , tmaxfd, stemax, deemax, epsil, stmin);
623 AliMedium(3, "Radiator", 3, 0, isxfld, sxmgmx
624 , tmaxfd, stemax, deemax, epsil, stmin);
626 AliMedium(4, "Xe", 4, 1, isxfld, sxmgmx
627 , tmaxfd, stemax, deemax, epsil, stmin);
629 AliMedium(5, "Padplane", 5, 1, isxfld, sxmgmx
630 , tmaxfd, stemax, deemax, epsil, stmin);
632 AliMedium(6, "Readout", 1, 0, isxfld, sxmgmx
633 , tmaxfd, stemax, deemax, epsil, stmin);
635 AliMedium(7, "C Frame", 6, 0, isxfld, sxmgmx
636 , tmaxfd, stemax, deemax, epsil, stmin);
638 AliMedium(8, "Mylar", 7, 0, isxfld, sxmgmx
639 , tmaxfd, stemax, deemax, epsil, stmin);
641 // Gas-mixture (Xe/CO2)
642 AliMedium(9, "Gas-mix", 10, 1, isxfld, sxmgmx
643 , tmaxfd, stemax, deemax, epsil, stmin);
646 // Gas-mixture (Xe/Isobutane)
647 AliMedium(9, "Gas-mix", 11, 1, isxfld, sxmgmx
648 , tmaxfd, stemax, deemax, epsil, stmin);
650 // Nomex-honeycomb (use carbon for the time being)
651 AliMedium(10, "Nomex", 6, 0, isxfld, sxmgmx
652 , tmaxfd, stemax, deemax, epsil, stmin);
653 // Kapton foils (use Mylar for the time being)
654 AliMedium(11, "Kapton", 7, 0, isxfld, sxmgmx
655 , tmaxfd, stemax, deemax, epsil, stmin);
656 // Gas-filling of the radiator
657 AliMedium(12, "CO2", 8, 0, isxfld, sxmgmx
658 , tmaxfd, stemax, deemax, epsil, stmin);
660 AliMedium(13, "G10-plates",12, 0, isxfld, sxmgmx
661 , tmaxfd, stemax, deemax, epsil, stmin);
663 AliMedium(14, "Water", 13, 0, isxfld, sxmgmx
664 , tmaxfd, stemax, deemax, epsil, stmin);
665 // Rohacell (plexiglas) for the radiator
666 AliMedium(15, "Rohacell", 14, 0, isxfld, sxmgmx
667 , tmaxfd, stemax, deemax, epsil, stmin);
669 AliMedium(16, "MCM-Al" , 1, 0, isxfld, sxmgmx
670 , tmaxfd, stemax, deemax, epsil, stmin);
672 AliMedium(17, "MCM-Sn" , 15, 0, isxfld, sxmgmx
673 , tmaxfd, stemax, deemax, epsil, stmin);
675 AliMedium(18, "MCM-Cu" , 5, 0, isxfld, sxmgmx
676 , tmaxfd, stemax, deemax, epsil, stmin);
678 AliMedium(19, "MCM-G10" , 12, 0, isxfld, sxmgmx
679 , tmaxfd, stemax, deemax, epsil, stmin);
680 // Si in readout chips
681 AliMedium(20, "Chip-Si" , 16, 0, isxfld, sxmgmx
682 , tmaxfd, stemax, deemax, epsil, stmin);
683 // Epoxy in readout chips
684 AliMedium(21, "Chip-Ep" , 17, 0, isxfld, sxmgmx
685 , tmaxfd, stemax, deemax, epsil, stmin);
687 AliMedium(22, "Conn-PE" , 3, 0, isxfld, sxmgmx
688 , tmaxfd, stemax, deemax, epsil, stmin);
690 AliMedium(23, "Chip-Cu" , 5, 0, isxfld, sxmgmx
691 , tmaxfd, stemax, deemax, epsil, stmin);
692 // Al of cooling pipes
693 AliMedium(24, "Cooling" , 1, 0, isxfld, sxmgmx
694 , tmaxfd, stemax, deemax, epsil, stmin);
696 AliMedium(25, "Serv-Cu" , 5, 0, isxfld, sxmgmx
697 , tmaxfd, stemax, deemax, epsil, stmin);
699 // Save the density values for the TRD absorbtion
708 //_____________________________________________________________________________
709 void AliTRD::DrawModule() const
712 // Draw a shaded view of the Transition Radiation Detector version 0
715 // Set everything unseen
716 gMC->Gsatt("*" ,"SEEN",-1);
718 // Set ALIC mother transparent
719 gMC->Gsatt("ALIC","SEEN", 0);
721 // Set the volumes visible
722 if (fGeometry->IsVersion() == 0) {
723 gMC->Gsatt("B071","SEEN", 0);
724 gMC->Gsatt("B074","SEEN", 0);
725 gMC->Gsatt("B075","SEEN", 0);
726 gMC->Gsatt("B077","SEEN", 0);
727 gMC->Gsatt("BTR1","SEEN", 0);
728 gMC->Gsatt("BTR2","SEEN", 0);
729 gMC->Gsatt("BTR3","SEEN", 0);
730 gMC->Gsatt("UTR1","SEEN", 0);
731 gMC->Gsatt("UTR2","SEEN", 0);
732 gMC->Gsatt("UTR3","SEEN", 0);
735 gMC->Gsatt("B071","SEEN", 0);
736 gMC->Gsatt("B074","SEEN", 0);
737 gMC->Gsatt("B075","SEEN", 0);
738 gMC->Gsatt("B077","SEEN", 0);
739 gMC->Gsatt("BTR1","SEEN", 0);
740 gMC->Gsatt("BTR2","SEEN", 0);
741 gMC->Gsatt("BTR3","SEEN", 0);
742 gMC->Gsatt("UTR1","SEEN", 0);
743 if (fGeometry->GetPHOShole())
744 gMC->Gsatt("UTR2","SEEN", 0);
745 if (fGeometry->GetRICHhole())
746 gMC->Gsatt("UTR3","SEEN", 0);
748 // gMC->Gsatt("UCII","SEEN", 0);
749 // gMC->Gsatt("UCIM","SEEN", 0);
750 // gMC->Gsatt("UCIO","SEEN", 0);
751 // gMC->Gsatt("UL02","SEEN", 1);
752 // gMC->Gsatt("UL05","SEEN", 1);
753 // gMC->Gsatt("UL06","SEEN", 1);
755 gMC->Gdopt("hide", "on");
756 gMC->Gdopt("shad", "on");
757 gMC->Gsatt("*", "fill", 7);
758 gMC->SetClipBox(".");
759 gMC->SetClipBox("*", 0, 2000, -2000, 2000, -2000, 2000);
761 gMC->Gdraw("alic", 40, 30, 0, 12, 9.4, .021, .021);
762 gMC->Gdhead(1111, "Transition Radiation Detector");
763 gMC->Gdman(18, 4, "MAN");
767 //_____________________________________________________________________________
768 Int_t AliTRD::DistancetoPrimitive(Int_t , Int_t ) const
771 // Distance between the mouse and the TRD detector on the screen
778 //_____________________________________________________________________________
782 // Initialize the TRD detector after the geometry has been created
788 printf("\n%s: ",ClassName());
789 for (i = 0; i < 35; i++) printf("*");
790 printf(" TRD_INIT ");
791 for (i = 0; i < 35; i++) printf("*");
795 if (fGeometry->IsVersion() == 0) {
796 printf("%s: Geometry for spaceframe with holes initialized\n",ClassName());
798 else if (fGeometry->IsVersion() == 1) {
799 printf("%s: Geometry for spaceframe without holes initialized\n",ClassName());
800 if (fGeometry->GetPHOShole())
801 printf("%s: Leave space in front of PHOS free\n",ClassName());
802 if (fGeometry->GetRICHhole())
803 printf("%s: Leave space in front of RICH free\n",ClassName());
807 printf("%s: Gas Mixture: 85%% Xe + 15%% CO2\n",ClassName());
810 printf("%s: Gas Mixture: 97%% Xe + 3%% Isobutane\n",ClassName());
815 //_____________________________________________________________________________
816 void AliTRD::LoadPoints(Int_t )
819 // Store x, y, z of all hits in memory.
820 // Hit originating from TR photons are given a different color
824 // AliDetector::LoadPoints(track);
828 if ((fHits == 0) && (fTrackHits == 0)) return;
832 nhits = fHits->GetEntriesFast();
835 nhits = fTrackHits->GetEntriesFast();
837 if (nhits == 0) return;
839 Int_t tracks = gAlice->GetMCApp()->GetNtrack();
840 if (fPoints == 0) fPoints = new TObjArray(tracks);
844 Int_t *ntrkE = new Int_t[tracks];
845 Int_t *ntrkT = new Int_t[tracks];
846 Int_t *limiE = new Int_t[tracks];
847 Int_t *limiT = new Int_t[tracks];
848 Float_t **coorE = new Float_t*[tracks];
849 Float_t **coorT = new Float_t*[tracks];
850 for(Int_t i = 0; i < tracks; i++) {
859 AliTRDpoints *points = 0;
862 Int_t chunk = nhits / 4 + 1;
864 // Loop over all the hits and store their position
865 ahit = (AliTRDhit *) FirstHit(-1);
869 if (ahit->GetCharge() >= 0) {
871 trk = ahit->GetTrack();
872 if (ntrkE[trk] == limiE[trk]) {
873 // Initialise a new track
874 fp = new Float_t[3*(limiE[trk]+chunk)];
876 memcpy(fp,coorE[trk],sizeof(Float_t)*3*limiE[trk]);
877 delete [] coorE[trk];
885 fp[3*ntrkE[trk] ] = ahit->X();
886 fp[3*ntrkE[trk]+1] = ahit->Y();
887 fp[3*ntrkE[trk]+2] = ahit->Z();
892 else if ((ahit->GetCharge() < 0) && (fDrawTR)) {
894 trk = ahit->GetTrack();
895 if (ntrkT[trk] == limiT[trk]) {
896 // Initialise a new track
897 fp = new Float_t[3*(limiT[trk]+chunk)];
899 memcpy(fp,coorT[trk],sizeof(Float_t)*3*limiT[trk]);
900 delete [] coorT[trk];
908 fp[3*ntrkT[trk] ] = ahit->X();
909 fp[3*ntrkT[trk]+1] = ahit->Y();
910 fp[3*ntrkT[trk]+2] = ahit->Z();
915 ahit = (AliTRDhit *) NextHit();
919 for (trk = 0; trk < tracks; ++trk) {
921 if (ntrkE[trk] || ntrkT[trk]) {
923 points = new AliTRDpoints();
924 points->SetDetector(this);
925 points->SetParticle(trk);
927 // Set the dEdx points
929 points->SetMarkerColor(GetMarkerColor());
930 points->SetMarkerSize(GetMarkerSize());
931 points->SetPolyMarker(ntrkE[trk],coorE[trk],GetMarkerStyle());
932 delete [] coorE[trk];
936 // Set the TR photon points
938 points->SetTRpoints(ntrkT[trk],coorT[trk]);
939 delete [] coorT[trk];
943 fPoints->AddAt(points,trk);
958 //_____________________________________________________________________________
959 void AliTRD::MakeBranch(Option_t* option)
962 // Create Tree branches for the TRD digits.
965 Int_t buffersize = 4000;
966 Char_t branchname[15];
967 sprintf(branchname,"%s",GetName());
969 const char *cD = strstr(option,"D");
971 AliDetector::MakeBranch(option);
973 if (fDigits && gAlice->TreeD() && cD) {
974 MakeBranchInTree(gAlice->TreeD(),branchname,&fDigits,buffersize,0);
978 MakeBranch2(option,0);
983 //_____________________________________________________________________________
984 void AliTRD::ResetDigits()
987 // Reset number of digits and the digits array for this detector
991 if (fDigits) fDigits->Clear();
995 //_____________________________________________________________________________
996 void AliTRD::ResetRecPoints()
999 // Reset number of reconstructed points and the point array
1004 Int_t nentr = fRecPoints->GetEntriesFast();
1005 for (Int_t i = 0; i < nentr; i++) delete fRecPoints->RemoveAt(i);
1010 //_____________________________________________________________________________
1011 void AliTRD::SetTreeAddress()
1014 // Set the branch addresses for the trees.
1017 Char_t branchname[15];
1019 if ( fLoader->TreeH() && (fHits == 0x0)) fHits = new TClonesArray("AliTRDhit",405);
1020 AliDetector::SetTreeAddress();
1023 TTree *treeR = fLoader->TreeR();
1026 sprintf(branchname,"%scluster",GetName());
1027 if (fRecPoints == 0x0) fRecPoints = new TObjArray(400);
1029 branch = treeR->GetBranch(branchname);
1031 branch->SetAddress(&fRecPoints);
1042 //_____________________________________________________________________________
1043 void AliTRD::SetGasMix(Int_t imix)
1046 // Defines the gas mixture (imix=0: Xe/Isobutane imix=1: Xe/CO2)
1049 if ((imix < 0) || (imix > 1)) {
1050 printf("Wrong input value: %d\n",imix);
1051 printf("Use standard setting\n");
1060 //_____________________________________________________________________________
1061 void AliTRD::SetPHOShole()
1064 // Selects a geometry with a hole in front of the PHOS
1067 fGeometry->SetPHOShole();
1071 //_____________________________________________________________________________
1072 void AliTRD::SetRICHhole()
1075 // Selects a geometry with a hole in front of the RICH
1078 fGeometry->SetRICHhole();
1082 //_____________________________________________________________________________
1083 AliTRD &AliTRD::operator=(const AliTRD &trd)
1086 // Assignment operator
1089 if (this != &trd) ((AliTRD &) trd).Copy(*this);
1094 //_____________________________________________________________________________
1095 void AliTRD::FinishPrimary()
1098 // Store the hits in the containers after all primaries are finished
1102 fTrackHits->FlushHitStack();
1107 //_____________________________________________________________________________
1108 void AliTRD::RemapTrackHitIDs(Int_t *map)
1111 // Remap the track IDs
1119 TClonesArray *arr = fTrackHits->GetArray();;
1120 for (Int_t i = 0; i < arr->GetEntriesFast(); i++){
1121 AliTrackHitsParamV2 *info = (AliTrackHitsParamV2 *) (arr->At(i));
1122 info->fTrackID = map[info->fTrackID];
1128 //_____________________________________________________________________________
1129 void AliTRD::ResetHits()
1135 AliDetector::ResetHits();
1137 fTrackHits->Clear();
1142 //_____________________________________________________________________________
1143 AliHit* AliTRD::FirstHit(Int_t track)
1146 // Return the first hit of a track
1150 return FirstHit2(track);
1153 return AliDetector::FirstHit(track);
1157 //_____________________________________________________________________________
1158 AliHit* AliTRD::NextHit()
1161 // Returns the next hit of a track
1168 return AliDetector::NextHit();
1172 //_____________________________________________________________________________
1173 AliHit* AliTRD::FirstHit2(Int_t track)
1176 // Initializes the hit iterator.
1177 // Returns the address of the first hit of a track.
1178 // If <track> >= 0 the track is read from disk,
1179 // while if <track> < 0 the first hit of the current
1180 // track is returned.
1184 gAlice->ResetHits();
1185 TreeH()->GetEvent(track);
1189 fTrackHits->First();
1190 return (AliHit*) fTrackHits->GetHit();
1198 //_____________________________________________________________________________
1199 AliHit* AliTRD::NextHit2()
1202 // Returns the next hit of the current track
1207 return (AliHit *) fTrackHits->GetHit();
1215 //_____________________________________________________________________________
1216 void AliTRD::MakeBranch2(Option_t *option, const char* )
1219 // Create a new branch in the current Root tree.
1220 // The branch of fHits is automatically split.
1227 char branchname[10];
1228 sprintf(branchname,"%s2",GetName());
1230 // Get the pointer to the header
1231 const char *cH = strstr(option,"H");
1234 fTrackHits = new AliTRDtrackHits();
1238 if (fTrackHits && TreeH() && cH)
1240 TreeH()->Branch(branchname,"AliTRDtrackHits",&fTrackHits,fBufferSize,99);
1241 Info("MakeBranch2","Making Branch %s for trackhits",branchname);
1245 //_____________________________________________________________________________
1246 void AliTRD::SetTreeAddress2()
1249 // Set the branch address for the trackHits tree
1251 if (GetDebug()) Info("SetTreeAddress2","");
1254 char branchname[20];
1255 sprintf(branchname,"%s2",GetName());
1257 // Branch address for hit tree
1258 TTree *treeH = TreeH();
1259 if ((treeH) && (fHitType > 0)) {
1260 branch = treeH->GetBranch(branchname);
1263 branch->SetAddress(&fTrackHits);
1265 Info("SetTreeAddress2","Success.");
1270 Info("SetTreeAddress2","Can NOT get the branch %s",branchname);
1276 //_____________________________________________________________________________
1277 void AliTRD::AddHit2(Int_t track, Int_t det, Float_t *hits, Int_t q
1281 // Add a hit to the list
1287 Int_t primary = gAlice->GetMCApp()->GetPrimary(track);
1288 gAlice->GetMCApp()->Particle(primary)->SetBit(kKeepBit);
1293 gAlice->GetMCApp()->FlagTrack(track);
1296 if ((fTrackHits) && (fHitType > 0)) {
1297 fTrackHits->AddHitTRD(det,rtrack,hits[0],hits[1],hits[2],q,inDrift);