]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDtrackingSector.cxx
update the calculation of used clusters per tracklet
[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 "AliTRDcalibDB.h"\r
29 #include "AliTRDCommonParam.h"\r
30 #include "AliTRDReconstructor.h"\r
31 #include "AliTRDpadPlane.h"\r
32 #include "AliTRDtrackingSector.h"\r
33 #include "AliTRDtrackingChamber.h"\r
34 \r
35 \r
36 ClassImp(AliTRDtrackingSector)\r
37 \r
38 //_____________________________________________________________________________\r
39 AliTRDtrackingSector::AliTRDtrackingSector()\r
40   :fSector(-1)\r
41   ,fN(0)\r
42   ,fGeom(0x0)\r
43 {\r
44   // Default constructor\r
45   \r
46   memset(fChamber, 0, AliTRDgeometry::kNdets*sizeof(AliTRDtrackingChamber*));\r
47   memset(fIndex, -1, AliTRDgeometry::kNdets*sizeof(Char_t));\r
48   memset(fX0, 0, AliTRDgeometry::kNlayer*sizeof(Float_t));\r
49 }\r
50 \r
51 //_____________________________________________________________________________\r
52 AliTRDtrackingSector::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
61   memset(fChamber, 0, AliTRDgeometry::kNdets*sizeof(AliTRDtrackingChamber*));\r
62   memset(fIndex, -1, AliTRDgeometry::kNdets*sizeof(Char_t));\r
63   memset(fX0, 0, AliTRDgeometry::kNlayer*sizeof(Float_t));\r
64 }\r
65 \r
66     \r
67 //_____________________________________________________________________________\r
68 void AliTRDtrackingSector::Init(const AliTRDReconstructor *rec, const AliTRDCalDet *cal)\r
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
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<AliTRDseedV1::kNtb; itb++){\r
78       if(!(tb = (*tc)->GetTB(itb))) continue;\r
79       tb->SetReconstructor(rec);\r
80     }\r
81     (*tc)->Build(fGeom, cal, rec->IsHLT());\r
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
90       fX0[il] += GetChamber(fIndex[idx])->GetX(); \r
91       nl++; \r
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
104 void AliTRDtrackingSector::Clear(const Option_t *opt)\r
105 {\r
106 // Reset counters and steer chamber clear\r
107 \r
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
112   }     \r
113   memset(fIndex, -1, AliTRDgeometry::kNdets*sizeof(Char_t));\r
114   fN = 0;\r
115 }\r
116 \r
117 //_____________________________________________________________________________\r
118 AliTRDtrackingChamber* 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
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
134   \r
135   AliTRDtrackingChamber *chmb = fChamber[Int_t(fIndex[ch])] = new AliTRDtrackingChamber();\r
136   chmb->SetDetector(AliTRDgeometry::GetDetector(layer, stack, fSector));\r
137   return chmb;\r
138 }\r
139 \r
140 //_____________________________________________________________________________\r
141 AliTRDtrackingChamber** 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
162 void AliTRDtrackingSector::Print(Option_t *opt) const\r
163 {\r
164 // Dump info about this tracking sector and the tracking chamber within\r
165 // \r
166 \r
167   printf("\n\tSector[%2d]\n", fSector);\r
168   for(int il=0; il<AliTRDgeometry::kNlayer; il++){\r
169     for(int is =0; is<AliTRDgeometry::kNstack; is++){\r
170       Int_t ch = is*AliTRDgeometry::kNlayer + il;\r
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
173     }\r
174     if(!opt) printf("\n");\r
175   }\r
176 \r
177 }\r