CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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

CrossingPtBasedLinearizationPointFinderclone () const override
 
 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 &)
 
GlobalPoint getLinearizationPoint (const std::vector< reco::TransientTrack > &) const override
 
GlobalPoint getLinearizationPoint (const std::vector< FreeTrajectoryState > &) const override
 
 ~CrossingPtBasedLinearizationPointFinder () override
 
- 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 91 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 95 of file CrossingPtBasedLinearizationPointFinder.cc.

CrossingPtBasedLinearizationPointFinder::CrossingPtBasedLinearizationPointFinder ( const CrossingPtBasedLinearizationPointFinder o)
CrossingPtBasedLinearizationPointFinder::~CrossingPtBasedLinearizationPointFinder ( )
override

Member Function Documentation

CrossingPtBasedLinearizationPointFinder* CrossingPtBasedLinearizationPointFinder::clone ( ) const
inlineoverridevirtual
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 178 of file CrossingPtBasedLinearizationPointFinder.cc.

References input, and runTheMatrix::ret.

Referenced by getLinearizationPoint(), useAllTracks(), and useFullMatrix().

178  {
179  /*
180  std::cout << "[CrossingPtBasedLinearizationPointFinder] input size="
181  << input.size() << std::endl;*/
182  GlobalPoint ret = (*theAlgo)(input);
183 #ifdef Use_GraphicsHarvester
184 
185  graphicsDebug(input);
186 #endif
187 
188  return ret;
189 }
tuple ret
prodAgent to be discontinued
static std::string const input
Definition: EdmProvDump.cc:47
std::vector< reco::TransientTrack > CrossingPtBasedLinearizationPointFinder::getBestTracks ( const std::vector< reco::TransientTrack > &  tracks) const
private

Definition at line 109 of file CrossingPtBasedLinearizationPointFinder.cc.

References theNPairs, and tracks.

Referenced by getLinearizationPoint().

110  {
111  unsigned int n_tracks = (2 * (unsigned int)(theNPairs)) < tracks.size() ? 2 * theNPairs : tracks.size();
112 
113  std::vector<reco::TransientTrack> newtracks = tracks;
114  partial_sort(newtracks.begin(), newtracks.begin() + n_tracks, newtracks.end(), CompareTwoTracks());
115  newtracks.erase(newtracks.begin() + n_tracks, newtracks.end());
116 
117  /*
118  * old version, when we have a default constructor
119  *
120 
121  std::vector <reco::TransientTrack> newtracks ( n_tracks );
122  partial_sort_copy ( tracks.begin(), tracks.end(), newtracks.begin(),
123  newtracks.begin() + n_tracks , CompareTwoTracks() );
124  */
125 
126  return newtracks;
127 }
auto const & tracks
cannot be loose
GlobalPoint CrossingPtBasedLinearizationPointFinder::getLinearizationPoint ( const std::vector< reco::TransientTrack > &  tracks) const
overridevirtual

Method giving back the Initial Linearization Point.

Implements LinearizationPointFinder.

Definition at line 191 of file CrossingPtBasedLinearizationPointFinder.cc.

References TwoTrackMinimumDistance::calculate(), RecTracksDistanceMatrix::crossingPoint(), DeadROC_duringRun::dir, RecTracksDistanceMatrix::distance(), find(), getBestTracks(), FallbackLinearizationPointFinder::getLinearizationPoint(), reco::TransientTrack::impactPointState(), TwoTrackMinimumDistance::points(), RPCpg::pts, mps_update::status, theMatrix, theNPairs, useAllTracks(), useFullMatrix(), useMatrix, and findQualityFiles::v.

