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 "AliTRDdigit.h"
47 #include "AliTRDdigitizer.h"
48 #include "AliTRDdigitsManager.h"
49 #include "AliTRDgeometryFull.h"
50 #include "AliTRDgeometryHole.h"
51 #include "AliTRDhit.h"
52 #include "AliTRDpoints.h"
53 #include "AliTRDtrackHits.h"
54 #include "AliTRDrawData.h"
55 #include "AliTrackReference.h"
60 //_____________________________________________________________________________
64 // Default constructor
85 //_____________________________________________________________________________
86 AliTRD::AliTRD(const char *name, const char *title)
87 : AliDetector(name,title)
90 // Standard constructor for the TRD
93 // Check that FRAME is there otherwise we have no place where to
95 AliModule* frame = gAlice->GetModule("FRAME");
97 Error("Ctor","TRD needs FRAME to be present\n");
101 // Define the TRD geometry
102 if ((frame->IsVersion() == 0) ||
103 (frame->IsVersion() == 1)) {
104 fGeometry = new AliTRDgeometryFull();
107 Error("Ctor","Could not find valid FRAME version\n");
112 TDirectory* saveDir = gDirectory;
113 gAlice->GetRunLoader()->CdGAFile();
114 fGeometry->Write("TRDgeometry");
117 // Allocate the hit array
118 fHits = new TClonesArray("AliTRDhit" ,405);
119 gAlice->GetMCApp()->AddHitList(fHits);
121 // Allocate the digits array
136 SetMarkerColor(kWhite);
140 //_____________________________________________________________________________
141 AliTRD::AliTRD(const AliTRD &trd):AliDetector(trd)
147 ((AliTRD &) trd).Copy(*this);
151 //_____________________________________________________________________________
169 // delete fRecPoints;
179 //_____________________________________________________________________________
180 void AliTRD::Hits2Digits()
185 AliTRDdigitizer digitizer("TRDdigitizer","TRD digitizer class");
186 digitizer.SetDebug(GetDebug());
189 digitizer.InitDetector();
191 if (!fLoader->TreeH()) fLoader->LoadHits("read");
192 fLoader->LoadDigits("recreate");
193 AliRunLoader* runLoader = fLoader->GetRunLoader();
195 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
196 digitizer.Open(runLoader->GetFileName().Data(), iEvent);
197 digitizer.MakeDigits();
198 digitizer.WriteDigits();
201 fLoader->UnloadHits();
202 fLoader->UnloadDigits();
205 //_____________________________________________________________________________
206 void AliTRD::Hits2SDigits()
209 // Create summable digits
211 AliTRDdigitizer digitizer("TRDdigitizer","TRD digitizer class");
212 // For the summable digits
213 digitizer.SetSDigits(kTRUE);
214 digitizer.SetDebug(GetDebug());
217 digitizer.InitDetector();
219 if (!fLoader->TreeH()) fLoader->LoadHits("read");
220 fLoader->LoadSDigits("recreate");
221 AliRunLoader* runLoader = fLoader->GetRunLoader();
223 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
224 digitizer.Open(runLoader->GetFileName().Data(), iEvent);
225 digitizer.MakeDigits();
226 digitizer.WriteDigits();
229 fLoader->UnloadHits();
230 fLoader->UnloadSDigits();
233 //_____________________________________________________________________________
234 AliDigitizer* AliTRD::CreateDigitizer(AliRunDigitizer* manager) const
236 return new AliTRDdigitizer(manager);
239 //_____________________________________________________________________________
240 void AliTRD::SDigits2Digits()
243 // Create final digits from summable digits
246 // Create the TRD digitizer
247 AliTRDdigitizer digitizer("TRDdigitizer","TRD digitizer class");
248 digitizer.SetDebug(GetDebug());
251 digitizer.SetEvent(gAlice->GetEvNumber());
254 digitizer.InitDetector();
256 // Read the s-digits via digits manager
257 AliTRDdigitsManager sdigitsManager;
259 sdigitsManager.SetDebug(GetDebug());
260 sdigitsManager.SetSDigits(kTRUE);
261 sdigitsManager.CreateArrays();
263 if (!fLoader->TreeS())
264 if (fLoader->LoadSDigits("read"))
266 Error("SDigits2Digits","Error while reading SDigits for event %d",gAlice->GetEvNumber());
269 if (!fLoader->TreeS()) return;
271 sdigitsManager.ReadDigits(fLoader->TreeS());
273 // Add the s-digits to the input list
274 digitizer.AddSDigitsManager(&sdigitsManager);
276 // Convert the s-digits to normal digits
277 digitizer.SDigits2Digits();
280 if (!fLoader->TreeD()) fLoader->MakeTree("D");
281 if (digitizer.MakeBranch(fLoader->TreeD())){
282 digitizer.WriteDigits();
287 //_____________________________________________________________________________
288 void AliTRD::Digits2Raw()
291 // convert digits of the current event to raw data
294 fLoader->LoadDigits();
295 TTree* digits = fLoader->TreeD();
297 Error("Digits2Raw", "no digits tree");
301 AliTRDrawData rawWriter;
302 // rawWriter.SetDebug(2);
303 if (!rawWriter.Digits2Raw(digits)) {
304 Error("AliTRD::Digits2Raw","The raw writer could not load the digits tree");
307 fLoader->UnloadDigits();
311 //_____________________________________________________________________________
312 void AliTRD::AddHit(Int_t track, Int_t det, Float_t *hits, Int_t q
316 // Add a hit for the TRD
318 // The data structure is set according to fHitType:
319 // bit0: standard TClonesArray
320 // bit1: compressed trackHits structure
324 TClonesArray &lhits = *fHits;
325 new(lhits[fNhits++]) AliTRDhit(fIshunt,track,det,hits,q);
329 AddHit2(track,det,hits,q,inDrift);
334 //_____________________________________________________________________________
335 void AliTRD::BuildGeometry()
338 // Create the ROOT TNode geometry for the TRD
345 Float_t zmax1, zmax2;
349 const Int_t kColorTRD = 46;
351 // Find the top node alice
352 top = gAlice->GetGeometry()->GetNode("alice");
354 if (fDisplayType == 0) {
356 pgon = new TPGON("S_TRD","TRD","void",0,360,AliTRDgeometry::Nsect(),4);
357 rmin = AliTRDgeometry::Rmin();
358 rmax = AliTRDgeometry::Rmax();
359 pgon->DefineSection(0,-AliTRDgeometry::Zmax1(),rmax,rmax);
360 pgon->DefineSection(1,-AliTRDgeometry::Zmax2(),rmin,rmax);
361 pgon->DefineSection(2, AliTRDgeometry::Zmax2(),rmin,rmax);
362 pgon->DefineSection(3, AliTRDgeometry::Zmax1(),rmax,rmax);
364 node = new TNode("TRD","TRD","S_TRD",0,0,0,"");
365 node->SetLineColor(kColorTRD);
369 else if (fDisplayType == 1) {
373 Float_t slope = (AliTRDgeometry::Zmax1() - AliTRDgeometry::Zmax2())
374 / (AliTRDgeometry::Rmax() - AliTRDgeometry::Rmin());
376 rmin = AliTRDgeometry::Rmin() + AliTRDgeometry::CraHght();
377 rmax = rmin + AliTRDgeometry::CdrHght();
379 Float_t thickness = rmin - AliTRDgeometry::Rmin();
380 zmax2 = AliTRDgeometry::Zmax2() + slope * thickness;
381 zmax1 = zmax2 + slope * AliTRDgeometry::DrThick();
383 for (iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) {
385 sprintf(name,"S_TR1%d",iPlan);
386 pgon = new TPGON(name,"TRD","void",0,360,AliTRDgeometry::Nsect(),4);
387 pgon->DefineSection(0,-zmax1,rmax,rmax);
388 pgon->DefineSection(1,-zmax2,rmin,rmax);
389 pgon->DefineSection(2, zmax2,rmin,rmax);
390 pgon->DefineSection(3, zmax1,rmax,rmax);
392 node = new TNode("TRD","TRD",name,0,0,0,"");
393 node->SetLineColor(kColorTRD);
396 Float_t height = AliTRDgeometry::Cheight() + AliTRDgeometry::Cspace();
397 rmin = rmin + height;
398 rmax = rmax + height;
399 zmax1 = zmax1 + slope * height;
400 zmax2 = zmax2 + slope * height;
404 thickness += AliTRDgeometry::DrThick();
405 rmin = AliTRDgeometry::Rmin() + thickness;
406 rmax = rmin + AliTRDgeometry::AmThick();
407 zmax2 = AliTRDgeometry::Zmax2() + slope * thickness;
408 zmax1 = zmax2 + slope * AliTRDgeometry::AmThick();
410 for (iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) {
412 sprintf(name,"S_TR2%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;
435 //_____________________________________________________________________________
436 void AliTRD::Copy(TObject &trd)
442 ((AliTRD &) trd).fGasMix = fGasMix;
443 ((AliTRD &) trd).fGeometry = fGeometry;
444 ((AliTRD &) trd).fGasDensity = fGasDensity;
445 ((AliTRD &) trd).fFoilDensity = fFoilDensity;
446 ((AliTRD &) trd).fDrawTR = fDrawTR;
447 ((AliTRD &) trd).fDisplayType = fDisplayType;
448 ((AliTRD &) trd).fHitType = fHitType;
450 //AliDetector::Copy(trd);
454 //_____________________________________________________________________________
455 void AliTRD::CreateGeometry()
458 // Creates the volumes for the TRD chambers
461 // Check that FRAME is there otherwise we have no place where to put the TRD
462 AliModule* frame = gAlice->GetModule("FRAME");
464 printf(" The TRD needs the FRAME to be defined first\n");
468 fGeometry->CreateGeometry(fIdtmed->GetArray() - 1299);
472 //_____________________________________________________________________________
473 void AliTRD::CreateMaterials()
476 // Create the materials for the TRD
480 Int_t isxfld = gAlice->Field()->Integ();
481 Float_t sxmgmx = gAlice->Field()->Max();
483 // For polyethilene (CH2)
484 Float_t ape[2] = { 12., 1. };
485 Float_t zpe[2] = { 6., 1. };
486 Float_t wpe[2] = { 1., 2. };
489 // For mylar (C5H4O2)
490 Float_t amy[3] = { 12., 1., 16. };
491 Float_t zmy[3] = { 6., 1., 8. };
492 Float_t wmy[3] = { 5., 4., 2. };
496 Float_t aco[2] = { 12., 16. };
497 Float_t zco[2] = { 6., 8. };
498 Float_t wco[2] = { 1., 2. };
499 Float_t dco = 0.001977;
502 Float_t awa[2] = { 1., 16. };
503 Float_t zwa[2] = { 1., 8. };
504 Float_t wwa[2] = { 2., 1. };
507 // For isobutane (C4H10)
508 Float_t ais[2] = { 12., 1. };
509 Float_t zis[2] = { 6., 1. };
510 Float_t wis[2] = { 4., 10. };
511 Float_t dis = 0.00267;
513 // For plexiglas (C5H8O2)
514 Float_t apg[3] = { 12.011 , 1.0 , 15.9994 };
515 Float_t zpg[3] = { 6.0 , 1.0 , 8.0 };
516 Float_t wpg[3] = { 5.0 , 8.0 , 2.0 };
519 // For Xe/CO2-gas-mixture
520 // Xe-content of the Xe/CO2-mixture (85% / 15%)
522 // Xe-content of the Xe/Isobutane-mixture (97% / 3%)
524 Float_t dxe = .005858;
526 // General tracking parameter
527 Float_t tmaxfd = -10.;
528 Float_t stemax = -1e10;
529 Float_t deemax = -0.1;
530 Float_t epsil = 1e-4;
531 Float_t stmin = -0.001;
533 Float_t absl, radl, d, buf[1];
534 Float_t agm[2], zgm[2], wgm[2];
538 //////////////////////////////////////////////////////////////////////////
540 //////////////////////////////////////////////////////////////////////////
542 AliMaterial( 1, "Al" , 26.98, 13.0, 2.7 , 8.9 , 37.2);
543 AliMaterial( 2, "Air" , 14.61, 7.3, 0.001205, 30420.0 , 67500.0);
544 AliMaterial( 4, "Xe" , 131.29, 54.0, dxe , 1447.59, 0.0);
545 AliMaterial( 5, "Cu" , 63.54, 29.0, 8.96 , 1.43, 14.8);
546 AliMaterial( 6, "C" , 12.01, 6.0, 2.265 , 18.8 , 74.4);
547 AliMaterial(12, "G10" , 20.00, 10.0, 1.7 , 19.4 , 999.0);
548 AliMaterial(15, "Sn" , 118.71, 50.0, 7.31 , 1.21, 14.8);
549 AliMaterial(16, "Si" , 28.09, 14.0, 2.33 , 9.36, 37.2);
550 AliMaterial(17, "Epoxy", 17.75, 8.9, 1.8 , 21.82, 999.0);
553 AliMixture(3, "Polyethilene", ape, zpe, dpe, -2, wpe);
554 AliMixture(7, "Mylar", amy, zmy, dmy, -3, wmy);
555 AliMixture(8, "CO2", aco, zco, dco, -2, wco);
556 AliMixture(9, "Isobutane", ais, zis, dis, -2, wis);
557 AliMixture(13,"Water", awa, zwa, dwa, -2, wwa);
558 AliMixture(14,"Plexiglas", apg, zpg, dpg, -3, wpg);
561 Char_t namate[21]="";
563 // Get properties of Xe
564 gMC->Gfmate((*fIdmate)[4], namate, agm[0], zgm[0], d, radl, absl, buf, nbuf);
565 // Get properties of CO2
566 gMC->Gfmate((*fIdmate)[8], namate, agm[1], zgm[1], d, radl, absl, buf, nbuf);
567 // Create gas mixture
570 dgm1 = wgm[0] * dxe + wgm[1] * dco;
571 AliMixture(10, "Gas mixture 1", agm, zgm, dgm1, 2, wgm);
572 // Xe/Isobutane-mixture
573 // Get properties of Xe
574 gMC->Gfmate((*fIdmate)[4], namate, agm[0], zgm[0], d, radl, absl, buf, nbuf);
575 // Get properties of Isobutane
576 gMC->Gfmate((*fIdmate)[9], namate, agm[1], zgm[1], d, radl, absl, buf, nbuf);
577 // Create gas mixture
580 dgm2 = wgm[0] * dxe + wgm[1] * dis;
581 AliMixture(11, "Gas mixture 2", agm, zgm, dgm2, 2, wgm);
583 //////////////////////////////////////////////////////////////////////////
584 // Tracking Media Parameters
585 //////////////////////////////////////////////////////////////////////////
588 AliMedium(1, "Al Frame", 1, 0, isxfld, sxmgmx
589 , tmaxfd, stemax, deemax, epsil, stmin);
591 AliMedium(2, "Air", 2, 0, isxfld, sxmgmx
592 , tmaxfd, stemax, deemax, epsil, stmin);
594 AliMedium(3, "Radiator", 3, 0, isxfld, sxmgmx
595 , tmaxfd, stemax, deemax, epsil, stmin);
597 AliMedium(4, "Xe", 4, 1, isxfld, sxmgmx
598 , tmaxfd, stemax, deemax, epsil, stmin);
600 AliMedium(5, "Padplane", 5, 1, isxfld, sxmgmx
601 , tmaxfd, stemax, deemax, epsil, stmin);
603 AliMedium(6, "Readout", 1, 0, isxfld, sxmgmx
604 , tmaxfd, stemax, deemax, epsil, stmin);
606 AliMedium(7, "C Frame", 6, 0, isxfld, sxmgmx
607 , tmaxfd, stemax, deemax, epsil, stmin);
609 AliMedium(8, "Mylar", 7, 0, isxfld, sxmgmx
610 , tmaxfd, stemax, deemax, epsil, stmin);
612 // Gas-mixture (Xe/CO2)
613 AliMedium(9, "Gas-mix", 10, 1, isxfld, sxmgmx
614 , tmaxfd, stemax, deemax, epsil, stmin);
617 // Gas-mixture (Xe/Isobutane)
618 AliMedium(9, "Gas-mix", 11, 1, isxfld, sxmgmx
619 , tmaxfd, stemax, deemax, epsil, stmin);
621 // Nomex-honeycomb (use carbon for the time being)
622 AliMedium(10, "Nomex", 6, 0, isxfld, sxmgmx
623 , tmaxfd, stemax, deemax, epsil, stmin);
624 // Kapton foils (use Mylar for the time being)
625 AliMedium(11, "Kapton", 7, 0, isxfld, sxmgmx
626 , tmaxfd, stemax, deemax, epsil, stmin);
627 // Gas-filling of the radiator
628 AliMedium(12, "CO2", 8, 0, isxfld, sxmgmx
629 , tmaxfd, stemax, deemax, epsil, stmin);
631 AliMedium(13, "G10-plates",12, 0, isxfld, sxmgmx
632 , tmaxfd, stemax, deemax, epsil, stmin);
634 AliMedium(14, "Water", 13, 0, isxfld, sxmgmx
635 , tmaxfd, stemax, deemax, epsil, stmin);
636 // Rohacell (plexiglas) for the radiator
637 AliMedium(15, "Rohacell", 14, 0, isxfld, sxmgmx
638 , tmaxfd, stemax, deemax, epsil, stmin);
640 AliMedium(16, "MCM-Al" , 1, 0, isxfld, sxmgmx
641 , tmaxfd, stemax, deemax, epsil, stmin);
643 AliMedium(17, "MCM-Sn" , 15, 0, isxfld, sxmgmx
644 , tmaxfd, stemax, deemax, epsil, stmin);
646 AliMedium(18, "MCM-Cu" , 5, 0, isxfld, sxmgmx
647 , tmaxfd, stemax, deemax, epsil, stmin);
649 AliMedium(19, "MCM-G10" , 12, 0, isxfld, sxmgmx
650 , tmaxfd, stemax, deemax, epsil, stmin);
651 // Si in readout chips
652 AliMedium(20, "Chip-Si" , 16, 0, isxfld, sxmgmx
653 , tmaxfd, stemax, deemax, epsil, stmin);
654 // Epoxy in readout chips
655 AliMedium(21, "Chip-Ep" , 17, 0, isxfld, sxmgmx
656 , tmaxfd, stemax, deemax, epsil, stmin);
658 AliMedium(22, "Conn-PE" , 3, 0, isxfld, sxmgmx
659 , tmaxfd, stemax, deemax, epsil, stmin);
661 AliMedium(23, "Chip-Cu" , 5, 0, isxfld, sxmgmx
662 , tmaxfd, stemax, deemax, epsil, stmin);
663 // Al of cooling pipes
664 AliMedium(24, "Cooling" , 1, 0, isxfld, sxmgmx
665 , tmaxfd, stemax, deemax, epsil, stmin);
667 AliMedium(25, "Serv-Cu" , 5, 0, isxfld, sxmgmx
668 , tmaxfd, stemax, deemax, epsil, stmin);
670 // Save the density values for the TRD absorbtion
679 //_____________________________________________________________________________
680 void AliTRD::DrawModule() const
683 // Draw a shaded view of the Transition Radiation Detector version 0
686 // Set everything unseen
687 gMC->Gsatt("*" ,"SEEN",-1);
689 // Set ALIC mother transparent
690 gMC->Gsatt("ALIC","SEEN", 0);
692 // Set the volumes visible
693 if (fGeometry->IsVersion() == 0) {
694 gMC->Gsatt("B071","SEEN", 0);
695 gMC->Gsatt("B074","SEEN", 0);
696 gMC->Gsatt("B075","SEEN", 0);
697 gMC->Gsatt("B077","SEEN", 0);
698 gMC->Gsatt("BTR1","SEEN", 0);
699 gMC->Gsatt("BTR2","SEEN", 0);
700 gMC->Gsatt("BTR3","SEEN", 0);
701 gMC->Gsatt("UTR1","SEEN", 0);
702 gMC->Gsatt("UTR2","SEEN", 0);
703 gMC->Gsatt("UTR3","SEEN", 0);
706 gMC->Gsatt("B071","SEEN", 0);
707 gMC->Gsatt("B074","SEEN", 0);
708 gMC->Gsatt("B075","SEEN", 0);
709 gMC->Gsatt("B077","SEEN", 0);
710 gMC->Gsatt("BTR1","SEEN", 0);
711 gMC->Gsatt("BTR2","SEEN", 0);
712 gMC->Gsatt("BTR3","SEEN", 0);
713 gMC->Gsatt("UTR1","SEEN", 0);
714 if (fGeometry->GetPHOShole())
715 gMC->Gsatt("UTR2","SEEN", 0);
716 if (fGeometry->GetRICHhole())
717 gMC->Gsatt("UTR3","SEEN", 0);
719 // gMC->Gsatt("UCII","SEEN", 0);
720 // gMC->Gsatt("UCIM","SEEN", 0);
721 // gMC->Gsatt("UCIO","SEEN", 0);
722 // gMC->Gsatt("UL02","SEEN", 1);
723 // gMC->Gsatt("UL05","SEEN", 1);
724 // gMC->Gsatt("UL06","SEEN", 1);
726 gMC->Gdopt("hide", "on");
727 gMC->Gdopt("shad", "on");
728 gMC->Gsatt("*", "fill", 7);
729 gMC->SetClipBox(".");
730 gMC->SetClipBox("*", 0, 2000, -2000, 2000, -2000, 2000);
732 gMC->Gdraw("alic", 40, 30, 0, 12, 9.4, .021, .021);
733 gMC->Gdhead(1111, "Transition Radiation Detector");
734 gMC->Gdman(18, 4, "MAN");
738 //_____________________________________________________________________________
739 Int_t AliTRD::DistancetoPrimitive(Int_t , Int_t ) const
742 // Distance between the mouse and the TRD detector on the screen
749 //_____________________________________________________________________________
753 // Initialize the TRD detector after the geometry has been created
759 printf("\n%s: ",ClassName());
760 for (i = 0; i < 35; i++) printf("*");
761 printf(" TRD_INIT ");
762 for (i = 0; i < 35; i++) printf("*");
766 if (fGeometry->IsVersion() == 1) {
767 printf("%s: Full geometry version initialized\n",ClassName());
768 if (fGeometry->GetPHOShole())
769 printf("%s: Leave space in front of PHOS free\n",ClassName());
770 if (fGeometry->GetRICHhole())
771 printf("%s: Leave space in front of RICH free\n",ClassName());
774 printf("%s: Not a valid geometry\n",ClassName());
778 printf("%s: Gas Mixture: 85%% Xe + 15%% CO2\n",ClassName());
781 printf("%s: Gas Mixture: 97%% Xe + 3%% Isobutane\n",ClassName());
786 //_____________________________________________________________________________
787 void AliTRD::LoadPoints(Int_t )
790 // Store x, y, z of all hits in memory.
791 // Hit originating from TR photons are given a different color
795 // AliDetector::LoadPoints(track);
799 if ((fHits == 0) && (fTrackHits == 0)) return;
803 nhits = fHits->GetEntriesFast();
806 nhits = fTrackHits->GetEntriesFast();
808 if (nhits == 0) return;
810 Int_t tracks = gAlice->GetMCApp()->GetNtrack();
811 if (fPoints == 0) fPoints = new TObjArray(tracks);
815 Int_t *ntrkE = new Int_t[tracks];
816 Int_t *ntrkT = new Int_t[tracks];
817 Int_t *limiE = new Int_t[tracks];
818 Int_t *limiT = new Int_t[tracks];
819 Float_t **coorE = new Float_t*[tracks];
820 Float_t **coorT = new Float_t*[tracks];
821 for(Int_t i = 0; i < tracks; i++) {
830 AliTRDpoints *points = 0;
833 Int_t chunk = nhits / 4 + 1;
835 // Loop over all the hits and store their position
836 ahit = (AliTRDhit *) FirstHit(-1);
840 if (ahit->GetCharge() >= 0) {
842 trk = ahit->GetTrack();
843 if (ntrkE[trk] == limiE[trk]) {
844 // Initialise a new track
845 fp = new Float_t[3*(limiE[trk]+chunk)];
847 memcpy(fp,coorE[trk],sizeof(Float_t)*3*limiE[trk]);
848 delete [] coorE[trk];
856 fp[3*ntrkE[trk] ] = ahit->X();
857 fp[3*ntrkE[trk]+1] = ahit->Y();
858 fp[3*ntrkE[trk]+2] = ahit->Z();
863 else if ((ahit->GetCharge() < 0) && (fDrawTR)) {
865 trk = ahit->GetTrack();
866 if (ntrkT[trk] == limiT[trk]) {
867 // Initialise a new track
868 fp = new Float_t[3*(limiT[trk]+chunk)];
870 memcpy(fp,coorT[trk],sizeof(Float_t)*3*limiT[trk]);
871 delete [] coorT[trk];
879 fp[3*ntrkT[trk] ] = ahit->X();
880 fp[3*ntrkT[trk]+1] = ahit->Y();
881 fp[3*ntrkT[trk]+2] = ahit->Z();
886 ahit = (AliTRDhit *) NextHit();
890 for (trk = 0; trk < tracks; ++trk) {
892 if (ntrkE[trk] || ntrkT[trk]) {
894 points = new AliTRDpoints();
895 points->SetDetector(this);
896 points->SetParticle(trk);
898 // Set the dEdx points
900 points->SetMarkerColor(GetMarkerColor());
901 points->SetMarkerSize(GetMarkerSize());
902 points->SetPolyMarker(ntrkE[trk],coorE[trk],GetMarkerStyle());
903 delete [] coorE[trk];
907 // Set the TR photon points
909 points->SetTRpoints(ntrkT[trk],coorT[trk]);
910 delete [] coorT[trk];
914 fPoints->AddAt(points,trk);
929 //_____________________________________________________________________________
930 void AliTRD::MakeBranch(Option_t* option)
933 // Create Tree branches for the TRD digits.
936 Int_t buffersize = 4000;
937 Char_t branchname[15];
938 sprintf(branchname,"%s",GetName());
940 const char *cD = strstr(option,"D");
942 AliDetector::MakeBranch(option);
944 if (fDigits && gAlice->TreeD() && cD) {
945 MakeBranchInTree(gAlice->TreeD(),branchname,&fDigits,buffersize,0);
949 MakeBranch2(option,0);
954 //_____________________________________________________________________________
955 void AliTRD::ResetDigits()
958 // Reset number of digits and the digits array for this detector
962 if (fDigits) fDigits->Clear();
966 //_____________________________________________________________________________
967 void AliTRD::SetTreeAddress()
970 // Set the branch addresses for the trees.
973 if ( fLoader->TreeH() && (fHits == 0x0)) fHits = new TClonesArray("AliTRDhit",405);
974 AliDetector::SetTreeAddress();
982 //_____________________________________________________________________________
983 void AliTRD::SetGasMix(Int_t imix)
986 // Defines the gas mixture (imix=0: Xe/Isobutane imix=1: Xe/CO2)
989 if ((imix < 0) || (imix > 1)) {
990 printf("Wrong input value: %d\n",imix);
991 printf("Use standard setting\n");
1000 //_____________________________________________________________________________
1001 void AliTRD::SetPHOShole()
1004 // Selects a geometry with a hole in front of the PHOS
1007 fGeometry->SetPHOShole();
1011 //_____________________________________________________________________________
1012 void AliTRD::SetRICHhole()
1015 // Selects a geometry with a hole in front of the RICH
1018 fGeometry->SetRICHhole();
1022 //_____________________________________________________________________________
1023 AliTRD &AliTRD::operator=(const AliTRD &trd)
1026 // Assignment operator
1029 if (this != &trd) ((AliTRD &) trd).Copy(*this);
1034 //_____________________________________________________________________________
1035 void AliTRD::FinishPrimary()
1038 // Store the hits in the containers after all primaries are finished
1042 fTrackHits->FlushHitStack();
1047 //_____________________________________________________________________________
1048 void AliTRD::RemapTrackHitIDs(Int_t *map)
1051 // Remap the track IDs
1059 TClonesArray *arr = fTrackHits->GetArray();;
1060 for (Int_t i = 0; i < arr->GetEntriesFast(); i++){
1061 AliTrackHitsParamV2 *info = (AliTrackHitsParamV2 *) (arr->At(i));
1062 info->fTrackID = map[info->fTrackID];
1068 //_____________________________________________________________________________
1069 void AliTRD::ResetHits()
1075 AliDetector::ResetHits();
1077 fTrackHits->Clear();
1082 //_____________________________________________________________________________
1083 AliHit* AliTRD::FirstHit(Int_t track)
1086 // Return the first hit of a track
1090 return FirstHit2(track);
1093 return AliDetector::FirstHit(track);
1097 //_____________________________________________________________________________
1098 AliHit* AliTRD::NextHit()
1101 // Returns the next hit of a track
1108 return AliDetector::NextHit();
1112 //_____________________________________________________________________________
1113 AliHit* AliTRD::FirstHit2(Int_t track)
1116 // Initializes the hit iterator.
1117 // Returns the address of the first hit of a track.
1118 // If <track> >= 0 the track is read from disk,
1119 // while if <track> < 0 the first hit of the current
1120 // track is returned.
1124 gAlice->ResetHits();
1125 TreeH()->GetEvent(track);
1129 fTrackHits->First();
1130 return (AliHit*) fTrackHits->GetHit();
1138 //_____________________________________________________________________________
1139 AliHit* AliTRD::NextHit2()
1142 // Returns the next hit of the current track
1147 return (AliHit *) fTrackHits->GetHit();
1155 //_____________________________________________________________________________
1156 void AliTRD::MakeBranch2(Option_t *option, const char* )
1159 // Create a new branch in the current Root tree.
1160 // The branch of fHits is automatically split.
1167 char branchname[10];
1168 sprintf(branchname,"%s2",GetName());
1170 // Get the pointer to the header
1171 const char *cH = strstr(option,"H");
1174 fTrackHits = new AliTRDtrackHits();
1178 if (fTrackHits && TreeH() && cH)
1180 TreeH()->Branch(branchname,"AliTRDtrackHits",&fTrackHits,fBufferSize,99);
1181 Info("MakeBranch2","Making Branch %s for trackhits",branchname);
1185 //_____________________________________________________________________________
1186 void AliTRD::SetTreeAddress2()
1189 // Set the branch address for the trackHits tree
1191 if (GetDebug()) Info("SetTreeAddress2","");
1194 char branchname[20];
1195 sprintf(branchname,"%s2",GetName());
1197 // Branch address for hit tree
1198 TTree *treeH = TreeH();
1199 if ((treeH) && (fHitType > 0)) {
1200 branch = treeH->GetBranch(branchname);
1203 branch->SetAddress(&fTrackHits);
1205 Info("SetTreeAddress2","Success.");
1210 Info("SetTreeAddress2","Can NOT get the branch %s",branchname);
1216 //_____________________________________________________________________________
1217 void AliTRD::AddHit2(Int_t track, Int_t det, Float_t *hits, Int_t q
1221 // Add a hit to the list
1227 Int_t primary = gAlice->GetMCApp()->GetPrimary(track);
1228 gAlice->GetMCApp()->Particle(primary)->SetBit(kKeepBit);
1233 gAlice->GetMCApp()->FlagTrack(track);
1236 if ((fTrackHits) && (fHitType > 0)) {
1237 fTrackHits->AddHitTRD(det,rtrack,hits[0],hits[1],hits[2],q,inDrift);