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 **************************************************************************/
16 /* $Id: AliTRDtrackingSector.cxx 23810 2008-02-08 09:00:27Z hristov $ */
18 ///////////////////////////////////////////////////////////////////////////////
20 // Tracking data container for one sector //
23 // Alex Bercuci <A.Bercuci@gsi.de> //
24 // Markus Fasel <M.Fasel@gsi.de> //
26 ///////////////////////////////////////////////////////////////////////////////
28 #include "AliTRDReconstructor.h"
29 #include "AliTRDtrackingSector.h"
30 #include "AliTRDtrackingChamber.h"
33 ClassImp(AliTRDtrackingSector)
35 //_____________________________________________________________________________
36 AliTRDtrackingSector::AliTRDtrackingSector()
41 // Default constructor
43 memset(fChamber, 0, AliTRDgeometry::kNdets*sizeof(AliTRDtrackingChamber*));
44 memset(fStack, 0, AliTRDgeometry::kNlayer*sizeof(AliTRDtrackingChamber*));
45 memset(fIndex, -1, AliTRDgeometry::kNdets*sizeof(Char_t));
46 memset(fX0, 0, AliTRDgeometry::kNlayer*sizeof(Float_t));
49 //_____________________________________________________________________________
50 AliTRDtrackingSector::AliTRDtrackingSector(AliTRDgeometry *geo, Int_t gs)
56 // AliTRDtrackingSector Constructor
59 memset(fChamber, 0, AliTRDgeometry::kNdets*sizeof(AliTRDtrackingChamber*));
60 memset(fStack, 0, AliTRDgeometry::kNlayer*sizeof(AliTRDtrackingChamber*));
61 memset(fIndex, -1, AliTRDgeometry::kNdets*sizeof(Char_t));
62 memset(fX0, 0, AliTRDgeometry::kNlayer*sizeof(Float_t));
66 //_____________________________________________________________________________
67 void AliTRDtrackingSector::Init(const AliTRDReconstructor *rec)
69 // Steer building of tracking chambers and build tracking sector.
70 // Propagate radial position information (calibration/alignment aware) from chambers to sector level
73 AliTRDchamberTimeBin *tb = NULL;
74 AliTRDtrackingChamber **tc = &fChamber[0];
75 for(Int_t ic = 0; (ic<AliTRDgeometry::kNdets) && (*tc); ic++, tc++){
76 for(Int_t itb=0; itb<AliTRDseedV1::kNtb; itb++){
77 if(!(tb = (*tc)->GetTB(itb))) continue;
78 tb->SetReconstructor(rec);
80 (*tc)->Build(fGeom, rec->IsHLT());
84 for(int il=0; il<AliTRDgeometry::kNlayer; il++){
86 for(int is=0; is<AliTRDgeometry::kNstack; is++){
87 Int_t idx = is*AliTRDgeometry::kNlayer + il;
88 if(fIndex[idx]<0) continue;
89 fX0[il] += GetChamber(fIndex[idx])->GetX();
93 //printf("Could not estimate radial position of plane %d in sector %d.\n", ip, fSector);
96 fX0[il] /= Float_t(nl);
102 //_____________________________________________________________________________
103 void AliTRDtrackingSector::Clear(const Option_t *opt)
105 // Reset counters and steer chamber clear
107 AliTRDtrackingChamber **tc = &fChamber[0];
108 for(Int_t ich=0; ich<fN; ich++, tc++){
110 delete (*tc); (*tc) = NULL; // I would avoid
112 memset(fIndex, -1, AliTRDgeometry::kNdets*sizeof(Char_t));
116 //_____________________________________________________________________________
117 AliTRDtrackingChamber* AliTRDtrackingSector::GetChamber(Int_t stack, Int_t layer, Bool_t build)
119 // Return chamber at position (stack, plane) in current
120 // sector or build a new one if it is not already created
122 Int_t ch = stack*AliTRDgeometry::kNlayer + layer;
123 if(fIndex[ch] >= 0) return fChamber[Int_t(fIndex[ch])];
124 else if(!build) return NULL;
126 // CHAMBER HAS TO BE BUILD
127 Int_t rch = ch;do rch--; while(rch>=0 && fIndex[rch]<0);
128 fIndex[ch] = rch >=0 ? fIndex[rch]+1 : 0;
131 memmove(&fChamber[Int_t(fIndex[ch])+1], &fChamber[Int_t(fIndex[ch])], (AliTRDgeometry::kNdets-fIndex[ch]-1)*sizeof(void*));
132 for(Int_t ic = ch+1; ic<AliTRDgeometry::kNdets; ic++) fIndex[ic] += fIndex[ic] >= 0 ? 1 : 0;
134 AliTRDtrackingChamber *chmb = fChamber[Int_t(fIndex[ch])] = new AliTRDtrackingChamber();
135 chmb->SetDetector(AliTRDgeometry::GetDetector(layer, stack, fSector));
139 //_____________________________________________________________________________
140 AliTRDtrackingChamber** AliTRDtrackingSector::GetStack(Int_t stack)
142 // Return chamber at position (stack, plane) in current
143 // sector or build a new one if it is not already created
145 if(stack<0 || stack>=AliTRDgeometry::kNstack) return NULL;
148 for(int il=0; il<AliTRDgeometry::kNlayer; il++){
149 ich = stack*AliTRDgeometry::kNlayer + il;
150 if(fIndex[ich] < 0) fStack[il] = NULL;
152 fStack[il] = fChamber[Int_t(fIndex[ich])];
157 return n ? &fStack[0] : NULL;
160 //_____________________________________________________________________________
161 void AliTRDtrackingSector::Print(Option_t *opt) const
163 // Dump info about this tracking sector and the tracking chamber within
166 printf("\n\tSector[%2d]\n", fSector);
167 for(int il=0; il<AliTRDgeometry::kNlayer; il++){
168 for(int is =0; is<AliTRDgeometry::kNstack; is++){
169 Int_t ch = is*AliTRDgeometry::kNlayer + il;
170 if(opt) fChamber[Int_t(fIndex[ch])]->Print(opt);
171 else printf("%2d[%2d] ", fIndex[ch], fIndex[ch]>=0 ? fChamber[Int_t(fIndex[ch])]->GetNClusters() : 0);
173 if(!opt) printf("\n");