#include <TrimmedVertexFinder.h>
Algorithm to find 0 or 1 cluster of tracks that are compatible with a single vertex, among `remain`, the initial set of tracks. A track is declared incompatible with the vertex if the chi-squared probability between the track and the vertex is smaller than `min`. The algorithm applied is:
1) fit a single vertex with all tracks;
2) remove incompatible tracks 1 by 1 starting from the least compatible one.
On output, `remain` contains the incompatible tracks. This algorithm has 1 parameter that can be set at runtime via the corresponding set() method:
Definition at line 28 of file TrimmedVertexFinder.h.
typedef ReferenceCountingPointer<LinearizedTrackState<5> > TrimmedVertexFinder::RefCountedLinearizedTrackState |
Definition at line 33 of file TrimmedVertexFinder.h.
Definition at line 32 of file TrimmedVertexFinder.h.
TrimmedVertexFinder::TrimmedVertexFinder | ( | const VertexFitter< 5 > * | vf, |
const VertexUpdator< 5 > * | vu, | ||
const VertexTrackCompatibilityEstimator< 5 > * | ve | ||
) |
Definition at line 9 of file TrimmedVertexFinder.cc.
Referenced by clone().
: theFitter(vf->clone()), theUpdator(vu->clone()), theEstimator(ve->clone()), theMinProb(0.05) {}
TrimmedVertexFinder::TrimmedVertexFinder | ( | const TrimmedVertexFinder & | other | ) |
Copy constructor, needed to handle copy of pointer data members correctly
Definition at line 17 of file TrimmedVertexFinder.cc.
: theFitter(other.theFitter->clone()), theUpdator(other.theUpdator->clone()), theEstimator(other.theEstimator->clone()), theMinProb(other.theMinProb) {}
TrimmedVertexFinder::~TrimmedVertexFinder | ( | ) |
Definition at line 26 of file TrimmedVertexFinder.cc.
References theEstimator, theFitter, and theUpdator.
{ delete theFitter; delete theUpdator; delete theEstimator; }
TrimmedVertexFinder* TrimmedVertexFinder::clone | ( | void | ) | const [inline] |
clone method
Definition at line 68 of file TrimmedVertexFinder.h.
References TrimmedVertexFinder().
{ return new TrimmedVertexFinder(*this); }
void TrimmedVertexFinder::setTrackCompatibilityCut | ( | float | cut | ) | [inline] |
Set parameter
Definition at line 64 of file TrimmedVertexFinder.h.
References GOODCOLL_filter_cfg::cut, and theMinProb.
Referenced by ConfigurableTrimmedVertexFinder::vertexCandidates().
{ theMinProb = cut; }
std::vector< TrimmedVertexFinder::RefCountedVertexTrack >::iterator TrimmedVertexFinder::theWorst | ( | const CachingVertex< 5 > & | vtx, |
std::vector< RefCountedVertexTrack > & | vtxTracks, | ||
float | cut | ||
) | const [private] |
Definition at line 153 of file TrimmedVertexFinder.cc.
References ChiSquaredProbability(), VertexTrackCompatibilityEstimator< N >::estimate(), CachingVertex< N >::isValid(), VertexUpdator< N >::remove(), query::result, theEstimator, theUpdator, and CachingVertex< N >::tracks().
Referenced by vertices().
{ // cout << "Cut is now " << cut << endl; // find track with worst compatibility std::vector<RefCountedVertexTrack>::iterator iWorst = vtxTracks.end(); float worseChi2 = 0.; for (std::vector<RefCountedVertexTrack>::iterator itr = vtxTracks.begin(); itr != vtxTracks.end(); itr++) { CachingVertex<5> newV = theUpdator->remove(vtx, *itr); if (!newV.isValid()) return itr; std::pair<bool, double> result = theEstimator->estimate(newV, *itr); if (!result.first) return itr; float chi2 = result.second; // compute number of degrees of freedom if ( chi2 > 0. ) { // we want to keep negative chi squares, and avoid calling // ChiSquaredProbability with a negative chi2. int ndf = 2; if (vtx.tracks().size() == 2) ndf = 1; float prob = ChiSquaredProbability(chi2, ndf); if (prob < cut && chi2 >= worseChi2) { // small inconsistency: sorting on chi2, not on chi2 probability // because large chi2 are not rounded off while small probabilities // are rounded off to 0.... // should not matter since at a given iteration // all track chi2 increments have the same ndf iWorst = itr; worseChi2 = chi2; } } } return iWorst; }
float TrimmedVertexFinder::trackCompatibilityCut | ( | ) | const [inline] |
Access to parameter
Definition at line 60 of file TrimmedVertexFinder.h.
References theMinProb.
{ return theMinProb; }
std::vector< TransientVertex > TrimmedVertexFinder::vertices | ( | std::vector< reco::TransientTrack > & | remain | ) | const |
Make 0 or 1 vertex On output, `remain` contains the incompatible tracks
Definition at line 33 of file TrimmedVertexFinder.cc.
Referenced by ConfigurableTrimmedVertexFinder::vertexCandidates().
{ // FIXME write this!!! return vertices ( tks, reco::BeamSpot(), false ); }
std::vector< TransientVertex > TrimmedVertexFinder::vertices | ( | std::vector< reco::TransientTrack > & | remain, |
const reco::BeamSpot & | s, | ||
bool | use_beamspot = true |
||
) | const |
Same as above, only with the extra information of the beamspot constraint.
Definition at line 40 of file TrimmedVertexFinder.cc.
References cond::ecalcond::all, Exception, newFWLiteAna::found, i, CachingVertex< N >::isValid(), lumiQTWidget::t, theFitter, theMinProb, theWorst(), CachingVertex< N >::tracks(), and VertexFitter< N >::vertex().
{ std::vector<TransientVertex> all; if (tks.size() < 2) return all; // prepare vertex tracks and initial vertex CachingVertex<5> vtx; if ( use_spot ) { vtx = theFitter->vertex(tks, spot ); } else { vtx = theFitter->vertex(tks); } if (!vtx.isValid()) { edm::LogWarning ( "TrimmedVertexFinder" ) << "initial vertex invalid." << " vertex finding stops here."; return all; } std::vector<RefCountedVertexTrack> selected = vtx.tracks(); // reject incompatible tracks starting from the worst std::vector<RefCountedVertexTrack> remain; bool found = false; while (!found && selected.size() >= 2) { // find track with worst compatibility std::vector<RefCountedVertexTrack>::iterator iWorst = theWorst(vtx, selected, theMinProb); if (iWorst != selected.end()) { // reject track remain.push_back(*iWorst); selected.erase(iWorst); if (selected.size() == 1) { // not enough tracks to build new vertices remain.push_back(selected.front()); } else { // removing track from vertex // need to redo the vertex fit instead of removing the track; // successive removals lead to numerical problems // this is however quick since intermediate quantities are cached // in the RefCountedVertexTracks if ( use_spot ) // && all.size()==0 ) { vtx = theFitter->vertex(selected,spot); } else { vtx = theFitter->vertex(selected); } if (!vtx.isValid()) { edm::LogWarning ( "TrimmedVertexFinder" ) << "current vertex invalid" << "vertex finding stops here."; return all; } // ref-counted tracks may have changed during the fit // if the linearization point has moved too much selected = vtx.tracks(); } } else { // no incompatible track remains, make vertex found = true; int n_tracks_in_vertex = selected.size(); // now return all tracks with weight < 0.5 to 'remain'. for ( std::vector< RefCountedVertexTrack >::const_iterator t=selected.begin(); t!=selected.end() ; ++t ) { if ( (**t).weight() < 0.5 ) { /* cout << "[TrimmedVertexFinder] recycling track with weight " << (**t).weight() << endl;*/ remain.push_back ( *t ); n_tracks_in_vertex--; // one 'good' track less in the vertex }; }; if ( n_tracks_in_vertex > 1 ) { all.push_back(vtx); } else { edm::LogError ( "TrimmedVertexFinder" ) << "found vertex has less than 2 tracks"; } } } // modify list of incompatible tracks tks.clear(); for (std::vector<RefCountedVertexTrack>::const_iterator i = remain.begin(); i != remain.end(); i++) { const PerigeeLinearizedTrackState* plts = dynamic_cast<const PerigeeLinearizedTrackState*> ((**i).linearizedTrack().get()); if (plts == 0) { throw cms::Exception("TrimmedVertexFinder: can't take track from non-perigee track state"); } tks.push_back(plts->track()); } // return 0 or 1 vertex return all; }
Definition at line 85 of file TrimmedVertexFinder.h.
Referenced by theWorst(), and ~TrimmedVertexFinder().
VertexFitter<5>* TrimmedVertexFinder::theFitter [private] |
Definition at line 83 of file TrimmedVertexFinder.h.
Referenced by vertices(), and ~TrimmedVertexFinder().
float TrimmedVertexFinder::theMinProb [private] |
Definition at line 86 of file TrimmedVertexFinder.h.
Referenced by setTrackCompatibilityCut(), trackCompatibilityCut(), and vertices().
VertexUpdator<5>* TrimmedVertexFinder::theUpdator [private] |
Definition at line 84 of file TrimmedVertexFinder.h.
Referenced by theWorst(), and ~TrimmedVertexFinder().