]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSRecPoint.cxx
Coverity warnings
[u/mrichter/AliRoot.git] / ITS / AliITSRecPoint.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$ */
17
18 ///////////////////////////////////////////////////////////////////////////////
19 //  Reconstructed space point class for set:ITS   
20 //  Reconstructed points are expressed simultaneously in two different 
21 //  reference frames, both differing from the global system.
22 //  The first is referred to the sensor (see AliITSsegmentation for the
23 //  definition) and each point is represented by two coordinates: fXloc and
24 //  fZloc. This system in the code is referred to as "local"
25 //  The second is used for tracking (V2, SA and MI versions) and the X axis 
26 //  represents the radial coordinate (this system is, in the bending plane, 
27 //  a rotated system w.r.t. the global reference system). 
28 //  Each reaconstructed point is represented by two coordinates: fY and fZ, 
29 //  inherited from AliCluster. This system in the code is referred to as 
30 //  "trackingV2".
31 ///////////////////////////////////////////////////////////////////////////////
32
33 #include <TGeoMatrix.h>
34 #include "AliITSRecPoint.h"
35 #include "AliAlignObj.h"
36
37 ClassImp(AliITSRecPoint)
38
39 //_____________________________________________________________
40 AliITSRecPoint::AliITSRecPoint(): 
41 AliCluster(),
42 fXloc(0),
43 fZloc(0),
44 fdEdX(0),
45 fIndex(0),
46 fQ(0),
47 fLayer(0),
48 fNz(0),
49 fNy(0),
50 fChargeRatio(0),
51 fType(0),
52 fDeltaProb(0),
53 fDriftTime(0.),
54 fDriftSide(0)
55 {
56     // default constructor
57 }
58
59 //________________________________________________________________________
60 AliITSRecPoint::AliITSRecPoint(Int_t *lab,Float_t *hit, Int_t *info, Bool_t local):
61 AliCluster(AliGeomManager::LayerToVolUID((info[2]+AliGeomManager::kSPD1),lab[3]&0x3FF),hit,0,0,lab),
62 fXloc(0),
63 fZloc(0),
64 fdEdX(0),
65 fIndex(lab[3]),
66 fQ(hit[4]),
67 fLayer(info[2]),
68 fNz(info[1]),
69 fNy(info[0]),
70 fChargeRatio(0),
71 fType(0),
72 fDeltaProb(0),
73 fDriftTime(0.),
74 fDriftSide(0)
75 {
76   //standard constructor used in AliITSClusterFinderV2
77
78   if (!local) { // Cluster V2
79     Double_t txyz[3] = {GetX(), GetY(), GetZ()};
80     Double_t lxyz[3] = {0, 0, 0};
81     GetTracking2LocalMatrix()->LocalToMaster(txyz,lxyz);
82     fXloc = lxyz[0]; fZloc = lxyz[2];
83     if(fLayer==4) hit[5]=-hit[5];
84     if( (fLayer==4) || (fLayer==5) ) SetSigmaYZ(hit[5]); 
85   }
86   else {
87     switch (fLayer) {
88     case 0:
89     case 1:
90       fdEdX = 0;
91       break;
92     case 2:
93     case 3:
94       fdEdX=fQ*1e-6;
95       break;
96     case 4:
97       fdEdX=fQ*2.16;
98       SetSigmaYZ(hit[5]);
99       break;
100     case 5:
101       fdEdX=fQ*2.16;
102       hit[5]=-hit[5];
103       SetSigmaYZ(hit[5]);
104       break;
105     default:
106       AliError(Form("Wrong ITS layer %d (0 -> 5)",fLayer));
107       break;
108     }
109     fXloc = hit[0];
110     fZloc = hit[1];
111     Double_t lxyz[3] = {fXloc, 0, fZloc};
112     Double_t txyz[3] = {0, 0, 0};
113     GetTracking2LocalMatrix()->MasterToLocal(lxyz,txyz);
114
115     SetX(0.); SetY(txyz[1]); SetZ(txyz[2]);
116
117   }
118
119 }
120
121 //_______________________________________________________________________
122 AliITSRecPoint::AliITSRecPoint(const AliITSRecPoint& pt):
123   AliCluster(pt),
124   fXloc(pt.fXloc),
125   fZloc(pt.fZloc),
126   fdEdX(pt.fdEdX),
127   fIndex(pt.fIndex),
128   fQ(pt.fQ),
129   fLayer(pt.fLayer),
130   fNz(pt.fNz),
131   fNy(pt.fNy),
132   fChargeRatio(pt.fChargeRatio),
133   fType(pt.fType),
134   fDeltaProb(pt.fDeltaProb),
135   fDriftTime(pt.fDriftTime),
136   fDriftSide(pt.fDriftSide)
137 {
138   //Copy constructor
139
140 }
141
142 //______________________________________________________________________
143 AliITSRecPoint& AliITSRecPoint::operator=(const AliITSRecPoint& source){
144   // Assignment operator
145
146   this->~AliITSRecPoint();
147   new(this) AliITSRecPoint(source);
148   return *this;
149
150 }
151
152 //----------------------------------------------------------------------
153 void AliITSRecPoint::Print(ostream *os){
154     ////////////////////////////////////////////////////////////////////////
155     // Standard output format for this class.
156     ////////////////////////////////////////////////////////////////////////
157 #if defined __GNUC__
158 #if __GNUC__ > 2
159     ios::fmtflags fmt;
160 #else
161     Int_t fmt;
162 #endif
163 #else
164 #if defined __ICC || defined __ECC || defined __xlC__
165     ios::fmtflags fmt;
166 #else
167     Int_t fmt;
168 #endif
169 #endif
170  
171     fmt = os->setf(ios::fixed);  // set fixed floating point output
172     *os << GetLabel(0) << " " << GetLabel(1) << " " << GetLabel(2) << " ";
173     fmt = os->setf(ios::scientific); // set scientific for dEdX.
174     *os << GetX() <<" " << GetY() << " " << GetZ() << " " ;
175     *os << GetSigmaY2() << " " << GetSigmaZ2() << " " << GetSigmaYZ() << " ";
176     fmt = os->setf(ios::fixed);
177     *os << GetVolumeId() << " "<< Misalign() /*fIsMisaligned*/ << " ";
178     fmt = os->setf(ios::scientific); // set scientific for dEdX.
179     *os << fXloc << " " << fZloc << " " << fdEdX << " ";
180     fmt = os->setf(ios::fixed); // every fixed
181     *os << fIndex <<" " << fQ << " "<<fLayer <<" "<<fNz<<" "<<fNy<<" ";
182     *os << fChargeRatio<<" " << fType << " " << fDeltaProb << " " << fDriftTime<< " " << fDriftSide;
183     os->flags(fmt); // reset back to old formating.
184     return;
185 }
186
187 //----------------------------------------------------------------------
188 Int_t AliITSRecPoint::GetNpixels() const {
189 //
190 // returns the number of pixels used for the SPD clusters
191 //
192
193  if(fLayer > 1) return -1;
194  else return fType;
195
196 }
197
198 //----------------------------------------------------------------------
199 Int_t AliITSRecPoint::GetSPDclusterType() const {
200 //
201 // returns an Int_t with encoded information on cluster size
202 //    type <= 16: cluster type identifier according to conventional numbering
203 //    type >  16: Npixels+1000*Ny+1000000*Nz
204 //
205
206  Int_t type = -1;
207  if(fLayer > 1) return type;
208  else {
209
210    switch (fType) {
211      case 1 : type = 1 ;break;
212      case 2 : if(fNy == 2) type = 2;
213               else         type = 3;
214               break;
215      case 3 : if(fNy == 3)      type = 4;
216               else if(fNz == 3) type = 6;
217               else              type = 5;
218               break;
219      case 4 : if(fNz == 1)                  type = 7;
220               else if(fNz == 2 && fNy == 2) type = 8;
221               else if(fNy == 2 && fNz == 3) type = 11;
222               else if(fNy == 3 && fNz == 2) type = 9;
223               else                          type = 15;
224               break;
225      case 5 : if(fNy == 3 && fNz == 2)  type = 10;
226               if(fNy == 2 && fNz == 3 ) type = 12;
227               if(fNy == 5)              type = 16;
228               else                      type = fType+1000*fNy+1000000*fNz;
229               break; 
230      case 6 : if(fNy ==3 && fNz == 2) type = 13;
231               if(fNy ==2 && fNz == 3) type = 14;
232               else                    type = fType+1000*fNy+1000000*fNz;
233               break; 
234      default: type = fType+1000*fNy+1000000*fNz;
235               break; 
236    }  
237
238    return type;
239  }
240 }
241
242 //----------------------------------------------------------------------
243 Int_t AliITSRecPoint::GetSDDclusterType() const {
244 // returns an Int_t with encoded information on cluster size
245 // Byte1 = fNz Byte0=fNy, other two bytes empty for extra information
246 // max. allowed cluster size = 255
247   Int_t typ=(fNz&0xFF)<<8;
248   typ+=fNy&0xFF;
249   if(fDriftSide==1) typ+=1<<16;
250   return typ;
251 }
252 //----------------------------------------------------------------------
253 void  AliITSRecPoint::DecodeSDDclusterType(Int_t cluType, Int_t &cluSizAn, Int_t& cluSizTb, Int_t &drSide){
254 // Extract cluster sizes and drift side from cluster type 
255   cluSizTb=cluType&0xFF;
256   cluSizAn=(cluType>>8)&0xFF;
257   drSide=(cluType>>16);
258   return;
259 }
260 //----------------------------------------------------------------------
261 Int_t AliITSRecPoint::GetSSDclusterType() const {
262 // returns an Int_t with encoded information on cluster size
263 // Byte1 = fNz Byte0=fNy, other two bytes empty for extra information
264 // max. allowed cluster size = 255
265   Int_t typ=(fNz&0xFF)<<8;
266   typ+=fNy&0xFF;
267   return typ;
268 }
269
270 //----------------------------------------------------------------------
271 void AliITSRecPoint::Read(istream *is){
272 ////////////////////////////////////////////////////////////////////////
273 // Standard input format for this class.
274 ////////////////////////////////////////////////////////////////////////
275     Bool_t mis;
276     Int_t lab[4];
277     Float_t hit[6];
278     lab[3] = 0; // ??
279     *is >> lab[0] >> lab[1] >> lab[2];
280     SetLabel(lab[0],0); SetLabel(lab[1],1); SetLabel(lab[2],2);
281     *is >> hit[0] >> hit[1] >> hit[2] >> hit[3] >> hit[4] >> hit[5];
282     SetX(hit[0]);SetY(hit[1]);SetZ(hit[2]);SetSigmaY2(hit[3]);
283     SetSigmaZ2(hit[4]);//fSigmaYZ=hit[5];
284     *is >> lab[0] >> mis;
285     SetVolumeId(lab[0]);// fIsMisalinged = mis;
286     *is >> fXloc >> fZloc >> fdEdX;
287     *is >> fIndex >> fQ >> fLayer >> fNz >> fNy >> fChargeRatio >> fType;
288     *is >> fDeltaProb >> fDriftTime >> fDriftSide;
289
290     return;
291 }
292 //----------------------------------------------------------------------
293 ostream &operator<<(ostream &os,AliITSRecPoint &p){
294 ////////////////////////////////////////////////////////////////////////
295 // Standard output streaming function.
296 ////////////////////////////////////////////////////////////////////////
297  
298     p.Print(&os);
299     return os;
300 }
301 //----------------------------------------------------------------------
302 istream &operator>>(istream &is,AliITSRecPoint &r){
303 ////////////////////////////////////////////////////////////////////////
304 // Standard input streaming function.
305 ////////////////////////////////////////////////////////////////////////
306  
307     r.Read(&is);
308     return is;
309 }
310 //----------------------------------------------------------------------