CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
TrajectorySegmentBuilder Class Reference

#include <TrajectorySegmentBuilder.h>

Public Member Functions

TempTrajectoryContainer segments (const TSOS startingState)
 new segments within layer More...
 
 TrajectorySegmentBuilder (const LayerMeasurements *theInputLayerMeasurements, const DetLayer &layer, const Propagator &propagator, const TrajectoryStateUpdator &updator, const MeasurementEstimator &estimator, bool lockHits, bool bestHitOnly, int maxCand)
 constructor from layer and helper objects More...
 
 ~TrajectorySegmentBuilder ()
 destructor More...
 

Private Types

typedef TransientTrackingRecHit::ConstRecHitContainer ConstRecHitContainer
 
typedef TransientTrackingRecHit::ConstRecHitPointer ConstRecHitPointer
 
typedef FreeTrajectoryState FTS
 
typedef std::vector< TempTrajectoryTempTrajectoryContainer
 
typedef TrajectoryMeasurement TM
 
typedef TrajectoryMeasurementGroup TMG
 
typedef std::vector< TrajectoryTrajectoryContainer
 
typedef TrajectoryStateOnSurface TSOS
 

Private Member Functions

std::vector< TempTrajectoryaddGroup (TempTrajectory const &traj, std::vector< TrajectoryMeasurementGroup >::const_iterator begin, std::vector< TrajectoryMeasurementGroup >::const_iterator end)
 
void cleanCandidates (std::vector< TempTrajectory > &candidates) const
 clean a set of candidates More...
 
void lockMeasurement (const TM &measurement)
 mark a hit as used More...
 
std::vector< TrajectoryMeasurementredoMeasurements (const TempTrajectory &traj, const DetGroup &detGroup) const
 retrieve compatible hits from a DetGroup More...
 
std::vector< TrajectoryMeasurementunlockedMeasurements (const std::vector< TM > &measurements) const
 get list of unused hits More...
 
void updateCandidates (TempTrajectory const &traj, const std::vector< TM > &measurements, TempTrajectoryContainer &candidates)
 creation of new candidates from a segment and a collection of hits More...
 
void updateCandidatesWithBestHit (TempTrajectory const &traj, TM measurements, TempTrajectoryContainer &candidates)
 creation of a new candidate from a segment and the best hit out of a collection More...
 
void updateTrajectory (TempTrajectory &traj, TM tm) const
 update of a trajectory with a hit More...
 
void updateWithInvalidHit (TempTrajectory &traj, const std::vector< TMG > &groups, TempTrajectoryContainer &candidates) const
 

Private Attributes

bool theBestHitOnly
 
bool theDbgFlg
 
const MeasurementEstimatortheEstimator
 
const PropagatortheFullPropagator
 
const PropagatortheGeomPropagator
 
const DetLayertheLayer
 
const LayerMeasurementstheLayerMeasurements
 
ConstRecHitContainer theLockedHits
 
bool theLockHits
 
int theMaxCand
 
const TrajectoryStateUpdatortheUpdator
 

Detailed Description

Definition at line 31 of file TrajectorySegmentBuilder.h.

Member Typedef Documentation

Definition at line 40 of file TrajectorySegmentBuilder.h.

Definition at line 41 of file TrajectorySegmentBuilder.h.

Definition at line 34 of file TrajectorySegmentBuilder.h.

Definition at line 39 of file TrajectorySegmentBuilder.h.

Definition at line 36 of file TrajectorySegmentBuilder.h.

Definition at line 37 of file TrajectorySegmentBuilder.h.

Definition at line 38 of file TrajectorySegmentBuilder.h.

Definition at line 35 of file TrajectorySegmentBuilder.h.

Constructor & Destructor Documentation

TrajectorySegmentBuilder::TrajectorySegmentBuilder ( const LayerMeasurements theInputLayerMeasurements,
const DetLayer layer,
const Propagator propagator,
const TrajectoryStateUpdator updator,
const MeasurementEstimator estimator,
bool  lockHits,
bool  bestHitOnly,
int  maxCand 
)
inline

