1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 // ------------------------
19 // Class AliMUONHitForRec
20 // ------------------------
21 // Hit for reconstruction in ALICE dimuon spectrometer
24 #include "AliTrackReference.h"
25 #include "AliMUONHitForRec.h"
26 #include "AliMUONRawCluster.h"
27 #include "AliMUONHit.h"
28 #include "AliMUONConstants.h"
30 #include "Riostream.h"
33 ClassImp(AliMUONHitForRec) // Class implementation in ROOT context
36 //__________________________________________________________________________
37 AliMUONHitForRec::AliMUONHitForRec()
49 fIndexOfFirstSegment(0),
53 /// Default Constructor
57 //__________________________________________________________________________
58 AliMUONHitForRec::AliMUONHitForRec(AliTrackReference* theGhit)
60 fBendingCoor(theGhit->Y()),
61 fNonBendingCoor(theGhit->X()),
70 fIndexOfFirstSegment(-1),
74 /// Constructor for AliMUONHitForRec from a track ref. hit.
75 /// Fills the bending, non bending, and Z coordinates,
76 /// which are taken from the coordinates of the track ref. hit,
77 /// the track number (track ref. and not TH),
78 /// and the chamber number (0...).
80 // fTrack = theGhit->fTrack; ?????????
81 fDetElemId = theGhit->UserId();
82 if (fDetElemId) fChamberNumber = fDetElemId / 100 - 1;
83 else fChamberNumber = AliMUONConstants::ChamberNumber(fZ);
84 // other fields will be updated in
85 // AliMUONEventReconstructor::NewHitForRecFromTrackRef
89 // //__________________________________________________________________________
90 // AliMUONHitForRec::AliMUONHitForRec(AliMUONReconstHit* CathCorrel)
92 // // Constructor for AliMUONHitForRec from a (cathode correlated) raw cluster.
93 // // Fills the bending and non bending coordinates.
94 // // Only the first correlation is taken into account.
95 // // The bending coordinate is taken from the first cathode.
96 // // The non bending coordinate is taken
97 // // from the second cathode if it exists,
98 // // from the first one otherwise.
99 // fBendingCoor = CathCorrel->fY[3];
100 // if (CathCorrel->fCorrelIndex[0] >= 0) fNonBendingCoor = CathCorrel->fX[0];
101 // else fNonBendingCoor = CathCorrel->fX[3];
105 //__________________________________________________________________________
106 AliMUONHitForRec::AliMUONHitForRec(AliMUONRawCluster* theRawCluster)
108 fBendingCoor(theRawCluster->GetY(0)),
109 fNonBendingCoor(theRawCluster->GetX(0)),
112 fNonBendingReso2(0.),
114 fDetElemId(theRawCluster->GetDetElemId()),
118 fIndexOfFirstSegment(-1),
122 /// Constructor for AliMUONHitForRec from a raw cluster.
123 /// Fills the bending and non bending coordinates.
125 // other fields will be updated in
126 // AliMUONEventReconstructor::AddHitsForRecFromRawClusters,
130 //__________________________________________________________________________
131 AliMUONHitForRec::AliMUONHitForRec (const AliMUONHitForRec& theMUONHitForRec)
132 : TObject(theMUONHitForRec),
133 fBendingCoor(theMUONHitForRec.fBendingCoor),
134 fNonBendingCoor(theMUONHitForRec.fNonBendingCoor),
135 fZ(theMUONHitForRec.fZ),
136 fBendingReso2(theMUONHitForRec.fBendingReso2),
137 fNonBendingReso2(theMUONHitForRec.fNonBendingReso2),
138 fChamberNumber(theMUONHitForRec.fChamberNumber),
139 fDetElemId(theMUONHitForRec.fDetElemId),
140 fHitNumber(theMUONHitForRec.fHitNumber),
141 fTTRTrack(theMUONHitForRec.fTTRTrack),
142 fTrackRefSignal(theMUONHitForRec.fTrackRefSignal),
143 fIndexOfFirstSegment(theMUONHitForRec.fIndexOfFirstSegment),
144 fNSegments(theMUONHitForRec.fNSegments),
145 fNTrackHits(theMUONHitForRec.fNTrackHits)
151 //__________________________________________________________________________
152 AliMUONHitForRec & AliMUONHitForRec::operator=(const AliMUONHitForRec& theMUONHitForRec)
154 /// Assignment operator
156 fBendingCoor = theMUONHitForRec.fBendingCoor;
157 fNonBendingCoor = theMUONHitForRec.fNonBendingCoor;
158 fZ = theMUONHitForRec.fZ;
159 fBendingReso2 = theMUONHitForRec.fBendingReso2;
160 fNonBendingReso2 = theMUONHitForRec.fNonBendingReso2;
161 fChamberNumber = theMUONHitForRec.fChamberNumber;
162 fDetElemId = theMUONHitForRec.fDetElemId;
163 fHitNumber = theMUONHitForRec.fHitNumber;
164 fTTRTrack = theMUONHitForRec.fTTRTrack;
165 fTrackRefSignal = theMUONHitForRec.fTrackRefSignal;
166 fIndexOfFirstSegment = theMUONHitForRec.fIndexOfFirstSegment;
167 fNSegments = theMUONHitForRec.fNSegments;
168 fNTrackHits = theMUONHitForRec.fNTrackHits;
171 //__________________________________________________________________________
173 Int_t AliMUONHitForRec::Compare(const TObject* Hit) const
175 // "Compare" function to sort with increasing chamber number.
176 // Returns -1 (0, +1) if ChamberNumber of current HitForRec
177 // is smaller than (equal to, larger than) ChamberNumber of Hit
178 if (fChamberNumber < ((AliMUONHitForRec*)Hit)->fChamberNumber) return(-1);
179 else if (fChamberNumber == ((AliMUONHitForRec*)Hit)->fChamberNumber) return( 0);
183 //__________________________________________________________________________
184 Int_t AliMUONHitForRec::Compare(const TObject* Hit) const
186 /// "Compare" function to sort with decreasing Z-coordinate (spectro. MUON z<0).
187 /// Returns 1 (0, -1) if Z-coordinate of current HitForRec
188 /// is smaller than (equal to, larger than) Z-coordinate of Hit
190 if (fZ < ((AliMUONHitForRec*)Hit)->fZ) return(1);
191 else if (fZ == ((AliMUONHitForRec*)Hit)->fZ) return( 0);
195 //__________________________________________________________________________
196 Double_t AliMUONHitForRec::NormalizedChi2WithHitForRec(AliMUONHitForRec* hitForRec, Double_t Sigma2Cut) const
198 /// Calculate the normalized Chi2 between the current hitForRec (this)
199 /// and the hitForRec pointed to by "hitForRec",
200 /// i.e. the square deviations between the coordinates,
201 /// in both the bending and the non bending plane,
202 /// divided by the variance of the same quantities and by "Sigma2Cut".
203 /// Returns 3 if none of the 2 quantities is OK,
204 /// something smaller than or equal to 2 otherwise.
205 /// Would it be more correct to use a real chi square
206 /// including the non diagonal term ????
208 Double_t chi2, chi2Max, diff, normDiff;
211 // coordinate in bending plane
212 diff = fBendingCoor - hitForRec->fBendingCoor;
213 normDiff = diff * diff /
214 (fBendingReso2 + hitForRec->fBendingReso2) / Sigma2Cut;
215 if (normDiff > 1.0) return chi2Max;
216 chi2 = chi2 + normDiff;
217 // coordinate in non bending plane
218 diff = fNonBendingCoor - hitForRec->fNonBendingCoor;
219 normDiff = diff * diff /
220 (fNonBendingReso2 + hitForRec->fNonBendingReso2) / Sigma2Cut;
221 if (normDiff > 1.0) return chi2Max;
222 chi2 = chi2 + normDiff;
226 //______________________________________________________________________________
228 AliMUONHitForRec::Print(Option_t* /*opt*/) const
232 cout << "<AliMUONHitForRec> Coordinates (B,NB,Z) = ("
233 << setw(8) << setprecision(5) << fBendingCoor
234 << "," << setw(8) << setprecision(5) << fNonBendingCoor << ","
235 << setw(8) << setprecision(5) << fZ << ") "
236 << "Reso (B,NB)=(" << setw(8) << setprecision(5) << TMath::Sqrt(fBendingReso2)
237 << "," << setw(8) << setprecision(5) << TMath::Sqrt(fNonBendingReso2)
239 << "Number " << setw(3) << fHitNumber
240 << " within chamber " << setw(3) <<fChamberNumber
241 << " DE " << setw(4) << fDetElemId