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