constructor from layer and helper objects

Definition at line 45 of file TrajectorySegmentBuilder.h.

53  : theLayerMeasurements(theInputLayerMeasurements),
54  theLayer(layer),
55  theFullPropagator(propagator),
56  theUpdator(updator),
57  theEstimator(estimator),
58  theGeomPropagator(propagator),
59  // theGeomPropagator(propagator.propagationDirection()),
const MeasurementEstimator & theEstimator
const LayerMeasurements * theLayerMeasurements
const TrajectoryStateUpdator & theUpdator
TrajectorySegmentBuilder::~TrajectorySegmentBuilder ( )
inline

destructor

Definition at line 65 of file TrajectorySegmentBuilder.h.

References begin, HLT_2018_cff::candidates, and end.

65 {}

Member Function Documentation

TrajectorySegmentBuilder::TempTrajectoryContainer TrajectorySegmentBuilder::addGroup ( TempTrajectory const &  traj,
std::vector< TrajectoryMeasurementGroup >::const_iterator  begin,
std::vector< TrajectoryMeasurementGroup >::const_iterator  end 
)
private

Definition at line 216 of file TrajectorySegmentBuilder.cc.

References gather_cfg::cout, cmsutils::bqueue< T >::empty(), TempTrajectory::empty(), TempTrajectory::measurements(), eostools::move(), runTheMatrix::ret, cmsutils::bqueue< T >::size(), OrderedSet::t, and UNLIKELY.

218  {
219  vector<TempTrajectory> ret;
220  if (begin == end) {
221  //std::cout << "TrajectorySegmentBuilder::addGroup" << " traj.empty()=" << traj.empty() << "EMPTY" << std::endl;
222  if
223  UNLIKELY(theDbgFlg) cout << "TSB::addGroup : no groups left" << endl;
224  if (!traj.empty())
225  ret.push_back(traj);
226  return ret;
227  }
228 
229  if
231  cout << "TSB::addGroup : traj.size() = " << traj.measurements().size() << " first group at "
232  << &(*begin)
233  // << " nr. of candidates = " << candidates.size()
234  << endl;
235 
236  TempTrajectoryContainer updatedTrajectories;
237  updatedTrajectories.reserve(2);
238  if (traj.measurements().empty()) {
239  if (theMaxCand == 1) {
240  auto&& firstMeasurements = unlockedMeasurements(begin->measurements());
241  if (!firstMeasurements.empty())
242  updateCandidatesWithBestHit(traj, std::move(firstMeasurements.front()), updatedTrajectories);
243  } else {
244  updateCandidates(traj, begin->measurements(), updatedTrajectories);
245  }
246  if
248  cout << "TSB::addGroup : updating with first group - " << updatedTrajectories.size() << " trajectories" << endl;
249  } else {
250  auto&& meas = redoMeasurements(traj, begin->detGroup());
251  if (!meas.empty()) {
252  if (theBestHitOnly) {
253  updateCandidatesWithBestHit(traj, std::move(meas.front()), updatedTrajectories);
254  } else {
255  updateCandidates(traj, std::move(meas), updatedTrajectories);
256  }
257  if
259  cout << "TSB::addGroup : updating" << updatedTrajectories.size() << " trajectories-1" << endl;
260  }
261  }
262  // keep old trajectory
263  //
264  updatedTrajectories.push_back(traj);
265 
266  if (begin + 1 != end) {
267  ret.reserve(4); // a good upper bound
268  for (auto const& ut : updatedTrajectories) {
269  if
271  cout << "TSB::addGroup : trying to extend candidate at " << &ut << " size " << ut.measurements().size() << endl;
272  vector<TempTrajectory>&& finalTrajectories = addGroup(ut, begin + 1, end);
273  if
275  cout << "TSB::addGroup : " << finalTrajectories.size() << " finalised candidates before cleaning" << endl;
276  //B.M. to be ported later
277  // V.I. only mark invalidate
278  cleanCandidates(finalTrajectories);
279 
280  if
282  int ntf = 0;
283  for (auto const& t : finalTrajectories)
284  if (t.isValid())
285  ++ntf;
286  cout << "TSB::addGroup : got " << ntf << " finalised candidates" << endl;
287  }
288 
289  for (auto& t : finalTrajectories)
290  if (t.isValid())
291  ret.push_back(std::move(t));
292 
293  // ret.insert(ret.end(),make_move_iterator(finalTrajectories.begin()),
294  // make_move_iterator(finalTrajectories.end()));
295  }
296  } else {
297  ret.reserve(updatedTrajectories.size());
298  for (auto& t : updatedTrajectories)
299  if (!t.empty())
300  ret.push_back(std::move(t));
301  }
302 
303  //std::cout << "TrajectorySegmentBuilder::addGroup" <<
304  // " traj.empty()=" << traj.empty() <<
305  // " end-begin=" << (end-begin) <<
306  // " #updated=" << updatedTrajectories.size() <<
307  // " #result=" << ret.size() << std::endl;
308  return ret;
309 }
size
Write out results.
std::vector< TempTrajectory > TempTrajectoryContainer
void cleanCandidates(std::vector< TempTrajectory > &candidates) const
clean a set of candidates
ret
prodAgent to be discontinued
std::vector< TrajectoryMeasurement > unlockedMeasurements(const std::vector< TM > &measurements) const
get list of unused hits
std::vector< TempTrajectory > addGroup(TempTrajectory const &traj, std::vector< TrajectoryMeasurementGroup >::const_iterator begin, std::vector< TrajectoryMeasurementGroup >::const_iterator end)
return((rh^lh)&mask)
void updateCandidatesWithBestHit(TempTrajectory const &traj, TM measurements, TempTrajectoryContainer &candidates)
creation of a new candidate from a segment and the best hit out of a collection
std::vector< TrajectoryMeasurement > redoMeasurements(const TempTrajectory &traj, const DetGroup &detGroup) const
retrieve compatible hits from a DetGroup
#define end
Definition: vmac.h:39
#define begin
Definition: vmac.h:32
void updateCandidates(TempTrajectory const &traj, const std::vector< TM > &measurements, TempTrajectoryContainer &candidates)
creation of new candidates from a segment and a collection of hits
#define UNLIKELY(x)
Definition: Likely.h:21
def move(src, dest)
Definition: eostools.py:511
void TrajectorySegmentBuilder::cleanCandidates ( std::vector< TempTrajectory > &  candidates) const
private

