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"
59 #include "AliTRDclusterizerV1.h"
60 #include "AliTRDparameter.h"
61 #include "AliTRDtracker.h"
65 //_____________________________________________________________________________
69 // Default constructor
93 //_____________________________________________________________________________
94 AliTRD::AliTRD(const char *name, const char *title)
95 : AliDetector(name,title)
98 // Standard constructor for the TRD
101 // Check that FRAME is there otherwise we have no place where to
103 AliModule* frame = gAlice->GetModule("FRAME");
105 Error("Ctor","TRD needs FRAME to be present\n");
109 // Define the TRD geometry according to the FRAME geometry
110 if (frame->IsVersion() == 0) {
111 // Geometry with hole
112 fGeometry = new AliTRDgeometryHole();
114 else if (frame->IsVersion() == 1) {
115 // Geometry without hole
116 fGeometry = new AliTRDgeometryFull();
119 Error("Ctor","Could not find valid FRAME version\n");
123 // Allocate the hit array
124 fHits = new TClonesArray("AliTRDhit" ,405);
125 gAlice->GetMCApp()->AddHitList(fHits);
127 // Allocate the digits array
130 // Allocate the rec point array
131 fRecPoints = new TObjArray(400);
146 SetMarkerColor(kWhite);
150 //_____________________________________________________________________________
151 AliTRD::AliTRD(const AliTRD &trd):AliDetector(trd)
157 ((AliTRD &) trd).Copy(*this);
161 //_____________________________________________________________________________
189 //_____________________________________________________________________________
190 void AliTRD::AddCluster(Float_t *pos, Int_t det, Float_t amp
191 , Int_t *tracks, Float_t *sig, Int_t iType)
194 // Add a cluster for the TRD
197 AliTRDcluster *c = new AliTRDcluster();
200 c->AddTrackIndex(tracks);
204 c->SetSigmaY2(sig[0]);
205 c->SetSigmaZ2(sig[1]);
206 c->SetLocalTimeBin(((Int_t) pos[2]));
230 //_____________________________________________________________________________
231 void AliTRD::Hits2Digits()
236 AliTRDdigitizer *digitizer = new AliTRDdigitizer("TRDdigitizer"
237 ,"TRD digitizer class");
238 digitizer->SetDebug(GetDebug());
241 digitizer->InitDetector();
243 if (!fLoader->TreeH()) fLoader->LoadHits("read");
244 fLoader->LoadDigits("recreate");
245 AliRunLoader* runLoader = fLoader->GetRunLoader();
247 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
248 digitizer->Open(runLoader->GetFileName().Data(), iEvent);
249 digitizer->MakeDigits();
250 digitizer->WriteDigits();
253 fLoader->UnloadHits();
254 fLoader->UnloadDigits();
257 //_____________________________________________________________________________
258 void AliTRD::Hits2SDigits()
261 // Create summable digits
263 AliTRDdigitizer *digitizer = new AliTRDdigitizer("TRDdigitizer"
264 ,"TRD digitizer class");
265 // For the summable digits
266 digitizer->SetSDigits(kTRUE);
267 digitizer->SetDebug(GetDebug());
270 digitizer->InitDetector();
272 if (!fLoader->TreeH()) fLoader->LoadHits("read");
273 fLoader->LoadSDigits("recreate");
274 AliRunLoader* runLoader = fLoader->GetRunLoader();
276 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
277 digitizer->Open(runLoader->GetFileName().Data(), iEvent);
278 digitizer->MakeDigits();
279 digitizer->WriteDigits();
282 fLoader->UnloadHits();
283 fLoader->UnloadSDigits();
286 //_____________________________________________________________________________
287 AliDigitizer* AliTRD::CreateDigitizer(AliRunDigitizer* manager) const
289 return new AliTRDdigitizer(manager);
292 //_____________________________________________________________________________
293 void AliTRD::SDigits2Digits()
296 // Create final digits from summable digits
299 // Create the TRD digitizer
300 AliTRDdigitizer *digitizer = new AliTRDdigitizer("TRDdigitizer"
301 ,"TRD digitizer class");
302 digitizer->SetDebug(GetDebug());
305 digitizer->SetEvent(gAlice->GetEvNumber());
308 digitizer->InitDetector();
310 // Read the s-digits via digits manager
311 AliTRDdigitsManager *sdigitsManager = new AliTRDdigitsManager();
313 sdigitsManager->SetDebug(GetDebug());
314 sdigitsManager->SetSDigits(kTRUE);
315 sdigitsManager->CreateArrays();
317 if (!fLoader->TreeS())
318 if (fLoader->LoadSDigits("read"))
320 Error("SDigits2Digits","Error while reading SDigits for event %d",gAlice->GetEvNumber());
323 if (!fLoader->TreeS()) return;
325 sdigitsManager->ReadDigits(fLoader->TreeS());
327 // Add the s-digits to the input list
328 digitizer->AddSDigitsManager(sdigitsManager);
330 // Convert the s-digits to normal digits
331 digitizer->SDigits2Digits();
334 if (!fLoader->TreeD()) fLoader->MakeTree("D");
335 if (digitizer->MakeBranch(fLoader->TreeD())){
336 digitizer->WriteDigits();
341 //_____________________________________________________________________________
342 void AliTRD::AddHit(Int_t track, Int_t det, Float_t *hits, Int_t q
346 // Add a hit for the TRD
348 // The data structure is set according to fHitType:
349 // bit0: standard TClonesArray
350 // bit1: compressed trackHits structure
354 TClonesArray &lhits = *fHits;
355 new(lhits[fNhits++]) AliTRDhit(fIshunt,track,det,hits,q);
359 AddHit2(track,det,hits,q,inDrift);
364 //_____________________________________________________________________________
365 void AliTRD::BuildGeometry()
368 // Create the ROOT TNode geometry for the TRD
375 Float_t zmax1, zmax2;
379 const Int_t kColorTRD = 46;
381 // Find the top node alice
382 top = gAlice->GetGeometry()->GetNode("alice");
384 if (fDisplayType == 0) {
386 pgon = new TPGON("S_TRD","TRD","void",0,360,AliTRDgeometry::Nsect(),4);
387 rmin = AliTRDgeometry::Rmin();
388 rmax = AliTRDgeometry::Rmax();
389 pgon->DefineSection(0,-AliTRDgeometry::Zmax1(),rmax,rmax);
390 pgon->DefineSection(1,-AliTRDgeometry::Zmax2(),rmin,rmax);
391 pgon->DefineSection(2, AliTRDgeometry::Zmax2(),rmin,rmax);
392 pgon->DefineSection(3, AliTRDgeometry::Zmax1(),rmax,rmax);
394 node = new TNode("TRD","TRD","S_TRD",0,0,0,"");
395 node->SetLineColor(kColorTRD);
399 else if (fDisplayType == 1) {
403 Float_t slope = (AliTRDgeometry::Zmax1() - AliTRDgeometry::Zmax2())
404 / (AliTRDgeometry::Rmax() - AliTRDgeometry::Rmin());
406 rmin = AliTRDgeometry::Rmin() + AliTRDgeometry::CraHght();
407 rmax = rmin + AliTRDgeometry::CdrHght();
409 Float_t thickness = rmin - AliTRDgeometry::Rmin();
410 zmax2 = AliTRDgeometry::Zmax2() + slope * thickness;
411 zmax1 = zmax2 + slope * AliTRDgeometry::DrThick();
413 for (iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) {
415 sprintf(name,"S_TR1%d",iPlan);
416 pgon = new TPGON(name,"TRD","void",0,360,AliTRDgeometry::Nsect(),4);
417 pgon->DefineSection(0,-zmax1,rmax,rmax);
418 pgon->DefineSection(1,-zmax2,rmin,rmax);
419 pgon->DefineSection(2, zmax2,rmin,rmax);
420 pgon->DefineSection(3, zmax1,rmax,rmax);
422 node = new TNode("TRD","TRD",name,0,0,0,"");
423 node->SetLineColor(kColorTRD);
426 Float_t height = AliTRDgeometry::Cheight() + AliTRDgeometry::Cspace();
427 rmin = rmin + height;
428 rmax = rmax + height;
429 zmax1 = zmax1 + slope * height;
430 zmax2 = zmax2 + slope * height;
434 thickness += AliTRDgeometry::DrThick();
435 rmin = AliTRDgeometry::Rmin() + thickness;
436 rmax = rmin + AliTRDgeometry::AmThick();
437 zmax2 = AliTRDgeometry::Zmax2() + slope * thickness;
438 zmax1 = zmax2 + slope * AliTRDgeometry::AmThick();
440 for (iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) {
442 sprintf(name,"S_TR2%d",iPlan);
443 pgon = new TPGON(name,"TRD","void",0,360,AliTRDgeometry::Nsect(),4);
444 pgon->DefineSection(0,-zmax1,rmax,rmax);
445 pgon->DefineSection(1,-zmax2,rmin,rmax);
446 pgon->DefineSection(2, zmax2,rmin,rmax);
447 pgon->DefineSection(3, zmax1,rmax,rmax);
449 node = new TNode("TRD","TRD",name,0,0,0,"");
450 node->SetLineColor(kColorTRD);
453 Float_t height = AliTRDgeometry::Cheight() + AliTRDgeometry::Cspace();
454 rmin = rmin + height;
455 rmax = rmax + height;
456 zmax1 = zmax1 + slope * height;
457 zmax2 = zmax2 + slope * height;
465 //_____________________________________________________________________________
466 void AliTRD::Copy(TObject &trd)
472 ((AliTRD &) trd).fGasMix = fGasMix;
473 ((AliTRD &) trd).fGeometry = fGeometry;
474 ((AliTRD &) trd).fRecPoints = fRecPoints;
475 ((AliTRD &) trd).fNRecPoints = fNRecPoints;
476 ((AliTRD &) trd).fGasDensity = fGasDensity;
477 ((AliTRD &) trd).fFoilDensity = fFoilDensity;
478 ((AliTRD &) trd).fDrawTR = fDrawTR;
479 ((AliTRD &) trd).fDisplayType = fDisplayType;
480 ((AliTRD &) trd).fHitType = fHitType;
482 //AliDetector::Copy(trd);
486 //_____________________________________________________________________________
487 void AliTRD::CreateGeometry()
490 // Creates the volumes for the TRD chambers
493 // Check that FRAME is there otherwise we have no place where to put the TRD
494 AliModule* frame = gAlice->GetModule("FRAME");
496 printf(" The TRD needs the FRAME to be defined first\n");
500 fGeometry->CreateGeometry(fIdtmed->GetArray() - 1299);
504 //_____________________________________________________________________________
505 void AliTRD::CreateMaterials()
508 // Create the materials for the TRD
512 Int_t isxfld = gAlice->Field()->Integ();
513 Float_t sxmgmx = gAlice->Field()->Max();
515 // For polyethilene (CH2)
516 Float_t ape[2] = { 12., 1. };
517 Float_t zpe[2] = { 6., 1. };
518 Float_t wpe[2] = { 1., 2. };
521 // For mylar (C5H4O2)
522 Float_t amy[3] = { 12., 1., 16. };
523 Float_t zmy[3] = { 6., 1., 8. };
524 Float_t wmy[3] = { 5., 4., 2. };
528 Float_t aco[2] = { 12., 16. };
529 Float_t zco[2] = { 6., 8. };
530 Float_t wco[2] = { 1., 2. };
531 Float_t dco = 0.001977;
534 Float_t awa[2] = { 1., 16. };
535 Float_t zwa[2] = { 1., 8. };
536 Float_t wwa[2] = { 2., 1. };
539 // For isobutane (C4H10)
540 Float_t ais[2] = { 12., 1. };
541 Float_t zis[2] = { 6., 1. };
542 Float_t wis[2] = { 4., 10. };
543 Float_t dis = 0.00267;
545 // For plexiglas (C5H8O2)
546 Float_t apg[3] = { 12.011 , 1.0 , 15.9994 };
547 Float_t zpg[3] = { 6.0 , 1.0 , 8.0 };
548 Float_t wpg[3] = { 5.0 , 8.0 , 2.0 };
551 // For Xe/CO2-gas-mixture
552 // Xe-content of the Xe/CO2-mixture (85% / 15%)
554 // Xe-content of the Xe/Isobutane-mixture (97% / 3%)
556 Float_t dxe = .005858;
558 // General tracking parameter
559 Float_t tmaxfd = -10.;
560 Float_t stemax = -1e10;
561 Float_t deemax = -0.1;
562 Float_t epsil = 1e-4;
563 Float_t stmin = -0.001;
565 Float_t absl, radl, d, buf[1];
566 Float_t agm[2], zgm[2], wgm[2];
570 //////////////////////////////////////////////////////////////////////////
572 //////////////////////////////////////////////////////////////////////////
574 AliMaterial( 1, "Al" , 26.98, 13.0, 2.7 , 8.9 , 37.2);
575 AliMaterial( 2, "Air" , 14.61, 7.3, 0.001205, 30420.0 , 67500.0);
576 AliMaterial( 4, "Xe" , 131.29, 54.0, dxe , 1447.59, 0.0);
577 AliMaterial( 5, "Cu" , 63.54, 29.0, 8.96 , 1.43, 14.8);
578 AliMaterial( 6, "C" , 12.01, 6.0, 2.265 , 18.8 , 74.4);
579 AliMaterial(12, "G10" , 20.00, 10.0, 1.7 , 19.4 , 999.0);
580 AliMaterial(15, "Sn" , 118.71, 50.0, 7.31 , 1.21, 14.8);
581 AliMaterial(16, "Si" , 28.09, 14.0, 2.33 , 9.36, 37.2);
582 AliMaterial(17, "Epoxy", 17.75, 8.9, 1.8 , 21.82, 999.0);
585 AliMixture(3, "Polyethilene", ape, zpe, dpe, -2, wpe);
586 AliMixture(7, "Mylar", amy, zmy, dmy, -3, wmy);
587 AliMixture(8, "CO2", aco, zco, dco, -2, wco);
588 AliMixture(9, "Isobutane", ais, zis, dis, -2, wis);
589 AliMixture(13,"Water", awa, zwa, dwa, -2, wwa);
590 AliMixture(14,"Plexiglas", apg, zpg, dpg, -3, wpg);
593 Char_t namate[21]="";
595 // Get properties of Xe
596 gMC->Gfmate((*fIdmate)[4], namate, agm[0], zgm[0], d, radl, absl, buf, nbuf);
597 // Get properties of CO2
598 gMC->Gfmate((*fIdmate)[8], namate, agm[1], zgm[1], d, radl, absl, buf, nbuf);
599 // Create gas mixture
602 dgm1 = wgm[0] * dxe + wgm[1] * dco;
603 AliMixture(10, "Gas mixture 1", agm, zgm, dgm1, 2, wgm);
604 // Xe/Isobutane-mixture
605 // Get properties of Xe
606 gMC->Gfmate((*fIdmate)[4], namate, agm[0], zgm[0], d, radl, absl, buf, nbuf);
607 // Get properties of Isobutane
608 gMC->Gfmate((*fIdmate)[9], namate, agm[1], zgm[1], d, radl, absl, buf, nbuf);
609 // Create gas mixture
612 dgm2 = wgm[0] * dxe + wgm[1] * dis;
613 AliMixture(11, "Gas mixture 2", agm, zgm, dgm2, 2, wgm);
615 //////////////////////////////////////////////////////////////////////////
616 // Tracking Media Parameters
617 //////////////////////////////////////////////////////////////////////////
620 AliMedium(1, "Al Frame", 1, 0, isxfld, sxmgmx
621 , tmaxfd, stemax, deemax, epsil, stmin);
623 AliMedium(2, "Air", 2, 0, isxfld, sxmgmx
624 , tmaxfd, stemax, deemax, epsil, stmin);
626 AliMedium(3, "Radiator", 3, 0, isxfld, sxmgmx
627 , tmaxfd, stemax, deemax, epsil, stmin);
629 AliMedium(4, "Xe", 4, 1, isxfld, sxmgmx
630 , tmaxfd, stemax, deemax, epsil, stmin);
632 AliMedium(5, "Padplane", 5, 1, isxfld, sxmgmx
633 , tmaxfd, stemax, deemax, epsil, stmin);
635 AliMedium(6, "Readout", 1, 0, isxfld, sxmgmx
636 , tmaxfd, stemax, deemax, epsil, stmin);
638 AliMedium(7, "C Frame", 6, 0, isxfld, sxmgmx
639 , tmaxfd, stemax, deemax, epsil, stmin);
641 AliMedium(8, "Mylar", 7, 0, isxfld, sxmgmx
642 , tmaxfd, stemax, deemax, epsil, stmin);
644 // Gas-mixture (Xe/CO2)
645 AliMedium(9, "Gas-mix", 10, 1, isxfld, sxmgmx
646 , tmaxfd, stemax, deemax, epsil, stmin);
649 // Gas-mixture (Xe/Isobutane)
650 AliMedium(9, "Gas-mix", 11, 1, isxfld, sxmgmx
651 , tmaxfd, stemax, deemax, epsil, stmin);
653 // Nomex-honeycomb (use carbon for the time being)
654 AliMedium(10, "Nomex", 6, 0, isxfld, sxmgmx
655 , tmaxfd, stemax, deemax, epsil, stmin);
656 // Kapton foils (use Mylar for the time being)
657 AliMedium(11, "Kapton", 7, 0, isxfld, sxmgmx
658 , tmaxfd, stemax, deemax, epsil, stmin);
659 // Gas-filling of the radiator
660 AliMedium(12, "CO2", 8, 0, isxfld, sxmgmx
661 , tmaxfd, stemax, deemax, epsil, stmin);
663 AliMedium(13, "G10-plates",12, 0, isxfld, sxmgmx
664 , tmaxfd, stemax, deemax, epsil, stmin);
666 AliMedium(14, "Water", 13, 0, isxfld, sxmgmx
667 , tmaxfd, stemax, deemax, epsil, stmin);
668 // Rohacell (plexiglas) for the radiator
669 AliMedium(15, "Rohacell", 14, 0, isxfld, sxmgmx
670 , tmaxfd, stemax, deemax, epsil, stmin);
672 AliMedium(16, "MCM-Al" , 1, 0, isxfld, sxmgmx
673 , tmaxfd, stemax, deemax, epsil, stmin);
675 AliMedium(17, "MCM-Sn" , 15, 0, isxfld, sxmgmx
676 , tmaxfd, stemax, deemax, epsil, stmin);
678 AliMedium(18, "MCM-Cu" , 5, 0, isxfld, sxmgmx
679 , tmaxfd, stemax, deemax, epsil, stmin);
681 AliMedium(19, "MCM-G10" , 12, 0, isxfld, sxmgmx
682 , tmaxfd, stemax, deemax, epsil, stmin);
683 // Si in readout chips
684 AliMedium(20, "Chip-Si" , 16, 0, isxfld, sxmgmx
685 , tmaxfd, stemax, deemax, epsil, stmin);
686 // Epoxy in readout chips
687 AliMedium(21, "Chip-Ep" , 17, 0, isxfld, sxmgmx
688 , tmaxfd, stemax, deemax, epsil, stmin);
690 AliMedium(22, "Conn-PE" , 3, 0, isxfld, sxmgmx
691 , tmaxfd, stemax, deemax, epsil, stmin);
693 AliMedium(23, "Chip-Cu" , 5, 0, isxfld, sxmgmx
694 , tmaxfd, stemax, deemax, epsil, stmin);
695 // Al of cooling pipes
696 AliMedium(24, "Cooling" , 1, 0, isxfld, sxmgmx
697 , tmaxfd, stemax, deemax, epsil, stmin);
699 AliMedium(25, "Serv-Cu" , 5, 0, isxfld, sxmgmx
700 , tmaxfd, stemax, deemax, epsil, stmin);
702 // Save the density values for the TRD absorbtion
711 //_____________________________________________________________________________
712 void AliTRD::DrawModule() const
715 // Draw a shaded view of the Transition Radiation Detector version 0
718 // Set everything unseen
719 gMC->Gsatt("*" ,"SEEN",-1);
721 // Set ALIC mother transparent
722 gMC->Gsatt("ALIC","SEEN", 0);
724 // Set the volumes visible
725 if (fGeometry->IsVersion() == 0) {
726 gMC->Gsatt("B071","SEEN", 0);
727 gMC->Gsatt("B074","SEEN", 0);
728 gMC->Gsatt("B075","SEEN", 0);
729 gMC->Gsatt("B077","SEEN", 0);
730 gMC->Gsatt("BTR1","SEEN", 0);
731 gMC->Gsatt("BTR2","SEEN", 0);
732 gMC->Gsatt("BTR3","SEEN", 0);
733 gMC->Gsatt("UTR1","SEEN", 0);
734 gMC->Gsatt("UTR2","SEEN", 0);
735 gMC->Gsatt("UTR3","SEEN", 0);
738 gMC->Gsatt("B071","SEEN", 0);
739 gMC->Gsatt("B074","SEEN", 0);
740 gMC->Gsatt("B075","SEEN", 0);
741 gMC->Gsatt("B077","SEEN", 0);
742 gMC->Gsatt("BTR1","SEEN", 0);
743 gMC->Gsatt("BTR2","SEEN", 0);
744 gMC->Gsatt("BTR3","SEEN", 0);
745 gMC->Gsatt("UTR1","SEEN", 0);
746 if (fGeometry->GetPHOShole())
747 gMC->Gsatt("UTR2","SEEN", 0);
748 if (fGeometry->GetRICHhole())
749 gMC->Gsatt("UTR3","SEEN", 0);
751 // gMC->Gsatt("UCII","SEEN", 0);
752 // gMC->Gsatt("UCIM","SEEN", 0);
753 // gMC->Gsatt("UCIO","SEEN", 0);
754 // gMC->Gsatt("UL02","SEEN", 1);
755 // gMC->Gsatt("UL05","SEEN", 1);
756 // gMC->Gsatt("UL06","SEEN", 1);
758 gMC->Gdopt("hide", "on");
759 gMC->Gdopt("shad", "on");
760 gMC->Gsatt("*", "fill", 7);
761 gMC->SetClipBox(".");
762 gMC->SetClipBox("*", 0, 2000, -2000, 2000, -2000, 2000);
764 gMC->Gdraw("alic", 40, 30, 0, 12, 9.4, .021, .021);
765 gMC->Gdhead(1111, "Transition Radiation Detector");
766 gMC->Gdman(18, 4, "MAN");
770 //_____________________________________________________________________________
771 Int_t AliTRD::DistancetoPrimitive(Int_t , Int_t ) const
774 // Distance between the mouse and the TRD detector on the screen
781 //_____________________________________________________________________________
785 // Initialize the TRD detector after the geometry has been created
791 printf("\n%s: ",ClassName());
792 for (i = 0; i < 35; i++) printf("*");
793 printf(" TRD_INIT ");
794 for (i = 0; i < 35; i++) printf("*");
798 if (fGeometry->IsVersion() == 0) {
799 printf("%s: Geometry for spaceframe with holes initialized\n",ClassName());
801 else if (fGeometry->IsVersion() == 1) {
802 printf("%s: Geometry for spaceframe without holes initialized\n",ClassName());
803 if (fGeometry->GetPHOShole())
804 printf("%s: Leave space in front of PHOS free\n",ClassName());
805 if (fGeometry->GetRICHhole())
806 printf("%s: Leave space in front of RICH free\n",ClassName());
810 printf("%s: Gas Mixture: 85%% Xe + 15%% CO2\n",ClassName());
813 printf("%s: Gas Mixture: 97%% Xe + 3%% Isobutane\n",ClassName());
818 //_____________________________________________________________________________
819 void AliTRD::LoadPoints(Int_t )
822 // Store x, y, z of all hits in memory.
823 // Hit originating from TR photons are given a different color
827 // AliDetector::LoadPoints(track);
831 if ((fHits == 0) && (fTrackHits == 0)) return;
835 nhits = fHits->GetEntriesFast();
838 nhits = fTrackHits->GetEntriesFast();
840 if (nhits == 0) return;
842 Int_t tracks = gAlice->GetMCApp()->GetNtrack();
843 if (fPoints == 0) fPoints = new TObjArray(tracks);
847 Int_t *ntrkE = new Int_t[tracks];
848 Int_t *ntrkT = new Int_t[tracks];
849 Int_t *limiE = new Int_t[tracks];
850 Int_t *limiT = new Int_t[tracks];
851 Float_t **coorE = new Float_t*[tracks];
852 Float_t **coorT = new Float_t*[tracks];
853 for(Int_t i = 0; i < tracks; i++) {
862 AliTRDpoints *points = 0;
865 Int_t chunk = nhits / 4 + 1;
867 // Loop over all the hits and store their position
868 ahit = (AliTRDhit *) FirstHit(-1);
872 if (ahit->GetCharge() >= 0) {
874 trk = ahit->GetTrack();
875 if (ntrkE[trk] == limiE[trk]) {
876 // Initialise a new track
877 fp = new Float_t[3*(limiE[trk]+chunk)];
879 memcpy(fp,coorE[trk],sizeof(Float_t)*3*limiE[trk]);
880 delete [] coorE[trk];
888 fp[3*ntrkE[trk] ] = ahit->X();
889 fp[3*ntrkE[trk]+1] = ahit->Y();
890 fp[3*ntrkE[trk]+2] = ahit->Z();
895 else if ((ahit->GetCharge() < 0) && (fDrawTR)) {
897 trk = ahit->GetTrack();
898 if (ntrkT[trk] == limiT[trk]) {
899 // Initialise a new track
900 fp = new Float_t[3*(limiT[trk]+chunk)];
902 memcpy(fp,coorT[trk],sizeof(Float_t)*3*limiT[trk]);
903 delete [] coorT[trk];
911 fp[3*ntrkT[trk] ] = ahit->X();
912 fp[3*ntrkT[trk]+1] = ahit->Y();
913 fp[3*ntrkT[trk]+2] = ahit->Z();
918 ahit = (AliTRDhit *) NextHit();
922 for (trk = 0; trk < tracks; ++trk) {
924 if (ntrkE[trk] || ntrkT[trk]) {
926 points = new AliTRDpoints();
927 points->SetDetector(this);
928 points->SetParticle(trk);
930 // Set the dEdx points
932 points->SetMarkerColor(GetMarkerColor());
933 points->SetMarkerSize(GetMarkerSize());
934 points->SetPolyMarker(ntrkE[trk],coorE[trk],GetMarkerStyle());
935 delete [] coorE[trk];
939 // Set the TR photon points
941 points->SetTRpoints(ntrkT[trk],coorT[trk]);
942 delete [] coorT[trk];
946 fPoints->AddAt(points,trk);
961 //_____________________________________________________________________________
962 void AliTRD::MakeBranch(Option_t* option)
965 // Create Tree branches for the TRD digits.
968 Int_t buffersize = 4000;
969 Char_t branchname[15];
970 sprintf(branchname,"%s",GetName());
972 const char *cD = strstr(option,"D");
974 AliDetector::MakeBranch(option);
976 if (fDigits && gAlice->TreeD() && cD) {
977 MakeBranchInTree(gAlice->TreeD(),branchname,&fDigits,buffersize,0);
981 MakeBranch2(option,0);
986 //_____________________________________________________________________________
987 void AliTRD::ResetDigits()
990 // Reset number of digits and the digits array for this detector
994 if (fDigits) fDigits->Clear();
998 //_____________________________________________________________________________
999 void AliTRD::ResetRecPoints()
1002 // Reset number of reconstructed points and the point array
1007 Int_t nentr = fRecPoints->GetEntriesFast();
1008 for (Int_t i = 0; i < nentr; i++) delete fRecPoints->RemoveAt(i);
1013 //_____________________________________________________________________________
1014 void AliTRD::SetTreeAddress()
1017 // Set the branch addresses for the trees.
1020 Char_t branchname[15];
1022 if ( fLoader->TreeH() && (fHits == 0x0)) fHits = new TClonesArray("AliTRDhit",405);
1023 AliDetector::SetTreeAddress();
1026 TTree *treeR = fLoader->TreeR();
1029 sprintf(branchname,"%scluster",GetName());
1030 if (fRecPoints == 0x0) fRecPoints = new TObjArray(400);
1032 branch = treeR->GetBranch(branchname);
1034 branch->SetAddress(&fRecPoints);
1045 //_____________________________________________________________________________
1046 void AliTRD::SetGasMix(Int_t imix)
1049 // Defines the gas mixture (imix=0: Xe/Isobutane imix=1: Xe/CO2)
1052 if ((imix < 0) || (imix > 1)) {
1053 printf("Wrong input value: %d\n",imix);
1054 printf("Use standard setting\n");
1063 //_____________________________________________________________________________
1064 void AliTRD::SetPHOShole()
1067 // Selects a geometry with a hole in front of the PHOS
1070 fGeometry->SetPHOShole();
1074 //_____________________________________________________________________________
1075 void AliTRD::SetRICHhole()
1078 // Selects a geometry with a hole in front of the RICH
1081 fGeometry->SetRICHhole();
1085 //_____________________________________________________________________________
1086 AliTRD &AliTRD::operator=(const AliTRD &trd)
1089 // Assignment operator
1092 if (this != &trd) ((AliTRD &) trd).Copy(*this);
1097 //_____________________________________________________________________________
1098 void AliTRD::FinishPrimary()
1101 // Store the hits in the containers after all primaries are finished
1105 fTrackHits->FlushHitStack();
1110 //_____________________________________________________________________________
1111 void AliTRD::RemapTrackHitIDs(Int_t *map)
1114 // Remap the track IDs
1122 TClonesArray *arr = fTrackHits->GetArray();;
1123 for (Int_t i = 0; i < arr->GetEntriesFast(); i++){
1124 AliTrackHitsParamV2 *info = (AliTrackHitsParamV2 *) (arr->At(i));
1125 info->fTrackID = map[info->fTrackID];
1131 //_____________________________________________________________________________
1132 void AliTRD::ResetHits()
1138 AliDetector::ResetHits();
1140 fTrackHits->Clear();
1145 //_____________________________________________________________________________
1146 AliHit* AliTRD::FirstHit(Int_t track)
1149 // Return the first hit of a track
1153 return FirstHit2(track);
1156 return AliDetector::FirstHit(track);
1160 //_____________________________________________________________________________
1161 AliHit* AliTRD::NextHit()
1164 // Returns the next hit of a track
1171 return AliDetector::NextHit();
1175 //_____________________________________________________________________________
1176 AliHit* AliTRD::FirstHit2(Int_t track)
1179 // Initializes the hit iterator.
1180 // Returns the address of the first hit of a track.
1181 // If <track> >= 0 the track is read from disk,
1182 // while if <track> < 0 the first hit of the current
1183 // track is returned.
1187 gAlice->ResetHits();
1188 TreeH()->GetEvent(track);
1192 fTrackHits->First();
1193 return (AliHit*) fTrackHits->GetHit();
1201 //_____________________________________________________________________________
1202 AliHit* AliTRD::NextHit2()
1205 // Returns the next hit of the current track
1210 return (AliHit *) fTrackHits->GetHit();
1218 //_____________________________________________________________________________
1219 void AliTRD::MakeBranch2(Option_t *option, const char* )
1222 // Create a new branch in the current Root tree.
1223 // The branch of fHits is automatically split.
1230 char branchname[10];
1231 sprintf(branchname,"%s2",GetName());
1233 // Get the pointer to the header
1234 const char *cH = strstr(option,"H");
1237 fTrackHits = new AliTRDtrackHits();
1241 if (fTrackHits && TreeH() && cH)
1243 TreeH()->Branch(branchname,"AliTRDtrackHits",&fTrackHits,fBufferSize,99);
1244 Info("MakeBranch2","Making Branch %s for trackhits",branchname);
1248 //_____________________________________________________________________________
1249 void AliTRD::SetTreeAddress2()
1252 // Set the branch address for the trackHits tree
1254 if (GetDebug()) Info("SetTreeAddress2","");
1257 char branchname[20];
1258 sprintf(branchname,"%s2",GetName());
1260 // Branch address for hit tree
1261 TTree *treeH = TreeH();
1262 if ((treeH) && (fHitType > 0)) {
1263 branch = treeH->GetBranch(branchname);
1266 branch->SetAddress(&fTrackHits);
1268 Info("SetTreeAddress2","Success.");
1273 Info("SetTreeAddress2","Can NOT get the branch %s",branchname);
1279 //_____________________________________________________________________________
1280 void AliTRD::AddHit2(Int_t track, Int_t det, Float_t *hits, Int_t q
1284 // Add a hit to the list
1290 Int_t primary = gAlice->GetMCApp()->GetPrimary(track);
1291 gAlice->GetMCApp()->Particle(primary)->SetBit(kKeepBit);
1296 gAlice->GetMCApp()->FlagTrack(track);
1299 if ((fTrackHits) && (fHitType > 0)) {
1300 fTrackHits->AddHitTRD(det,rtrack,hits[0],hits[1],hits[2],q,inDrift);
1306 //_____________________________________________________________________________
1307 void AliTRD::Reconstruct() const
1309 // reconstruct clusters
1311 AliTRDclusterizerV1 clusterer("clusterer", "TRD clusterizer");
1312 AliRunLoader* runLoader = GetLoader()->GetRunLoader();
1313 runLoader->CdGAFile();
1314 AliTRDparameter* trdParam = (AliTRDparameter*) gFile->Get("TRDparameter");
1316 Error("Reconstruct", "no TRD parameters found");
1320 clusterer.SetParameter(trdParam);
1321 Int_t nEvents = runLoader->GetNumberOfEvents();
1323 for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
1324 clusterer.Open(runLoader->GetFileName(), iEvent);
1325 clusterer.ReadDigits();
1326 clusterer.MakeClusters();
1327 clusterer.WriteClusters(-1);
1331 //_____________________________________________________________________________
1332 AliTracker* AliTRD::CreateTracker() const
1334 // create a TRD tracker
1336 GetLoader()->GetRunLoader()->CdGAFile();
1337 return new AliTRDtracker(gFile);