The present commit corresponds to an important change in the way the
[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
885e9b30 28#include "AliTRDcalibDB.h"\r
29#include "AliTRDCommonParam.h"\r
0d83b3a5 30#include "AliTRDReconstructor.h"\r
885e9b30 31#include "AliTRDpadPlane.h"\r
349f5eeb 32#include "AliTRDtrackingSector.h"\r
885e9b30 33#include "AliTRDtrackingChamber.h"\r
34\r
349f5eeb 35\r
885e9b30 36ClassImp(AliTRDtrackingSector)\r
37\r
38//_____________________________________________________________________________\r
39AliTRDtrackingSector::AliTRDtrackingSector()\r
40 :fSector(-1)\r
41 ,fN(0)\r
42 ,fGeom(0x0)\r
43{\r
44 // Default constructor\r
45 \r
349f5eeb 46 memset(fChamber, 0, AliTRDgeometry::kNdets*sizeof(AliTRDtrackingChamber*));\r
d12ef0c7 47 memset(fIndex, -1, AliTRDgeometry::kNdets*sizeof(Char_t));\r
349f5eeb 48 memset(fX0, 0, AliTRDgeometry::kNlayer*sizeof(Float_t));\r
885e9b30 49}\r
50\r
51//_____________________________________________________________________________\r
52AliTRDtrackingSector::AliTRDtrackingSector(AliTRDgeometry *geo, Int_t gs)\r
53 :fSector(gs)\r
54 ,fN(0)\r
55 ,fGeom(geo)\r
56{\r
57 //\r
58 // AliTRDtrackingSector Constructor\r
59 //\r
60\r
349f5eeb 61 memset(fChamber, 0, AliTRDgeometry::kNdets*sizeof(AliTRDtrackingChamber*));\r
d12ef0c7 62 memset(fIndex, -1, AliTRDgeometry::kNdets*sizeof(Char_t));\r
349f5eeb 63 memset(fX0, 0, AliTRDgeometry::kNlayer*sizeof(Float_t));\r
885e9b30 64}\r
65\r
885e9b30 66 \r
67//_____________________________________________________________________________\r
b0a48c4d 68void AliTRDtrackingSector::Init(const AliTRDReconstructor *rec, const AliTRDCalDet *cal)\r
885e9b30 69{ \r
70// Steer building of tracking chambers and build tracking sector.\r
71// Propagate radial position information (calibration/alignment aware) from chambers to sector level\r
72//\r
73 \r
74 AliTRDchamberTimeBin *tb = 0x0;\r
349f5eeb 75 AliTRDtrackingChamber **tc = &fChamber[0];\r
76 for(Int_t ic = 0; (ic<AliTRDgeometry::kNdets) && (*tc); ic++, tc++){\r
77 for(Int_t itb=0; itb<AliTRDseed::knTimebins; itb++){\r
78 if(!(tb = (*tc)->GetTB(itb))) continue;\r
885e9b30 79 tb->SetReconstructor(rec);\r
80 }\r
349f5eeb 81 (*tc)->Build(fGeom, cal, rec->IsHLT());\r
885e9b30 82 }\r
83 \r
84 Int_t nl;\r
85 for(int il=0; il<AliTRDgeometry::kNlayer; il++){\r
86 fX0[il] = 0.; nl = 0;\r
87 for(int is=0; is<AliTRDgeometry::kNstack; is++){\r
88 Int_t idx = is*AliTRDgeometry::kNlayer + il;\r
89 if(fIndex[idx]<0) continue;\r
349f5eeb 90 fX0[il] += GetChamber(fIndex[idx])->GetX(); \r
91 nl++; \r
885e9b30 92 }\r
93 if(!nl){\r
94 //printf("Could not estimate radial position of plane %d in sector %d.\n", ip, fSector);\r
95 continue;\r
96 }\r
97 fX0[il] /= Float_t(nl);\r
98 }\r
99}\r
100\r
101\r
102\r
103//_____________________________________________________________________________\r
104void AliTRDtrackingSector::Clear(const Option_t *opt)\r
105{\r
106// Reset counters and steer chamber clear\r
107\r
349f5eeb 108 AliTRDtrackingChamber **tc = &fChamber[0];\r
109 for(Int_t ich=0; ich<fN; ich++, tc++){ \r
110 (*tc)->Clear(opt);\r
111 delete (*tc); (*tc) = 0x0; // I would avoid\r
885e9b30 112 } \r
d12ef0c7 113 memset(fIndex, -1, AliTRDgeometry::kNdets*sizeof(Char_t));\r
885e9b30 114 fN = 0;\r
115}\r
116\r
117//_____________________________________________________________________________\r
118AliTRDtrackingChamber* AliTRDtrackingSector::GetChamber(Int_t stack, Int_t layer, Bool_t build)\r
119{\r
120// Return chamber at position (stack, plane) in current \r
121// sector or build a new one if it is not already created\r
122 \r
123 Int_t ch = stack*AliTRDgeometry::kNlayer + layer;\r
124 if(fIndex[ch] >= 0) return fChamber[Int_t(fIndex[ch])];\r
125 else if(!build) return 0x0;\r
126 \r
127 // CHAMBER HAS TO BE BUILD\r
128 Int_t rch = ch;do rch--; while(rch>=0 && fIndex[rch]<0);\r
129 fIndex[ch] = rch >=0 ? fIndex[rch]+1 : 0; \r
130 fN++;\r
131 \r
349f5eeb 132 memmove(&fChamber[Int_t(fIndex[ch])+1], &fChamber[Int_t(fIndex[ch])], (AliTRDgeometry::kNdets-fIndex[ch]-1)*sizeof(void*));\r
133 for(Int_t ic = ch+1; ic<AliTRDgeometry::kNdets; ic++) fIndex[ic] += fIndex[ic] >= 0 ? 1 : 0;\r
885e9b30 134 \r
349f5eeb 135 AliTRDtrackingChamber *chmb = fChamber[Int_t(fIndex[ch])] = new AliTRDtrackingChamber();\r
136 chmb->SetDetector(AliTRDgeometry::GetDetector(layer, stack, fSector));\r
137 return chmb;\r
885e9b30 138}\r
139\r
140//_____________________________________________________________________________\r
141AliTRDtrackingChamber** AliTRDtrackingSector::GetStack(Int_t stack)\r
142{\r
143// Return chamber at position (stack, plane) in current \r
144// sector or build a new one if it is not already created\r
145 \r
146 if(stack<0 || stack>=AliTRDgeometry::kNstack) return 0x0;\r
147 \r
148 Int_t ich, n = 0;\r
149 for(int il=0; il<AliTRDgeometry::kNlayer; il++){\r
150 ich = stack*AliTRDgeometry::kNlayer + il;\r
151 if(fIndex[ich] < 0) fStack[il] = 0x0; \r
152 else{\r
153 fStack[il] = fChamber[Int_t(fIndex[ich])];\r
154 n++;\r
155 }\r
156 }\r
157 \r
158 return n ? &fStack[0] : 0x0;\r
159}\r
160\r
161//_____________________________________________________________________________\r
6c207d50 162void AliTRDtrackingSector::Print(Option_t *opt) const\r
885e9b30 163{\r
164// Dump info about this tracking sector and the tracking chamber within\r
165// \r
166\r
6c207d50 167 printf("\n\tSector[%2d]\n", fSector);\r
349f5eeb 168 for(int il=0; il<AliTRDgeometry::kNlayer; il++){\r
169 for(int is =0; is<AliTRDgeometry::kNstack; is++){\r
885e9b30 170 Int_t ch = is*AliTRDgeometry::kNlayer + il;\r
6c207d50 171 if(opt) fChamber[Int_t(fIndex[ch])]->Print(opt);\r
172 else printf("%2d[%2d] ", fIndex[ch], fIndex[ch]>=0 ? fChamber[Int_t(fIndex[ch])]->GetNClusters() : 0);\r
885e9b30 173 }\r
6c207d50 174 if(!opt) printf("\n");\r
885e9b30 175 }\r
176\r
177}\r