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