CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes
CrossingPtBasedLinearizationPointFinder Class Reference

#include <CrossingPtBasedLinearizationPointFinder.h>

Inheritance diagram for CrossingPtBasedLinearizationPointFinder:
LinearizationPointFinder FsmwLinearizationPointFinder HSMLinearizationPointFinder LMSLinearizationPointFinder SMSLinearizationPointFinder SubsetHSMLinearizationPointFinder DefaultLinearizationPointFinder

Classes

struct  CompareTwoTracks
 

Public Member Functions

virtual
CrossingPtBasedLinearizationPointFinder
clone () const
 
 CrossingPtBasedLinearizationPointFinder (const ModeFinder3d &algo, const signed int n_pairs=5)
 
 CrossingPtBasedLinearizationPointFinder (const RecTracksDistanceMatrix *m, const ModeFinder3d &algo, const signed int n_pairs=-1)
 
 CrossingPtBasedLinearizationPointFinder (const CrossingPtBasedLinearizationPointFinder &)
 
virtual GlobalPoint getLinearizationPoint (const std::vector< reco::TransientTrack > &) const
 
virtual GlobalPoint getLinearizationPoint (const std::vector< FreeTrajectoryState > &) const
 
 ~CrossingPtBasedLinearizationPointFinder ()
 
- Public Member Functions inherited from LinearizationPointFinder
virtual ~LinearizationPointFinder ()
 

Protected Attributes

const RecTracksDistanceMatrixtheMatrix
 
signed int theNPairs
 
const bool useMatrix
 

Private Member Functions

GlobalPoint find (const std::vector< std::pair< GlobalPoint, float > > &) const
 
std::vector< reco::TransientTrackgetBestTracks (const std::vector< reco::TransientTrack > &) const
 
GlobalPoint useAllTracks (const std::vector< reco::TransientTrack > &) const
 
GlobalPoint useFullMatrix (const std::vector< reco::TransientTrack > &) const
 

Private Attributes

ModeFinder3dtheAlgo
 

Detailed Description

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.

Constructor & Destructor Documentation

CrossingPtBasedLinearizationPointFinder::CrossingPtBasedLinearizationPointFinder ( const ModeFinder3d algo,
const signed int  n_pairs = 5 
)
Parameters
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.

Parameters
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.

Member Function Documentation

virtual CrossingPtBasedLinearizationPointFinder* CrossingPtBasedLinearizationPointFinder::clone ( ) const
inlinevirtual
GlobalPoint CrossingPtBasedLinearizationPointFinder::find ( const std::vector< std::pair< GlobalPoint, float > > &  ) const
private

calls (*theAglo) (input) can optionally save input / output in .root file

Definition at line 214 of file CrossingPtBasedLinearizationPointFinder.cc.

References LaserDQM_cfg::input, and run_regression::ret.

Referenced by BeautifulSoup.Tag::_invert(), getLinearizationPoint(), BeautifulSoup.PageElement::insert(), useAllTracks(), and useFullMatrix().

216 {
217  /*
218  std::cout << "[CrossingPtBasedLinearizationPointFinder] input size="
219  << input.size() << std::endl;*/
220  GlobalPoint ret = (*theAlgo) (input);
221 #ifdef Use_GraphicsHarvester
222 
223  graphicsDebug ( input );
224 #endif
225 
226  return ret;
227 }
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().

131 {
132  unsigned int n_tracks = (2*(unsigned int) (theNPairs)) < tracks.size() ? 2*theNPairs : tracks.size();
133 
134  std::vector <reco::TransientTrack> newtracks = tracks;
135  partial_sort ( newtracks.begin(), newtracks.begin()+n_tracks, newtracks.end(), CompareTwoTracks() );
136  newtracks.erase ( newtracks.begin()+n_tracks, newtracks.end() );
137 
138  /*
139  * old version, when we have a default constructor
140  *
141 
142  std::vector <reco::TransientTrack> newtracks ( n_tracks );
143  partial_sort_copy ( tracks.begin(), tracks.end(), newtracks.begin(),
144  newtracks.begin() + n_tracks , CompareTwoTracks() );
145  */
146 
147  return newtracks;
148 }
tuple tracks
Definition: testEve_cfg.py:39
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(), RPCpg::pts, ntuplemaker::status, theMatrix, theNPairs, useAllTracks(), useFullMatrix(), useMatrix, and v.

