CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
< TempTrajectory
TempTrajectoryContainer
 
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
< TrajectoryMeasurement
redoMeasurements (const TempTrajectory &traj, const DetGroup &detGroup) const
 retrieve compatible hits from a DetGroup More...
 
std::vector
< TrajectoryMeasurement
unlockedMeasurements (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 32 of file TrajectorySegmentBuilder.h.

Member Typedef Documentation

Definition at line 42 of file TrajectorySegmentBuilder.h.

Definition at line 43 of file TrajectorySegmentBuilder.h.

Definition at line 36 of file TrajectorySegmentBuilder.h.

Definition at line 41 of file TrajectorySegmentBuilder.h.

Definition at line 38 of file TrajectorySegmentBuilder.h.

Definition at line 39 of file TrajectorySegmentBuilder.h.

Definition at line 40 of file TrajectorySegmentBuilder.h.

Definition at line 37 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 48 of file TrajectorySegmentBuilder.h.

53  :
54  theLayerMeasurements(theInputLayerMeasurements),
55  theLayer(layer),
56  theFullPropagator(propagator),
57  theUpdator(updator),
58  theEstimator(estimator),
59  theGeomPropagator(propagator),
60 // theGeomPropagator(propagator.propagationDirection()),
61  theLockHits(lockHits),theBestHitOnly(bestHitOnly),theMaxCand(maxCand)
62  {}
const MeasurementEstimator & theEstimator
const LayerMeasurements * theLayerMeasurements
const TrajectoryStateUpdator & theUpdator
TrajectorySegmentBuilder::~TrajectorySegmentBuilder ( )
inline

destructor

Definition at line 65 of file TrajectorySegmentBuilder.h.

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 229 of file TrajectorySegmentBuilder.cc.

References gather_cfg::cout, cmsutils::bqueue< T >::empty(), TempTrajectory::empty(), TempTrajectory::measurements(), eostools::move(), run_regression::ret, cmsutils::bqueue< T >::size(), lumiQTWidget::t, and unlikely.

232 {
233  vector<TempTrajectory> ret;
234  if ( begin==end ) {
235  //std::cout << "TrajectorySegmentBuilder::addGroup" << " traj.empty()=" << traj.empty() << "EMPTY" << std::endl;
236  if unlikely(theDbgFlg) cout << "TSB::addGroup : no groups left" << endl;
237  if ( !traj.empty() )
238  ret.push_back(traj);
239  return ret;
240  }
241 
242  if unlikely(theDbgFlg) cout << "TSB::addGroup : traj.size() = " << traj.measurements().size()
243  << " first group at " << &(*begin)
244  // << " nr. of candidates = " << candidates.size()
245  << endl;
246 
247 
248  TempTrajectoryContainer updatedTrajectories; updatedTrajectories.reserve(2);
249  if ( traj.measurements().empty() ) {
250  if ( theMaxCand == 1 ) {
251  auto && firstMeasurements = unlockedMeasurements(begin->measurements());
252  if (!firstMeasurements.empty()) updateCandidatesWithBestHit(traj,std::move(firstMeasurements.front()),updatedTrajectories);
253  } else {
254  updateCandidates(traj,begin->measurements(),updatedTrajectories);
255  }
256  if unlikely(theDbgFlg) cout << "TSB::addGroup : updating with first group - "
257  << updatedTrajectories.size() << " trajectories" << endl;
258  }
259  else {
260  auto && meas = redoMeasurements(traj,begin->detGroup());
261  if (!meas.empty()) {
262  if ( theBestHitOnly ) {
263  updateCandidatesWithBestHit(traj,std::move(meas.front()),
264  updatedTrajectories);
265  }else{
266  updateCandidates(traj,std::move(meas),
267  updatedTrajectories);
268  }
269  if unlikely(theDbgFlg) cout << "TSB::addGroup : updating"
270  << updatedTrajectories.size() << " trajectories-1" << endl;
271  }
272  }
273  // keep old trajectory
274  //
275  updatedTrajectories.push_back(traj);
276 
277 
278  if (begin+1 != end) {
279  ret.reserve(4); // a good upper bound
280  for (auto const & ut : updatedTrajectories) {
281  if unlikely(theDbgFlg) cout << "TSB::addGroup : trying to extend candidate at "
282  << &ut << " size " << ut.measurements().size() << endl;
283  vector<TempTrajectory> && finalTrajectories = addGroup(ut,begin+1,end);
284  if unlikely(theDbgFlg) cout << "TSB::addGroup : " << finalTrajectories.size()
285  << " finalised candidates before cleaning" << endl;
286  //B.M. to be ported later
287  // V.I. only mark invalidate
288  cleanCandidates(finalTrajectories);
289 
291  int ntf=0; for ( auto const & t : finalTrajectories) if (t.isValid()) ++ntf;
292  cout << "TSB::addGroup : got " << ntf
293  << " finalised candidates" << endl;
294  }
295 
296  for ( auto & t : finalTrajectories)
297  if (t.isValid()) ret.push_back(std::move(t));
298 
299  // ret.insert(ret.end(),make_move_iterator(finalTrajectories.begin()),
300  // make_move_iterator(finalTrajectories.end()));
301  }
302  } else {
303  ret.reserve(updatedTrajectories.size());
304  for (auto & t : updatedTrajectories)
305  if (!t.empty()) ret.push_back(std::move(t));
306  }
307 
308  //std::cout << "TrajectorySegmentBuilder::addGroup" <<
309  // " traj.empty()=" << traj.empty() <<
310  // " end-begin=" << (end-begin) <<
311  // " #updated=" << updatedTrajectories.size() <<
312  // " #result=" << ret.size() << std::endl;
313  return ret;
314 }
std::vector< TempTrajectory > TempTrajectoryContainer
void cleanCandidates(std::vector< TempTrajectory > &candidates) const
clean a set of candidates
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)
else
Definition: XrdSource.cc:104
#define unlikely(x)
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
def move
Definition: eostools.py:510
std::vector< TrajectoryMeasurement > redoMeasurements(const TempTrajectory &traj, const DetGroup &detGroup) const
retrieve compatible hits from a DetGroup
if(c.getParameter< edm::InputTag >("puppiValueMap").label().size()!=0)
#define end
Definition: vmac.h:37
tuple group
Definition: watchdog.py:82
#define begin
Definition: vmac.h:30
void updateCandidates(TempTrajectory const &traj, const std::vector< TM > &measurements, TempTrajectoryContainer &candidates)
creation of new candidates from a segment and a collection of hits
tuple cout
Definition: gather_cfg.py:121
tuple size
Write out results.
void TrajectorySegmentBuilder::cleanCandidates ( std::vector< TempTrajectory > &  candidates) const
private