clean a set of candidates

Definition at line 483 of file TrajectorySegmentBuilder.cc.

References TrackingRecHit::all, newFWLiteAna::found, mps_fire::i, testProducerWithPsetDescEmpty_cfi::i1, testProducerWithPsetDescEmpty_cfi::i2, dqmiolumiharvest::j, lessByFoundHits(), cmsutils::bqueue< T >::rbegin(), and cmsutils::bqueue< T >::rend().

483  {
484  //
485  // remove candidates which are subsets of others
486  // assumptions: no invalid hits and no duplicates
487  //
488  if (candidates.size() <= 1)
489  return;
490  //RecHitEqualByChannels recHitEqual(false,true);
491  //
492  const int NC = candidates.size();
493  int index[NC];
494  for (int i = 0; i != NC; ++i)
495  index[i] = i;
496  std::sort(index, index + NC, [&candidates](int i, int j) { return lessByFoundHits(candidates[i], candidates[j]); });
497  // cout << "SortedCandidates.foundHits";
498  // for (auto i1 : index)
499  // cout << " " << candidates[i1].foundHits();
500  // cout << endl;
501  //
502  for (auto i1 = index; i1 != index + NC - 1; ++i1) {
503  // get measurements of candidate to be checked
504  const TempTrajectory::DataContainer& measurements1 = candidates[*i1].measurements();
505  for (auto i2 = i1 + 1; i2 != index + NC; ++i2) {
506  // no duplicates: two candidates of same size are different
507  if (candidates[*i2].foundHits() == candidates[*i1].foundHits())
508  continue;
509  // get measurements of "reference"
510  const TempTrajectory::DataContainer& measurements2 = candidates[*i2].measurements();
511  //
512  // use the fact that TMs are ordered:
513  // start search in trajectory#1 from last hit match found
514  //
515  bool allFound(true);
516  TempTrajectory::DataContainer::const_iterator from2 = measurements2.rbegin(), im2end = measurements2.rend();
517  for (TempTrajectory::DataContainer::const_iterator im1 = measurements1.rbegin(), im1end = measurements1.rend();
518  im1 != im1end;
519  --im1) {
520  // redundant protection - segments should not contain invalid RecHits
521  // assert( im1->recHit()->isValid());
522  bool found(false);
523  for (TempTrajectory::DataContainer::const_iterator im2 = from2; im2 != im2end; --im2) {
524  // redundant protection - segments should not contain invalid RecHits
525  // assert (im2->recHit()->isValid());
526  if (im1->recHitR().hit()->sharesInput(im2->recHitR().hit(), TrackingRecHit::all)) {
527  found = true;
528  from2 = im2;
529  --from2;
530  break;
531  }
532  }
533  if (!found) {
534  allFound = false;
535  break;
536  }
537  }
538  if (allFound) {
539  candidates[*i1].invalidate();
540  statCount.invalid();
541  }
542  }
543  }
544 }
const_iterator rend() const
Definition: bqueue.h:198
const_iterator rbegin() const
Definition: bqueue.h:197
bool lessByFoundHits(const Trajectory &a, const Trajectory &b)
void TrajectorySegmentBuilder::lockMeasurement ( const TM measurement)
private

