CMS 3D CMS Logo

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 CrossingPtBasedLinearizationPointFinder &)
 
 CrossingPtBasedLinearizationPointFinder (const ModeFinder3d &algo, const signed int n_pairs=5)
 
 CrossingPtBasedLinearizationPointFinder (const RecTracksDistanceMatrix *m, const ModeFinder3d &algo, const signed int n_pairs=-1)
 
GlobalPoint getLinearizationPoint (const std::vector< FreeTrajectoryState > &) const override
 
GlobalPoint getLinearizationPoint (const std::vector< reco::TransientTrack > &) 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() [1/3]

CrossingPtBasedLinearizationPointFinder::CrossingPtBasedLinearizationPointFinder ( const ModeFinder3d algo,
const signed int  n_pairs = 5 
)
Parameters
n_pairshow many track pairs will be considered (maximum) a value of -1 means full combinatorics.

Definition at line 91 of file CrossingPtBasedLinearizationPointFinder.cc.

93  : useMatrix(false), theNPairs(n_pairs), theMatrix(nullptr), theAlgo(algo.clone()) {}

Referenced by clone().

◆ CrossingPtBasedLinearizationPointFinder() [2/3]

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_pairshow many track pairs will be considered (maximum) a value of -1 means full combinatorics.

Definition at line 95 of file CrossingPtBasedLinearizationPointFinder.cc.

98  : useMatrix(m->hasCrossingPoints()), theNPairs(n_pairs), theMatrix(m), theAlgo(algo.clone()) {}

◆ CrossingPtBasedLinearizationPointFinder() [3/3]

CrossingPtBasedLinearizationPointFinder::CrossingPtBasedLinearizationPointFinder ( const CrossingPtBasedLinearizationPointFinder o)

Definition at line 100 of file CrossingPtBasedLinearizationPointFinder.cc.

102  : useMatrix(o.useMatrix),
103  theNPairs(o.theNPairs),
104  theMatrix(o.theMatrix /* nope, we dont clone!! */),
105  theAlgo(o.theAlgo->clone()) {}

◆ ~CrossingPtBasedLinearizationPointFinder()

CrossingPtBasedLinearizationPointFinder::~CrossingPtBasedLinearizationPointFinder ( )
override

Definition at line 107 of file CrossingPtBasedLinearizationPointFinder.cc.

107 { delete theAlgo; }

References theAlgo.

Member Function Documentation

◆ clone()

CrossingPtBasedLinearizationPointFinder* CrossingPtBasedLinearizationPointFinder::clone ( ) const
inlineoverridevirtual

◆ find()

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.

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 }

References input, and runTheMatrix::ret.

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

◆ getBestTracks()

std::vector< reco::TransientTrack > CrossingPtBasedLinearizationPointFinder::getBestTracks ( const std::vector< reco::TransientTrack > &  tracks) const
private

Definition at line 109 of file CrossingPtBasedLinearizationPointFinder.cc.

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 }

References createfilelist::int, theNPairs, and PDWG_EXOHSCP_cff::tracks.

Referenced by getLinearizationPoint().

◆ getLinearizationPoint() [1/2]

GlobalPoint CrossingPtBasedLinearizationPointFinder::getLinearizationPoint ( const std::vector< FreeTrajectoryState > &  tracks) const
overridevirtual

◆ getLinearizationPoint() [2/2]

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.

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 }

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

◆ useAllTracks()

GlobalPoint CrossingPtBasedLinearizationPointFinder::useAllTracks ( const std::vector< reco::TransientTrack > &  tracks) const
private

Definition at line 131 of file CrossingPtBasedLinearizationPointFinder.cc.

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 }

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

Referenced by getLinearizationPoint().

◆ useFullMatrix()

GlobalPoint CrossingPtBasedLinearizationPointFinder::useFullMatrix ( const std::vector< reco::TransientTrack > &  tracks) const
private

Definition at line 155 of file CrossingPtBasedLinearizationPointFinder.cc.

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 }

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

Referenced by getLinearizationPoint().

Member Data Documentation

◆ theAlgo

ModeFinder3d* CrossingPtBasedLinearizationPointFinder::theAlgo
private

◆ theMatrix

const RecTracksDistanceMatrix* CrossingPtBasedLinearizationPointFinder::theMatrix
protected

◆ theNPairs

signed int CrossingPtBasedLinearizationPointFinder::theNPairs
protected

