]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONHitForRec.cxx
- Remove double declaration in Digitizer
[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   // other fields will be updated in
57   // AliMUONEventReconstructor::NewHitForRecFromTrackRef,
58   // except the following ones
59   fIndexOfFirstSegment = -1;
60   fNSegments = 0;
61   fFirstTrackHitPtr = fLastTrackHitPtr = NULL;
62   fNTrackHits = 0;
63   return;
64 }
65
66 //   //__________________________________________________________________________
67 // AliMUONHitForRec::AliMUONHitForRec(AliMUONReconstHit* CathCorrel)
68 // {
69 //   // Constructor for AliMUONHitForRec from a (cathode correlated) raw cluster.
70 //   // Fills the bending and non bending coordinates.
71 //   // Only the first correlation is taken into account.
72 //   // The bending coordinate is taken from the first cathode.
73 //   // The non bending coordinate is taken 
74 //   // from the second cathode if it exists,
75 //   // from the first one otherwise.
76 //   fBendingCoor = CathCorrel->fY[3];
77 //   if (CathCorrel->fCorrelIndex[0] >= 0) fNonBendingCoor = CathCorrel->fX[0];
78 //   else fNonBendingCoor = CathCorrel->fX[3];
79 //   return;
80 // }
81
82   //__________________________________________________________________________
83 AliMUONHitForRec::AliMUONHitForRec(AliMUONRawCluster* theRawCluster)
84   : TObject()
85 {
86   // Constructor for AliMUONHitForRec from a raw cluster.
87   // Fills the bending and non bending coordinates.
88   fNonBendingCoor = theRawCluster->GetX(0);
89   fBendingCoor = theRawCluster->GetY(0);
90   // other fields will be updated in
91   // AliMUONEventReconstructor::AddHitsForRecFromRawClusters,
92   // except the following ones
93   fTTRTrack = -1;
94   fTrackRefSignal = -1;
95   fIndexOfFirstSegment = -1;
96   fNSegments = 0;
97   fFirstTrackHitPtr = fLastTrackHitPtr = NULL;
98   fNTrackHits = 0;
99   return;
100 }
101
102   //__________________________________________________________________________
103 AliMUONHitForRec::AliMUONHitForRec (const AliMUONHitForRec& theMUONHitForRec)
104   :  TObject(theMUONHitForRec)
105 {
106   fBendingCoor = theMUONHitForRec.fBendingCoor;
107   fNonBendingCoor = theMUONHitForRec.fNonBendingCoor;
108   fZ = theMUONHitForRec.fZ;
109   fBendingReso2 = theMUONHitForRec.fBendingReso2;
110   fNonBendingReso2 = theMUONHitForRec.fNonBendingReso2;
111   fChamberNumber = theMUONHitForRec.fChamberNumber;
112   fHitNumber = theMUONHitForRec.fHitNumber;
113   fTTRTrack = theMUONHitForRec.fTTRTrack;
114   fTrackRefSignal = theMUONHitForRec.fTrackRefSignal;
115   fIndexOfFirstSegment = theMUONHitForRec.fIndexOfFirstSegment;
116   fNSegments = theMUONHitForRec.fNSegments;
117   fFirstTrackHitPtr = theMUONHitForRec.fFirstTrackHitPtr;
118   fLastTrackHitPtr = theMUONHitForRec.fLastTrackHitPtr;
119   fNTrackHits = theMUONHitForRec.fNTrackHits;
120
121 }
122
123   //__________________________________________________________________________
124 AliMUONHitForRec & AliMUONHitForRec::operator=(const AliMUONHitForRec& theMUONHitForRec)
125 {
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   fHitNumber = theMUONHitForRec.fHitNumber;
133   fTTRTrack = theMUONHitForRec.fTTRTrack;
134   fTrackRefSignal = theMUONHitForRec.fTrackRefSignal;
135   fIndexOfFirstSegment = theMUONHitForRec.fIndexOfFirstSegment;
136   fNSegments = theMUONHitForRec.fNSegments;
137   fFirstTrackHitPtr = theMUONHitForRec.fFirstTrackHitPtr;
138   fLastTrackHitPtr = theMUONHitForRec.fLastTrackHitPtr;
139   fNTrackHits = theMUONHitForRec.fNTrackHits;
140
141   return *this;
142 }
143   //__________________________________________________________________________
144 /*AZ
145 Int_t AliMUONHitForRec::Compare(const TObject* Hit) const
146 {
147   // "Compare" function to sort with increasing chamber number.
148   // Returns -1 (0, +1) if ChamberNumber of current HitForRec
149   // is smaller than (equal to, larger than) ChamberNumber of Hit
150   if (fChamberNumber <  ((AliMUONHitForRec*)Hit)->fChamberNumber) return(-1);
151   else if (fChamberNumber == ((AliMUONHitForRec*)Hit)->fChamberNumber) return( 0);
152   else return(+1);
153 }
154 */
155   //__________________________________________________________________________
156 Int_t AliMUONHitForRec::Compare(const TObject* Hit) const
157 {
158   // "Compare" function to sort with decreasing Z-coordinate (spectro. MUON z<0).
159   // Returns 1 (0, -1) if Z-coordinate of current HitForRec
160   // is smaller than (equal to, larger than) Z-coordinate of Hit
161   if (fZ <  ((AliMUONHitForRec*)Hit)->fZ) return(1);
162   else if (fZ == ((AliMUONHitForRec*)Hit)->fZ) return( 0);
163   else return(-1);
164 }
165
166   //__________________________________________________________________________
167 Double_t AliMUONHitForRec::NormalizedChi2WithHitForRec(AliMUONHitForRec* hitForRec, Double_t Sigma2Cut) const
168 {
169   // Calculate the normalized Chi2 between the current hitForRec (this)
170   // and the hitForRec pointed to by "hitForRec",
171   // i.e. the square deviations between the coordinates,
172   // in both the bending and the non bending plane,
173   // divided by the variance of the same quantities and by "Sigma2Cut".
174   // Returns 3 if none of the 2 quantities is OK,
175   // something smaller than or equal to 2 otherwise.
176   // Would it be more correct to use a real chi square
177   // including the non diagonal term ????
178   Double_t chi2, chi2Max, diff, normDiff;
179   chi2 = 0.0;
180   chi2Max = 3.0;
181   // coordinate in bending plane
182   diff = fBendingCoor - hitForRec->fBendingCoor;
183   normDiff = diff * diff /
184     (fBendingReso2 + hitForRec->fBendingReso2) / Sigma2Cut;
185   if (normDiff > 1.0) return chi2Max;
186   chi2 = chi2 + normDiff;
187   // coordinate in non bending plane
188   diff = fNonBendingCoor - hitForRec->fNonBendingCoor;
189   normDiff = diff * diff /
190     (fNonBendingReso2 + hitForRec->fNonBendingReso2) / Sigma2Cut;
191   if (normDiff > 1.0) return chi2Max;
192   chi2 = chi2 + normDiff;
193   return chi2;
194 }