#include <MuonKinkFinder.h>
Public Member Functions | |
bool | fillTrkKink (reco::MuonQuality &quality, const Trajectory &trajectory) const |
bool | fillTrkKink (reco::MuonQuality &quality, const reco::Track &track) const |
void | init (const edm::EventSetup &iSetup) |
MuonKinkFinder (const edm::ParameterSet &iConfig) | |
~MuonKinkFinder () | |
Private Member Functions | |
void | cropAndInvert (AlgebraicSymMatrix55 &cov) const |
double | getChi2 (const TrajectoryStateOnSurface &start, const TrajectoryStateOnSurface &other) const |
Private Attributes | |
bool | diagonalOnly_ |
use only on-diagonal terms of the covariance matrices | |
TrackTransformer | refitter_ |
Track Transformer. | |
bool | usePosition_ |
if true, use full 5x5 track state; if false, use only the track direction |
Definition at line 7 of file MuonKinkFinder.h.
MuonKinkFinder::MuonKinkFinder | ( | const edm::ParameterSet & | iConfig | ) |
Definition at line 5 of file MuonKinkFinder.cc.
: diagonalOnly_(iConfig.getParameter<bool>("diagonalOnly")), usePosition_(iConfig.getParameter<bool>("usePosition")), refitter_(iConfig) { }
MuonKinkFinder::~MuonKinkFinder | ( | ) |
Definition at line 12 of file MuonKinkFinder.cc.
{ }
void MuonKinkFinder::cropAndInvert | ( | AlgebraicSymMatrix55 & | cov | ) | const [private] |
Definition at line 59 of file MuonKinkFinder.cc.
References diagonalOnly_, i, j, and usePosition_.
Referenced by getChi2().
{ if (usePosition_) { if (diagonalOnly_) { for (size_t i = 0; i < 5; ++i) { for (size_t j = i+1; j < 5; ++j) { cov(i,j) = 0; } } } cov.Invert(); } else { // get 3x3 covariance AlgebraicSymMatrix33 momCov = cov.Sub<AlgebraicSymMatrix33>(0,0); // get 3x3 matrix if (diagonalOnly_) { momCov(0,1) = 0; momCov(0,2) = 0; momCov(1,2) = 0; } // invert momCov.Invert(); // place it cov.Place_at(momCov,0,0); // zero the rest for (size_t i = 3; i < 5; ++i) { for (size_t j = i; j < 5; ++j) { cov(i,j) = 0; } } } }
bool MuonKinkFinder::fillTrkKink | ( | reco::MuonQuality & | quality, |
const Trajectory & | trajectory | ||
) | const |
Definition at line 28 of file MuonKinkFinder.cc.
References newFWLiteAna::found, getChi2(), TrajectoryStateOnSurface::isValid(), Trajectory::measurements(), pos, reco::MuonQuality::tkKink_position, reco::MuonQuality::trkKink, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().
Referenced by fillTrkKink().
{ const std::vector<TrajectoryMeasurement> &tms = trajectory.measurements(); quality.trkKink = -1.0; quality.tkKink_position = math::XYZPoint(0,0,0); bool found = false; for (int itm = 3, nm = tms.size() - 3; itm < nm; ++itm) { TrajectoryStateOnSurface pre = tms[itm].forwardPredictedState(); TrajectoryStateOnSurface post = tms[itm].backwardPredictedState(); if (!pre.isValid() || !post.isValid()) continue; found = true; double c2f = getChi2(pre,post); if (c2f > quality.trkKink) { quality.trkKink = c2f; GlobalPoint pos = (tms[itm].updatedState().isValid() ? tms[itm].updatedState() : pre).globalPosition(); quality.tkKink_position = math::XYZPoint(pos.x(), pos.y(), pos.z()); } } if (!found) quality.trkKink = 999; return found; }
bool MuonKinkFinder::fillTrkKink | ( | reco::MuonQuality & | quality, |
const reco::Track & | track | ||
) | const |
Definition at line 18 of file MuonKinkFinder.cc.
References fillTrkKink(), refitter_, reco::MuonQuality::tkKink_position, TrackTransformer::transform(), and reco::MuonQuality::trkKink.
{ std::vector<Trajectory> traj = refitter_.transform(track); if (traj.size() != 1) { quality.trkKink = 999; quality.tkKink_position = math::XYZPoint(0,0,0); return false; } return fillTrkKink(quality, traj.front()); }
double MuonKinkFinder::getChi2 | ( | const TrajectoryStateOnSurface & | start, |
const TrajectoryStateOnSurface & | other | ||
) | const [private] |
Definition at line 49 of file MuonKinkFinder.cc.
References cropAndInvert(), diffTreeTool::diff, TrajectoryStateOnSurface::hasError(), TrajectoryStateOnSurface::localError(), TrajectoryStateOnSurface::localParameters(), LocalTrajectoryError::matrix(), and LocalTrajectoryParameters::mixedFormatVector().
Referenced by fillTrkKink().
{ if (!start.hasError() && !other.hasError()) throw cms::Exception("LogicError") << "At least one of the two states must have errors to make chi2s.\n"; AlgebraicSymMatrix55 cov; if (start.hasError()) cov += start.localError().matrix(); if (other.hasError()) cov += other.localError().matrix(); cropAndInvert(cov); AlgebraicVector5 diff(start.localParameters().mixedFormatVector() - other.localParameters().mixedFormatVector()); return ROOT::Math::Similarity(diff, cov); }
void MuonKinkFinder::init | ( | const edm::EventSetup & | iSetup | ) |
Definition at line 14 of file MuonKinkFinder.cc.
References refitter_, and TrackTransformer::setServices().
{ refitter_.setServices(iSetup); }
bool MuonKinkFinder::diagonalOnly_ [private] |
use only on-diagonal terms of the covariance matrices
Definition at line 23 of file MuonKinkFinder.h.
Referenced by cropAndInvert().
TrackTransformer MuonKinkFinder::refitter_ [private] |
Track Transformer.
Definition at line 28 of file MuonKinkFinder.h.
Referenced by fillTrkKink(), and init().
bool MuonKinkFinder::usePosition_ [private] |
if true, use full 5x5 track state; if false, use only the track direction
Definition at line 25 of file MuonKinkFinder.h.
Referenced by cropAndInvert().