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