mark a hit as used

Definition at line 480 of file TrajectorySegmentBuilder.cc.

References TrajectoryMeasurement::recHit().

480 { theLockedHits.push_back(measurement.recHit()); }
ConstRecHitContainer theLockedHits
vector< TrajectoryMeasurement > TrajectorySegmentBuilder::redoMeasurements ( const TempTrajectory traj,
const DetGroup detGroup 
) const
private

retrieve compatible hits from a DetGroup

Definition at line 339 of file TrajectorySegmentBuilder.cc.

References tracking::TempMeasurements::clear(), gather_cfg::cout, tracking::TempMeasurements::distances, tracking::TempMeasurements::hits, mps_fire::i, GeomDetCompatibilityChecker::isCompatible(), TempTrajectory::lastMeasurement(), MeasurementDetWithData::measurements(), eostools::move(), mps_fire::result, tracking::TempMeasurements::size(), UNLIKELY, and TrajectoryMeasurement::updatedState().

340  {
341  vector<TM> result;
342  //
343  // loop over all dets
344  //
345  if
346  UNLIKELY(theDbgFlg) cout << "TSB::redoMeasurements : nr. of measurements / group =";
347 
348  tracking::TempMeasurements tmps;
349 
350  for (auto const& det : detGroup) {
351  pair<bool, TrajectoryStateOnSurface> compat = GeomDetCompatibilityChecker().isCompatible(
353 
354  if
355  UNLIKELY(theDbgFlg && !compat.first) std::cout << " 0";
356 
357  if (!compat.first)
358  continue;
359 
360  MeasurementDetWithData mdet = theLayerMeasurements->idToDet(det.det()->geographicalId());
361  // verify also that first (and only!) not be inactive..
362  if (mdet.measurements(compat.second, theEstimator, tmps) && tmps.hits[0]->isValid())
363  for (std::size_t i = 0; i != tmps.size(); ++i)
364  result.emplace_back(compat.second, std::move(tmps.hits[i]), tmps.distances[i], &theLayer);
365 
366  if
367  UNLIKELY(theDbgFlg) std::cout << " " << tmps.size();
368  tmps.clear();
369  }
370 
371  if
372  UNLIKELY(theDbgFlg) cout << endl;
373 
374  std::sort(result.begin(), result.end(), TrajMeasLessEstim());
375 
376  return result;
377 }
size
Write out results.
const MeasurementEstimator & theEstimator
const LayerMeasurements * theLayerMeasurements
return((rh^lh)&mask)
const TrajectoryMeasurement & lastMeasurement() const
U second(std::pair< T, U > const &p)
static std::pair< bool, TrajectoryStateOnSurface > isCompatible(const GeomDet *theDet, const TrajectoryStateOnSurface &ts, const Propagator &prop, const MeasurementEstimator &est)
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
Definition: matutil.cc:151
std::vector< TrajectoryMeasurement > redoMeasurements(const TempTrajectory &traj, const DetGroup &detGroup) const
retrieve compatible hits from a DetGroup
#define end
Definition: vmac.h:39
#define begin
Definition: vmac.h:32
TrajectoryStateOnSurface const & updatedState() const
#define UNLIKELY(x)
Definition: Likely.h:21
def move(src, dest)
Definition: eostools.py:511
TrajectorySegmentBuilder::TempTrajectoryContainer TrajectorySegmentBuilder::segments ( const TSOS  startingState)

new segments within layer

Definition at line 65 of file TrajectorySegmentBuilder.cc.

References HLT_2018_cff::candidates, constexpr, gather_cfg::cout, LIKELY, TrajectoryStateOnSurface::localError(), visualization-live-secondInstance_cfg::m, LocalTrajectoryError::matrix(), Skims_PA_cff::name, and UNLIKELY.

65  {
66  //
67  // create empty trajectory
68  //
69  theLockedHits.clear();
70  TempTrajectory startingTrajectory(theFullPropagator.propagationDirection(), 0);
71  //
72  // get measurement groups
73  //
74  auto&& measGroups =
76 
77 #ifdef DBG_TSB
78  cout << "TSB: number of measurement groups = " << measGroups.size() << endl;
79  // theDbgFlg = measGroups.size()>1;
80  theDbgFlg = true;
81 #else
82  theDbgFlg = false;
83 #endif
84 
85 #ifdef TSB_TRUNCATE
86  // V.I. to me makes things slower...
87 
88  //
89  // check number of combinations
90  //
91  constexpr long long MAXCOMB = 100000000;
92  long long ncomb(1);
93  int ngrp(0);
94  bool truncate(false);
95  for (auto const& gr : measGroups) {
96  ++ngrp;
97  int nhit(0);
98  for (auto const& m : gr.measurements())
99  if
100  LIKELY(m.recHitR().isValid()) nhit++;
101 
102  if (nhit > 1)
103  ncomb *= nhit;
104  if
105  UNLIKELY(ncomb > MAXCOMB) {
106  edm::LogInfo("TrajectorySegmentBuilder")
107  << " found " << measGroups.size() << " groups and more than " << static_cast<unsigned int>(MAXCOMB)
108  << " combinations - limiting to " << (ngrp - 1) << " groups";
109  truncate = true;
110 
111  statCount.truncated();
112 
113  break;
114  }
115  }
116  // cout << "Groups / combinations = " << measGroups.size() << " " << ncomb << endl;
117  if
118  UNLIKELY(truncate && ngrp > 0) measGroups.resize(ngrp - 1);
119 
120 #endif
121 
122 #ifdef DBG_TSB
123  if (theDbgFlg) {
124  int ntot(1);
125  for (vector<TMG>::const_iterator ig = measGroups.begin(); ig != measGroups.end(); ++ig) {
126  int ngrp(0);
127  const vector<TM>& measurements = ig->measurements();
128  for (vector<TM>::const_iterator im = measurements.begin(); im != measurements.end(); ++im) {
129  if (im->recHit()->isValid())
130  ngrp++;
131  }
132  cout << " " << ngrp;
133  if (ngrp > 0)
134  ntot *= ngrp;
135  }
136  cout << endl;
137  cout << "TrajectorySegmentBuilder::partialTrajectories:: det ids & hit types / group" << endl;
138  for (vector<TMG>::const_iterator ig = measGroups.begin(); ig != measGroups.end(); ++ig) {
139  const vector<TM>& measurements = ig->measurements();
140  for (vector<TM>::const_iterator im = measurements.begin(); im != measurements.end(); ++im) {
141  if (im != measurements.begin())
142  cout << " / ";
143  if (im->recHit()->det())
144  cout << im->recHit()->det()->geographicalId().rawId() << " " << im->recHit()->getType();
145  else
146  cout << "no det";
147  }
148  cout << endl;
149  }
150 
151  // if ( measGroups.size()>4 ) {
152  cout << typeid(theLayer).name() << endl;
153  cout << startingState.localError().matrix() << endl;
154  // for (vector<TMG>::const_iterator ig=measGroups.begin();
155  // ig!=measGroups.end(); ig++) {
156  // cout << "Nr. of measurements = " << ig->measurements().size() << endl;
157  // const DetGroup& dg = ig->detGroup();
158  // for ( DetGroup::const_iterator id=dg.begin();
159  // id!=dg.end(); id++ ) {
160  // GlobalPoint p(id->det()->position());
161  // GlobalVector v(id->det()->toGlobal(LocalVector(0.,0.,1.)));
162  // cout << p.perp() << " " << p.phi() << " " << p.z() << " ; "
163  // << v.phi() << " " << v.z() << endl;
164  // }
165  // }
166  // }
167  }
168 #endif
169 
170  TempTrajectoryContainer candidates = addGroup(startingTrajectory, measGroups.begin(), measGroups.end());
171 
172  if
173  UNLIKELY(theDbgFlg) cout << "TSB: back with " << candidates.size() << " candidates" << endl;
174 
175  //
176  // add invalid hit - try to get first detector hit by the extrapolation
177  //
178 
179  updateWithInvalidHit(startingTrajectory, measGroups, candidates);
180 
181  if
182  UNLIKELY(theDbgFlg) cout << "TSB: " << candidates.size() << " candidates after invalid hit" << endl;
183 
184  statCount.incr(measGroups.size(), candidates.size(), theLockedHits.size());
185 
187 
188  return candidates;
189 }
size
Write out results.
const MeasurementEstimator & theEstimator
std::vector< TempTrajectory > TempTrajectoryContainer
const LayerMeasurements * theLayerMeasurements
#define LIKELY(x)
Definition: Likely.h:20
std::vector< TempTrajectory > addGroup(TempTrajectory const &traj, std::vector< TrajectoryMeasurementGroup >::const_iterator begin, std::vector< TrajectoryMeasurementGroup >::const_iterator end)
return((rh^lh)&mask)
virtual PropagationDirection propagationDirection() const final
Definition: Propagator.h:139
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
Definition: matutil.cc:151
const AlgebraicSymMatrix55 & matrix() const
const LocalTrajectoryError & localError() const
std::vector< TrajectoryMeasurementGroup > groupedMeasurements(const DetLayer &layer, const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
ConstRecHitContainer theLockedHits
#define UNLIKELY(x)
Definition: Likely.h:21
#define constexpr
void updateWithInvalidHit(TempTrajectory &traj, const std::vector< TMG > &groups, TempTrajectoryContainer &candidates) const
vector< TrajectoryMeasurement > TrajectorySegmentBuilder::unlockedMeasurements ( const std::vector< TM > &  measurements) const
private

get list of unused hits

Definition at line 452 of file TrajectorySegmentBuilder.cc.

References TrackingRecHit::all, newFWLiteAna::found, h, LIKELY, visualization-live-secondInstance_cfg::m, mps_fire::result, and UNLIKELY.

452  {
453  // if ( !theLockHits ) return measurements;
454 
455  vector<TM> result;
456  result.reserve(measurements.size());
457 
458  //RecHitEqualByChannels recHitEqual(false,true);
459 
460  for (auto const& m : measurements) {
461  auto const& testHit = m.recHitR();
462  if
463  UNLIKELY(!testHit.isValid()) continue;
464  bool found(false);
465  if
467  for (auto const& h : theLockedHits) {
468  if (h->hit()->sharesInput(testHit.hit(), TrackingRecHit::all)) {
469  found = true;
470  break;
471  }
472  }
473  }
474  if
475  LIKELY(!found) result.push_back(m);
476  }
477  return result;
478 }
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
#define LIKELY(x)
Definition: Likely.h:20
return((rh^lh)&mask)
ConstRecHitContainer theLockedHits
#define UNLIKELY(x)
Definition: Likely.h:21
void TrajectorySegmentBuilder::updateCandidates ( TempTrajectory const &  traj,
const std::vector< TM > &  measurements,
TempTrajectoryContainer candidates 
)
private

creation of new candidates from a segment and a collection of hits

Definition at line 311 of file TrajectorySegmentBuilder.cc.

313  {
314  //
315  // generate updated candidates with all valid hits
316  //
317  for (auto im = measurements.begin(); im != measurements.end(); ++im) {
318  if (im->recHit()->isValid()) {
319  candidates.push_back(traj);
320  updateTrajectory(candidates.back(), *im);
321  if (theLockHits)
322  lockMeasurement(*im);
323  }
324  }
325 }
void updateTrajectory(TempTrajectory &traj, TM tm) const
update of a trajectory with a hit
void lockMeasurement(const TM &measurement)
mark a hit as used
void TrajectorySegmentBuilder::updateCandidatesWithBestHit ( TempTrajectory const &  traj,
TM  measurements,
TempTrajectoryContainer candidates 
)
private

creation of a new candidate from a segment and the best hit out of a collection

Definition at line 327 of file TrajectorySegmentBuilder.cc.

References eostools::move().

329  {
330  // here we arrive with only valid hits and sorted.
331  //so the best is the first!
332 
333  if (theLockHits)
334  lockMeasurement(measurement);
335  candidates.push_back(traj);
336  updateTrajectory(candidates.back(), std::move(measurement));
337 }
void updateTrajectory(TempTrajectory &traj, TM tm) const
update of a trajectory with a hit
void lockMeasurement(const TM &measurement)
mark a hit as used
def move(src, dest)
Definition: eostools.py:511
void TrajectorySegmentBuilder::updateTrajectory ( TempTrajectory traj,
TM  tm 
) const
private

update of a trajectory with a hit

Definition at line 191 of file TrajectorySegmentBuilder.cc.

References TempTrajectory::emplace(), TrajectoryMeasurement::estimate(), TrajectoryMeasurement::layer(), eostools::move(), TrajectoryMeasurement::predictedState(), and TrajectoryMeasurement::recHit().

191  {
192  auto&& predictedState = tm.predictedState();
193  auto&& hit = tm.recHit();
194 
195  if (hit->isValid()) {
196  auto&& upState = theUpdator.update(predictedState, *hit);
197  traj.emplace(std::move(predictedState), std::move(upState), std::move(hit), tm.estimate(), tm.layer());
198 
199  // TrajectoryMeasurement tm(traj.lastMeasurement());
200  // if ( tm.updatedState().isValid() ) {
201  // if ( !hit.det().surface()->bounds().inside(tm.updatedState().localPosition(),
202  // tm.updatedState().localError().positionError(),3.f) ) {
203  // cout << "Incompatibility after update for det at " << hit.det().position() << ":" << endl;
204  // cout << tm.predictedState().localPosition() << " "
205  // << tm.predictedState().localError().positionError() << endl;
206  // cout << hit.localPosition() << " " << hit.localPositionError() << endl;
207  // cout << tm.updatedState().localPosition() << " "
208  // << tm.updatedState().localError().positionError() << endl;
209  // }
210  // }
211  } else {
212  traj.emplace(std::move(predictedState), std::move(hit), 0, tm.layer());
213  }
214 }
const TrajectoryStateUpdator & theUpdator
virtual TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TrackingRecHit &) const =0
void emplace(Args &&...args)
def move(src, dest)
Definition: eostools.py:511
void TrajectorySegmentBuilder::updateWithInvalidHit ( TempTrajectory traj,
const std::vector< TMG > &  groups,
TempTrajectoryContainer candidates 
) const
private

