]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONHitForRec.cxx
Cleanuo Effc++ warnings (Sasha)
[u/mrichter/AliRoot.git] / MUON / AliMUONHitForRec.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 // Class AliMUONHitForRec
20 // ------------------------
21 // Hit for reconstruction in ALICE dimuon spectrometer
22 // Author: J. Gosset
23
24 #include "AliTrackReference.h" 
25 #include "AliMUONHitForRec.h" 
26 #include "AliMUONRawCluster.h"
27 #include "AliMUONHit.h"
28 #include "AliMUONConstants.h"
29 #include "AliLog.h"
30
31 ClassImp(AliMUONHitForRec) // Class implementation in ROOT context
32
33   //__________________________________________________________________________
34 AliMUONHitForRec::AliMUONHitForRec()
35   : TObject(),
36     fBendingCoor(0.),
37     fNonBendingCoor(0.),
38     fZ(0.),
39     fBendingReso2(0.),
40     fNonBendingReso2(0.),
41     fChamberNumber(0),
42     fDetElemId(0),
43     fHitNumber(0),
44     fTTRTrack(0),
45     fTrackRefSignal(0),
46     fIndexOfFirstSegment(0),
47     fNSegments(0),
48     fFirstTrackHitPtr(0x0),
49     fLastTrackHitPtr(0x0),
50     fNTrackHits(0)
51 {
52 /// Default Constructor
53  
54 }
55
56   //__________________________________________________________________________
57 AliMUONHitForRec::AliMUONHitForRec(AliTrackReference* theGhit)
58   : TObject(),
59     fBendingCoor(theGhit->Y()),
60     fNonBendingCoor(theGhit->X()),
61     fZ(theGhit->Z()),
62     fBendingReso2(0.),
63     fNonBendingReso2(0.),
64     fChamberNumber(0),
65     fDetElemId(0),
66     fHitNumber(0),
67     fTTRTrack(0),
68     fTrackRefSignal(0),
69     fIndexOfFirstSegment(-1),
70     fNSegments(0),
71     fFirstTrackHitPtr(0x0),
72     fLastTrackHitPtr(0x0),
73     fNTrackHits(0)
74 {
75 /// Constructor for AliMUONHitForRec from a track ref. hit.
76 /// Fills the bending, non bending, and Z coordinates,
77 /// which are taken from the coordinates of the track ref. hit,
78 /// the track number (track ref. and not TH),
79 /// and the chamber number (0...).
80
81   // fTrack = theGhit->fTrack; ?????????
82   fDetElemId = theGhit->UserId();
83   if (fDetElemId) fChamberNumber = fDetElemId / 100 - 1;
84   else fChamberNumber = AliMUONConstants::ChamberNumber(fZ);
85   // other fields will be updated in
86   // AliMUONEventReconstructor::NewHitForRecFromTrackRef
87   return;
88 }
89
90 //   //__________________________________________________________________________
91 // AliMUONHitForRec::AliMUONHitForRec(AliMUONReconstHit* CathCorrel)
92 // {
93 //   // Constructor for AliMUONHitForRec from a (cathode correlated) raw cluster.
94 //   // Fills the bending and non bending coordinates.
95 //   // Only the first correlation is taken into account.
96 //   // The bending coordinate is taken from the first cathode.
97 //   // The non bending coordinate is taken 
98 //   // from the second cathode if it exists,
99 //   // from the first one otherwise.
100 //   fBendingCoor = CathCorrel->fY[3];
101 //   if (CathCorrel->fCorrelIndex[0] >= 0) fNonBendingCoor = CathCorrel->fX[0];
102 //   else fNonBendingCoor = CathCorrel->fX[3];
103 //   return;
104 // }
105
106   //__________________________________________________________________________
107 AliMUONHitForRec::AliMUONHitForRec(AliMUONRawCluster* theRawCluster)
108   : TObject(),
109     fBendingCoor(theRawCluster->GetY(0)),
110     fNonBendingCoor(theRawCluster->GetX(0)),
111     fZ(0.),
112     fBendingReso2(0.),
113     fNonBendingReso2(0.),
114     fChamberNumber(0),
115     fDetElemId(theRawCluster->GetDetElemId()),
116     fHitNumber(0),
117     fTTRTrack(-1),
118     fTrackRefSignal(-1),
119     fIndexOfFirstSegment(-1),
120     fNSegments(0),
121     fFirstTrackHitPtr(0x0),
122     fLastTrackHitPtr(0x0),
123     fNTrackHits(0)
124 {
125 /// Constructor for AliMUONHitForRec from a raw cluster.
126 /// Fills the bending and non bending coordinates.
127
128   // other fields will be updated in
129   // AliMUONEventReconstructor::AddHitsForRecFromRawClusters,
130   return;
131 }
132
133   //__________________________________________________________________________
134 AliMUONHitForRec::AliMUONHitForRec (const AliMUONHitForRec& theMUONHitForRec)
135   : TObject(theMUONHitForRec),
136     fBendingCoor(theMUONHitForRec.fBendingCoor),
137     fNonBendingCoor(theMUONHitForRec.fNonBendingCoor),
138     fZ(theMUONHitForRec.fZ),
139     fBendingReso2(theMUONHitForRec.fBendingReso2),
140     fNonBendingReso2(theMUONHitForRec.fNonBendingReso2),
141     fChamberNumber(theMUONHitForRec.fChamberNumber),
142     fDetElemId(theMUONHitForRec.fDetElemId),
143     fHitNumber(theMUONHitForRec.fHitNumber),
144     fTTRTrack(theMUONHitForRec.fTTRTrack),
145     fTrackRefSignal(theMUONHitForRec.fTrackRefSignal),
146     fIndexOfFirstSegment(theMUONHitForRec.fIndexOfFirstSegment),
147     fNSegments(theMUONHitForRec.fNSegments),
148     fFirstTrackHitPtr(theMUONHitForRec.fFirstTrackHitPtr),
149     fLastTrackHitPtr(theMUONHitForRec.fLastTrackHitPtr),
150     fNTrackHits(theMUONHitForRec.fNTrackHits)
151 {
152 /// Copy constructor
153
154 }
155
156   //__________________________________________________________________________
157 AliMUONHitForRec & AliMUONHitForRec::operator=(const AliMUONHitForRec& theMUONHitForRec)
158 {
159 /// Assignment operator
160
161   fBendingCoor = theMUONHitForRec.fBendingCoor;
162   fNonBendingCoor = theMUONHitForRec.fNonBendingCoor;
163   fZ = theMUONHitForRec.fZ;
164   fBendingReso2 = theMUONHitForRec.fBendingReso2;
165   fNonBendingReso2 = theMUONHitForRec.fNonBendingReso2;
166   fChamberNumber = theMUONHitForRec.fChamberNumber;
167   fDetElemId = theMUONHitForRec.fDetElemId;
168   fHitNumber = theMUONHitForRec.fHitNumber;
169   fTTRTrack = theMUONHitForRec.fTTRTrack;
170   fTrackRefSignal = theMUONHitForRec.fTrackRefSignal;
171   fIndexOfFirstSegment = theMUONHitForRec.fIndexOfFirstSegment;
172   fNSegments = theMUONHitForRec.fNSegments;
173   fFirstTrackHitPtr = theMUONHitForRec.fFirstTrackHitPtr;
174   fLastTrackHitPtr = theMUONHitForRec.fLastTrackHitPtr;
175   fNTrackHits = theMUONHitForRec.fNTrackHits;
176   return *this;
177 }
178   //__________________________________________________________________________
179 /*AZ
180 Int_t AliMUONHitForRec::Compare(const TObject* Hit) const
181 {
182   // "Compare" function to sort with increasing chamber number.
183   // Returns -1 (0, +1) if ChamberNumber of current HitForRec
184   // is smaller than (equal to, larger than) ChamberNumber of Hit
185   if (fChamberNumber <  ((AliMUONHitForRec*)Hit)->fChamberNumber) return(-1);
186   else if (fChamberNumber == ((AliMUONHitForRec*)Hit)->fChamberNumber) return( 0);
187   else return(+1);
188 }
189 */
190   //__________________________________________________________________________
191 Int_t AliMUONHitForRec::Compare(const TObject* Hit) const
192 {
193 /// "Compare" function to sort with decreasing Z-coordinate (spectro. MUON z<0).
194 /// Returns 1 (0, -1) if Z-coordinate of current HitForRec
195 /// is smaller than (equal to, larger than) Z-coordinate of Hit
196
197   if (fZ <  ((AliMUONHitForRec*)Hit)->fZ) return(1);
198   else if (fZ == ((AliMUONHitForRec*)Hit)->fZ) return( 0);
199   else return(-1);
200 }
201
202   //__________________________________________________________________________
203 Double_t AliMUONHitForRec::NormalizedChi2WithHitForRec(AliMUONHitForRec* hitForRec, Double_t Sigma2Cut) const
204 {
205 /// Calculate the normalized Chi2 between the current hitForRec (this)
206 /// and the hitForRec pointed to by "hitForRec",
207 /// i.e. the square deviations between the coordinates,
208 /// in both the bending and the non bending plane,
209 /// divided by the variance of the same quantities and by "Sigma2Cut".
210 /// Returns 3 if none of the 2 quantities is OK,
211 /// something smaller than or equal to 2 otherwise.
212 /// Would it be more correct to use a real chi square
213 /// including the non diagonal term ????
214
215   Double_t chi2, chi2Max, diff, normDiff;
216   chi2 = 0.0;
217   chi2Max = 3.0;
218   // coordinate in bending plane
219   diff = fBendingCoor - hitForRec->fBendingCoor;
220   normDiff = diff * diff /
221     (fBendingReso2 + hitForRec->fBendingReso2) / Sigma2Cut;
222   if (normDiff > 1.0) return chi2Max;
223   chi2 = chi2 + normDiff;
224   // coordinate in non bending plane
225   diff = fNonBendingCoor - hitForRec->fNonBendingCoor;
226   normDiff = diff * diff /
227     (fNonBendingReso2 + hitForRec->fNonBendingReso2) / Sigma2Cut;
228   if (normDiff > 1.0) return chi2Max;
229   chi2 = chi2 + normDiff;
230   return chi2;
231 }