]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDtrackingSector.cxx
Tentative version of the new raw-reader class which will handle the online reconstruc...
[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   :fSector(-1)
40   ,fN(0)
41   ,fGeom(0x0)
42 {
43         // Default constructor
44         
45         for(int ic=0; ic<kNChambersSector; ic++){
46                 fChamber[ic] = 0x0;
47                 fIndex[ic]   = -1;
48         }
49         for(int ip=0; ip<AliTRDgeometry::kNplan; ip++) fX0[ip] = 0.;
50 }
51
52 //_____________________________________________________________________________
53 AliTRDtrackingSector::AliTRDtrackingSector(AliTRDgeometry *geo, Int_t gs)
54   :fSector(gs)
55   ,fN(0)
56   ,fGeom(geo)
57 {
58   //
59   // AliTRDtrackingSector Constructor
60   //
61
62         for(int ic=0; ic<kNChambersSector; ic++){
63                 fChamber[ic] = 0x0;
64                 fIndex[ic]   = -1;
65         }
66         for(int ip=0; ip<AliTRDgeometry::kNplan; ip++) fX0[ip] = 0.;
67 }
68
69 //_____________________________________________________________________________
70 AliTRDtrackingSector::AliTRDtrackingSector(const AliTRDtrackingSector &/*t*/)
71   :fSector(-1)
72   ,fN(0)
73   ,fGeom(0x0)
74 {
75   //
76   // Copy constructor
77   //
78
79 }
80
81 //_____________________________________________________________________________
82 AliTRDtrackingSector::~AliTRDtrackingSector()
83 {
84   //
85   // Destructor
86   //
87
88 }
89                 
90 //_____________________________________________________________________________
91 void AliTRDtrackingSector::Init()
92 {               
93 //      Steer building of tracking chambers and build tracking sector.
94 //      Propagate radial position information (calibration/alignment aware) from chambers to sector level
95 //
96         
97         AliTRDtrackingChamber *tc = 0x0; int ic = 0; 
98         while((ic<kNChambersSector) && (tc = fChamber[ic++])) tc->Build(fGeom);
99                 
100         Int_t np;
101         for(int ip=0; ip<AliTRDgeometry::kNplan; ip++){
102                 fX0[ip] = 0.; np = 0;
103                 for(int is=0; is<AliTRDgeometry::kNcham; is++){
104                         Int_t idx = is*AliTRDgeometry::kNplan + ip;
105                         if(fIndex[idx]<0) continue;
106                         tc = GetChamber(fIndex[idx]);
107                         fX0[ip] += tc->GetX(); np++; 
108                 }
109                 if(!np){
110                         //printf("Could not estimate radial position  of plane %d in sector %d.\n", ip, fSector);
111                         continue;
112                 }
113                 fX0[ip] /= Float_t(np);
114         }
115 }
116 //_____________________________________________________________________________
117 void AliTRDtrackingSector::Clear(const Option_t *opt)
118 {
119 // Reset counters and steer chamber clear
120
121         for(Int_t ich=0; ich<fN; ich++){ 
122                 fChamber[ich]->Clear(opt);
123                 delete fChamber[ich]; fChamber[ich] = 0x0;   // I would avoid
124         }       
125         for(Int_t ich=0; ich<kNChambersSector; ich++) fIndex[ich] = -1;
126         fN = 0;
127 }
128
129 //_____________________________________________________________________________
130 AliTRDtrackingChamber* AliTRDtrackingSector::GetChamber(Int_t stack, Int_t plane, Bool_t build)
131 {
132 // Return chamber at position (stack, plane) in current 
133 // sector or build a new one if it is not already created
134         
135         Int_t ch = stack*AliTRDgeometry::kNplan + plane;
136         if(fIndex[ch] >= 0) return fChamber[Int_t(fIndex[ch])];
137         else if(!build) return 0x0;
138         
139         // CHAMBER HAS TO BE BUILD
140         Int_t rch = ch;do rch--; while(rch>=0 && fIndex[rch]<0);
141         fIndex[ch] = rch >=0 ? fIndex[rch]+1 : 0; 
142         fN++;
143         
144         memmove(&fChamber[Int_t(fIndex[ch])+1], &fChamber[Int_t(fIndex[ch])], (kNChambersSector-fIndex[ch]-1)*sizeof(void*));
145         for(Int_t ic = ch+1; ic<kNChambersSector; ic++) fIndex[ic] += fIndex[ic] >= 0 ? 1 : 0;
146         
147         return fChamber[Int_t(fIndex[ch])] = new AliTRDtrackingChamber(AliTRDgeometry::GetDetector(plane, stack, fSector));
148 }
149
150 //_____________________________________________________________________________
151 AliTRDtrackingChamber** AliTRDtrackingSector::GetStack(Int_t stack)
152 {
153 // Return chamber at position (stack, plane) in current 
154 // sector or build a new one if it is not already created
155         
156         if(stack<0 || stack>=AliTRDgeometry::kNcham) return 0x0;
157         
158         Int_t ich, n = 0;
159         for(int ip=0; ip<AliTRDgeometry::kNplan; ip++){
160                 ich = stack*AliTRDgeometry::kNplan + ip;
161                 if(fIndex[ich] < 0) fStack[ip] = 0x0; 
162                 else{
163                         fStack[ip] = fChamber[Int_t(fIndex[ich])];
164                         n++;
165                 }
166         }
167         
168         return n ? &fStack[0] : 0x0;
169 }
170
171 //_____________________________________________________________________________
172 void AliTRDtrackingSector::Print(Option_t *)
173 {
174 // Dump info about this tracking sector and the tracking chamber within
175 // 
176
177         printf("\tSector %2d\n", fSector);
178         for(int ip=0; ip<6; ip++){
179                 for(int is =0; is<5; is++){
180                         Int_t ch = is*AliTRDgeometry::kNplan + ip;
181                         printf("%2d[%2d] ", fIndex[ch], fIndex[ch]>=0 ? fChamber[Int_t(fIndex[ch])]->GetNClusters() : 0);
182                 }
183                 printf("\n");
184         }
185
186 }