]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONHitForRec.cxx
ProcessRun() returns Bool_t and new pure virtual StopRun() added
[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 "AliMUONHitForRec.h" 
24 #include "AliMUONRawCluster.h"
25 #include "AliMUONHit.h"
26
27 ClassImp(AliMUONHitForRec) // Class implementation in ROOT context
28
29   //__________________________________________________________________________
30 AliMUONHitForRec::AliMUONHitForRec()
31   : TObject()
32 {
33  // Default Constructor
34  
35     fFirstTrackHitPtr = 0;
36     fLastTrackHitPtr = 0;
37 }
38
39   //__________________________________________________________________________
40 AliMUONHitForRec::AliMUONHitForRec(AliMUONHit* theGhit)
41   : TObject()
42 {
43   // Constructor for AliMUONHitForRec from a GEANT hit.
44   // Fills the bending, non bending, and Z coordinates,
45   // which are taken from the coordinates of the GEANT hit,
46   // the track number (GEANT and not TH),
47   // and the chamber number (0...).
48   fBendingCoor = theGhit->Y();
49   fNonBendingCoor = theGhit->X();
50   fZ = theGhit->Z();
51   // fTrack = theGhit->fTrack; ?????????
52   fChamberNumber = theGhit->Chamber() - 1;
53   // other fields will be updated in
54   // AliMUONEventReconstructor::NewHitForRecFromGEANT,
55   // except the following ones
56   fIndexOfFirstSegment = -1;
57   fNSegments = 0;
58   fFirstTrackHitPtr = fLastTrackHitPtr = NULL;
59   fNTrackHits = 0;
60   return;
61 }
62
63 //   //__________________________________________________________________________
64 // AliMUONHitForRec::AliMUONHitForRec(AliMUONReconstHit* CathCorrel)
65 // {
66 //   // Constructor for AliMUONHitForRec from a (cathode correlated) raw cluster.
67 //   // Fills the bending and non bending coordinates.
68 //   // Only the first correlation is taken into account.
69 //   // The bending coordinate is taken from the first cathode.
70 //   // The non bending coordinate is taken 
71 //   // from the second cathode if it exists,
72 //   // from the first one otherwise.
73 //   fBendingCoor = CathCorrel->fY[3];
74 //   if (CathCorrel->fCorrelIndex[0] >= 0) fNonBendingCoor = CathCorrel->fX[0];
75 //   else fNonBendingCoor = CathCorrel->fX[3];
76 //   return;
77 // }
78
79   //__________________________________________________________________________
80 AliMUONHitForRec::AliMUONHitForRec(AliMUONRawCluster* theRawCluster)
81   : TObject()
82 {
83   // Constructor for AliMUONHitForRec from a raw cluster.
84   // Fills the bending and non bending coordinates.
85   fNonBendingCoor = theRawCluster->GetX(0);
86   fBendingCoor = theRawCluster->GetY(0);
87   // other fields will be updated in
88   // AliMUONEventReconstructor::AddHitsForRecFromRawClusters,
89   // except the following ones
90   fTHTrack = -1;
91   fGeantSignal = -1;
92   fIndexOfFirstSegment = -1;
93   fNSegments = 0;
94   fFirstTrackHitPtr = fLastTrackHitPtr = NULL;
95   fNTrackHits = 0;
96   return;
97 }
98
99   //__________________________________________________________________________
100 AliMUONHitForRec::AliMUONHitForRec (const AliMUONHitForRec& rhs)
101   : TObject(rhs)
102 {
103 // Protected copy constructor
104
105   Fatal("AliMUONHitForRec", "Not implemented.");
106 }
107
108   //__________________________________________________________________________
109 AliMUONHitForRec & AliMUONHitForRec::operator=(const AliMUONHitForRec& rhs)
110 {
111 // Protected assignement operator
112
113   if (this == &rhs) return *this;
114
115   Fatal("operator=", "Not implemented.");
116     
117   return *this;  
118 }
119   //__________________________________________________________________________
120 /*AZ
121 Int_t AliMUONHitForRec::Compare(const TObject* Hit) const
122 {
123   // "Compare" function to sort with increasing chamber number.
124   // Returns -1 (0, +1) if ChamberNumber of current HitForRec
125   // is smaller than (equal to, larger than) ChamberNumber of Hit
126   if (fChamberNumber <  ((AliMUONHitForRec*)Hit)->fChamberNumber) return(-1);
127   else if (fChamberNumber == ((AliMUONHitForRec*)Hit)->fChamberNumber) return( 0);
128   else return(+1);
129 }
130 */
131   //__________________________________________________________________________
132 Int_t AliMUONHitForRec::Compare(const TObject* Hit) const
133 {
134   // "Compare" function to sort with decreasing Z-coordinate (spectro. MUON z<0).
135   // Returns 1 (0, -1) if Z-coordinate of current HitForRec
136   // is smaller than (equal to, larger than) Z-coordinate of Hit
137   if (fZ <  ((AliMUONHitForRec*)Hit)->fZ) return(1);
138   else if (fZ == ((AliMUONHitForRec*)Hit)->fZ) return( 0);
139   else return(-1);
140 }
141
142   //__________________________________________________________________________
143 Double_t AliMUONHitForRec::NormalizedChi2WithHitForRec(AliMUONHitForRec* hitForRec, Double_t Sigma2Cut) const
144 {
145   // Calculate the normalized Chi2 between the current hitForRec (this)
146   // and the hitForRec pointed to by "hitForRec",
147   // i.e. the square deviations between the coordinates,
148   // in both the bending and the non bending plane,
149   // divided by the variance of the same quantities and by "Sigma2Cut".
150   // Returns 3 if none of the 2 quantities is OK,
151   // something smaller than or equal to 2 otherwise.
152   // Would it be more correct to use a real chi square
153   // including the non diagonal term ????
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 /
160     (fBendingReso2 + hitForRec->fBendingReso2) / Sigma2Cut;
161   if (normDiff > 1.0) return chi2Max;
162   chi2 = chi2 + normDiff;
163   // coordinate in non bending plane
164   diff = fNonBendingCoor - hitForRec->fNonBendingCoor;
165   normDiff = diff * diff /
166     (fNonBendingReso2 + hitForRec->fNonBendingReso2) / Sigma2Cut;
167   if (normDiff > 1.0) return chi2Max;
168   chi2 = chi2 + normDiff;
169   return chi2;
170 }