◆ useMatrix

const bool CrossingPtBasedLinearizationPointFinder::useMatrix
protected

Definition at line 54 of file CrossingPtBasedLinearizationPointFinder.h.

Referenced by getLinearizationPoint().

runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:373
DDAxes::y
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
input
static const std::string input
Definition: EdmProvDump.cc:48
mps_update.status
status
Definition: mps_update.py:69
TwoTrackMinimumDistance
Definition: TwoTrackMinimumDistance.h:20
CrossingPtBasedLinearizationPointFinder::CrossingPtBasedLinearizationPointFinder
CrossingPtBasedLinearizationPointFinder(const ModeFinder3d &algo, const signed int n_pairs=5)
Definition: CrossingPtBasedLinearizationPointFinder.cc:91
DDAxes::x
findQualityFiles.v
v
Definition: findQualityFiles.py:179
EcalTangentSkim_cfg.o
o
Definition: EcalTangentSkim_cfg.py:36
TwoTrackMinimumDistance::calculate
bool calculate(const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb) override
Definition: TwoTrackMinimumDistance.cc:83
RecTracksDistanceMatrix::distance
virtual double distance(const reco::TransientTrack, const reco::TransientTrack) const =0
cmsdt::algo
algo
Definition: constants.h:164
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
CrossingPtBasedLinearizationPointFinder::theAlgo
ModeFinder3d * theAlgo
Definition: CrossingPtBasedLinearizationPointFinder.h:67
mps_fire.end
end
Definition: mps_fire.py:242
CrossingPtBasedLinearizationPointFinder::useFullMatrix
GlobalPoint useFullMatrix(const std::vector< reco::TransientTrack > &) const
Definition: CrossingPtBasedLinearizationPointFinder.cc:155
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Point3DBase< float, GlobalTag >
TwoTrackMinimumDistance::points
std::pair< GlobalPoint, GlobalPoint > points() const override
Definition: TwoTrackMinimumDistance.cc:75
CrossingPtBasedLinearizationPointFinder::useMatrix
const bool useMatrix
Definition: CrossingPtBasedLinearizationPointFinder.h:54
reco::TransientTrack::impactPointState
TrajectoryStateOnSurface impactPointState() const
Definition: TransientTrack.h:98
CrossingPtBasedLinearizationPointFinder::getBestTracks
std::vector< reco::TransientTrack > getBestTracks(const std::vector< reco::TransientTrack > &) const
Definition: CrossingPtBasedLinearizationPointFinder.cc:109
createfilelist.int
int
Definition: createfilelist.py:10
CrossingPtBasedLinearizationPointFinder::theNPairs
signed int theNPairs
Definition: CrossingPtBasedLinearizationPointFinder.h:58
RPCpg::pts
static const double pts[33]
Definition: Constants.h:30
FallbackLinearizationPointFinder::getLinearizationPoint
GlobalPoint getLinearizationPoint(const std::vector< reco::TransientTrack > &) const override
Definition: FallbackLinearizationPointFinder.cc:13
LinPtException
Definition: LinPtException.h:10
reco::TransientTrack
Definition: TransientTrack.h:19
RecTracksDistanceMatrix::crossingPoint
virtual GlobalPoint crossingPoint(const reco::TransientTrack, const reco::TransientTrack) const =0
PointAndDistance
std::pair< GlobalPoint, float > PointAndDistance
Definition: CrossingPtBasedLinearizationPointFinder.cc:129
LinearizationPointFinder::getLinearizationPoint
virtual GlobalPoint getLinearizationPoint(const std::vector< reco::TransientTrack > &) const =0
FallbackLinearizationPointFinder
Definition: FallbackLinearizationPointFinder.h:13
CrossingPtBasedLinearizationPointFinder::theMatrix
const RecTracksDistanceMatrix * theMatrix
Definition: CrossingPtBasedLinearizationPointFinder.h:59
CrossingPtBasedLinearizationPointFinder::find
GlobalPoint find(const std::vector< std::pair< GlobalPoint, float > > &) const
Definition: CrossingPtBasedLinearizationPointFinder.cc:178
CompareTwoTracks
Definition: ConversionTrackPairFinder.h:32
CrossingPtBasedLinearizationPointFinder::useAllTracks
GlobalPoint useAllTracks(const std::vector< reco::TransientTrack > &) const
Definition: CrossingPtBasedLinearizationPointFinder.cc:131
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23