192  {
193  if (tracks.size() < 2)
194  throw LinPtException("CrossingPtBasedLinPtFinder: too few tracks given.");
195  std::vector<PointAndDistance> vgp;
196  if (theNPairs == -1) {
197  if (useMatrix) {
198  return useFullMatrix(tracks);
199  } else {
200  return useAllTracks(tracks);
201  }
202  }
203 
204  if (sum(tracks.size() - 1) < ((unsigned int)(theNPairs))) {
205  /*
206  std::cout << "[CrossingPtBasedLinearizationPointFinder] we exploit all track pairs"
207  << std::endl;*/
208  // we have fewer track pair options than is foreseen
209  // in the quota.
210  // so we exploit all tracks pairs.
211  return useAllTracks(tracks);
212  }
213 
214  std::vector<reco::TransientTrack> goodtracks = getBestTracks(tracks);
215 
216  // we sort according to momenta.
217  if (goodtracks.size() < 2)
218  throw LinPtException("CrossingPtBasedLinPtFinder: less than two tracks given");
219  // vgp.reserve ( theNPairs - 1 );
220  unsigned int t_first = 0;
221  unsigned int t_interval = goodtracks.size() / 2;
222  unsigned int lim = goodtracks.size() - 1;
223 
224  /*
225  std::cout << "[CrossingPtBasedLinearizationPointFinder] we start: npairs=" << theNPairs
226  << std::endl;
227  std::cout << "[CrossingPtBasedLinearizationPointFinder] t_interval=" << t_interval << std::endl;
228  std::cout << "[CrossingPtBasedLinearizationPointFinder goodtracks.size=" << goodtracks.size()
229  << std::endl;*/
230 
231  // the 'direction' false: intervals will expand
232  // true: intervals will shrink
233  bool dir = false;
234 
235  while (vgp.size() < ((unsigned int)(theNPairs))) {
236  reco::TransientTrack rt1 = goodtracks[t_first];
237  reco::TransientTrack rt2 = goodtracks[t_first + t_interval];
238  // std::cout << "Considering now: " << t_first << ", " << t_first+t_interval << std::endl;
239  if (useMatrix) {
241  vgp.push_back(v);
242  } else { // No DistanceMatrix available
244  bool status = ttmd.calculate(rt1.impactPointState(), rt2.impactPointState());
245  if (status) {
246  std::pair<GlobalPoint, GlobalPoint> pts = ttmd.points();
247  PointAndDistance v((pts.second + pts.first) / 2., (pts.second - pts.first).mag());
248  vgp.push_back(v);
249  }
250  }
251  if ((t_first + t_interval) < lim) {
252  t_first++;
253  } else if (dir) {
254  t_first = 0;
255  t_interval--;
256  if (t_interval == 0) {
257  /* std::cout << "[CrossingPtBasedLinearizationPointFinder] t_interval=0. break."
258  << std::endl;*/
259  break;
260  }
261  } else {
262  t_first = 0;
263  t_interval++;
264  if (t_interval == goodtracks.size()) {
265  /* std::cout << "[CrossingPtBasedLinearizationPointFinder] t_interval="
266  << goodtracks.size() << "(max). start to decrease intervals"
267  << std::endl; */
268  dir = true;
269  t_interval = goodtracks.size() / 2 - 1;
270  }
271  }
272  }
273  if (vgp.empty()) {
274  // no crossing points? Fallback to a crossingpoint-less lin pt finder!
276  }
277  return find(vgp);
278 
279  return GlobalPoint(0., 0., 0.); // if nothing else, then return 0,0,0
280 }
GlobalPoint useAllTracks(const std::vector< reco::TransientTrack > &) const
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
list status
Definition: mps_update.py:107
std::vector< reco::TransientTrack > getBestTracks(const std::vector< reco::TransientTrack > &) const
auto const & tracks
cannot be loose
bool calculate(const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb) override
static const double pts[33]
Definition: Constants.h:30
std::pair< GlobalPoint, GlobalPoint > points() const override
virtual GlobalPoint crossingPoint(const reco::TransientTrack, const reco::TransientTrack) const =0
GlobalPoint getLinearizationPoint(const std::vector< reco::TransientTrack > &) const override
TrajectoryStateOnSurface impactPointState() const
GlobalPoint useFullMatrix(const std::vector< reco::TransientTrack > &) const
GlobalPoint CrossingPtBasedLinearizationPointFinder::getLinearizationPoint ( const std::vector< FreeTrajectoryState > &  tracks) const
overridevirtual