Definition at line 379 of file TrajectorySegmentBuilder.cc.

References gather_cfg::cout, align_cfg::iteration, LIKELY, TrackingRecHit::missing, UNLIKELY, and TrackingRecHit::valid.

381  {
382  //
383  // first try to find an inactive hit with dets crossed by the prediction,
384  // then take any inactive hit
385  //
386  // loop over groups
387  for (int iteration = 0; iteration < 2; iteration++) {
388  for (auto const& gr : groups) {
389  auto const& measurements = gr.measurements();
390  for (auto im = measurements.rbegin(); im != measurements.rend(); ++im) {
391  auto const& hit = im->recHitR();
392  if ((hit.getType() == TrackingRecHit::valid) | (hit.getType() == TrackingRecHit::missing))
393  continue;
394  //
395  // check, if the extrapolation traverses the Det or
396  // if 2nd iteration
397  //
398  if (hit.det()) {
399  auto const& predState = im->predictedState();
400  if (iteration > 0 ||
401  (predState.isValid() && hit.det()->surface().bounds().inside(predState.localPosition()))) {
402  // add the hit
403  candidates.push_back(traj);
404  updateTrajectory(candidates.back(), *im);
405  if
408  << "added inactive hit" << endl;
409  return;
410  }
411  }
412  }
413  }
414  }
415  //
416  // No suitable inactive hit: add a missing one
417  //
418  for (int iteration = 0; iteration < 2; iteration++) {
419  //
420  // loop over groups
421  //
422  for (auto const& gr : groups) {
423  auto const& measurements = gr.measurements();
424  for (auto im = measurements.rbegin(); im != measurements.rend(); ++im) {
425  // only use invalid hits
426  auto const& hit = im->recHitR();
427  if
428  LIKELY(hit.isValid()) continue;
429 
430  // check, if the extrapolation traverses the Det
431  auto const& predState = im->predictedState();
432  if (iteration > 0 || (predState.isValid() && hit.surface()->bounds().inside(predState.localPosition()))) {
433  // add invalid hit
434  candidates.push_back(traj);
435  updateTrajectory(candidates.back(), *im);
436  return;
437  }
438  }
439  }
440  if
441  UNLIKELY(theDbgFlg && iteration == 0)
443  << " did not find invalid hit on 1st iteration" << endl;
444  }
445 
446  if
449  << " did not find invalid hit" << endl;
450 }
#define LIKELY(x)
Definition: Likely.h:20
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
return((rh^lh)&mask)
void updateTrajectory(TempTrajectory &traj, TM tm) const
update of a trajectory with a hit
#define UNLIKELY(x)
Definition: Likely.h:21
void updateWithInvalidHit(TempTrajectory &traj, const std::vector< TMG > &groups, TempTrajectoryContainer &candidates) const

