X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=MUON%2FAliMUONTriggerTrack.cxx;h=13bd46c8f1a85aa0c6b6c67836b6d036509bfe09;hb=538ae08959e0b4dd3ee92c3e1aa6a66ab2d760e9;hp=da7b85bb0bfaf21e638d8e89a6a4914fe8632eb8;hpb=ee8a8d650ec1b36d3606026bbb107cfa152d4993;p=u%2Fmrichter%2FAliRoot.git diff --git a/MUON/AliMUONTriggerTrack.cxx b/MUON/AliMUONTriggerTrack.cxx index da7b85bb0bf..13bd46c8f1a 100644 --- a/MUON/AliMUONTriggerTrack.cxx +++ b/MUON/AliMUONTriggerTrack.cxx @@ -26,9 +26,12 @@ #include "AliMUONTriggerTrack.h" #include "AliMUONTrackReconstructor.h" +#include "TString.h" #include #include "AliLog.h" +using std::endl; +using std::cout; /// \cond CLASSIMP ClassImp(AliMUONTriggerTrack) /// \endcond @@ -38,28 +41,37 @@ AliMUONTriggerTrack::AliMUONTriggerTrack() : TObject(), fx11(0), fy11(0), - fthetax(0), - fthetay(0), + fz11(0.), + fz21(0.), + fSlopeX(0), + fSlopeY(0), floTrgNum(0), - fGTPattern(0) - + fGTPattern(0), + fPtCutLevel(0), + fHitsPatternInTrigCh(0), + fCovariances(0x0) { /// default ctr - AliDebug(1,Form("this=%p",this)); + AliDebug(5,Form("this=%p",this)); } //__________________________________________________________________________ -AliMUONTriggerTrack::AliMUONTriggerTrack(Float_t x11, Float_t y11, Float_t thetax, Float_t thetay, Int_t loTrgNum, Long_t theGTPattern) +AliMUONTriggerTrack::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) : TObject(), fx11(x11), fy11(y11), - fthetax(thetax), - fthetay(thetay), + fz11(z11), + fz21(z21), + fSlopeX(slopeX), + fSlopeY(slopeY), floTrgNum(loTrgNum), - fGTPattern(theGTPattern) + fGTPattern(theGTPattern), + fPtCutLevel(ptCutLevel), + fHitsPatternInTrigCh(0), + fCovariances(0x0) { /// ctor from local trigger output - AliDebug(1,Form("this=%p x11=%f y11=%f thetax=%f thetay=%f loTrgNum=%d GTPattern=%ld", - this,x11,y11,thetax,thetay,loTrgNum,theGTPattern)); + AliDebug(5,Form("this=%p x11=%f y11=%f z11=%f z21=%f slopeX=%f slopeY=%f loTrgNum=%d GTPattern=%ld HitsPatternInTrigCh %i", + this,x11,y11,z11,z21,slopeX,slopeY,loTrgNum,theGTPattern,fHitsPatternInTrigCh)); } @@ -67,7 +79,11 @@ AliMUONTriggerTrack::AliMUONTriggerTrack(Float_t x11, Float_t y11, Float_t theta AliMUONTriggerTrack::~AliMUONTriggerTrack() { /// Destructor - AliDebug(1,Form("this=%p",this)); + AliDebug(5,Form("this=%p",this)); + if (fCovariances) { + delete fCovariances; + fCovariances = 0x0; + } } //__________________________________________________________________________ @@ -75,15 +91,21 @@ AliMUONTriggerTrack::AliMUONTriggerTrack (const AliMUONTriggerTrack& theMUONTrig : TObject(theMUONTriggerTrack), fx11(theMUONTriggerTrack.fx11), fy11(theMUONTriggerTrack.fy11), - fthetax(theMUONTriggerTrack.fthetax), - fthetay(theMUONTriggerTrack.fthetay), + fz11(theMUONTriggerTrack.fz11), + fz21(theMUONTriggerTrack.fz21), + fSlopeX(theMUONTriggerTrack.fSlopeX), + fSlopeY(theMUONTriggerTrack.fSlopeY), floTrgNum(theMUONTriggerTrack.floTrgNum), - fGTPattern(theMUONTriggerTrack.fGTPattern) + fGTPattern(theMUONTriggerTrack.fGTPattern), + fPtCutLevel(theMUONTriggerTrack.fPtCutLevel), + fHitsPatternInTrigCh(theMUONTriggerTrack.fHitsPatternInTrigCh), + fCovariances(0x0) { /// /// copy ctor /// - AliDebug(1,Form("this=%p copy ctor",this)); + if (theMUONTriggerTrack.fCovariances) fCovariances = new TMatrixD(*(theMUONTriggerTrack.fCovariances)); + AliDebug(5,Form("this=%p copy ctor",this)); } @@ -102,20 +124,135 @@ theMUONTriggerTrack) fx11 = theMUONTriggerTrack.fx11; fy11 = theMUONTriggerTrack.fy11; - fthetax = theMUONTriggerTrack.fthetax; - fthetay = theMUONTriggerTrack.fthetay; + fz11 = theMUONTriggerTrack.fz11; + fz21 = theMUONTriggerTrack.fz21; + fSlopeX = theMUONTriggerTrack.fSlopeX; + fSlopeY = theMUONTriggerTrack.fSlopeY; floTrgNum = theMUONTriggerTrack.floTrgNum; fGTPattern = theMUONTriggerTrack.fGTPattern; + fHitsPatternInTrigCh = theMUONTriggerTrack.fHitsPatternInTrigCh; + + if (theMUONTriggerTrack.fCovariances) { + if (fCovariances) *fCovariances = *(theMUONTriggerTrack.fCovariances); + else fCovariances = new TMatrixD(*(theMUONTriggerTrack.fCovariances)); + } else { + delete fCovariances; + fCovariances = 0x0; + } return *this; } +//__________________________________________________________________________ +void AliMUONTriggerTrack::Clear(Option_t* /*opt*/) +{ + /// Clean memory + delete fCovariances; + fCovariances = 0x0; +} + //__________________________________________________________________________ void -AliMUONTriggerTrack::Print(Option_t*) const +AliMUONTriggerTrack::Print(Option_t* opt) const { /// Printing + TString optString(opt); + optString.ToUpper(); + if ( optString.Contains("FULL") ) optString = "PARAM COV"; + + if ( optString.Contains("PARAM")) + 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", + fx11,fy11,fz11,fz21,fSlopeX,fSlopeY,floTrgNum,fGTPattern,fHitsPatternInTrigCh) << endl; + + if ( optString.Contains("COV") ){ + if ( ! fCovariances ) cout << "Covariances not initialized " << endl; + else fCovariances->Print(); + } +} + +//__________________________________________________________________________ +void AliMUONTriggerTrack::SetCovariances(const TMatrixD& covariances) +{ + /// Set the covariance matrix + if (fCovariances) *fCovariances = covariances; + else fCovariances = new TMatrixD(covariances); +} + +//__________________________________________________________________________ +void AliMUONTriggerTrack::SetCovariances(const Double_t matrix[3][3]) +{ + /// Set the covariance matrix + if (fCovariances) fCovariances->SetMatrixArray(&(matrix[0][0])); + else fCovariances = new TMatrixD(3,3,&(matrix[0][0])); +} + +//__________________________________________________________________________ +const TMatrixD& AliMUONTriggerTrack::GetCovariances() const +{ + /// Return the covariance matrix (create it before if needed) + if (!fCovariances) { + fCovariances = new TMatrixD(3,3); + fCovariances->Zero(); + } + return *fCovariances; +} + +//__________________________________________________________________________ +Bool_t AliMUONTriggerTrack::Match(AliMUONTriggerTrack &track, + Double_t sigmaCut) const +{ + /// Try to match this track with the given track. Matching conditions: + /// - x, y position and y slope within sigmaCut + + // Find the track with the covariances correctly set + // Extrapolate to the z of the other track + Bool_t hasCov1 = ( GetCovariances().NonZeros() != 0 ); + Bool_t hasCov2 = ( track.GetCovariances().NonZeros() != 0 ); + + const AliMUONTriggerTrack* trackToExtrap = ( hasCov2 ) ? &track : this; + const AliMUONTriggerTrack* fixedTrack = ( hasCov2 ) ? this : &track; + + TMatrixD paramDiff(3,1); + Double_t deltaZ = fixedTrack->GetZ11() - trackToExtrap->GetZ11(); + paramDiff(0,0) = fixedTrack->GetX11() - trackToExtrap->GetX11(); + paramDiff(1,0) = fixedTrack->GetY11() - ( trackToExtrap->GetY11() + trackToExtrap->GetSlopeY() * deltaZ ); + paramDiff(2,0) = fixedTrack->GetSlopeY() - trackToExtrap->GetSlopeY(); + Double_t chi2 = 0.; + + TMatrixD cov1(fixedTrack->GetCovariances()); + TMatrixD cov2(trackToExtrap->GetCovariances()); + + // Extrapolate covariances to z + if ( deltaZ != 0 ) { + if ( hasCov1 || hasCov2 ){ + TMatrixD jacob(3,3); + jacob.UnitMatrix(); + jacob(1,2) = deltaZ; + TMatrixD tmp(trackToExtrap->GetCovariances(),TMatrixD::kMultTranspose,jacob); + TMatrixD tmp2(jacob,TMatrixD::kMult,tmp); + cov2 = tmp2; + } + } + + 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())); + + TMatrixD sumCov(cov1,TMatrixD::kPlus,cov2); + if (sumCov.Determinant() != 0) { + sumCov.Invert(); + TMatrixD tmp(sumCov,TMatrixD::kMult,paramDiff); + TMatrixD chi2M(paramDiff,TMatrixD::kTransposeMult,tmp); + chi2 = chi2M(0,0); + } else { + AliWarning(" Determinant = 0"); + Double_t sigma2 = 0.; + for (Int_t iVar = 0; iVar < 3; iVar++) { + sigma2 = cov1(iVar,iVar) + cov2(iVar,iVar); + chi2 += paramDiff(iVar,0) * paramDiff(iVar,0) / sigma2; + } + } - cout << Form("(X,Y)11=(%7.2f,%7.2f) Theta(X,Y)=(%7.2f,%7.2f) LocalBoard #%3d GlobalTriggerPattern %x", - fx11,fy11,fthetax,fthetay,floTrgNum,fGTPattern) << endl; + if ( chi2/3 > sigmaCut * sigmaCut ) + return kFALSE; + + return kTRUE; }