]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDtrackingSector.cxx
Adding TString in the included files.
[u/mrichter/AliRoot.git] / TRD / AliTRDtrackingSector.cxx
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
28 #include "AliTRDtrackingSector.h"\r
29 #include "AliTRDtrackingChamber.h"\r
30 \r
31 \r
32 ClassImp(AliTRDtrackingSector)\r
33 \r
34 //_____________________________________________________________________________\r
35 AliTRDtrackingSector::AliTRDtrackingSector()\r
36   :fSector(-1)\r
37   ,fN(0)\r
38   ,fGeom(NULL)\r
39 {\r
40   // Default constructor\r
41   \r
42   memset(fChamber, 0, AliTRDgeometry::kNdets*sizeof(AliTRDtrackingChamber*));\r
43   memset(fIndex, -1, AliTRDgeometry::kNdets*sizeof(Char_t));\r
44   memset(fX0, 0, AliTRDgeometry::kNlayer*sizeof(Float_t));\r
45 }\r
46 \r
47 //_____________________________________________________________________________\r
48 AliTRDtrackingSector::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
57   memset(fChamber, 0, AliTRDgeometry::kNdets*sizeof(AliTRDtrackingChamber*));\r
58   memset(fIndex, -1, AliTRDgeometry::kNdets*sizeof(Char_t));\r
59   memset(fX0, 0, AliTRDgeometry::kNlayer*sizeof(Float_t));\r
60 }\r
61 \r
62     \r
63 //_____________________________________________________________________________\r
64 void AliTRDtrackingSector::Init(const AliTRDReconstructor *rec, const AliTRDCalDet *cal)\r
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
70   AliTRDchamberTimeBin *tb = NULL;\r
71   AliTRDtrackingChamber **tc = &fChamber[0];\r
72   for(Int_t ic = 0; (ic<AliTRDgeometry::kNdets) && (*tc); ic++, tc++){\r
73     for(Int_t itb=0; itb<AliTRDseedV1::kNtb; itb++){\r
74       if(!(tb = (*tc)->GetTB(itb))) continue;\r
75       tb->SetReconstructor(rec);\r
76     }\r
77     (*tc)->Build(fGeom, cal, rec->IsHLT());\r
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
86       fX0[il] += GetChamber(fIndex[idx])->GetX(); \r
87       nl++; \r
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
100 void AliTRDtrackingSector::Clear(const Option_t *opt)\r
101 {\r
102 // Reset counters and steer chamber clear\r
103 \r
104   AliTRDtrackingChamber **tc = &fChamber[0];\r
105   for(Int_t ich=0; ich<fN; ich++, tc++){ \r
106     (*tc)->Clear(opt);\r
107     delete (*tc); (*tc) = NULL;   // I would avoid\r
108   }     \r
109   memset(fIndex, -1, AliTRDgeometry::kNdets*sizeof(Char_t));\r
110   fN = 0;\r
111 }\r
112 \r
113 //_____________________________________________________________________________\r
114 AliTRDtrackingChamber* 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
121   else if(!build) return NULL;\r
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
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
130   \r
131   AliTRDtrackingChamber *chmb = fChamber[Int_t(fIndex[ch])] = new AliTRDtrackingChamber();\r
132   chmb->SetDetector(AliTRDgeometry::GetDetector(layer, stack, fSector));\r
133   return chmb;\r
134 }\r
135 \r
136 //_____________________________________________________________________________\r
137 AliTRDtrackingChamber** 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
142   if(stack<0 || stack>=AliTRDgeometry::kNstack) return NULL;\r
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
147     if(fIndex[ich] < 0) fStack[il] = NULL; \r
148     else{\r
149       fStack[il] = fChamber[Int_t(fIndex[ich])];\r
150       n++;\r
151     }\r
152   }\r
153   \r
154   return n ? &fStack[0] : NULL;\r
155 }\r
156 \r
157 //_____________________________________________________________________________\r
158 void AliTRDtrackingSector::Print(Option_t *opt) const\r
159 {\r
160 // Dump info about this tracking sector and the tracking chamber within\r
161 // \r
162 \r
163   printf("\n\tSector[%2d]\n", fSector);\r
164   for(int il=0; il<AliTRDgeometry::kNlayer; il++){\r
165     for(int is =0; is<AliTRDgeometry::kNstack; is++){\r
166       Int_t ch = is*AliTRDgeometry::kNlayer + il;\r
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
169     }\r
170     if(!opt) printf("\n");\r
171   }\r
172 \r
173 }\r