Member Data Documentation

bool TrajectorySegmentBuilder::theBestHitOnly
private

Definition at line 116 of file TrajectorySegmentBuilder.h.

bool TrajectorySegmentBuilder::theDbgFlg
private

Definition at line 120 of file TrajectorySegmentBuilder.h.

const MeasurementEstimator& TrajectorySegmentBuilder::theEstimator
private

Definition at line 111 of file TrajectorySegmentBuilder.h.

const Propagator& TrajectorySegmentBuilder::theFullPropagator
private

Definition at line 109 of file TrajectorySegmentBuilder.h.

const Propagator& TrajectorySegmentBuilder::theGeomPropagator
private

Definition at line 113 of file TrajectorySegmentBuilder.h.

const DetLayer& TrajectorySegmentBuilder::theLayer
private

Definition at line 108 of file TrajectorySegmentBuilder.h.

const LayerMeasurements* TrajectorySegmentBuilder::theLayerMeasurements
private

Definition at line 107 of file TrajectorySegmentBuilder.h.

ConstRecHitContainer TrajectorySegmentBuilder::theLockedHits
private

Definition at line 118 of file TrajectorySegmentBuilder.h.

bool TrajectorySegmentBuilder::theLockHits
private

Definition at line 115 of file TrajectorySegmentBuilder.h.

int TrajectorySegmentBuilder::theMaxCand
private

Definition at line 117 of file TrajectorySegmentBuilder.h.

const TrajectoryStateUpdator& TrajectorySegmentBuilder::theUpdator
private

Definition at line 110 of file TrajectorySegmentBuilder.h.