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