o small fix
[u/mrichter/AliRoot.git] / TRD / AliTRDtrackingSector.cxx
CommitLineData
885e9b30 1/**************************************************************************\r
2* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
3* *\r
4* Author: The ALICE Off-line Project. *\r
5* Contributors are mentioned in the code where appropriate. *\r
6* *\r
7* Permission to use, copy, modify and distribute this software and its *\r
8* documentation strictly for non-commercial purposes is hereby granted *\r
9* without fee, provided that the above copyright notice appears in all *\r
10* copies and that both the copyright notice and this permission notice *\r
11* appear in the supporting documentation. The authors make no claims *\r
12* about the suitability of this software for any purpose. It is *\r
13* provided "as is" without express or implied warranty. *\r
14**************************************************************************/\r
15\r
16/* $Id: AliTRDtrackingSector.cxx 23810 2008-02-08 09:00:27Z hristov $ */\r
17\r
18///////////////////////////////////////////////////////////////////////////////\r
19// //\r
20// Tracking data container for one sector //\r
21// //\r
22// Authors: //\r
23// Alex Bercuci <A.Bercuci@gsi.de> //\r
24// Markus Fasel <M.Fasel@gsi.de> //\r
25// //\r
26///////////////////////////////////////////////////////////////////////////////\r
27\r
4ecadb52 28#include "AliTRDReconstructor.h"\r
349f5eeb 29#include "AliTRDtrackingSector.h"\r
885e9b30 30#include "AliTRDtrackingChamber.h"\r
31\r
349f5eeb 32\r
885e9b30 33ClassImp(AliTRDtrackingSector)\r
34\r
35//_____________________________________________________________________________\r
36AliTRDtrackingSector::AliTRDtrackingSector()\r
37 :fSector(-1)\r
38 ,fN(0)\r
4d6aee34 39 ,fGeom(NULL)\r
885e9b30 40{\r
41 // Default constructor\r
42 \r
349f5eeb 43 memset(fChamber, 0, AliTRDgeometry::kNdets*sizeof(AliTRDtrackingChamber*));\r
41f024fb 44 memset(fStack, 0, AliTRDgeometry::kNlayer*sizeof(AliTRDtrackingChamber*));\r
d12ef0c7 45 memset(fIndex, -1, AliTRDgeometry::kNdets*sizeof(Char_t));\r
349f5eeb 46 memset(fX0, 0, AliTRDgeometry::kNlayer*sizeof(Float_t));\r
885e9b30 47}\r
48\r
49//_____________________________________________________________________________\r
50AliTRDtrackingSector::AliTRDtrackingSector(AliTRDgeometry *geo, Int_t gs)\r
51 :fSector(gs)\r
52 ,fN(0)\r
53 ,fGeom(geo)\r
54{\r
55 //\r
56 // AliTRDtrackingSector Constructor\r
57 //\r
58\r
349f5eeb 59 memset(fChamber, 0, AliTRDgeometry::kNdets*sizeof(AliTRDtrackingChamber*));\r
41f024fb 60 memset(fStack, 0, AliTRDgeometry::kNlayer*sizeof(AliTRDtrackingChamber*));\r
d12ef0c7 61 memset(fIndex, -1, AliTRDgeometry::kNdets*sizeof(Char_t));\r
349f5eeb 62 memset(fX0, 0, AliTRDgeometry::kNlayer*sizeof(Float_t));\r
885e9b30 63}\r
64\r
885e9b30 65 \r
66//_____________________________________________________________________________\r
c79857d5 67void AliTRDtrackingSector::Init(const AliTRDReconstructor *rec)\r
885e9b30 68{ \r
69// Steer building of tracking chambers and build tracking sector.\r
70// Propagate radial position information (calibration/alignment aware) from chambers to sector level\r
71//\r
72 \r
4d6aee34 73 AliTRDchamberTimeBin *tb = NULL;\r
349f5eeb 74 AliTRDtrackingChamber **tc = &fChamber[0];\r
75 for(Int_t ic = 0; (ic<AliTRDgeometry::kNdets) && (*tc); ic++, tc++){\r
fac58f00 76 for(Int_t itb=0; itb<AliTRDseedV1::kNtb; itb++){\r
349f5eeb 77 if(!(tb = (*tc)->GetTB(itb))) continue;\r
885e9b30 78 tb->SetReconstructor(rec);\r
79 }\r
5eb768d6 80 (*tc)->Build(fGeom, rec->IsHLT());\r
885e9b30 81 }\r
82 \r
83 Int_t nl;\r
84 for(int il=0; il<AliTRDgeometry::kNlayer; il++){\r
85 fX0[il] = 0.; nl = 0;\r
86 for(int is=0; is<AliTRDgeometry::kNstack; is++){\r
87 Int_t idx = is*AliTRDgeometry::kNlayer + il;\r
88 if(fIndex[idx]<0) continue;\r
349f5eeb 89 fX0[il] += GetChamber(fIndex[idx])->GetX(); \r
90 nl++; \r
885e9b30 91 }\r
92 if(!nl){\r
93 //printf("Could not estimate radial position of plane %d in sector %d.\n", ip, fSector);\r
94 continue;\r
95 }\r
96 fX0[il] /= Float_t(nl);\r
97 }\r
98}\r
99\r
100\r
101\r
102//_____________________________________________________________________________\r
103void AliTRDtrackingSector::Clear(const Option_t *opt)\r
104{\r
105// Reset counters and steer chamber clear\r
106\r
349f5eeb 107 AliTRDtrackingChamber **tc = &fChamber[0];\r
108 for(Int_t ich=0; ich<fN; ich++, tc++){ \r
109 (*tc)->Clear(opt);\r
4d6aee34 110 delete (*tc); (*tc) = NULL; // I would avoid\r
885e9b30 111 } \r
d12ef0c7 112 memset(fIndex, -1, AliTRDgeometry::kNdets*sizeof(Char_t));\r
885e9b30 113 fN = 0;\r
114}\r
115\r
116//_____________________________________________________________________________\r
117AliTRDtrackingChamber* AliTRDtrackingSector::GetChamber(Int_t stack, Int_t layer, Bool_t build)\r
118{\r
119// Return chamber at position (stack, plane) in current \r
120// sector or build a new one if it is not already created\r
121 \r
122 Int_t ch = stack*AliTRDgeometry::kNlayer + layer;\r
123 if(fIndex[ch] >= 0) return fChamber[Int_t(fIndex[ch])];\r
4d6aee34 124 else if(!build) return NULL;\r
885e9b30 125 \r
126 // CHAMBER HAS TO BE BUILD\r
127 Int_t rch = ch;do rch--; while(rch>=0 && fIndex[rch]<0);\r
128 fIndex[ch] = rch >=0 ? fIndex[rch]+1 : 0; \r
129 fN++;\r
130 \r
349f5eeb 131 memmove(&fChamber[Int_t(fIndex[ch])+1], &fChamber[Int_t(fIndex[ch])], (AliTRDgeometry::kNdets-fIndex[ch]-1)*sizeof(void*));\r
132 for(Int_t ic = ch+1; ic<AliTRDgeometry::kNdets; ic++) fIndex[ic] += fIndex[ic] >= 0 ? 1 : 0;\r
885e9b30 133 \r
349f5eeb 134 AliTRDtrackingChamber *chmb = fChamber[Int_t(fIndex[ch])] = new AliTRDtrackingChamber();\r
5eb768d6 135 chmb->SetDetector(AliTRDgeometry::GetDetector(layer, stack, fSector));\r
349f5eeb 136 return chmb;\r
885e9b30 137}\r
138\r
139//_____________________________________________________________________________\r
140AliTRDtrackingChamber** AliTRDtrackingSector::GetStack(Int_t stack)\r
141{\r
142// Return chamber at position (stack, plane) in current \r
143// sector or build a new one if it is not already created\r
144 \r
4d6aee34 145 if(stack<0 || stack>=AliTRDgeometry::kNstack) return NULL;\r
885e9b30 146 \r
147 Int_t ich, n = 0;\r
148 for(int il=0; il<AliTRDgeometry::kNlayer; il++){\r
149 ich = stack*AliTRDgeometry::kNlayer + il;\r
4d6aee34 150 if(fIndex[ich] < 0) fStack[il] = NULL; \r
885e9b30 151 else{\r
152 fStack[il] = fChamber[Int_t(fIndex[ich])];\r
153 n++;\r
154 }\r
155 }\r
156 \r
4d6aee34 157 return n ? &fStack[0] : NULL;\r
885e9b30 158}\r
159\r
160//_____________________________________________________________________________\r
6c207d50 161void AliTRDtrackingSector::Print(Option_t *opt) const\r
885e9b30 162{\r
163// Dump info about this tracking sector and the tracking chamber within\r
164// \r
165\r
6c207d50 166 printf("\n\tSector[%2d]\n", fSector);\r
349f5eeb 167 for(int il=0; il<AliTRDgeometry::kNlayer; il++){\r
168 for(int is =0; is<AliTRDgeometry::kNstack; is++){\r
885e9b30 169 Int_t ch = is*AliTRDgeometry::kNlayer + il;\r
6c207d50 170 if(opt) fChamber[Int_t(fIndex[ch])]->Print(opt);\r
171 else printf("%2d[%2d] ", fIndex[ch], fIndex[ch]>=0 ? fChamber[Int_t(fIndex[ch])]->GetNClusters() : 0);\r
885e9b30 172 }\r
6c207d50 173 if(!opt) printf("\n");\r
885e9b30 174 }\r
175\r
176}\r