#include <CrossingPtBasedLinearizationPointFinder.h>
A linearization point finder. It works the following way: 1. Calculate in an optimal way 'n_pairs' different crossing points. Optimal in this context means the following: a. Try to use as many different tracks as possible; avoid using the same track all the time. b. Use the most energetic tracks. c. Try not to group the most energetic tracks together. Try to group more energetic tracks with less energetic tracks. We assume collimated bundles here, so this is why. d. Perform optimally. Do not sort more tracks (by total energy, see b) than necessary. e. If n_pairs >= (number of all possible combinations), do not leave any combinations out. ( a. and e. are almost but not entirely fulfilled in the current impl ) 2. Apply theAlgo on the n points.
Definition at line 26 of file CrossingPtBasedLinearizationPointFinder.h.
CrossingPtBasedLinearizationPointFinder::CrossingPtBasedLinearizationPointFinder | ( | const ModeFinder3d & | algo, |
const signed int | n_pairs = 5 |
||
) |
n_pairs,: | how many track pairs will be considered (maximum) a value of -1 means full combinatorics. |
Definition at line 104 of file CrossingPtBasedLinearizationPointFinder.cc.
Referenced by clone().
CrossingPtBasedLinearizationPointFinder::CrossingPtBasedLinearizationPointFinder | ( | const RecTracksDistanceMatrix * | m, |
const ModeFinder3d & | algo, | ||
const signed int | n_pairs = -1 |
||
) |
This constructor exploits the information stored in a RecTracksDistanceMatrix object.
n_pairs,: | how many track pairs will be considered (maximum) a value of -1 means full combinatorics. |
Definition at line 110 of file CrossingPtBasedLinearizationPointFinder.cc.
CrossingPtBasedLinearizationPointFinder::CrossingPtBasedLinearizationPointFinder | ( | const CrossingPtBasedLinearizationPointFinder & | o | ) |
CrossingPtBasedLinearizationPointFinder::~CrossingPtBasedLinearizationPointFinder | ( | ) |
Definition at line 124 of file CrossingPtBasedLinearizationPointFinder.cc.
References theAlgo.
{ delete theAlgo; }
virtual CrossingPtBasedLinearizationPointFinder* CrossingPtBasedLinearizationPointFinder::clone | ( | ) | const [inline, virtual] |
Clone method
Implements LinearizationPointFinder.
Reimplemented in FsmwLinearizationPointFinder, HSMLinearizationPointFinder, LMSLinearizationPointFinder, SMSLinearizationPointFinder, and SubsetHSMLinearizationPointFinder.
Definition at line 55 of file CrossingPtBasedLinearizationPointFinder.h.
References CrossingPtBasedLinearizationPointFinder().
{ return new CrossingPtBasedLinearizationPointFinder ( * this ); };
GlobalPoint CrossingPtBasedLinearizationPointFinder::find | ( | const std::vector< std::pair< GlobalPoint, float > > & | ) | const [private] |
calls (*theAglo) (input) can optionally save input / output in .root file
Referenced by getLinearizationPoint(), useAllTracks(), and useFullMatrix().
std::vector< reco::TransientTrack > CrossingPtBasedLinearizationPointFinder::getBestTracks | ( | const std::vector< reco::TransientTrack > & | tracks | ) | const [private] |
Definition at line 129 of file CrossingPtBasedLinearizationPointFinder.cc.
References theNPairs, and testEve_cfg::tracks.
Referenced by getLinearizationPoint().
{ unsigned int n_tracks = (2*(unsigned int) (theNPairs)) < tracks.size() ? 2*theNPairs : tracks.size(); std::vector <reco::TransientTrack> newtracks = tracks; partial_sort ( newtracks.begin(), newtracks.begin()+n_tracks, newtracks.end(), CompareTwoTracks() ); newtracks.erase ( newtracks.begin()+n_tracks, newtracks.end() ); /* * old version, when we have a default constructor * std::vector <reco::TransientTrack> newtracks ( n_tracks ); partial_sort_copy ( tracks.begin(), tracks.end(), newtracks.begin(), newtracks.begin() + n_tracks , CompareTwoTracks() ); */ return newtracks; }
GlobalPoint CrossingPtBasedLinearizationPointFinder::getLinearizationPoint | ( | const std::vector< FreeTrajectoryState > & | tracks | ) | const [virtual] |
Reimplemented from LinearizationPointFinder.
Definition at line 208 of file CrossingPtBasedLinearizationPointFinder.cc.
References getLinearizationPoint().
{ return LinearizationPointFinder::getLinearizationPoint ( tracks ); }
GlobalPoint CrossingPtBasedLinearizationPointFinder::getLinearizationPoint | ( | const std::vector< reco::TransientTrack > & | tracks | ) | const [virtual] |
Method giving back the Initial Linearization Point.
Implements LinearizationPointFinder.
Definition at line 229 of file CrossingPtBasedLinearizationPointFinder.cc.
References TwoTrackMinimumDistance::calculate(), RecTracksDistanceMatrix::crossingPoint(), dir, RecTracksDistanceMatrix::distance(), find(), getBestTracks(), FallbackLinearizationPointFinder::getLinearizationPoint(), reco::TransientTrack::impactPointState(), TwoTrackMinimumDistance::points(), ntuplemaker::status, theMatrix, theNPairs, useAllTracks(), useFullMatrix(), useMatrix, and v.
Referenced by getLinearizationPoint().
{ if ( tracks.size() < 2 ) throw LinPtException ("CrossingPtBasedLinPtFinder: too few tracks given."); std::vector < PointAndDistance > vgp; if ( theNPairs == -1 ) { if ( useMatrix ) { return useFullMatrix( tracks ); } else { return useAllTracks ( tracks ); } } if ( sum ( tracks.size() - 1 ) < ((unsigned int) (theNPairs)) ) { /* std::cout << "[CrossingPtBasedLinearizationPointFinder] we exploit all track pairs" << std::endl;*/ // we have fewer track pair options than is foreseen // in the quota. // so we exploit all tracks pairs. return useAllTracks ( tracks ); } std::vector <reco::TransientTrack> goodtracks = getBestTracks ( tracks ); // we sort according to momenta. if ( goodtracks.size() < 2 ) throw LinPtException ( "CrossingPtBasedLinPtFinder: less than two tracks given"); // vgp.reserve ( theNPairs - 1 ); unsigned int t_first = 0; unsigned int t_interval = goodtracks.size() / 2; unsigned int lim = goodtracks.size() - 1; /* std::cout << "[CrossingPtBasedLinearizationPointFinder] we start: npairs=" << theNPairs << std::endl; std::cout << "[CrossingPtBasedLinearizationPointFinder] t_interval=" << t_interval << std::endl; std::cout << "[CrossingPtBasedLinearizationPointFinder goodtracks.size=" << goodtracks.size() << std::endl;*/ // the 'direction' false: intervals will expand // true: intervals will shrink bool dir = false; while ( vgp.size() < ((unsigned int) (theNPairs)) ) { reco::TransientTrack rt1 = goodtracks [ t_first ]; reco::TransientTrack rt2 = goodtracks [ t_first + t_interval ]; // std::cout << "Considering now: " << t_first << ", " << t_first+t_interval << std::endl; if ( useMatrix ) { PointAndDistance v ( theMatrix->crossingPoint ( rt1, rt2 ), theMatrix->distance ( rt1, rt2 ) ); vgp.push_back ( v ); } else { // No DistanceMatrix available TwoTrackMinimumDistance ttmd; bool status = ttmd.calculate( rt1.impactPointState(), rt2.impactPointState() ); if (status) { std::pair < GlobalPoint, GlobalPoint > pts = ttmd.points(); PointAndDistance v ( ( pts.second + pts.first ) / 2. , ( pts.second - pts.first ).mag() ); vgp.push_back( v ); } } if ( ( t_first + t_interval ) < lim ) { t_first++; } else if ( dir ) { t_first=0; t_interval--; if ( t_interval == 0 ) { /* std::cout << "[CrossingPtBasedLinearizationPointFinder] t_interval=0. break." << std::endl;*/ break; } } else { t_first=0; t_interval++; if ( t_interval == goodtracks.size() ) { /* std::cout << "[CrossingPtBasedLinearizationPointFinder] t_interval=" << goodtracks.size() << "(max). start to decrease intervals" << std::endl; */ dir=true; t_interval = goodtracks.size() / 2 - 1; } } } if (! vgp.size() ) { // no crossing points? Fallback to a crossingpoint-less lin pt finder! return FallbackLinearizationPointFinder().getLinearizationPoint ( tracks ); } return find ( vgp ); return GlobalPoint(0.,0.,0.); // if nothing else, then return 0,0,0 }
GlobalPoint CrossingPtBasedLinearizationPointFinder::useAllTracks | ( | const std::vector< reco::TransientTrack > & | tracks | ) | const [private] |
Definition at line 152 of file CrossingPtBasedLinearizationPointFinder.cc.
References TwoTrackMinimumDistance::calculate(), end, find(), FallbackLinearizationPointFinder::getLinearizationPoint(), TwoTrackMinimumDistance::points(), ntuplemaker::status, v, x, and detailsBasic3DVector::y.
Referenced by getLinearizationPoint().
{ std::vector< PointAndDistance > vgp; // vgp.reserve ( ( tracks.size() * ( tracks.size()-1 ) ) / 2 - 1 ); TwoTrackMinimumDistance ttmd; bool status; std::vector<reco::TransientTrack>::const_iterator end=tracks.end(); std::vector<reco::TransientTrack>::const_iterator endm1=(end-1); for ( std::vector<reco::TransientTrack>::const_iterator x=tracks.begin(); x!=endm1 ; ++x ) { for ( std::vector<reco::TransientTrack>::const_iterator y=x+1; y!=end; ++y ) { status = ttmd.calculate( (*x).impactPointState(), (*y).impactPointState() ); if (status) { std::pair < GlobalPoint, GlobalPoint > pts = ttmd.points(); std::pair < GlobalPoint , float > v ( ( pts.second + pts.first ) / 2. , ( pts.second - pts.first ).mag() ); vgp.push_back( v ); } // If sth goes wrong, we just dont add. Who cares? } } if (! vgp.size() ) { return FallbackLinearizationPointFinder().getLinearizationPoint ( tracks ); } return find ( vgp ); }
GlobalPoint CrossingPtBasedLinearizationPointFinder::useFullMatrix | ( | const std::vector< reco::TransientTrack > & | tracks | ) | const [private] |
Definition at line 183 of file CrossingPtBasedLinearizationPointFinder.cc.
References RecTracksDistanceMatrix::crossingPoint(), RecTracksDistanceMatrix::distance(), end, find(), FallbackLinearizationPointFinder::getLinearizationPoint(), theMatrix, v, x, and detailsBasic3DVector::y.
Referenced by getLinearizationPoint().
{ std::vector< PointAndDistance > vgp; vgp.reserve ( (int) ( tracks.size() * ( tracks.size() -1 ) / 2. - 1 ) ); std::vector<reco::TransientTrack>::const_iterator end=tracks.end(); std::vector<reco::TransientTrack>::const_iterator endm1=(end-1); for ( std::vector<reco::TransientTrack>::const_iterator x=tracks.begin(); x!=endm1 ; ++x ) { for ( std::vector<reco::TransientTrack>::const_iterator y=x+1; y!=end; ++y ) { PointAndDistance v ( theMatrix->crossingPoint ( *x , *y ), theMatrix->distance ( *x, *y ) ); vgp.push_back ( v ); } } if (! vgp.size() ) { return FallbackLinearizationPointFinder().getLinearizationPoint ( tracks ); } return find ( vgp ); }
Definition at line 68 of file CrossingPtBasedLinearizationPointFinder.h.
Referenced by ~CrossingPtBasedLinearizationPointFinder().
const RecTracksDistanceMatrix* CrossingPtBasedLinearizationPointFinder::theMatrix [protected] |
Definition at line 61 of file CrossingPtBasedLinearizationPointFinder.h.
Referenced by getLinearizationPoint(), and useFullMatrix().
signed int CrossingPtBasedLinearizationPointFinder::theNPairs [protected] |
Definition at line 60 of file CrossingPtBasedLinearizationPointFinder.h.
Referenced by getBestTracks(), and getLinearizationPoint().
const bool CrossingPtBasedLinearizationPointFinder::useMatrix [protected] |
Definition at line 57 of file CrossingPtBasedLinearizationPointFinder.h.
Referenced by getLinearizationPoint().