clean a set of candidates

Definition at line 496 of file TrajectorySegmentBuilder.cc.

References TrackingRecHit::all, newFWLiteAna::found, i, cmsHarvester::index, j, lessByFoundHits(), cmsutils::bqueue< T >::rbegin(), cmsutils::bqueue< T >::rend(), and python.multivaluedict::sort().

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

mark a hit as used

Definition at line 487 of file TrajectorySegmentBuilder.cc.

References TrajectoryMeasurement::recHit().

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

retrieve compatible hits from a DetGroup

Definition at line 348 of file TrajectorySegmentBuilder.cc.

References tracking::TempMeasurements::clear(), gather_cfg::cout, tracking::TempMeasurements::distances, tracking::TempMeasurements::hits, i, GeomDetCompatibilityChecker::isCompatible(), TempTrajectory::lastMeasurement(), MeasurementDetWithData::measurements(), eostools::move(), query::result, tracking::TempMeasurements::size(), python.multivaluedict::sort(), unlikely, and TrajectoryMeasurement::updatedState().

350 {
351  vector<TM> result;
352  //
353  // loop over all dets
354  //
355  if unlikely(theDbgFlg) cout << "TSB::redoMeasurements : nr. of measurements / group =";
356 
357  tracking::TempMeasurements tmps;
358 
359  for (auto const & det : detGroup) {
360 
361  pair<bool, TrajectoryStateOnSurface> compat =
363  traj.lastMeasurement().updatedState(),
365 
366  if unlikely(theDbgFlg && !compat.first) std::cout << " 0";
367 
368  if(!compat.first) continue;
369 
370  MeasurementDetWithData mdet = theLayerMeasurements->idToDet(det.det()->geographicalId());
371  // verify also that first (and only!) not be inactive..
372  if (mdet.measurements(compat.second, theEstimator,tmps) && tmps.hits[0]->isValid() )
373  for (std::size_t i=0; i!=tmps.size(); ++i)
374  result.emplace_back(compat.second,std::move(tmps.hits[i]),tmps.distances[i],&theLayer);
375 
376  if unlikely(theDbgFlg) std::cout << " " << tmps.size();
377  tmps.clear();
378 
379  }
380 
381  if unlikely(theDbgFlg) cout << endl;
382 
383  std::sort( result.begin(), result.end(), TrajMeasLessEstim());
384 
385  return result;
386 }
const MeasurementEstimator & theEstimator
int i
Definition: DBlmapReader.cc:9
const LayerMeasurements * theLayerMeasurements
return((rh^lh)&mask)
const TrajectoryMeasurement & lastMeasurement() const
#define unlikely(x)
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:167
tuple result
Definition: query.py:137
def move
Definition: eostools.py:510
std::vector< TrajectoryMeasurement > redoMeasurements(const TempTrajectory &traj, const DetGroup &detGroup) const
retrieve compatible hits from a DetGroup
if(c.getParameter< edm::InputTag >("puppiValueMap").label().size()!=0)
#define end
Definition: vmac.h:37
tuple group
Definition: watchdog.py:82
string const
Definition: compareJSON.py:14
#define begin
Definition: vmac.h:30
tuple cout
Definition: gather_cfg.py:121
TrajectoryStateOnSurface const & updatedState() const
for(const auto &isodef:isoDefs)
tuple size
Write out results.
TrajectorySegmentBuilder::TempTrajectoryContainer TrajectorySegmentBuilder::segments ( const TSOS  startingState)

