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