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 "AliTRDdigit.h"
48 #include "AliTRDdigitizer.h"
49 #include "AliTRDdigitsManager.h"
50 #include "AliTRDgeometryFull.h"
51 #include "AliTRDgeometryHole.h"
52 #include "AliTRDhit.h"
53 #include "AliTRDpoints.h"
54 #include "AliTRDrecPoint.h"
55 #include "AliTRDtrackHits.h"
56 #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
106 if ((frame->IsVersion() == 0) ||
107 (frame->IsVersion() == 1)) {
108 fGeometry = new AliTRDgeometryFull();
111 Error("Ctor","Could not find valid FRAME version\n");
115 // Allocate the hit array
116 fHits = new TClonesArray("AliTRDhit" ,405);
117 gAlice->GetMCApp()->AddHitList(fHits);
119 // Allocate the digits array
122 // Allocate the rec point array
123 fRecPoints = new TObjArray(400);
138 SetMarkerColor(kWhite);
142 //_____________________________________________________________________________
143 AliTRD::AliTRD(const AliTRD &trd):AliDetector(trd)
149 ((AliTRD &) trd).Copy(*this);
153 //_____________________________________________________________________________
181 //_____________________________________________________________________________
182 void AliTRD::AddCluster(Float_t *pos, Int_t det, Float_t amp
183 , Int_t *tracks, Float_t *sig, Int_t iType)
186 // Add a cluster for the TRD
189 AliTRDcluster *c = new AliTRDcluster();
192 c->AddTrackIndex(tracks);
196 c->SetSigmaY2(sig[0]);
197 c->SetSigmaZ2(sig[1]);
198 c->SetLocalTimeBin(((Int_t) pos[2]));
222 //_____________________________________________________________________________
223 void AliTRD::Hits2Digits()
228 AliTRDdigitizer digitizer("TRDdigitizer","TRD digitizer class");
229 digitizer.SetDebug(GetDebug());
232 digitizer.InitDetector();
234 if (!fLoader->TreeH()) fLoader->LoadHits("read");
235 fLoader->LoadDigits("recreate");
236 AliRunLoader* runLoader = fLoader->GetRunLoader();
238 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
239 digitizer.Open(runLoader->GetFileName().Data(), iEvent);
240 digitizer.MakeDigits();
241 digitizer.WriteDigits();
244 fLoader->UnloadHits();
245 fLoader->UnloadDigits();
248 //_____________________________________________________________________________
249 void AliTRD::Hits2SDigits()
252 // Create summable digits
254 AliTRDdigitizer digitizer("TRDdigitizer","TRD digitizer class");
255 // For the summable digits
256 digitizer.SetSDigits(kTRUE);
257 digitizer.SetDebug(GetDebug());
260 digitizer.InitDetector();
262 if (!fLoader->TreeH()) fLoader->LoadHits("read");
263 fLoader->LoadSDigits("recreate");
264 AliRunLoader* runLoader = fLoader->GetRunLoader();
266 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
267 digitizer.Open(runLoader->GetFileName().Data(), iEvent);
268 digitizer.MakeDigits();
269 digitizer.WriteDigits();
272 fLoader->UnloadHits();
273 fLoader->UnloadSDigits();
276 //_____________________________________________________________________________
277 AliDigitizer* AliTRD::CreateDigitizer(AliRunDigitizer* manager) const
279 return new AliTRDdigitizer(manager);
282 //_____________________________________________________________________________
283 void AliTRD::SDigits2Digits()
286 // Create final digits from summable digits
289 // Create the TRD digitizer
290 AliTRDdigitizer digitizer("TRDdigitizer","TRD digitizer class");
291 digitizer.SetDebug(GetDebug());
294 digitizer.SetEvent(gAlice->GetEvNumber());
297 digitizer.InitDetector();
299 // Read the s-digits via digits manager
300 AliTRDdigitsManager sdigitsManager;
302 sdigitsManager.SetDebug(GetDebug());
303 sdigitsManager.SetSDigits(kTRUE);
304 sdigitsManager.CreateArrays();
306 if (!fLoader->TreeS())
307 if (fLoader->LoadSDigits("read"))
309 Error("SDigits2Digits","Error while reading SDigits for event %d",gAlice->GetEvNumber());
312 if (!fLoader->TreeS()) return;
314 sdigitsManager.ReadDigits(fLoader->TreeS());
316 // Add the s-digits to the input list
317 digitizer.AddSDigitsManager(&sdigitsManager);
319 // Convert the s-digits to normal digits
320 digitizer.SDigits2Digits();
323 if (!fLoader->TreeD()) fLoader->MakeTree("D");
324 if (digitizer.MakeBranch(fLoader->TreeD())){
325 digitizer.WriteDigits();
330 //_____________________________________________________________________________
331 void AliTRD::AddHit(Int_t track, Int_t det, Float_t *hits, Int_t q
335 // Add a hit for the TRD
337 // The data structure is set according to fHitType:
338 // bit0: standard TClonesArray
339 // bit1: compressed trackHits structure
343 TClonesArray &lhits = *fHits;
344 new(lhits[fNhits++]) AliTRDhit(fIshunt,track,det,hits,q);
348 AddHit2(track,det,hits,q,inDrift);
353 //_____________________________________________________________________________
354 void AliTRD::BuildGeometry()
357 // Create the ROOT TNode geometry for the TRD
364 Float_t zmax1, zmax2;
368 const Int_t kColorTRD = 46;
370 // Find the top node alice
371 top = gAlice->GetGeometry()->GetNode("alice");
373 if (fDisplayType == 0) {
375 pgon = new TPGON("S_TRD","TRD","void",0,360,AliTRDgeometry::Nsect(),4);
376 rmin = AliTRDgeometry::Rmin();
377 rmax = AliTRDgeometry::Rmax();
378 pgon->DefineSection(0,-AliTRDgeometry::Zmax1(),rmax,rmax);
379 pgon->DefineSection(1,-AliTRDgeometry::Zmax2(),rmin,rmax);
380 pgon->DefineSection(2, AliTRDgeometry::Zmax2(),rmin,rmax);
381 pgon->DefineSection(3, AliTRDgeometry::Zmax1(),rmax,rmax);
383 node = new TNode("TRD","TRD","S_TRD",0,0,0,"");
384 node->SetLineColor(kColorTRD);
388 else if (fDisplayType == 1) {
392 Float_t slope = (AliTRDgeometry::Zmax1() - AliTRDgeometry::Zmax2())
393 / (AliTRDgeometry::Rmax() - AliTRDgeometry::Rmin());
395 rmin = AliTRDgeometry::Rmin() + AliTRDgeometry::CraHght();
396 rmax = rmin + AliTRDgeometry::CdrHght();
398 Float_t thickness = rmin - AliTRDgeometry::Rmin();
399 zmax2 = AliTRDgeometry::Zmax2() + slope * thickness;
400 zmax1 = zmax2 + slope * AliTRDgeometry::DrThick();
402 for (iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) {
404 sprintf(name,"S_TR1%d",iPlan);
405 pgon = new TPGON(name,"TRD","void",0,360,AliTRDgeometry::Nsect(),4);
406 pgon->DefineSection(0,-zmax1,rmax,rmax);
407 pgon->DefineSection(1,-zmax2,rmin,rmax);
408 pgon->DefineSection(2, zmax2,rmin,rmax);
409 pgon->DefineSection(3, zmax1,rmax,rmax);
411 node = new TNode("TRD","TRD",name,0,0,0,"");
412 node->SetLineColor(kColorTRD);
415 Float_t height = AliTRDgeometry::Cheight() + AliTRDgeometry::Cspace();
416 rmin = rmin + height;
417 rmax = rmax + height;
418 zmax1 = zmax1 + slope * height;
419 zmax2 = zmax2 + slope * height;
423 thickness += AliTRDgeometry::DrThick();
424 rmin = AliTRDgeometry::Rmin() + thickness;
425 rmax = rmin + AliTRDgeometry::AmThick();
426 zmax2 = AliTRDgeometry::Zmax2() + slope * thickness;
427 zmax1 = zmax2 + slope * AliTRDgeometry::AmThick();
429 for (iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) {
431 sprintf(name,"S_TR2%d",iPlan);
432 pgon = new TPGON(name,"TRD","void",0,360,AliTRDgeometry::Nsect(),4);
433 pgon->DefineSection(0,-zmax1,rmax,rmax);
434 pgon->DefineSection(1,-zmax2,rmin,rmax);
435 pgon->DefineSection(2, zmax2,rmin,rmax);
436 pgon->DefineSection(3, zmax1,rmax,rmax);
438 node = new TNode("TRD","TRD",name,0,0,0,"");
439 node->SetLineColor(kColorTRD);
442 Float_t height = AliTRDgeometry::Cheight() + AliTRDgeometry::Cspace();
443 rmin = rmin + height;
444 rmax = rmax + height;
445 zmax1 = zmax1 + slope * height;
446 zmax2 = zmax2 + slope * height;
454 //_____________________________________________________________________________
455 void AliTRD::Copy(TObject &trd)
461 ((AliTRD &) trd).fGasMix = fGasMix;
462 ((AliTRD &) trd).fGeometry = fGeometry;
463 ((AliTRD &) trd).fRecPoints = fRecPoints;
464 ((AliTRD &) trd).fNRecPoints = fNRecPoints;
465 ((AliTRD &) trd).fGasDensity = fGasDensity;
466 ((AliTRD &) trd).fFoilDensity = fFoilDensity;
467 ((AliTRD &) trd).fDrawTR = fDrawTR;
468 ((AliTRD &) trd).fDisplayType = fDisplayType;
469 ((AliTRD &) trd).fHitType = fHitType;
471 //AliDetector::Copy(trd);
475 //_____________________________________________________________________________
476 void AliTRD::CreateGeometry()
479 // Creates the volumes for the TRD chambers
482 // Check that FRAME is there otherwise we have no place where to put the TRD
483 AliModule* frame = gAlice->GetModule("FRAME");
485 printf(" The TRD needs the FRAME to be defined first\n");
489 fGeometry->CreateGeometry(fIdtmed->GetArray() - 1299);
493 //_____________________________________________________________________________
494 void AliTRD::CreateMaterials()
497 // Create the materials for the TRD
501 Int_t isxfld = gAlice->Field()->Integ();
502 Float_t sxmgmx = gAlice->Field()->Max();
504 // For polyethilene (CH2)
505 Float_t ape[2] = { 12., 1. };
506 Float_t zpe[2] = { 6., 1. };
507 Float_t wpe[2] = { 1., 2. };
510 // For mylar (C5H4O2)
511 Float_t amy[3] = { 12., 1., 16. };
512 Float_t zmy[3] = { 6., 1., 8. };
513 Float_t wmy[3] = { 5., 4., 2. };
517 Float_t aco[2] = { 12., 16. };
518 Float_t zco[2] = { 6., 8. };
519 Float_t wco[2] = { 1., 2. };
520 Float_t dco = 0.001977;
523 Float_t awa[2] = { 1., 16. };
524 Float_t zwa[2] = { 1., 8. };
525 Float_t wwa[2] = { 2., 1. };
528 // For isobutane (C4H10)
529 Float_t ais[2] = { 12., 1. };
530 Float_t zis[2] = { 6., 1. };
531 Float_t wis[2] = { 4., 10. };
532 Float_t dis = 0.00267;
534 // For plexiglas (C5H8O2)
535 Float_t apg[3] = { 12.011 , 1.0 , 15.9994 };
536 Float_t zpg[3] = { 6.0 , 1.0 , 8.0 };
537 Float_t wpg[3] = { 5.0 , 8.0 , 2.0 };
540 // For Xe/CO2-gas-mixture
541 // Xe-content of the Xe/CO2-mixture (85% / 15%)
543 // Xe-content of the Xe/Isobutane-mixture (97% / 3%)
545 Float_t dxe = .005858;
547 // General tracking parameter
548 Float_t tmaxfd = -10.;
549 Float_t stemax = -1e10;
550 Float_t deemax = -0.1;
551 Float_t epsil = 1e-4;
552 Float_t stmin = -0.001;
554 Float_t absl, radl, d, buf[1];
555 Float_t agm[2], zgm[2], wgm[2];
559 //////////////////////////////////////////////////////////////////////////
561 //////////////////////////////////////////////////////////////////////////
563 AliMaterial( 1, "Al" , 26.98, 13.0, 2.7 , 8.9 , 37.2);
564 AliMaterial( 2, "Air" , 14.61, 7.3, 0.001205, 30420.0 , 67500.0);
565 AliMaterial( 4, "Xe" , 131.29, 54.0, dxe , 1447.59, 0.0);
566 AliMaterial( 5, "Cu" , 63.54, 29.0, 8.96 , 1.43, 14.8);
567 AliMaterial( 6, "C" , 12.01, 6.0, 2.265 , 18.8 , 74.4);
568 AliMaterial(12, "G10" , 20.00, 10.0, 1.7 , 19.4 , 999.0);
569 AliMaterial(15, "Sn" , 118.71, 50.0, 7.31 , 1.21, 14.8);
570 AliMaterial(16, "Si" , 28.09, 14.0, 2.33 , 9.36, 37.2);
571 AliMaterial(17, "Epoxy", 17.75, 8.9, 1.8 , 21.82, 999.0);
574 AliMixture(3, "Polyethilene", ape, zpe, dpe, -2, wpe);
575 AliMixture(7, "Mylar", amy, zmy, dmy, -3, wmy);
576 AliMixture(8, "CO2", aco, zco, dco, -2, wco);
577 AliMixture(9, "Isobutane", ais, zis, dis, -2, wis);
578 AliMixture(13,"Water", awa, zwa, dwa, -2, wwa);
579 AliMixture(14,"Plexiglas", apg, zpg, dpg, -3, wpg);
582 Char_t namate[21]="";
584 // Get properties of Xe
585 gMC->Gfmate((*fIdmate)[4], namate, agm[0], zgm[0], d, radl, absl, buf, nbuf);
586 // Get properties of CO2
587 gMC->Gfmate((*fIdmate)[8], namate, agm[1], zgm[1], d, radl, absl, buf, nbuf);
588 // Create gas mixture
591 dgm1 = wgm[0] * dxe + wgm[1] * dco;
592 AliMixture(10, "Gas mixture 1", agm, zgm, dgm1, 2, wgm);
593 // Xe/Isobutane-mixture
594 // Get properties of Xe
595 gMC->Gfmate((*fIdmate)[4], namate, agm[0], zgm[0], d, radl, absl, buf, nbuf);
596 // Get properties of Isobutane
597 gMC->Gfmate((*fIdmate)[9], namate, agm[1], zgm[1], d, radl, absl, buf, nbuf);
598 // Create gas mixture
601 dgm2 = wgm[0] * dxe + wgm[1] * dis;
602 AliMixture(11, "Gas mixture 2", agm, zgm, dgm2, 2, wgm);
604 //////////////////////////////////////////////////////////////////////////
605 // Tracking Media Parameters
606 //////////////////////////////////////////////////////////////////////////
609 AliMedium(1, "Al Frame", 1, 0, isxfld, sxmgmx
610 , tmaxfd, stemax, deemax, epsil, stmin);
612 AliMedium(2, "Air", 2, 0, isxfld, sxmgmx
613 , tmaxfd, stemax, deemax, epsil, stmin);
615 AliMedium(3, "Radiator", 3, 0, isxfld, sxmgmx
616 , tmaxfd, stemax, deemax, epsil, stmin);
618 AliMedium(4, "Xe", 4, 1, isxfld, sxmgmx
619 , tmaxfd, stemax, deemax, epsil, stmin);
621 AliMedium(5, "Padplane", 5, 1, isxfld, sxmgmx
622 , tmaxfd, stemax, deemax, epsil, stmin);
624 AliMedium(6, "Readout", 1, 0, isxfld, sxmgmx
625 , tmaxfd, stemax, deemax, epsil, stmin);
627 AliMedium(7, "C Frame", 6, 0, isxfld, sxmgmx
628 , tmaxfd, stemax, deemax, epsil, stmin);
630 AliMedium(8, "Mylar", 7, 0, isxfld, sxmgmx
631 , tmaxfd, stemax, deemax, epsil, stmin);
633 // Gas-mixture (Xe/CO2)
634 AliMedium(9, "Gas-mix", 10, 1, isxfld, sxmgmx
635 , tmaxfd, stemax, deemax, epsil, stmin);
638 // Gas-mixture (Xe/Isobutane)
639 AliMedium(9, "Gas-mix", 11, 1, isxfld, sxmgmx
640 , tmaxfd, stemax, deemax, epsil, stmin);
642 // Nomex-honeycomb (use carbon for the time being)
643 AliMedium(10, "Nomex", 6, 0, isxfld, sxmgmx
644 , tmaxfd, stemax, deemax, epsil, stmin);
645 // Kapton foils (use Mylar for the time being)
646 AliMedium(11, "Kapton", 7, 0, isxfld, sxmgmx
647 , tmaxfd, stemax, deemax, epsil, stmin);
648 // Gas-filling of the radiator
649 AliMedium(12, "CO2", 8, 0, isxfld, sxmgmx
650 , tmaxfd, stemax, deemax, epsil, stmin);
652 AliMedium(13, "G10-plates",12, 0, isxfld, sxmgmx
653 , tmaxfd, stemax, deemax, epsil, stmin);
655 AliMedium(14, "Water", 13, 0, isxfld, sxmgmx
656 , tmaxfd, stemax, deemax, epsil, stmin);
657 // Rohacell (plexiglas) for the radiator
658 AliMedium(15, "Rohacell", 14, 0, isxfld, sxmgmx
659 , tmaxfd, stemax, deemax, epsil, stmin);
661 AliMedium(16, "MCM-Al" , 1, 0, isxfld, sxmgmx
662 , tmaxfd, stemax, deemax, epsil, stmin);
664 AliMedium(17, "MCM-Sn" , 15, 0, isxfld, sxmgmx
665 , tmaxfd, stemax, deemax, epsil, stmin);
667 AliMedium(18, "MCM-Cu" , 5, 0, isxfld, sxmgmx
668 , tmaxfd, stemax, deemax, epsil, stmin);
670 AliMedium(19, "MCM-G10" , 12, 0, isxfld, sxmgmx
671 , tmaxfd, stemax, deemax, epsil, stmin);
672 // Si in readout chips
673 AliMedium(20, "Chip-Si" , 16, 0, isxfld, sxmgmx
674 , tmaxfd, stemax, deemax, epsil, stmin);
675 // Epoxy in readout chips
676 AliMedium(21, "Chip-Ep" , 17, 0, isxfld, sxmgmx
677 , tmaxfd, stemax, deemax, epsil, stmin);
679 AliMedium(22, "Conn-PE" , 3, 0, isxfld, sxmgmx
680 , tmaxfd, stemax, deemax, epsil, stmin);
682 AliMedium(23, "Chip-Cu" , 5, 0, isxfld, sxmgmx
683 , tmaxfd, stemax, deemax, epsil, stmin);
684 // Al of cooling pipes
685 AliMedium(24, "Cooling" , 1, 0, isxfld, sxmgmx
686 , tmaxfd, stemax, deemax, epsil, stmin);
688 AliMedium(25, "Serv-Cu" , 5, 0, isxfld, sxmgmx
689 , tmaxfd, stemax, deemax, epsil, stmin);
691 // Save the density values for the TRD absorbtion
700 //_____________________________________________________________________________
701 void AliTRD::DrawModule() const
704 // Draw a shaded view of the Transition Radiation Detector version 0
707 // Set everything unseen
708 gMC->Gsatt("*" ,"SEEN",-1);
710 // Set ALIC mother transparent
711 gMC->Gsatt("ALIC","SEEN", 0);
713 // Set the volumes visible
714 if (fGeometry->IsVersion() == 0) {
715 gMC->Gsatt("B071","SEEN", 0);
716 gMC->Gsatt("B074","SEEN", 0);
717 gMC->Gsatt("B075","SEEN", 0);
718 gMC->Gsatt("B077","SEEN", 0);
719 gMC->Gsatt("BTR1","SEEN", 0);
720 gMC->Gsatt("BTR2","SEEN", 0);
721 gMC->Gsatt("BTR3","SEEN", 0);
722 gMC->Gsatt("UTR1","SEEN", 0);
723 gMC->Gsatt("UTR2","SEEN", 0);
724 gMC->Gsatt("UTR3","SEEN", 0);
727 gMC->Gsatt("B071","SEEN", 0);
728 gMC->Gsatt("B074","SEEN", 0);
729 gMC->Gsatt("B075","SEEN", 0);
730 gMC->Gsatt("B077","SEEN", 0);
731 gMC->Gsatt("BTR1","SEEN", 0);
732 gMC->Gsatt("BTR2","SEEN", 0);
733 gMC->Gsatt("BTR3","SEEN", 0);
734 gMC->Gsatt("UTR1","SEEN", 0);
735 if (fGeometry->GetPHOShole())
736 gMC->Gsatt("UTR2","SEEN", 0);
737 if (fGeometry->GetRICHhole())
738 gMC->Gsatt("UTR3","SEEN", 0);
740 // gMC->Gsatt("UCII","SEEN", 0);
741 // gMC->Gsatt("UCIM","SEEN", 0);
742 // gMC->Gsatt("UCIO","SEEN", 0);
743 // gMC->Gsatt("UL02","SEEN", 1);
744 // gMC->Gsatt("UL05","SEEN", 1);
745 // gMC->Gsatt("UL06","SEEN", 1);
747 gMC->Gdopt("hide", "on");
748 gMC->Gdopt("shad", "on");
749 gMC->Gsatt("*", "fill", 7);
750 gMC->SetClipBox(".");
751 gMC->SetClipBox("*", 0, 2000, -2000, 2000, -2000, 2000);
753 gMC->Gdraw("alic", 40, 30, 0, 12, 9.4, .021, .021);
754 gMC->Gdhead(1111, "Transition Radiation Detector");
755 gMC->Gdman(18, 4, "MAN");
759 //_____________________________________________________________________________
760 Int_t AliTRD::DistancetoPrimitive(Int_t , Int_t ) const
763 // Distance between the mouse and the TRD detector on the screen
770 //_____________________________________________________________________________
774 // Initialize the TRD detector after the geometry has been created
780 printf("\n%s: ",ClassName());
781 for (i = 0; i < 35; i++) printf("*");
782 printf(" TRD_INIT ");
783 for (i = 0; i < 35; i++) printf("*");
787 if (fGeometry->IsVersion() == 1) {
788 printf("%s: Full geometry version initialized\n",ClassName());
789 if (fGeometry->GetPHOShole())
790 printf("%s: Leave space in front of PHOS free\n",ClassName());
791 if (fGeometry->GetRICHhole())
792 printf("%s: Leave space in front of RICH free\n",ClassName());
795 printf("%s: Not a valid geometry\n",ClassName());
799 printf("%s: Gas Mixture: 85%% Xe + 15%% CO2\n",ClassName());
802 printf("%s: Gas Mixture: 97%% Xe + 3%% Isobutane\n",ClassName());
807 //_____________________________________________________________________________
808 void AliTRD::LoadPoints(Int_t )
811 // Store x, y, z of all hits in memory.
812 // Hit originating from TR photons are given a different color
816 // AliDetector::LoadPoints(track);
820 if ((fHits == 0) && (fTrackHits == 0)) return;
824 nhits = fHits->GetEntriesFast();
827 nhits = fTrackHits->GetEntriesFast();
829 if (nhits == 0) return;
831 Int_t tracks = gAlice->GetMCApp()->GetNtrack();
832 if (fPoints == 0) fPoints = new TObjArray(tracks);
836 Int_t *ntrkE = new Int_t[tracks];
837 Int_t *ntrkT = new Int_t[tracks];
838 Int_t *limiE = new Int_t[tracks];
839 Int_t *limiT = new Int_t[tracks];
840 Float_t **coorE = new Float_t*[tracks];
841 Float_t **coorT = new Float_t*[tracks];
842 for(Int_t i = 0; i < tracks; i++) {
851 AliTRDpoints *points = 0;
854 Int_t chunk = nhits / 4 + 1;
856 // Loop over all the hits and store their position
857 ahit = (AliTRDhit *) FirstHit(-1);
861 if (ahit->GetCharge() >= 0) {
863 trk = ahit->GetTrack();
864 if (ntrkE[trk] == limiE[trk]) {
865 // Initialise a new track
866 fp = new Float_t[3*(limiE[trk]+chunk)];
868 memcpy(fp,coorE[trk],sizeof(Float_t)*3*limiE[trk]);
869 delete [] coorE[trk];
877 fp[3*ntrkE[trk] ] = ahit->X();
878 fp[3*ntrkE[trk]+1] = ahit->Y();
879 fp[3*ntrkE[trk]+2] = ahit->Z();
884 else if ((ahit->GetCharge() < 0) && (fDrawTR)) {
886 trk = ahit->GetTrack();
887 if (ntrkT[trk] == limiT[trk]) {
888 // Initialise a new track
889 fp = new Float_t[3*(limiT[trk]+chunk)];
891 memcpy(fp,coorT[trk],sizeof(Float_t)*3*limiT[trk]);
892 delete [] coorT[trk];
900 fp[3*ntrkT[trk] ] = ahit->X();
901 fp[3*ntrkT[trk]+1] = ahit->Y();
902 fp[3*ntrkT[trk]+2] = ahit->Z();
907 ahit = (AliTRDhit *) NextHit();
911 for (trk = 0; trk < tracks; ++trk) {
913 if (ntrkE[trk] || ntrkT[trk]) {
915 points = new AliTRDpoints();
916 points->SetDetector(this);
917 points->SetParticle(trk);
919 // Set the dEdx points
921 points->SetMarkerColor(GetMarkerColor());
922 points->SetMarkerSize(GetMarkerSize());
923 points->SetPolyMarker(ntrkE[trk],coorE[trk],GetMarkerStyle());
924 delete [] coorE[trk];
928 // Set the TR photon points
930 points->SetTRpoints(ntrkT[trk],coorT[trk]);
931 delete [] coorT[trk];
935 fPoints->AddAt(points,trk);
950 //_____________________________________________________________________________
951 void AliTRD::MakeBranch(Option_t* option)
954 // Create Tree branches for the TRD digits.
957 Int_t buffersize = 4000;
958 Char_t branchname[15];
959 sprintf(branchname,"%s",GetName());
961 const char *cD = strstr(option,"D");
963 AliDetector::MakeBranch(option);
965 if (fDigits && gAlice->TreeD() && cD) {
966 MakeBranchInTree(gAlice->TreeD(),branchname,&fDigits,buffersize,0);
970 MakeBranch2(option,0);
975 //_____________________________________________________________________________
976 void AliTRD::ResetDigits()
979 // Reset number of digits and the digits array for this detector
983 if (fDigits) fDigits->Clear();
987 //_____________________________________________________________________________
988 void AliTRD::ResetRecPoints()
991 // Reset number of reconstructed points and the point array
996 Int_t nentr = fRecPoints->GetEntriesFast();
997 for (Int_t i = 0; i < nentr; i++) delete fRecPoints->RemoveAt(i);
1002 //_____________________________________________________________________________
1003 void AliTRD::SetTreeAddress()
1006 // Set the branch addresses for the trees.
1009 Char_t branchname[15];
1011 if ( fLoader->TreeH() && (fHits == 0x0)) fHits = new TClonesArray("AliTRDhit",405);
1012 AliDetector::SetTreeAddress();
1015 TTree *treeR = fLoader->TreeR();
1018 sprintf(branchname,"%scluster",GetName());
1019 if (fRecPoints == 0x0) fRecPoints = new TObjArray(400);
1021 branch = treeR->GetBranch(branchname);
1023 branch->SetAddress(&fRecPoints);
1034 //_____________________________________________________________________________
1035 void AliTRD::SetGasMix(Int_t imix)
1038 // Defines the gas mixture (imix=0: Xe/Isobutane imix=1: Xe/CO2)
1041 if ((imix < 0) || (imix > 1)) {
1042 printf("Wrong input value: %d\n",imix);
1043 printf("Use standard setting\n");
1052 //_____________________________________________________________________________
1053 void AliTRD::SetPHOShole()
1056 // Selects a geometry with a hole in front of the PHOS
1059 fGeometry->SetPHOShole();
1063 //_____________________________________________________________________________
1064 void AliTRD::SetRICHhole()
1067 // Selects a geometry with a hole in front of the RICH
1070 fGeometry->SetRICHhole();
1074 //_____________________________________________________________________________
1075 AliTRD &AliTRD::operator=(const AliTRD &trd)
1078 // Assignment operator
1081 if (this != &trd) ((AliTRD &) trd).Copy(*this);
1086 //_____________________________________________________________________________
1087 void AliTRD::FinishPrimary()
1090 // Store the hits in the containers after all primaries are finished
1094 fTrackHits->FlushHitStack();
1099 //_____________________________________________________________________________
1100 void AliTRD::RemapTrackHitIDs(Int_t *map)
1103 // Remap the track IDs
1111 TClonesArray *arr = fTrackHits->GetArray();;
1112 for (Int_t i = 0; i < arr->GetEntriesFast(); i++){
1113 AliTrackHitsParamV2 *info = (AliTrackHitsParamV2 *) (arr->At(i));
1114 info->fTrackID = map[info->fTrackID];
1120 //_____________________________________________________________________________
1121 void AliTRD::ResetHits()
1127 AliDetector::ResetHits();
1129 fTrackHits->Clear();
1134 //_____________________________________________________________________________
1135 AliHit* AliTRD::FirstHit(Int_t track)
1138 // Return the first hit of a track
1142 return FirstHit2(track);
1145 return AliDetector::FirstHit(track);
1149 //_____________________________________________________________________________
1150 AliHit* AliTRD::NextHit()
1153 // Returns the next hit of a track
1160 return AliDetector::NextHit();
1164 //_____________________________________________________________________________
1165 AliHit* AliTRD::FirstHit2(Int_t track)
1168 // Initializes the hit iterator.
1169 // Returns the address of the first hit of a track.
1170 // If <track> >= 0 the track is read from disk,
1171 // while if <track> < 0 the first hit of the current
1172 // track is returned.
1176 gAlice->ResetHits();
1177 TreeH()->GetEvent(track);
1181 fTrackHits->First();
1182 return (AliHit*) fTrackHits->GetHit();
1190 //_____________________________________________________________________________
1191 AliHit* AliTRD::NextHit2()
1194 // Returns the next hit of the current track
1199 return (AliHit *) fTrackHits->GetHit();
1207 //_____________________________________________________________________________
1208 void AliTRD::MakeBranch2(Option_t *option, const char* )
1211 // Create a new branch in the current Root tree.
1212 // The branch of fHits is automatically split.
1219 char branchname[10];
1220 sprintf(branchname,"%s2",GetName());
1222 // Get the pointer to the header
1223 const char *cH = strstr(option,"H");
1226 fTrackHits = new AliTRDtrackHits();
1230 if (fTrackHits && TreeH() && cH)
1232 TreeH()->Branch(branchname,"AliTRDtrackHits",&fTrackHits,fBufferSize,99);
1233 Info("MakeBranch2","Making Branch %s for trackhits",branchname);
1237 //_____________________________________________________________________________
1238 void AliTRD::SetTreeAddress2()
1241 // Set the branch address for the trackHits tree
1243 if (GetDebug()) Info("SetTreeAddress2","");
1246 char branchname[20];
1247 sprintf(branchname,"%s2",GetName());
1249 // Branch address for hit tree
1250 TTree *treeH = TreeH();
1251 if ((treeH) && (fHitType > 0)) {
1252 branch = treeH->GetBranch(branchname);
1255 branch->SetAddress(&fTrackHits);
1257 Info("SetTreeAddress2","Success.");
1262 Info("SetTreeAddress2","Can NOT get the branch %s",branchname);
1268 //_____________________________________________________________________________
1269 void AliTRD::AddHit2(Int_t track, Int_t det, Float_t *hits, Int_t q
1273 // Add a hit to the list
1279 Int_t primary = gAlice->GetMCApp()->GetPrimary(track);
1280 gAlice->GetMCApp()->Particle(primary)->SetBit(kKeepBit);
1285 gAlice->GetMCApp()->FlagTrack(track);
1288 if ((fTrackHits) && (fHitType > 0)) {
1289 fTrackHits->AddHitTRD(det,rtrack,hits[0],hits[1],hits[2],q,inDrift);