new segments within layer

Definition at line 71 of file TrajectorySegmentBuilder.cc.

References objects.IsoTrackAnalyzer::candidates, constexpr, gather_cfg::cout, likely, TrajectoryStateOnSurface::localError(), visualization-live-secondInstance_cfg::m, LocalTrajectoryError::matrix(), mergeVDriftHistosByStation::name, and unlikely.

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

References TrackingRecHit::all, newFWLiteAna::found, h, likely, visualization-live-secondInstance_cfg::m, query::result, and unlikely.

461 {
462 // if ( !theLockHits ) return measurements;
463 
464  vector<TM> result;
465  result.reserve(measurements.size());
466 
467  //RecHitEqualByChannels recHitEqual(false,true);
468 
469  for ( auto const & m : measurements) {
470  auto const & testHit = m.recHitR();
471  if unlikely( !testHit.isValid() ) continue;
472  bool found(false);
473  if likely( theLockHits ) {
474  for ( auto const & h : theLockedHits) {
475  if ( h->hit()->sharesInput(testHit.hit(), TrackingRecHit::all) ) {
476  found = true;
477  break;
478  }
479  }
480  }
481  if likely( !found ) result.push_back(m);
482  }
483  return result;
484 }
return((rh^lh)&mask)
#define unlikely(x)
#define likely(x)
tuple result
Definition: query.py:137
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
ConstRecHitContainer theLockedHits
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 317 of file TrajectorySegmentBuilder.cc.

320 {
321  //
322  // generate updated candidates with all valid hits
323  //
324  for ( auto im=measurements.begin();
325  im!=measurements.end(); ++im ) {
326  if ( im->recHit()->isValid() ) {
327  candidates.push_back(traj);
328  updateTrajectory(candidates.back(),*im);
329  if ( theLockHits ) lockMeasurement(*im);
330  }
331  }
332 }
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 335 of file TrajectorySegmentBuilder.cc.

References eostools::move().

338 {
339  // here we arrive with only valid hits and sorted.
340  //so the best is the first!
341 
342  if ( theLockHits ) lockMeasurement(measurement);
343  candidates.push_back(traj);
344  updateTrajectory(candidates.back(),std::move(measurement));
345 }
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
Definition: eostools.py:510
void TrajectorySegmentBuilder::updateTrajectory ( TempTrajectory traj,
TM  tm 
) const
private

update of a trajectory with a hit

Definition at line 199 of file TrajectorySegmentBuilder.cc.

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

200 {
201  auto && predictedState = tm.predictedState();
202  auto && hit = tm.recHit();
203 
204  if ( hit->isValid()) {
205  auto && upState = theUpdator.update( predictedState, *hit);
206  traj.emplace(std::move(predictedState), std::move(upState),
207  std::move(hit), tm.estimate(), tm.layer());
208 
209 // TrajectoryMeasurement tm(traj.lastMeasurement());
210 // if ( tm.updatedState().isValid() ) {
211 // if ( !hit.det().surface()->bounds().inside(tm.updatedState().localPosition(),
212 // tm.updatedState().localError().positionError(),3.f) ) {
213 // cout << "Incompatibility after update for det at " << hit.det().position() << ":" << endl;
214 // cout << tm.predictedState().localPosition() << " "
215 // << tm.predictedState().localError().positionError() << endl;
216 // cout << hit.localPosition() << " " << hit.localPositionError() << endl;
217 // cout << tm.updatedState().localPosition() << " "
218 // << tm.updatedState().localError().positionError() << endl;
219 // }
220 // }
221  }
222  else {
223  traj.emplace(std::move(predictedState), std::move(hit),0, tm.layer());
224  }
225 }
const TrajectoryStateUpdator & theUpdator
virtual TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TrackingRecHit &) const =0
def move
Definition: eostools.py:510
void emplace(Args &&...args)
void TrajectorySegmentBuilder::updateWithInvalidHit ( TempTrajectory traj,
const std::vector< TMG > &  groups,
TempTrajectoryContainer candidates 
) const
private

