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