231 {
232  if ( tracks.size() < 2 )
233  throw LinPtException
234  ("CrossingPtBasedLinPtFinder: too few tracks given.");
235  std::vector < PointAndDistance > vgp;
236  if ( theNPairs == -1 )
237  {
238  if ( useMatrix )
239  {
240  return useFullMatrix( tracks );
241  }
242  else
243  {
244  return useAllTracks ( tracks );
245  }
246  }
247 
248  if ( sum ( tracks.size() - 1 ) < ((unsigned int) (theNPairs)) )
249  {
250  /*
251  std::cout << "[CrossingPtBasedLinearizationPointFinder] we exploit all track pairs"
252  << std::endl;*/
253  // we have fewer track pair options than is foreseen
254  // in the quota.
255  // so we exploit all tracks pairs.
256  return useAllTracks ( tracks );
257  }
258 
259  std::vector <reco::TransientTrack> goodtracks = getBestTracks ( tracks );
260 
261  // we sort according to momenta.
262  if ( goodtracks.size() < 2 )
263  throw LinPtException (
264  "CrossingPtBasedLinPtFinder: less than two tracks given");
265  // vgp.reserve ( theNPairs - 1 );
266  unsigned int t_first = 0;
267  unsigned int t_interval = goodtracks.size() / 2;
268  unsigned int lim = goodtracks.size() - 1;
269 
270  /*
271  std::cout << "[CrossingPtBasedLinearizationPointFinder] we start: npairs=" << theNPairs
272  << std::endl;
273  std::cout << "[CrossingPtBasedLinearizationPointFinder] t_interval=" << t_interval << std::endl;
274  std::cout << "[CrossingPtBasedLinearizationPointFinder goodtracks.size=" << goodtracks.size()
275  << std::endl;*/
276 
277  // the 'direction' false: intervals will expand
278  // true: intervals will shrink
279  bool dir = false;
280 
281  while ( vgp.size() < ((unsigned int) (theNPairs)) )
282  {
283  reco::TransientTrack rt1 = goodtracks [ t_first ];
284  reco::TransientTrack rt2 = goodtracks [ t_first + t_interval ];
285  // std::cout << "Considering now: " << t_first << ", " << t_first+t_interval << std::endl;
286  if ( useMatrix )
287  {
288  PointAndDistance v ( theMatrix->crossingPoint ( rt1, rt2 ),
289  theMatrix->distance ( rt1, rt2 ) );
290  vgp.push_back ( v );
291  }
292  else
293  { // No DistanceMatrix available
295  bool status = ttmd.calculate( rt1.impactPointState(), rt2.impactPointState() );
296  if (status) {
297  std::pair < GlobalPoint, GlobalPoint > pts = ttmd.points();
298  PointAndDistance v ( ( pts.second + pts.first ) / 2. ,
299  ( pts.second - pts.first ).mag() );
300  vgp.push_back( v );
301  }
302  }
303  if ( ( t_first + t_interval ) < lim )
304  {
305  t_first++;
306  }
307  else if ( dir )
308  {
309  t_first=0;
310  t_interval--;
311  if ( t_interval == 0 )
312  {
313  /* std::cout << "[CrossingPtBasedLinearizationPointFinder] t_interval=0. break."
314  << std::endl;*/
315  break;
316  }
317  }
318  else
319  {
320  t_first=0;
321  t_interval++;
322  if ( t_interval == goodtracks.size() )
323  {
324  /* std::cout << "[CrossingPtBasedLinearizationPointFinder] t_interval="
325  << goodtracks.size() << "(max). start to decrease intervals"
326  << std::endl; */
327  dir=true;
328  t_interval = goodtracks.size() / 2 - 1;
329  }
330  }
331  }
332  if (! vgp.size() )
333  {
334  // no crossing points? Fallback to a crossingpoint-less lin pt finder!
336  }
337  return find ( vgp );
338 
339  return GlobalPoint(0.,0.,0.); // if nothing else, then return 0,0,0
340 }
GlobalPoint useAllTracks(const std::vector< reco::TransientTrack > &) const
virtual bool calculate(const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb)
GlobalPoint find(const std::vector< std::pair< GlobalPoint, float > > &) const
std::pair< GlobalPoint, float > PointAndDistance
virtual double distance(const reco::TransientTrack, const reco::TransientTrack) const =0
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
std::vector< reco::TransientTrack > getBestTracks(const std::vector< reco::TransientTrack > &) const
virtual GlobalPoint getLinearizationPoint(const std::vector< reco::TransientTrack > &) const
static const double pts[33]
Definition: Constants.h:31
virtual GlobalPoint crossingPoint(const reco::TransientTrack, const reco::TransientTrack) const =0
tuple tracks
Definition: testEve_cfg.py:39
TrajectoryStateOnSurface impactPointState() const
dbl *** dir
Definition: mlp_gen.cc:35
GlobalPoint useFullMatrix(const std::vector< reco::TransientTrack > &) const
tuple status
Definition: ntuplemaker.py:245
virtual std::pair< GlobalPoint, GlobalPoint > points() const
mathSSE::Vec4< T > v
GlobalPoint CrossingPtBasedLinearizationPointFinder::getLinearizationPoint ( const std::vector< FreeTrajectoryState > &  tracks) const
virtual