Definition at line 389 of file TrajectorySegmentBuilder.cc.

References gather_cfg::cout, align_cfg::iteration, likely, TrackingRecHit::missing, unlikely, and TrackingRecHit::valid.

392 {
393  //
394  // first try to find an inactive hit with dets crossed by the prediction,
395  // then take any inactive hit
396  //
397  // loop over groups
398  for ( int iteration=0; iteration<2; iteration++ ) {
399  for ( auto const & gr : groups ) {
400  auto const & measurements = gr.measurements();
401  for ( auto im=measurements.rbegin(); im!=measurements.rend(); ++im ) {
402  auto const & hit = im->recHitR();
403  if ( (hit.getType()==TrackingRecHit::valid) |
404  (hit.getType()==TrackingRecHit::missing) ) continue;
405  //
406  // check, if the extrapolation traverses the Det or
407  // if 2nd iteration
408  //
409  if ( hit.det() ) {
410  auto const & predState = im->predictedState();
411  if ( iteration>0 ||
412  (predState.isValid() &&
413  hit.det()->surface().bounds().inside(predState.localPosition())) ) {
414  // add the hit
415  candidates.push_back(traj);
416  updateTrajectory(candidates.back(), *im);
418  << "added inactive hit" << endl;
419  return;
420  }
421  }
422  }
423  }
424  }
425  //
426  // No suitable inactive hit: add a missing one
427  //
428  for ( int iteration=0; iteration<2; iteration++ ) {
429  //
430  // loop over groups
431  //
432  for ( auto const & gr : groups ) {
433  auto const & measurements = gr.measurements();
434  for ( auto im=measurements.rbegin(); im!=measurements.rend(); ++im ) {
435  // only use invalid hits
436  auto const & hit = im->recHitR();
437  if likely( hit.isValid() ) continue;
438 
439  // check, if the extrapolation traverses the Det
440  auto const & predState = im->predictedState();
441  if ( iteration>0 || (predState.isValid() &&
442  hit.surface()->bounds().inside(predState.localPosition())) ) {
443  // add invalid hit
444  candidates.push_back(traj);
445  updateTrajectory(candidates.back(), *im);
446  return;
447  }
448  }
449  }
451  << " did not find invalid hit on 1st iteration" << endl;
452  }
453 
456  << " did not find invalid hit" << endl;
457 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
return((rh^lh)&mask)
#define unlikely(x)
#define likely(x)
tuple iteration
Definition: align_cfg.py:5
void updateTrajectory(TempTrajectory &traj, TM tm) const
update of a trajectory with a hit
if(c.getParameter< edm::InputTag >("puppiValueMap").label().size()!=0)
tuple cout
Definition: gather_cfg.py:121
for(const auto &isodef:isoDefs)
void updateWithInvalidHit(TempTrajectory &traj, const std::vector< TMG > &groups, TempTrajectoryContainer &candidates) const

Member Data Documentation

bool TrajectorySegmentBuilder::theBestHitOnly
private

Definition at line 117 of file TrajectorySegmentBuilder.h.

bool TrajectorySegmentBuilder::theDbgFlg
private

Definition at line 121 of file TrajectorySegmentBuilder.h.

const MeasurementEstimator& TrajectorySegmentBuilder::theEstimator
private

Definition at line 112 of file TrajectorySegmentBuilder.h.

const Propagator& TrajectorySegmentBuilder::theFullPropagator
private

Definition at line 110 of file TrajectorySegmentBuilder.h.

const Propagator& TrajectorySegmentBuilder::theGeomPropagator
private

Definition at line 114 of file TrajectorySegmentBuilder.h.

const DetLayer& TrajectorySegmentBuilder::theLayer
private

Definition at line 109 of file TrajectorySegmentBuilder.h.

const LayerMeasurements* TrajectorySegmentBuilder::theLayerMeasurements
private

Definition at line 108 of file TrajectorySegmentBuilder.h.

ConstRecHitContainer TrajectorySegmentBuilder::theLockedHits
private

Definition at line 119 of file TrajectorySegmentBuilder.h.

bool TrajectorySegmentBuilder::theLockHits
private

Definition at line 116 of file TrajectorySegmentBuilder.h.

int TrajectorySegmentBuilder::theMaxCand
private

Definition at line 118 of file TrajectorySegmentBuilder.h.

const TrajectoryStateUpdator& TrajectorySegmentBuilder::theUpdator
private

Definition at line 111 of file TrajectorySegmentBuilder.h.