]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONTriggerTrack.cxx
Moving required CMake version from 2.8.4 to 2.8.8
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerTrack.cxx
CommitLineData
0b3dd00a 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
ee8a8d65 16// $Id$
0b3dd00a 17
ee8a8d65 18//-----------------------------------------------------------------------------
19// Class AliMUONTriggerTrack
20//---------------------------
21// Reconstructed Trigger track in ALICE dimuon spectrometer
22// Note: equivalent to AliMUONTriggerTrack for tracking,
23// No need for a AliMUONTriggerTrackParam
24// Author: Philippe Crochet
25//-----------------------------------------------------------------------------
0b3dd00a 26
0b3dd00a 27#include "AliMUONTriggerTrack.h"
29f1b13a 28#include "AliMUONTrackReconstructor.h"
bdfb6eef 29#include "TString.h"
e5e7be4b 30#include <Riostream.h>
31#include "AliLog.h"
0b3dd00a 32
cdd730d0 33using std::endl;
34using std::cout;
ee8a8d65 35/// \cond CLASSIMP
36ClassImp(AliMUONTriggerTrack)
37/// \endcond
38
0b3dd00a 39//__________________________________________________________________________
40AliMUONTriggerTrack::AliMUONTriggerTrack()
7fe0032c 41 : TObject(),
42 fx11(0),
43 fy11(0),
bdfb6eef 44 fz11(0.),
45 fz21(0.),
46 fSlopeX(0),
47 fSlopeY(0),
c6ba19f7 48 floTrgNum(0),
67c201be 49 fGTPattern(0),
b7474abb 50 fPtCutLevel(0),
bdfb6eef 51 fHitsPatternInTrigCh(0),
52 fCovariances(0x0)
0b3dd00a 53{
7945aae7 54 /// default ctr
9f164762 55 AliDebug(5,Form("this=%p",this));
0b3dd00a 56}
57//__________________________________________________________________________
b7474abb 58AliMUONTriggerTrack::AliMUONTriggerTrack(Float_t x11, Float_t y11, Float_t z11, Float_t z21, Float_t slopeX, Float_t slopeY, Int_t loTrgNum, Long_t theGTPattern, Int_t ptCutLevel)
1657f946 59 : TObject(),
60 fx11(x11),
61 fy11(y11),
bdfb6eef 62 fz11(z11),
63 fz21(z21),
64 fSlopeX(slopeX),
65 fSlopeY(slopeY),
c6ba19f7 66 floTrgNum(loTrgNum),
67c201be 67 fGTPattern(theGTPattern),
b7474abb 68 fPtCutLevel(ptCutLevel),
69 fHitsPatternInTrigCh(0),
bdfb6eef 70 fCovariances(0x0)
0b3dd00a 71{
7945aae7 72/// ctor from local trigger output
9f164762 73 AliDebug(5,Form("this=%p x11=%f y11=%f z11=%f z21=%f slopeX=%f slopeY=%f loTrgNum=%d GTPattern=%ld HitsPatternInTrigCh %i",
bdfb6eef 74 this,x11,y11,z11,z21,slopeX,slopeY,loTrgNum,theGTPattern,fHitsPatternInTrigCh));
e5e7be4b 75
0b3dd00a 76}
77
78//__________________________________________________________________________
79AliMUONTriggerTrack::~AliMUONTriggerTrack()
80{
7945aae7 81 /// Destructor
9f164762 82 AliDebug(5,Form("this=%p",this));
bdfb6eef 83 if (fCovariances) {
84 delete fCovariances;
85 fCovariances = 0x0;
86 }
0b3dd00a 87}
88
89//__________________________________________________________________________
30178c30 90AliMUONTriggerTrack::AliMUONTriggerTrack (const AliMUONTriggerTrack& theMUONTriggerTrack)
1657f946 91 : TObject(theMUONTriggerTrack),
92 fx11(theMUONTriggerTrack.fx11),
93 fy11(theMUONTriggerTrack.fy11),
bdfb6eef 94 fz11(theMUONTriggerTrack.fz11),
95 fz21(theMUONTriggerTrack.fz21),
96 fSlopeX(theMUONTriggerTrack.fSlopeX),
97 fSlopeY(theMUONTriggerTrack.fSlopeY),
c6ba19f7 98 floTrgNum(theMUONTriggerTrack.floTrgNum),
67c201be 99 fGTPattern(theMUONTriggerTrack.fGTPattern),
b7474abb 100 fPtCutLevel(theMUONTriggerTrack.fPtCutLevel),
bdfb6eef 101 fHitsPatternInTrigCh(theMUONTriggerTrack.fHitsPatternInTrigCh),
102 fCovariances(0x0)
0b3dd00a 103{
7945aae7 104///
105/// copy ctor
106///
bdfb6eef 107 if (theMUONTriggerTrack.fCovariances) fCovariances = new TMatrixD(*(theMUONTriggerTrack.fCovariances));
9f164762 108 AliDebug(5,Form("this=%p copy ctor",this));
e5e7be4b 109
0b3dd00a 110}
111
112//__________________________________________________________________________
113AliMUONTriggerTrack & AliMUONTriggerTrack::operator=(const AliMUONTriggerTrack&
30178c30 114theMUONTriggerTrack)
0b3dd00a 115{
7945aae7 116/// Assignment operator
117
30178c30 118 // check assignement to self
119 if (this == &theMUONTriggerTrack)
0b3dd00a 120 return *this;
121
7945aae7 122 /// base class assignement
30178c30 123 TObject::operator=(theMUONTriggerTrack);
124
30178c30 125 fx11 = theMUONTriggerTrack.fx11;
126 fy11 = theMUONTriggerTrack.fy11;
bdfb6eef 127 fz11 = theMUONTriggerTrack.fz11;
128 fz21 = theMUONTriggerTrack.fz21;
129 fSlopeX = theMUONTriggerTrack.fSlopeX;
130 fSlopeY = theMUONTriggerTrack.fSlopeY;
c6ba19f7 131 floTrgNum = theMUONTriggerTrack.floTrgNum;
30178c30 132 fGTPattern = theMUONTriggerTrack.fGTPattern;
67c201be 133 fHitsPatternInTrigCh = theMUONTriggerTrack.fHitsPatternInTrigCh;
9131b4fe 134
bdfb6eef 135 if (theMUONTriggerTrack.fCovariances) {
136 if (fCovariances) *fCovariances = *(theMUONTriggerTrack.fCovariances);
137 else fCovariances = new TMatrixD(*(theMUONTriggerTrack.fCovariances));
138 } else {
139 delete fCovariances;
140 fCovariances = 0x0;
141 }
142
0b3dd00a 143 return *this;
144}
c6ba19f7 145
7bf353da 146//__________________________________________________________________________
147void AliMUONTriggerTrack::Clear(Option_t* /*opt*/)
148{
149 /// Clean memory
150 delete fCovariances;
151 fCovariances = 0x0;
152}
153
e5e7be4b 154//__________________________________________________________________________
155void
bdfb6eef 156AliMUONTriggerTrack::Print(Option_t* opt) const
e5e7be4b 157{
158/// Printing
bdfb6eef 159 TString optString(opt);
160 optString.ToUpper();
161 if ( optString.Contains("FULL") ) optString = "PARAM COV";
162
163 if ( optString.Contains("PARAM"))
164 cout << Form("(X,Y,Z)11=(%7.2f,%7.2f,%7.2f) Z21=%7.2f Slope(X,Y)=(%7.2f,%7.2f) LocalBoard #%3d GlobalTriggerPattern %x HitsPatternInTrigCh %x",
165 fx11,fy11,fz11,fz21,fSlopeX,fSlopeY,floTrgNum,fGTPattern,fHitsPatternInTrigCh) << endl;
166
167 if ( optString.Contains("COV") ){
168 if ( ! fCovariances ) cout << "Covariances not initialized " << endl;
169 else fCovariances->Print();
170 }
171}
e5e7be4b 172
bdfb6eef 173//__________________________________________________________________________
174void AliMUONTriggerTrack::SetCovariances(const TMatrixD& covariances)
175{
176 /// Set the covariance matrix
177 if (fCovariances) *fCovariances = covariances;
178 else fCovariances = new TMatrixD(covariances);
179}
180
181//__________________________________________________________________________
182void AliMUONTriggerTrack::SetCovariances(const Double_t matrix[3][3])
183{
184 /// Set the covariance matrix
185 if (fCovariances) fCovariances->SetMatrixArray(&(matrix[0][0]));
186 else fCovariances = new TMatrixD(3,3,&(matrix[0][0]));
187}
188
189//__________________________________________________________________________
190const TMatrixD& AliMUONTriggerTrack::GetCovariances() const
191{
192 /// Return the covariance matrix (create it before if needed)
193 if (!fCovariances) {
194 fCovariances = new TMatrixD(3,3);
195 fCovariances->Zero();
196 }
197 return *fCovariances;
e5e7be4b 198}
9f164762 199
200//__________________________________________________________________________
64a3533c 201Bool_t AliMUONTriggerTrack::Match(AliMUONTriggerTrack &track,
202 Double_t sigmaCut) const
9f164762 203{
204 /// Try to match this track with the given track. Matching conditions:
205 /// - x, y position and y slope within sigmaCut
206
64a3533c 207 // Find the track with the covariances correctly set
208 // Extrapolate to the z of the other track
209 Bool_t hasCov1 = ( GetCovariances().NonZeros() != 0 );
210 Bool_t hasCov2 = ( track.GetCovariances().NonZeros() != 0 );
211
212 const AliMUONTriggerTrack* trackToExtrap = ( hasCov2 ) ? &track : this;
213 const AliMUONTriggerTrack* fixedTrack = ( hasCov2 ) ? this : &track;
214
9f164762 215 TMatrixD paramDiff(3,1);
64a3533c 216 Double_t deltaZ = fixedTrack->GetZ11() - trackToExtrap->GetZ11();
217 paramDiff(0,0) = fixedTrack->GetX11() - trackToExtrap->GetX11();
218 paramDiff(1,0) = fixedTrack->GetY11() - ( trackToExtrap->GetY11() + trackToExtrap->GetSlopeY() * deltaZ );
219 paramDiff(2,0) = fixedTrack->GetSlopeY() - trackToExtrap->GetSlopeY();
9f164762 220 Double_t chi2 = 0.;
9f164762 221
64a3533c 222 TMatrixD cov1(fixedTrack->GetCovariances());
223 TMatrixD cov2(trackToExtrap->GetCovariances());
224
225 // Extrapolate covariances to z
226 if ( deltaZ != 0 ) {
227 if ( hasCov1 || hasCov2 ){
228 TMatrixD jacob(3,3);
229 jacob.UnitMatrix();
230 jacob(1,2) = deltaZ;
231 TMatrixD tmp(trackToExtrap->GetCovariances(),TMatrixD::kMultTranspose,jacob);
232 TMatrixD tmp2(jacob,TMatrixD::kMult,tmp);
233 cov2 = tmp2;
234 }
235 }
236
237 AliDebug(3, Form("track1 Y11 %f track2 Y11: %f (Z11 %f) -> %f (Z11 %f)", fixedTrack->GetY11(), trackToExtrap->GetY11(), trackToExtrap->GetZ11(), trackToExtrap->GetY11() + trackToExtrap->GetSlopeY() * deltaZ, fixedTrack->GetZ11()));
9f164762 238
239 TMatrixD sumCov(cov1,TMatrixD::kPlus,cov2);
240 if (sumCov.Determinant() != 0) {
241 sumCov.Invert();
242 TMatrixD tmp(sumCov,TMatrixD::kMult,paramDiff);
243 TMatrixD chi2M(paramDiff,TMatrixD::kTransposeMult,tmp);
244 chi2 = chi2M(0,0);
245 } else {
246 AliWarning(" Determinant = 0");
247 Double_t sigma2 = 0.;
248 for (Int_t iVar = 0; iVar < 3; iVar++) {
249 sigma2 = cov1(iVar,iVar) + cov2(iVar,iVar);
250 chi2 += paramDiff(iVar,0) * paramDiff(iVar,0) / sigma2;
251 }
252 }
253
254 if ( chi2/3 > sigmaCut * sigmaCut )
255 return kFALSE;
256
257 return kTRUE;
258}