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 "AliTrackReference.h"
59 //_____________________________________________________________________________
63 // Default constructor
84 //_____________________________________________________________________________
85 AliTRD::AliTRD(const char *name, const char *title)
86 : AliDetector(name,title)
89 // Standard constructor for the TRD
92 // Check that FRAME is there otherwise we have no place where to
94 AliModule* frame = gAlice->GetModule("FRAME");
96 Error("Ctor","TRD needs FRAME to be present\n");
100 // Define the TRD geometry
101 if ((frame->IsVersion() == 0) ||
102 (frame->IsVersion() == 1)) {
103 fGeometry = new AliTRDgeometryFull();
106 Error("Ctor","Could not find valid FRAME version\n");
111 TDirectory* saveDir = gDirectory;
112 gAlice->GetRunLoader()->CdGAFile();
113 fGeometry->Write("TRDgeometry");
116 // Allocate the hit array
117 fHits = new TClonesArray("AliTRDhit" ,405);
118 gAlice->GetMCApp()->AddHitList(fHits);
120 // Allocate the digits array
135 SetMarkerColor(kWhite);
139 //_____________________________________________________________________________
140 AliTRD::AliTRD(const AliTRD &trd):AliDetector(trd)
146 ((AliTRD &) trd).Copy(*this);
150 //_____________________________________________________________________________
168 // delete fRecPoints;
178 //_____________________________________________________________________________
179 void AliTRD::Hits2Digits()
184 AliTRDdigitizer digitizer("TRDdigitizer","TRD digitizer class");
185 digitizer.SetDebug(GetDebug());
188 digitizer.InitDetector();
190 if (!fLoader->TreeH()) fLoader->LoadHits("read");
191 fLoader->LoadDigits("recreate");
192 AliRunLoader* runLoader = fLoader->GetRunLoader();
194 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
195 digitizer.Open(runLoader->GetFileName().Data(), iEvent);
196 digitizer.MakeDigits();
197 digitizer.WriteDigits();
200 fLoader->UnloadHits();
201 fLoader->UnloadDigits();
204 //_____________________________________________________________________________
205 void AliTRD::Hits2SDigits()
208 // Create summable digits
210 AliTRDdigitizer digitizer("TRDdigitizer","TRD digitizer class");
211 // For the summable digits
212 digitizer.SetSDigits(kTRUE);
213 digitizer.SetDebug(GetDebug());
216 digitizer.InitDetector();
218 if (!fLoader->TreeH()) fLoader->LoadHits("read");
219 fLoader->LoadSDigits("recreate");
220 AliRunLoader* runLoader = fLoader->GetRunLoader();
222 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
223 digitizer.Open(runLoader->GetFileName().Data(), iEvent);
224 digitizer.MakeDigits();
225 digitizer.WriteDigits();
228 fLoader->UnloadHits();
229 fLoader->UnloadSDigits();
232 //_____________________________________________________________________________
233 AliDigitizer* AliTRD::CreateDigitizer(AliRunDigitizer* manager) const
235 return new AliTRDdigitizer(manager);
238 //_____________________________________________________________________________
239 void AliTRD::SDigits2Digits()
242 // Create final digits from summable digits
245 // Create the TRD digitizer
246 AliTRDdigitizer digitizer("TRDdigitizer","TRD digitizer class");
247 digitizer.SetDebug(GetDebug());
250 digitizer.SetEvent(gAlice->GetEvNumber());
253 digitizer.InitDetector();
255 // Read the s-digits via digits manager
256 AliTRDdigitsManager sdigitsManager;
258 sdigitsManager.SetDebug(GetDebug());
259 sdigitsManager.SetSDigits(kTRUE);
260 sdigitsManager.CreateArrays();
262 if (!fLoader->TreeS())
263 if (fLoader->LoadSDigits("read"))
265 Error("SDigits2Digits","Error while reading SDigits for event %d",gAlice->GetEvNumber());
268 if (!fLoader->TreeS()) return;
270 sdigitsManager.ReadDigits(fLoader->TreeS());
272 // Add the s-digits to the input list
273 digitizer.AddSDigitsManager(&sdigitsManager);
275 // Convert the s-digits to normal digits
276 digitizer.SDigits2Digits();
279 if (!fLoader->TreeD()) fLoader->MakeTree("D");
280 if (digitizer.MakeBranch(fLoader->TreeD())){
281 digitizer.WriteDigits();
286 //_____________________________________________________________________________
287 void AliTRD::AddHit(Int_t track, Int_t det, Float_t *hits, Int_t q
291 // Add a hit for the TRD
293 // The data structure is set according to fHitType:
294 // bit0: standard TClonesArray
295 // bit1: compressed trackHits structure
299 TClonesArray &lhits = *fHits;
300 new(lhits[fNhits++]) AliTRDhit(fIshunt,track,det,hits,q);
304 AddHit2(track,det,hits,q,inDrift);
309 //_____________________________________________________________________________
310 void AliTRD::BuildGeometry()
313 // Create the ROOT TNode geometry for the TRD
320 Float_t zmax1, zmax2;
324 const Int_t kColorTRD = 46;
326 // Find the top node alice
327 top = gAlice->GetGeometry()->GetNode("alice");
329 if (fDisplayType == 0) {
331 pgon = new TPGON("S_TRD","TRD","void",0,360,AliTRDgeometry::Nsect(),4);
332 rmin = AliTRDgeometry::Rmin();
333 rmax = AliTRDgeometry::Rmax();
334 pgon->DefineSection(0,-AliTRDgeometry::Zmax1(),rmax,rmax);
335 pgon->DefineSection(1,-AliTRDgeometry::Zmax2(),rmin,rmax);
336 pgon->DefineSection(2, AliTRDgeometry::Zmax2(),rmin,rmax);
337 pgon->DefineSection(3, AliTRDgeometry::Zmax1(),rmax,rmax);
339 node = new TNode("TRD","TRD","S_TRD",0,0,0,"");
340 node->SetLineColor(kColorTRD);
344 else if (fDisplayType == 1) {
348 Float_t slope = (AliTRDgeometry::Zmax1() - AliTRDgeometry::Zmax2())
349 / (AliTRDgeometry::Rmax() - AliTRDgeometry::Rmin());
351 rmin = AliTRDgeometry::Rmin() + AliTRDgeometry::CraHght();
352 rmax = rmin + AliTRDgeometry::CdrHght();
354 Float_t thickness = rmin - AliTRDgeometry::Rmin();
355 zmax2 = AliTRDgeometry::Zmax2() + slope * thickness;
356 zmax1 = zmax2 + slope * AliTRDgeometry::DrThick();
358 for (iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) {
360 sprintf(name,"S_TR1%d",iPlan);
361 pgon = new TPGON(name,"TRD","void",0,360,AliTRDgeometry::Nsect(),4);
362 pgon->DefineSection(0,-zmax1,rmax,rmax);
363 pgon->DefineSection(1,-zmax2,rmin,rmax);
364 pgon->DefineSection(2, zmax2,rmin,rmax);
365 pgon->DefineSection(3, zmax1,rmax,rmax);
367 node = new TNode("TRD","TRD",name,0,0,0,"");
368 node->SetLineColor(kColorTRD);
371 Float_t height = AliTRDgeometry::Cheight() + AliTRDgeometry::Cspace();
372 rmin = rmin + height;
373 rmax = rmax + height;
374 zmax1 = zmax1 + slope * height;
375 zmax2 = zmax2 + slope * height;
379 thickness += AliTRDgeometry::DrThick();
380 rmin = AliTRDgeometry::Rmin() + thickness;
381 rmax = rmin + AliTRDgeometry::AmThick();
382 zmax2 = AliTRDgeometry::Zmax2() + slope * thickness;
383 zmax1 = zmax2 + slope * AliTRDgeometry::AmThick();
385 for (iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) {
387 sprintf(name,"S_TR2%d",iPlan);
388 pgon = new TPGON(name,"TRD","void",0,360,AliTRDgeometry::Nsect(),4);
389 pgon->DefineSection(0,-zmax1,rmax,rmax);
390 pgon->DefineSection(1,-zmax2,rmin,rmax);
391 pgon->DefineSection(2, zmax2,rmin,rmax);
392 pgon->DefineSection(3, zmax1,rmax,rmax);
394 node = new TNode("TRD","TRD",name,0,0,0,"");
395 node->SetLineColor(kColorTRD);
398 Float_t height = AliTRDgeometry::Cheight() + AliTRDgeometry::Cspace();
399 rmin = rmin + height;
400 rmax = rmax + height;
401 zmax1 = zmax1 + slope * height;
402 zmax2 = zmax2 + slope * height;
410 //_____________________________________________________________________________
411 void AliTRD::Copy(TObject &trd)
417 ((AliTRD &) trd).fGasMix = fGasMix;
418 ((AliTRD &) trd).fGeometry = fGeometry;
419 ((AliTRD &) trd).fGasDensity = fGasDensity;
420 ((AliTRD &) trd).fFoilDensity = fFoilDensity;
421 ((AliTRD &) trd).fDrawTR = fDrawTR;
422 ((AliTRD &) trd).fDisplayType = fDisplayType;
423 ((AliTRD &) trd).fHitType = fHitType;
425 //AliDetector::Copy(trd);
429 //_____________________________________________________________________________
430 void AliTRD::CreateGeometry()
433 // Creates the volumes for the TRD chambers
436 // Check that FRAME is there otherwise we have no place where to put the TRD
437 AliModule* frame = gAlice->GetModule("FRAME");
439 printf(" The TRD needs the FRAME to be defined first\n");
443 fGeometry->CreateGeometry(fIdtmed->GetArray() - 1299);
447 //_____________________________________________________________________________
448 void AliTRD::CreateMaterials()
451 // Create the materials for the TRD
455 Int_t isxfld = gAlice->Field()->Integ();
456 Float_t sxmgmx = gAlice->Field()->Max();
458 // For polyethilene (CH2)
459 Float_t ape[2] = { 12., 1. };
460 Float_t zpe[2] = { 6., 1. };
461 Float_t wpe[2] = { 1., 2. };
464 // For mylar (C5H4O2)
465 Float_t amy[3] = { 12., 1., 16. };
466 Float_t zmy[3] = { 6., 1., 8. };
467 Float_t wmy[3] = { 5., 4., 2. };
471 Float_t aco[2] = { 12., 16. };
472 Float_t zco[2] = { 6., 8. };
473 Float_t wco[2] = { 1., 2. };
474 Float_t dco = 0.001977;
477 Float_t awa[2] = { 1., 16. };
478 Float_t zwa[2] = { 1., 8. };
479 Float_t wwa[2] = { 2., 1. };
482 // For isobutane (C4H10)
483 Float_t ais[2] = { 12., 1. };
484 Float_t zis[2] = { 6., 1. };
485 Float_t wis[2] = { 4., 10. };
486 Float_t dis = 0.00267;
488 // For plexiglas (C5H8O2)
489 Float_t apg[3] = { 12.011 , 1.0 , 15.9994 };
490 Float_t zpg[3] = { 6.0 , 1.0 , 8.0 };
491 Float_t wpg[3] = { 5.0 , 8.0 , 2.0 };
494 // For Xe/CO2-gas-mixture
495 // Xe-content of the Xe/CO2-mixture (85% / 15%)
497 // Xe-content of the Xe/Isobutane-mixture (97% / 3%)
499 Float_t dxe = .005858;
501 // General tracking parameter
502 Float_t tmaxfd = -10.;
503 Float_t stemax = -1e10;
504 Float_t deemax = -0.1;
505 Float_t epsil = 1e-4;
506 Float_t stmin = -0.001;
508 Float_t absl, radl, d, buf[1];
509 Float_t agm[2], zgm[2], wgm[2];
513 //////////////////////////////////////////////////////////////////////////
515 //////////////////////////////////////////////////////////////////////////
517 AliMaterial( 1, "Al" , 26.98, 13.0, 2.7 , 8.9 , 37.2);
518 AliMaterial( 2, "Air" , 14.61, 7.3, 0.001205, 30420.0 , 67500.0);
519 AliMaterial( 4, "Xe" , 131.29, 54.0, dxe , 1447.59, 0.0);
520 AliMaterial( 5, "Cu" , 63.54, 29.0, 8.96 , 1.43, 14.8);
521 AliMaterial( 6, "C" , 12.01, 6.0, 2.265 , 18.8 , 74.4);
522 AliMaterial(12, "G10" , 20.00, 10.0, 1.7 , 19.4 , 999.0);
523 AliMaterial(15, "Sn" , 118.71, 50.0, 7.31 , 1.21, 14.8);
524 AliMaterial(16, "Si" , 28.09, 14.0, 2.33 , 9.36, 37.2);
525 AliMaterial(17, "Epoxy", 17.75, 8.9, 1.8 , 21.82, 999.0);
528 AliMixture(3, "Polyethilene", ape, zpe, dpe, -2, wpe);
529 AliMixture(7, "Mylar", amy, zmy, dmy, -3, wmy);
530 AliMixture(8, "CO2", aco, zco, dco, -2, wco);
531 AliMixture(9, "Isobutane", ais, zis, dis, -2, wis);
532 AliMixture(13,"Water", awa, zwa, dwa, -2, wwa);
533 AliMixture(14,"Plexiglas", apg, zpg, dpg, -3, wpg);
536 Char_t namate[21]="";
538 // Get properties of Xe
539 gMC->Gfmate((*fIdmate)[4], namate, agm[0], zgm[0], d, radl, absl, buf, nbuf);
540 // Get properties of CO2
541 gMC->Gfmate((*fIdmate)[8], namate, agm[1], zgm[1], d, radl, absl, buf, nbuf);
542 // Create gas mixture
545 dgm1 = wgm[0] * dxe + wgm[1] * dco;
546 AliMixture(10, "Gas mixture 1", agm, zgm, dgm1, 2, wgm);
547 // Xe/Isobutane-mixture
548 // Get properties of Xe
549 gMC->Gfmate((*fIdmate)[4], namate, agm[0], zgm[0], d, radl, absl, buf, nbuf);
550 // Get properties of Isobutane
551 gMC->Gfmate((*fIdmate)[9], namate, agm[1], zgm[1], d, radl, absl, buf, nbuf);
552 // Create gas mixture
555 dgm2 = wgm[0] * dxe + wgm[1] * dis;
556 AliMixture(11, "Gas mixture 2", agm, zgm, dgm2, 2, wgm);
558 //////////////////////////////////////////////////////////////////////////
559 // Tracking Media Parameters
560 //////////////////////////////////////////////////////////////////////////
563 AliMedium(1, "Al Frame", 1, 0, isxfld, sxmgmx
564 , tmaxfd, stemax, deemax, epsil, stmin);
566 AliMedium(2, "Air", 2, 0, isxfld, sxmgmx
567 , tmaxfd, stemax, deemax, epsil, stmin);
569 AliMedium(3, "Radiator", 3, 0, isxfld, sxmgmx
570 , tmaxfd, stemax, deemax, epsil, stmin);
572 AliMedium(4, "Xe", 4, 1, isxfld, sxmgmx
573 , tmaxfd, stemax, deemax, epsil, stmin);
575 AliMedium(5, "Padplane", 5, 1, isxfld, sxmgmx
576 , tmaxfd, stemax, deemax, epsil, stmin);
578 AliMedium(6, "Readout", 1, 0, isxfld, sxmgmx
579 , tmaxfd, stemax, deemax, epsil, stmin);
581 AliMedium(7, "C Frame", 6, 0, isxfld, sxmgmx
582 , tmaxfd, stemax, deemax, epsil, stmin);
584 AliMedium(8, "Mylar", 7, 0, isxfld, sxmgmx
585 , tmaxfd, stemax, deemax, epsil, stmin);
587 // Gas-mixture (Xe/CO2)
588 AliMedium(9, "Gas-mix", 10, 1, isxfld, sxmgmx
589 , tmaxfd, stemax, deemax, epsil, stmin);
592 // Gas-mixture (Xe/Isobutane)
593 AliMedium(9, "Gas-mix", 11, 1, isxfld, sxmgmx
594 , tmaxfd, stemax, deemax, epsil, stmin);
596 // Nomex-honeycomb (use carbon for the time being)
597 AliMedium(10, "Nomex", 6, 0, isxfld, sxmgmx
598 , tmaxfd, stemax, deemax, epsil, stmin);
599 // Kapton foils (use Mylar for the time being)
600 AliMedium(11, "Kapton", 7, 0, isxfld, sxmgmx
601 , tmaxfd, stemax, deemax, epsil, stmin);
602 // Gas-filling of the radiator
603 AliMedium(12, "CO2", 8, 0, isxfld, sxmgmx
604 , tmaxfd, stemax, deemax, epsil, stmin);
606 AliMedium(13, "G10-plates",12, 0, isxfld, sxmgmx
607 , tmaxfd, stemax, deemax, epsil, stmin);
609 AliMedium(14, "Water", 13, 0, isxfld, sxmgmx
610 , tmaxfd, stemax, deemax, epsil, stmin);
611 // Rohacell (plexiglas) for the radiator
612 AliMedium(15, "Rohacell", 14, 0, isxfld, sxmgmx
613 , tmaxfd, stemax, deemax, epsil, stmin);
615 AliMedium(16, "MCM-Al" , 1, 0, isxfld, sxmgmx
616 , tmaxfd, stemax, deemax, epsil, stmin);
618 AliMedium(17, "MCM-Sn" , 15, 0, isxfld, sxmgmx
619 , tmaxfd, stemax, deemax, epsil, stmin);
621 AliMedium(18, "MCM-Cu" , 5, 0, isxfld, sxmgmx
622 , tmaxfd, stemax, deemax, epsil, stmin);
624 AliMedium(19, "MCM-G10" , 12, 0, isxfld, sxmgmx
625 , tmaxfd, stemax, deemax, epsil, stmin);
626 // Si in readout chips
627 AliMedium(20, "Chip-Si" , 16, 0, isxfld, sxmgmx
628 , tmaxfd, stemax, deemax, epsil, stmin);
629 // Epoxy in readout chips
630 AliMedium(21, "Chip-Ep" , 17, 0, isxfld, sxmgmx
631 , tmaxfd, stemax, deemax, epsil, stmin);
633 AliMedium(22, "Conn-PE" , 3, 0, isxfld, sxmgmx
634 , tmaxfd, stemax, deemax, epsil, stmin);
636 AliMedium(23, "Chip-Cu" , 5, 0, isxfld, sxmgmx
637 , tmaxfd, stemax, deemax, epsil, stmin);
638 // Al of cooling pipes
639 AliMedium(24, "Cooling" , 1, 0, isxfld, sxmgmx
640 , tmaxfd, stemax, deemax, epsil, stmin);
642 AliMedium(25, "Serv-Cu" , 5, 0, isxfld, sxmgmx
643 , tmaxfd, stemax, deemax, epsil, stmin);
645 // Save the density values for the TRD absorbtion
654 //_____________________________________________________________________________
655 void AliTRD::DrawModule() const
658 // Draw a shaded view of the Transition Radiation Detector version 0
661 // Set everything unseen
662 gMC->Gsatt("*" ,"SEEN",-1);
664 // Set ALIC mother transparent
665 gMC->Gsatt("ALIC","SEEN", 0);
667 // Set the volumes visible
668 if (fGeometry->IsVersion() == 0) {
669 gMC->Gsatt("B071","SEEN", 0);
670 gMC->Gsatt("B074","SEEN", 0);
671 gMC->Gsatt("B075","SEEN", 0);
672 gMC->Gsatt("B077","SEEN", 0);
673 gMC->Gsatt("BTR1","SEEN", 0);
674 gMC->Gsatt("BTR2","SEEN", 0);
675 gMC->Gsatt("BTR3","SEEN", 0);
676 gMC->Gsatt("UTR1","SEEN", 0);
677 gMC->Gsatt("UTR2","SEEN", 0);
678 gMC->Gsatt("UTR3","SEEN", 0);
681 gMC->Gsatt("B071","SEEN", 0);
682 gMC->Gsatt("B074","SEEN", 0);
683 gMC->Gsatt("B075","SEEN", 0);
684 gMC->Gsatt("B077","SEEN", 0);
685 gMC->Gsatt("BTR1","SEEN", 0);
686 gMC->Gsatt("BTR2","SEEN", 0);
687 gMC->Gsatt("BTR3","SEEN", 0);
688 gMC->Gsatt("UTR1","SEEN", 0);
689 if (fGeometry->GetPHOShole())
690 gMC->Gsatt("UTR2","SEEN", 0);
691 if (fGeometry->GetRICHhole())
692 gMC->Gsatt("UTR3","SEEN", 0);
694 // gMC->Gsatt("UCII","SEEN", 0);
695 // gMC->Gsatt("UCIM","SEEN", 0);
696 // gMC->Gsatt("UCIO","SEEN", 0);
697 // gMC->Gsatt("UL02","SEEN", 1);
698 // gMC->Gsatt("UL05","SEEN", 1);
699 // gMC->Gsatt("UL06","SEEN", 1);
701 gMC->Gdopt("hide", "on");
702 gMC->Gdopt("shad", "on");
703 gMC->Gsatt("*", "fill", 7);
704 gMC->SetClipBox(".");
705 gMC->SetClipBox("*", 0, 2000, -2000, 2000, -2000, 2000);
707 gMC->Gdraw("alic", 40, 30, 0, 12, 9.4, .021, .021);
708 gMC->Gdhead(1111, "Transition Radiation Detector");
709 gMC->Gdman(18, 4, "MAN");
713 //_____________________________________________________________________________
714 Int_t AliTRD::DistancetoPrimitive(Int_t , Int_t ) const
717 // Distance between the mouse and the TRD detector on the screen
724 //_____________________________________________________________________________
728 // Initialize the TRD detector after the geometry has been created
734 printf("\n%s: ",ClassName());
735 for (i = 0; i < 35; i++) printf("*");
736 printf(" TRD_INIT ");
737 for (i = 0; i < 35; i++) printf("*");
741 if (fGeometry->IsVersion() == 1) {
742 printf("%s: Full geometry version initialized\n",ClassName());
743 if (fGeometry->GetPHOShole())
744 printf("%s: Leave space in front of PHOS free\n",ClassName());
745 if (fGeometry->GetRICHhole())
746 printf("%s: Leave space in front of RICH free\n",ClassName());
749 printf("%s: Not a valid geometry\n",ClassName());
753 printf("%s: Gas Mixture: 85%% Xe + 15%% CO2\n",ClassName());
756 printf("%s: Gas Mixture: 97%% Xe + 3%% Isobutane\n",ClassName());
761 //_____________________________________________________________________________
762 void AliTRD::LoadPoints(Int_t )
765 // Store x, y, z of all hits in memory.
766 // Hit originating from TR photons are given a different color
770 // AliDetector::LoadPoints(track);
774 if ((fHits == 0) && (fTrackHits == 0)) return;
778 nhits = fHits->GetEntriesFast();
781 nhits = fTrackHits->GetEntriesFast();
783 if (nhits == 0) return;
785 Int_t tracks = gAlice->GetMCApp()->GetNtrack();
786 if (fPoints == 0) fPoints = new TObjArray(tracks);
790 Int_t *ntrkE = new Int_t[tracks];
791 Int_t *ntrkT = new Int_t[tracks];
792 Int_t *limiE = new Int_t[tracks];
793 Int_t *limiT = new Int_t[tracks];
794 Float_t **coorE = new Float_t*[tracks];
795 Float_t **coorT = new Float_t*[tracks];
796 for(Int_t i = 0; i < tracks; i++) {
805 AliTRDpoints *points = 0;
808 Int_t chunk = nhits / 4 + 1;
810 // Loop over all the hits and store their position
811 ahit = (AliTRDhit *) FirstHit(-1);
815 if (ahit->GetCharge() >= 0) {
817 trk = ahit->GetTrack();
818 if (ntrkE[trk] == limiE[trk]) {
819 // Initialise a new track
820 fp = new Float_t[3*(limiE[trk]+chunk)];
822 memcpy(fp,coorE[trk],sizeof(Float_t)*3*limiE[trk]);
823 delete [] coorE[trk];
831 fp[3*ntrkE[trk] ] = ahit->X();
832 fp[3*ntrkE[trk]+1] = ahit->Y();
833 fp[3*ntrkE[trk]+2] = ahit->Z();
838 else if ((ahit->GetCharge() < 0) && (fDrawTR)) {
840 trk = ahit->GetTrack();
841 if (ntrkT[trk] == limiT[trk]) {
842 // Initialise a new track
843 fp = new Float_t[3*(limiT[trk]+chunk)];
845 memcpy(fp,coorT[trk],sizeof(Float_t)*3*limiT[trk]);
846 delete [] coorT[trk];
854 fp[3*ntrkT[trk] ] = ahit->X();
855 fp[3*ntrkT[trk]+1] = ahit->Y();
856 fp[3*ntrkT[trk]+2] = ahit->Z();
861 ahit = (AliTRDhit *) NextHit();
865 for (trk = 0; trk < tracks; ++trk) {
867 if (ntrkE[trk] || ntrkT[trk]) {
869 points = new AliTRDpoints();
870 points->SetDetector(this);
871 points->SetParticle(trk);
873 // Set the dEdx points
875 points->SetMarkerColor(GetMarkerColor());
876 points->SetMarkerSize(GetMarkerSize());
877 points->SetPolyMarker(ntrkE[trk],coorE[trk],GetMarkerStyle());
878 delete [] coorE[trk];
882 // Set the TR photon points
884 points->SetTRpoints(ntrkT[trk],coorT[trk]);
885 delete [] coorT[trk];
889 fPoints->AddAt(points,trk);
904 //_____________________________________________________________________________
905 void AliTRD::MakeBranch(Option_t* option)
908 // Create Tree branches for the TRD digits.
911 Int_t buffersize = 4000;
912 Char_t branchname[15];
913 sprintf(branchname,"%s",GetName());
915 const char *cD = strstr(option,"D");
917 AliDetector::MakeBranch(option);
919 if (fDigits && gAlice->TreeD() && cD) {
920 MakeBranchInTree(gAlice->TreeD(),branchname,&fDigits,buffersize,0);
924 MakeBranch2(option,0);
929 //_____________________________________________________________________________
930 void AliTRD::ResetDigits()
933 // Reset number of digits and the digits array for this detector
937 if (fDigits) fDigits->Clear();
941 //_____________________________________________________________________________
942 void AliTRD::SetTreeAddress()
945 // Set the branch addresses for the trees.
948 if ( fLoader->TreeH() && (fHits == 0x0)) fHits = new TClonesArray("AliTRDhit",405);
949 AliDetector::SetTreeAddress();
957 //_____________________________________________________________________________
958 void AliTRD::SetGasMix(Int_t imix)
961 // Defines the gas mixture (imix=0: Xe/Isobutane imix=1: Xe/CO2)
964 if ((imix < 0) || (imix > 1)) {
965 printf("Wrong input value: %d\n",imix);
966 printf("Use standard setting\n");
975 //_____________________________________________________________________________
976 void AliTRD::SetPHOShole()
979 // Selects a geometry with a hole in front of the PHOS
982 fGeometry->SetPHOShole();
986 //_____________________________________________________________________________
987 void AliTRD::SetRICHhole()
990 // Selects a geometry with a hole in front of the RICH
993 fGeometry->SetRICHhole();
997 //_____________________________________________________________________________
998 AliTRD &AliTRD::operator=(const AliTRD &trd)
1001 // Assignment operator
1004 if (this != &trd) ((AliTRD &) trd).Copy(*this);
1009 //_____________________________________________________________________________
1010 void AliTRD::FinishPrimary()
1013 // Store the hits in the containers after all primaries are finished
1017 fTrackHits->FlushHitStack();
1022 //_____________________________________________________________________________
1023 void AliTRD::RemapTrackHitIDs(Int_t *map)
1026 // Remap the track IDs
1034 TClonesArray *arr = fTrackHits->GetArray();;
1035 for (Int_t i = 0; i < arr->GetEntriesFast(); i++){
1036 AliTrackHitsParamV2 *info = (AliTrackHitsParamV2 *) (arr->At(i));
1037 info->fTrackID = map[info->fTrackID];
1043 //_____________________________________________________________________________
1044 void AliTRD::ResetHits()
1050 AliDetector::ResetHits();
1052 fTrackHits->Clear();
1057 //_____________________________________________________________________________
1058 AliHit* AliTRD::FirstHit(Int_t track)
1061 // Return the first hit of a track
1065 return FirstHit2(track);
1068 return AliDetector::FirstHit(track);
1072 //_____________________________________________________________________________
1073 AliHit* AliTRD::NextHit()
1076 // Returns the next hit of a track
1083 return AliDetector::NextHit();
1087 //_____________________________________________________________________________
1088 AliHit* AliTRD::FirstHit2(Int_t track)
1091 // Initializes the hit iterator.
1092 // Returns the address of the first hit of a track.
1093 // If <track> >= 0 the track is read from disk,
1094 // while if <track> < 0 the first hit of the current
1095 // track is returned.
1099 gAlice->ResetHits();
1100 TreeH()->GetEvent(track);
1104 fTrackHits->First();
1105 return (AliHit*) fTrackHits->GetHit();
1113 //_____________________________________________________________________________
1114 AliHit* AliTRD::NextHit2()
1117 // Returns the next hit of the current track
1122 return (AliHit *) fTrackHits->GetHit();
1130 //_____________________________________________________________________________
1131 void AliTRD::MakeBranch2(Option_t *option, const char* )
1134 // Create a new branch in the current Root tree.
1135 // The branch of fHits is automatically split.
1142 char branchname[10];
1143 sprintf(branchname,"%s2",GetName());
1145 // Get the pointer to the header
1146 const char *cH = strstr(option,"H");
1149 fTrackHits = new AliTRDtrackHits();
1153 if (fTrackHits && TreeH() && cH)
1155 TreeH()->Branch(branchname,"AliTRDtrackHits",&fTrackHits,fBufferSize,99);
1156 Info("MakeBranch2","Making Branch %s for trackhits",branchname);
1160 //_____________________________________________________________________________
1161 void AliTRD::SetTreeAddress2()
1164 // Set the branch address for the trackHits tree
1166 if (GetDebug()) Info("SetTreeAddress2","");
1169 char branchname[20];
1170 sprintf(branchname,"%s2",GetName());
1172 // Branch address for hit tree
1173 TTree *treeH = TreeH();
1174 if ((treeH) && (fHitType > 0)) {
1175 branch = treeH->GetBranch(branchname);
1178 branch->SetAddress(&fTrackHits);
1180 Info("SetTreeAddress2","Success.");
1185 Info("SetTreeAddress2","Can NOT get the branch %s",branchname);
1191 //_____________________________________________________________________________
1192 void AliTRD::AddHit2(Int_t track, Int_t det, Float_t *hits, Int_t q
1196 // Add a hit to the list
1202 Int_t primary = gAlice->GetMCApp()->GetPrimary(track);
1203 gAlice->GetMCApp()->Particle(primary)->SetBit(kKeepBit);
1208 gAlice->GetMCApp()->FlagTrack(track);
1211 if ((fTrackHits) && (fHitType > 0)) {
1212 fTrackHits->AddHitTRD(det,rtrack,hits[0],hits[1],hits[2],q,inDrift);