]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDtrackingSector.cxx
Update of tracking code (alignment/calibration awareness)
[u/mrichter/AliRoot.git] / TRD / AliTRDtrackingSector.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id: AliTRDtrackingSector.cxx 23810 2008-02-08 09:00:27Z hristov $ */
17
18 ///////////////////////////////////////////////////////////////////////////////
19 //                                                                           //
20 //  Tracking data container for one sector                                   //
21 //                                                                           //
22 //  Authors:                                                                 //
23 //    Alex Bercuci <A.Bercuci@gsi.de>                                        //
24 //    Markus Fasel <M.Fasel@gsi.de>                                          //
25 //                                                                           //
26 ///////////////////////////////////////////////////////////////////////////////
27
28 #include "AliTRDtrackingSector.h"
29 #include "AliTRDcalibDB.h"
30 #include "AliTRDCommonParam.h"
31 #include "AliTRDgeometry.h"
32 #include "AliTRDpadPlane.h"
33 #include "AliTRDtrackingChamber.h"
34
35 ClassImp(AliTRDtrackingSector)
36
37 //_____________________________________________________________________________
38 AliTRDtrackingSector::AliTRDtrackingSector()
39   :fTimeBinsPerPlane(0)
40   ,fSector(-1)
41   ,fN(0)
42   ,fGeom(0x0)
43 {
44         // Default constructor
45         
46         for(int ic=0; ic<kNChambersSector; ic++){
47                 fChamber[ic] = 0x0;
48                 fIndex[ic]   = -1;
49         }
50         for(int ip=0; ip<AliTRDgeometry::kNplan; ip++) fX0[ip] = 0.;
51 }
52
53 //_____________________________________________________________________________
54 AliTRDtrackingSector::AliTRDtrackingSector(AliTRDgeometry *geo, Int_t gs, Int_t tb)
55   :fTimeBinsPerPlane(tb)
56   ,fSector(gs)
57   ,fN(0)
58   ,fGeom(geo)
59 {
60   //
61   // AliTRDtrackingSector Constructor
62   //
63
64         for(int ic=0; ic<kNChambersSector; ic++){
65                 fChamber[ic] = 0x0;
66                 fIndex[ic]   = -1;
67         }
68         for(int ip=0; ip<AliTRDgeometry::kNplan; ip++) fX0[ip] = 0.;
69 }
70
71 //_____________________________________________________________________________
72 AliTRDtrackingSector::AliTRDtrackingSector(const AliTRDtrackingSector &/*t*/)
73   :fTimeBinsPerPlane(0)
74   ,fSector(-1)
75   ,fN(0)
76   ,fGeom(0x0)
77 {
78   //
79   // Copy constructor
80   //
81
82 }
83
84 //_____________________________________________________________________________
85 AliTRDtrackingSector::~AliTRDtrackingSector()
86 {
87   //
88   // Destructor
89   //
90
91 }
92                 
93 //_____________________________________________________________________________
94 void AliTRDtrackingSector::Init()
95 {               
96 //      Steer building of tracking chambers and build tracking sector.
97 //      Propagate radial position information (calibration/alignment aware) from chambers to sector level
98 //
99         
100         AliTRDtrackingChamber *tc = 0x0; int ic = 0; 
101         while((tc = fChamber[ic++])) tc->Build(fGeom);
102                 
103         Int_t np;
104         for(int ip=0; ip<AliTRDgeometry::kNplan; ip++){
105                 fX0[ip] = 0.; np = 0;
106                 for(int is=0; is<AliTRDgeometry::kNcham; is++){
107                         Int_t idx = is*AliTRDgeometry::kNplan + ip;
108                         if(fIndex[idx]<0) continue;
109                         tc = GetChamber(fIndex[idx]);
110                         fX0[ip] += tc->GetX(); np++; 
111                 }
112                 if(!np){
113                         //printf("Could not estimate radial position  of plane %d in sector %d.\n", ip, fSector);
114                         continue;
115                 }
116                 fX0[ip] /= Float_t(np);
117         }
118 }
119 //_____________________________________________________________________________
120 void AliTRDtrackingSector::Clear(const Option_t *opt)
121 {
122 // Reset counters and steer chamber clear
123
124         for(Int_t ich=0; ich<fN; ich++){ 
125                 fChamber[ich]->Clear(opt);
126                 delete fChamber[ich]; fChamber[ich] = 0x0;   // I would avoid
127         }       
128         for(Int_t ich=0; ich<kNChambersSector; ich++) fIndex[ich] = -1;
129         fN = 0;
130 }
131
132 //_____________________________________________________________________________
133 AliTRDtrackingChamber* AliTRDtrackingSector::GetChamber(Int_t stack, Int_t plane, Bool_t build)
134 {
135 // Return chamber at position (stack, plane) in current 
136 // sector or build a new one if it is not already created
137         
138         Int_t ch = stack*AliTRDgeometry::kNplan + plane;
139         if(fIndex[ch] >= 0) return fChamber[Int_t(fIndex[ch])];
140         else if(!build) return 0x0;
141         
142         // CHAMBER HAS TO BE BUILD
143         Int_t rch = ch;do rch--; while(rch>=0 && fIndex[rch]<0);
144         fIndex[ch] = rch >=0 ? fIndex[rch]+1 : 0; 
145         fN++;
146         
147         memmove(&fChamber[Int_t(fIndex[ch])+1], &fChamber[Int_t(fIndex[ch])], (kNChambersSector-fIndex[ch]-1)*sizeof(void*));
148         for(Int_t ic = ch+1; ic<kNChambersSector; ic++) fIndex[ic] += fIndex[ic] >= 0 ? 1 : 0;
149         
150         return fChamber[Int_t(fIndex[ch])] = new AliTRDtrackingChamber(AliTRDgeometry::GetDetector(plane, stack, fSector));
151 }
152
153 //_____________________________________________________________________________
154 AliTRDtrackingChamber** AliTRDtrackingSector::GetStack(Int_t stack)
155 {
156 // Return chamber at position (stack, plane) in current 
157 // sector or build a new one if it is not already created
158         
159         if(stack<0 || stack>=AliTRDgeometry::kNcham) return 0x0;
160         
161         Int_t ich, n = 0;
162         for(int ip=0; ip<AliTRDgeometry::kNplan; ip++){
163                 ich = stack*AliTRDgeometry::kNplan + ip;
164                 if(fIndex[ich] < 0) fStack[ip] = 0x0; 
165                 else{
166                         fStack[ip] = fChamber[Int_t(fIndex[ich])];
167                         n++;
168                 }
169         }
170         
171         return n ? &fStack[0] : 0x0;
172 }
173
174 //_____________________________________________________________________________
175 void AliTRDtrackingSector::Print(Option_t *)
176 {
177 // Dump info about this tracking sector and the tracking chamber within
178 // 
179
180         printf("\tSector %2d\n", fSector);
181         for(int ip=0; ip<6; ip++){
182                 for(int is =0; is<5; is++){
183                         Int_t ch = is*AliTRDgeometry::kNplan + ip;
184                         printf("%2d[%2d] ", fIndex[ch], fIndex[ch]>=0 ? fChamber[Int_t(fIndex[ch])]->GetNClusters() : 0);
185                 }
186                 printf("\n");
187         }
188
189 }