Reimplemented from LinearizationPointFinder.

Definition at line 208 of file CrossingPtBasedLinearizationPointFinder.cc.

References LinearizationPointFinder::getLinearizationPoint().

210 {
212 }
tuple tracks
Definition: testEve_cfg.py:39
virtual GlobalPoint getLinearizationPoint(const std::vector< reco::TransientTrack > &) const =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(), RPCpg::pts, ntuplemaker::status, v, x, and detailsBasic3DVector::y.

Referenced by getLinearizationPoint().

154 {
155  std::vector< PointAndDistance > vgp;
156  // vgp.reserve ( ( tracks.size() * ( tracks.size()-1 ) ) / 2 - 1 );
158  bool status;
159  std::vector<reco::TransientTrack>::const_iterator end=tracks.end();
160  std::vector<reco::TransientTrack>::const_iterator endm1=(end-1);
161  for ( std::vector<reco::TransientTrack>::const_iterator x=tracks.begin();
162  x!=endm1 ; ++x )
163  {
164  for ( std::vector<reco::TransientTrack>::const_iterator y=x+1;
165  y!=end; ++y )
166  {
167  status = ttmd.calculate( (*x).impactPointState(), (*y).impactPointState() );
168  if (status) {
169  std::pair < GlobalPoint, GlobalPoint > pts = ttmd.points();
170  std::pair < GlobalPoint , float > v ( ( pts.second + pts.first ) / 2. ,
171  ( pts.second - pts.first ).mag() );
172  vgp.push_back( v );
173  } // If sth goes wrong, we just dont add. Who cares?
174  }
175  }
176  if (! vgp.size() )
177  {
179  }
180  return find ( vgp );
181 }
virtual bool calculate(const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb)
GlobalPoint find(const std::vector< std::pair< GlobalPoint, float > > &) const
virtual GlobalPoint getLinearizationPoint(const std::vector< reco::TransientTrack > &) const
static const double pts[33]
Definition: Constants.h:31
#define end
Definition: vmac.h:38
tuple tracks
Definition: testEve_cfg.py:39
Definition: DDAxes.h:10
tuple status
Definition: ntuplemaker.py:245
virtual std::pair< GlobalPoint, GlobalPoint > points() const
mathSSE::Vec4< T > v
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().

185 {
186  std::vector< PointAndDistance > vgp;
187  vgp.reserve ( (int) ( tracks.size() * ( tracks.size() -1 ) / 2. - 1 ) );
188  std::vector<reco::TransientTrack>::const_iterator end=tracks.end();
189  std::vector<reco::TransientTrack>::const_iterator endm1=(end-1);
190  for ( std::vector<reco::TransientTrack>::const_iterator x=tracks.begin();
191  x!=endm1 ; ++x )
192  {
193  for ( std::vector<reco::TransientTrack>::const_iterator y=x+1;
194  y!=end; ++y )
195  {
197  theMatrix->distance ( *x, *y ) );
198  vgp.push_back ( v );
199  }
200  }
201  if (! vgp.size() )
202  {
204  }
205  return find ( vgp );
206 }
GlobalPoint find(const std::vector< std::pair< GlobalPoint, float > > &) const
std::pair< GlobalPoint, float > PointAndDistance
virtual double distance(const reco::TransientTrack, const reco::TransientTrack) const =0
virtual GlobalPoint getLinearizationPoint(const std::vector< reco::TransientTrack > &) const
#define end
Definition: vmac.h:38
virtual GlobalPoint crossingPoint(const reco::TransientTrack, const reco::TransientTrack) const =0
tuple tracks
Definition: testEve_cfg.py:39
Definition: DDAxes.h:10
mathSSE::Vec4< T > v

Member Data Documentation

ModeFinder3d* CrossingPtBasedLinearizationPointFinder::theAlgo
private
const RecTracksDistanceMatrix* CrossingPtBasedLinearizationPointFinder::theMatrix
protected
signed int CrossingPtBasedLinearizationPointFinder::theNPairs
protected
const bool CrossingPtBasedLinearizationPointFinder::useMatrix
protected

Definition at line 57 of file CrossingPtBasedLinearizationPointFinder.h.

Referenced by getLinearizationPoint().