]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONHitForRec.cxx
Added switch as new member for DA (Christian)
[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
25 #include "AliMUONHitForRec.h" 
26 #include "AliMUONVCluster.h"
27 #include "AliMUONConstants.h"
28 #include "AliLog.h"
29 #include "TMath.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(AliMUONVCluster* theRawCluster)
57   : TObject(),
58     fBendingCoor(theRawCluster->GetY()),
59     fNonBendingCoor(theRawCluster->GetX()),
60     fZ(0.),
61     fBendingReso2(0.),
62     fNonBendingReso2(0.),
63     fChamberNumber(0),
64     fDetElemId(theRawCluster->GetDetElemId()),
65     fHitNumber(0),
66     fTTRTrack(-1),
67     fTrackRefSignal(-1),
68     fNTrackHits(0)
69 {
70 /// Constructor for AliMUONHitForRec from a raw cluster.
71 /// Fills the bending and non bending coordinates.
72
73   // other fields will be updated in
74   // AliMUONEventReconstructor::AddHitsForRecFromRawClusters,
75   return;
76 }
77
78   //__________________________________________________________________________
79 AliMUONHitForRec::AliMUONHitForRec (const AliMUONHitForRec& theMUONHitForRec)
80   : TObject(theMUONHitForRec),
81     fBendingCoor(theMUONHitForRec.fBendingCoor),
82     fNonBendingCoor(theMUONHitForRec.fNonBendingCoor),
83     fZ(theMUONHitForRec.fZ),
84     fBendingReso2(theMUONHitForRec.fBendingReso2),
85     fNonBendingReso2(theMUONHitForRec.fNonBendingReso2),
86     fChamberNumber(theMUONHitForRec.fChamberNumber),
87     fDetElemId(theMUONHitForRec.fDetElemId),
88     fHitNumber(theMUONHitForRec.fHitNumber),
89     fTTRTrack(theMUONHitForRec.fTTRTrack),
90     fTrackRefSignal(theMUONHitForRec.fTrackRefSignal),
91     fNTrackHits(theMUONHitForRec.fNTrackHits)
92 {
93 /// Copy constructor
94
95 }
96
97   //__________________________________________________________________________
98 AliMUONHitForRec::~AliMUONHitForRec()
99 {
100 /// Destructor
101 }
102
103   //__________________________________________________________________________
104 AliMUONHitForRec & AliMUONHitForRec::operator=(const AliMUONHitForRec& theMUONHitForRec)
105 {
106 /// Assignment operator
107
108   fBendingCoor = theMUONHitForRec.fBendingCoor;
109   fNonBendingCoor = theMUONHitForRec.fNonBendingCoor;
110   fZ = theMUONHitForRec.fZ;
111   fBendingReso2 = theMUONHitForRec.fBendingReso2;
112   fNonBendingReso2 = theMUONHitForRec.fNonBendingReso2;
113   fChamberNumber = theMUONHitForRec.fChamberNumber;
114   fDetElemId = theMUONHitForRec.fDetElemId;
115   fHitNumber = theMUONHitForRec.fHitNumber;
116   fTTRTrack = theMUONHitForRec.fTTRTrack;
117   fTrackRefSignal = theMUONHitForRec.fTrackRefSignal;
118   fNTrackHits = theMUONHitForRec.fNTrackHits;
119   return *this;
120 }
121   //__________________________________________________________________________
122 /*AZ
123 Int_t AliMUONHitForRec::Compare(const TObject* Hit) const
124 {
125   // "Compare" function to sort with increasing chamber number.
126   // Returns -1 (0, +1) if ChamberNumber of current HitForRec
127   // is smaller than (equal to, larger than) ChamberNumber of Hit
128   if (fChamberNumber <  ((AliMUONHitForRec*)Hit)->fChamberNumber) return(-1);
129   else if (fChamberNumber == ((AliMUONHitForRec*)Hit)->fChamberNumber) return( 0);
130   else return(+1);
131 }
132 */
133   //__________________________________________________________________________
134 Int_t AliMUONHitForRec::Compare(const TObject* Hit) const
135 {
136 /// "Compare" function to sort with decreasing Z-coordinate (spectro. MUON z<0).
137 /// Returns 1 (0, -1) if Z-coordinate of current HitForRec
138 /// is smaller than (equal to, larger than) Z-coordinate of Hit
139
140   if (fZ <  ((AliMUONHitForRec*)Hit)->fZ) return(1);
141   else if (fZ == ((AliMUONHitForRec*)Hit)->fZ) return( 0);
142   else return(-1);
143 }
144
145   //__________________________________________________________________________
146 Double_t AliMUONHitForRec::NormalizedChi2WithHitForRec(AliMUONHitForRec* hitForRec, Double_t Sigma2Cut) const
147 {
148 /// Calculate the normalized Chi2 between the current hitForRec (this) and the hitForRec pointed to by "hitForRec",
149 /// i.e. the square deviations between the coordinates, in both the bending and the non bending plane,
150 /// divided by the variance of the same quantities and by "Sigma2Cut".
151 /// Returns 3 if none of the 2 quantities is OK, something smaller than or equal to 2 otherwise.
152 /// Would it be more correct to use a real chi square including the non diagonal term ????
153
154   Double_t chi2, chi2Max, diff, normDiff;
155   chi2 = 0.0;
156   chi2Max = 3.0;
157   // coordinate in bending plane
158   diff = fBendingCoor - hitForRec->fBendingCoor;
159   normDiff = diff * diff / (fBendingReso2 + hitForRec->fBendingReso2) / Sigma2Cut;
160   if (normDiff > 1.0) return chi2Max;
161   chi2 = chi2 + normDiff;
162   // coordinate in non bending plane
163   diff = fNonBendingCoor - hitForRec->fNonBendingCoor;
164   normDiff = diff * diff / (fNonBendingReso2 + hitForRec->fNonBendingReso2) / Sigma2Cut;
165   if (normDiff > 1.0) return chi2Max;
166   chi2 = chi2 + normDiff;
167   return chi2;
168 }
169
170 //______________________________________________________________________________
171 void
172 AliMUONHitForRec::Print(Option_t* /*opt*/) const
173 {
174 /// Printing
175
176   cout << "<AliMUONHitForRec> Coordinates (B,NB,Z) = (" 
177   << setw(8) << setprecision(5) << fBendingCoor
178   << "," << setw(8) << setprecision(5) << fNonBendingCoor << "," 
179   << setw(8) << setprecision(5) << fZ << ") "
180   << "Reso (B,NB)=(" << setw(8) << setprecision(5) << TMath::Sqrt(fBendingReso2) 
181   << "," << setw(8) << setprecision(5) << TMath::Sqrt(fNonBendingReso2)
182   << ") " 
183   << "Number " << setw(3) << fHitNumber 
184   << " within chamber " << setw(3) <<fChamberNumber 
185   << " DE " << setw(4) << fDetElemId
186   << endl;
187 }