Correcting MUONGenerateGeometryData.C macro description
[u/mrichter/AliRoot.git] / MUON / AliMUONHitForRec.cxx
CommitLineData
a9e2aefa 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
88cb7938 16/* $Id$ */
a9e2aefa 17
18//__________________________________________________________________________
19//
20// Hit for reconstruction in ALICE dimuon spectrometer
21//__________________________________________________________________________
22
29fc2c86 23#include "AliTrackReference.h"
a9e2aefa 24#include "AliMUONHitForRec.h"
a9e2aefa 25#include "AliMUONRawCluster.h"
26#include "AliMUONHit.h"
29fc2c86 27#include "AliMUONConstants.h"
8c343c7c 28#include "AliLog.h"
a9e2aefa 29
30ClassImp(AliMUONHitForRec) // Class implementation in ROOT context
31
32 //__________________________________________________________________________
30178c30 33AliMUONHitForRec::AliMUONHitForRec()
34 : TObject()
35{
36 // Default Constructor
37
38 fFirstTrackHitPtr = 0;
39 fLastTrackHitPtr = 0;
40}
41
42 //__________________________________________________________________________
29fc2c86 43AliMUONHitForRec::AliMUONHitForRec(AliTrackReference* theGhit)
30178c30 44 : TObject()
a9e2aefa 45{
29fc2c86 46 // Constructor for AliMUONHitForRec from a track ref. hit.
a9e2aefa 47 // Fills the bending, non bending, and Z coordinates,
29fc2c86 48 // which are taken from the coordinates of the track ref. hit,
49 // the track number (track ref. and not TH),
a9e2aefa 50 // and the chamber number (0...).
30178c30 51 fBendingCoor = theGhit->Y();
52 fNonBendingCoor = theGhit->X();
53 fZ = theGhit->Z();
54 // fTrack = theGhit->fTrack; ?????????
29fc2c86 55 fChamberNumber = AliMUONConstants::ChamberNumber(fZ);
a9e2aefa 56 // other fields will be updated in
29fc2c86 57 // AliMUONEventReconstructor::NewHitForRecFromTrackRef,
a9e2aefa 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 //__________________________________________________________________________
30178c30 83AliMUONHitForRec::AliMUONHitForRec(AliMUONRawCluster* theRawCluster)
84 : TObject()
a9e2aefa 85{
86 // Constructor for AliMUONHitForRec from a raw cluster.
87 // Fills the bending and non bending coordinates.
30178c30 88 fNonBendingCoor = theRawCluster->GetX(0);
89 fBendingCoor = theRawCluster->GetY(0);
a9e2aefa 90 // other fields will be updated in
91 // AliMUONEventReconstructor::AddHitsForRecFromRawClusters,
92 // except the following ones
29fc2c86 93 fTTRTrack = -1;
94 fTrackRefSignal = -1;
a9e2aefa 95 fIndexOfFirstSegment = -1;
96 fNSegments = 0;
97 fFirstTrackHitPtr = fLastTrackHitPtr = NULL;
98 fNTrackHits = 0;
99 return;
100}
101
30178c30 102 //__________________________________________________________________________
b8dc484b 103AliMUONHitForRec::AliMUONHitForRec (const AliMUONHitForRec& theMUONHitForRec)
104 : TObject(theMUONHitForRec)
a9e2aefa 105{
b8dc484b 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;
29fc2c86 113 fTTRTrack = theMUONHitForRec.fTTRTrack;
114 fTrackRefSignal = theMUONHitForRec.fTrackRefSignal;
b8dc484b 115 fIndexOfFirstSegment = theMUONHitForRec.fIndexOfFirstSegment;
116 fNSegments = theMUONHitForRec.fNSegments;
117 fFirstTrackHitPtr = theMUONHitForRec.fFirstTrackHitPtr;
118 fLastTrackHitPtr = theMUONHitForRec.fLastTrackHitPtr;
119 fNTrackHits = theMUONHitForRec.fNTrackHits;
30178c30 120
a9e2aefa 121}
122
30178c30 123 //__________________________________________________________________________
b8dc484b 124AliMUONHitForRec & AliMUONHitForRec::operator=(const AliMUONHitForRec& theMUONHitForRec)
a9e2aefa 125{
b8dc484b 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;
29fc2c86 133 fTTRTrack = theMUONHitForRec.fTTRTrack;
134 fTrackRefSignal = theMUONHitForRec.fTrackRefSignal;
b8dc484b 135 fIndexOfFirstSegment = theMUONHitForRec.fIndexOfFirstSegment;
136 fNSegments = theMUONHitForRec.fNSegments;
137 fFirstTrackHitPtr = theMUONHitForRec.fFirstTrackHitPtr;
138 fLastTrackHitPtr = theMUONHitForRec.fLastTrackHitPtr;
139 fNTrackHits = theMUONHitForRec.fNTrackHits;
30178c30 140
b8dc484b 141 return *this;
a9e2aefa 142}
a9e2aefa 143 //__________________________________________________________________________
83dbc640 144/*AZ
2a941f4e 145Int_t AliMUONHitForRec::Compare(const TObject* Hit) const
a9e2aefa 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}
83dbc640 154*/
155 //__________________________________________________________________________
156Int_t AliMUONHitForRec::Compare(const TObject* Hit) const
157{
5b64e914 158 // "Compare" function to sort with decreasing Z-coordinate (spectro. MUON z<0).
159 // Returns 1 (0, -1) if Z-coordinate of current HitForRec
83dbc640 160 // is smaller than (equal to, larger than) Z-coordinate of Hit
5b64e914 161 if (fZ < ((AliMUONHitForRec*)Hit)->fZ) return(1);
83dbc640 162 else if (fZ == ((AliMUONHitForRec*)Hit)->fZ) return( 0);
5b64e914 163 else return(-1);
83dbc640 164}
a9e2aefa 165
166 //__________________________________________________________________________
30178c30 167Double_t AliMUONHitForRec::NormalizedChi2WithHitForRec(AliMUONHitForRec* hitForRec, Double_t Sigma2Cut) const
a9e2aefa 168{
30178c30 169 // Calculate the normalized Chi2 between the current hitForRec (this)
170 // and the hitForRec pointed to by "hitForRec",
a9e2aefa 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
30178c30 182 diff = fBendingCoor - hitForRec->fBendingCoor;
a9e2aefa 183 normDiff = diff * diff /
30178c30 184 (fBendingReso2 + hitForRec->fBendingReso2) / Sigma2Cut;
a9e2aefa 185 if (normDiff > 1.0) return chi2Max;
186 chi2 = chi2 + normDiff;
187 // coordinate in non bending plane
30178c30 188 diff = fNonBendingCoor - hitForRec->fNonBendingCoor;
a9e2aefa 189 normDiff = diff * diff /
30178c30 190 (fNonBendingReso2 + hitForRec->fNonBendingReso2) / Sigma2Cut;
a9e2aefa 191 if (normDiff > 1.0) return chi2Max;
192 chi2 = chi2 + normDiff;
193 return chi2;
194}