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