Reimplemented from LinearizationPointFinder.

Definition at line 173 of file CrossingPtBasedLinearizationPointFinder.cc.

References LinearizationPointFinder::getLinearizationPoint().

174  {
176 }
auto const & tracks
cannot be loose
virtual GlobalPoint getLinearizationPoint(const std::vector< reco::TransientTrack > &) const =0
GlobalPoint CrossingPtBasedLinearizationPointFinder::useAllTracks ( const std::vector< reco::TransientTrack > &  tracks) const
private

Definition at line 131 of file CrossingPtBasedLinearizationPointFinder.cc.

References TwoTrackMinimumDistance::calculate(), dataset::end, find(), FallbackLinearizationPointFinder::getLinearizationPoint(), TwoTrackMinimumDistance::points(), RPCpg::pts, mps_update::status, findQualityFiles::v, x, and y.

Referenced by getLinearizationPoint().

132  {
133  std::vector<PointAndDistance> vgp;
134  // vgp.reserve ( ( tracks.size() * ( tracks.size()-1 ) ) / 2 - 1 );
136  bool status;
137  std::vector<reco::TransientTrack>::const_iterator end = tracks.end();
138  std::vector<reco::TransientTrack>::const_iterator endm1 = (end - 1);
139  for (std::vector<reco::TransientTrack>::const_iterator x = tracks.begin(); x != endm1; ++x) {
140  for (std::vector<reco::TransientTrack>::const_iterator y = x + 1; y != end; ++y) {
141  status = ttmd.calculate((*x).impactPointState(), (*y).impactPointState());
142  if (status) {
143  std::pair<GlobalPoint, GlobalPoint> pts = ttmd.points();
144  std::pair<GlobalPoint, float> v((pts.second + pts.first) / 2., (pts.second - pts.first).mag());
145  vgp.push_back(v);
146  } // If sth goes wrong, we just dont add. Who cares?
147  }
148  }
149  if (vgp.empty()) {
151  }
152  return find(vgp);
153 }
GlobalPoint find(const std::vector< std::pair< GlobalPoint, float > > &) const
list status
Definition: mps_update.py:107
auto const & tracks
cannot be loose
bool calculate(const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb) override
static const double pts[33]
Definition: Constants.h:30
std::pair< GlobalPoint, GlobalPoint > points() const override
string end
Definition: dataset.py:937
GlobalPoint getLinearizationPoint(const std::vector< reco::TransientTrack > &) const override
GlobalPoint CrossingPtBasedLinearizationPointFinder::useFullMatrix ( const std::vector< reco::TransientTrack > &  tracks) const
private

Definition at line 155 of file CrossingPtBasedLinearizationPointFinder.cc.

References RecTracksDistanceMatrix::crossingPoint(), RecTracksDistanceMatrix::distance(), dataset::end, find(), FallbackLinearizationPointFinder::getLinearizationPoint(), theMatrix, findQualityFiles::v, x, and y.

Referenced by getLinearizationPoint().

156  {
157  std::vector<PointAndDistance> vgp;
158  vgp.reserve((int)(tracks.size() * (tracks.size() - 1) / 2. - 1));
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(); x != endm1; ++x) {
162  for (std::vector<reco::TransientTrack>::const_iterator y = x + 1; y != end; ++y) {
164  vgp.push_back(v);
165  }
166  }
167  if (vgp.empty()) {
169  }
170  return find(vgp);
171 }
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
auto const & tracks
cannot be loose
virtual GlobalPoint crossingPoint(const reco::TransientTrack, const reco::TransientTrack) const =0
string end
Definition: dataset.py:937
GlobalPoint getLinearizationPoint(const std::vector< reco::TransientTrack > &) const override

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 54 of file CrossingPtBasedLinearizationPointFinder.h.

Referenced by getLinearizationPoint().