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