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)
 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, const std::vector< 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, const 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
 
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 
)
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)
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 232 of file TrajectorySegmentBuilder.cc.

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

235 {
236  vector<TempTrajectory> ret;
237  if ( begin==end ) {
238  //std::cout << "TrajectorySegmentBuilder::addGroup" << " traj.empty()=" << traj.empty() << "EMPTY" << std::endl;
239  if unlikely(theDbgFlg) cout << "TSB::addGroup : no groups left" << endl;
240  if ( !traj.empty() )
241  ret.push_back(traj);
242  return ret;
243  }
244 
245  if unlikely(theDbgFlg) cout << "TSB::addGroup : traj.size() = " << traj.measurements().size()
246  << " first group at " << &(*begin)
247  // << " nr. of candidates = " << candidates.size()
248  << endl;
249 
250 
251  TempTrajectoryContainer updatedTrajectories; updatedTrajectories.reserve(2);
252  if ( traj.measurements().empty() ) {
253  vector<TM> const & firstMeasurements = unlockedMeasurements(begin->measurements());
254  if ( theBestHitOnly )
255  updateCandidatesWithBestHit(traj,firstMeasurements,updatedTrajectories);
256  else
257  updateCandidates(traj,begin->measurements(),updatedTrajectories);
258  if unlikely(theDbgFlg) cout << "TSB::addGroup : updating with first group - "
259  << updatedTrajectories.size() << " trajectories" << endl;
260  }
261  else {
262  if ( theBestHitOnly )
263  updateCandidatesWithBestHit(traj,redoMeasurements(traj,begin->detGroup()),
264  updatedTrajectories);
265  else
266  updateCandidates(traj,redoMeasurements(traj,begin->detGroup()),
267  updatedTrajectories);
268  if unlikely(theDbgFlg) cout << "TSB::addGroup : updating"
269  << updatedTrajectories.size() << " trajectories" << endl;
270  }
271 
272  if (begin+1 != end) {
273  ret.reserve(4); // a good upper bound
274  for (auto const & ut : updatedTrajectories) {
275  if unlikely(theDbgFlg) cout << "TSB::addGroup : trying to extend candidate at "
276  << &ut << " size " << ut.measurements().size() << endl;
277  vector<TempTrajectory> finalTrajectories = addGroup(ut,begin+1,end);
278  if unlikely(theDbgFlg) cout << "TSB::addGroup : " << finalTrajectories.size()
279  << " finalised candidates before cleaning" << endl;
280  //B.M. to be ported later
281  // V.I. only mark invalidate
282  cleanCandidates(finalTrajectories);
283 
285  int ntf=0; for ( auto const & t : finalTrajectories) if (t.isValid()) ++ntf;
286  cout << "TSB::addGroup : got " << ntf
287  << " finalised candidates" << endl;
288  }
289 
290  for ( auto & t : finalTrajectories)
291  if (t.isValid()) 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()) ret.push_back(std::move(t));
300  }
301 
302  //std::cout << "TrajectorySegmentBuilder::addGroup" <<
303  // " traj.empty()=" << traj.empty() <<
304  // " end-begin=" << (end-begin) <<
305  // " #updated=" << updatedTrajectories.size() <<
306  // " #result=" << ret.size() << std::endl;
307  return ret;
308 }
void updateCandidatesWithBestHit(TempTrajectory const &traj, const std::vector< TM > &measurements, TempTrajectoryContainer &candidates)
creation of a new candidate from a segment and the best hit out of a collection
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)
#define unlikely(x)
Definition: Likely.h:21
std::vector< TrajectoryMeasurement > redoMeasurements(const TempTrajectory &traj, const DetGroup &detGroup) const
retrieve compatible hits from a DetGroup
#define end
Definition: vmac.h:37
bool first
Definition: L1TdeRCT.cc:79
return(e1-e2)*(e1-e2)+dp *dp
#define begin
Definition: vmac.h:30
if(dp >Float(M_PI)) dp-
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.
list at
Definition: asciidump.py:428
void TrajectorySegmentBuilder::cleanCandidates ( std::vector< TempTrajectory > &  candidates) const
private

clean a set of candidates

Definition at line 556 of file TrajectorySegmentBuilder.cc.

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

557 {
558  //
559  // remove candidates which are subsets of others
560  // assumptions: no invalid hits and no duplicates
561  //
562  if ( candidates.size()<=1 ) return;
563  //RecHitEqualByChannels recHitEqual(false,true);
564  //
565  const int NC = candidates.size();
566  int index[NC]; for (int i=0; i!=NC; ++i) index[i]=i;
567  std::sort(index,index+NC,[&candidates](int i, int j) { return lessByFoundHits(candidates[i],candidates[j]);});
568 // cout << "SortedCandidates.foundHits";
569 // for (auto i1 : index)
570 // cout << " " << candidates[i1].foundHits();
571 // cout << endl;
572  //
573  for ( auto i1 = index; i1!=index+NC-1; ++i1) {
574  // get measurements of candidate to be checked
575  const TempTrajectory::DataContainer & measurements1 = candidates[*i1].measurements();
576  for ( auto i2=i1+1; i2!=index+NC; ++i2 ) {
577  // no duplicates: two candidates of same size are different
578  if ( candidates[*i2].foundHits()==candidates[*i1].foundHits() ) continue;
579  // get measurements of "reference"
580  const TempTrajectory::DataContainer & measurements2 = candidates[*i2].measurements();
581  //
582  // use the fact that TMs are ordered:
583  // start search in trajectory#1 from last hit match found
584  //
585  bool allFound(true);
586  TempTrajectory::DataContainer::const_iterator from2 = measurements2.rbegin(), im2end = measurements2.rend();
587  for ( TempTrajectory::DataContainer::const_iterator im1=measurements1.rbegin(),im1end = measurements1.rend();
588  im1!=im1end; --im1 ) {
589  // redundant protection - segments should not contain invalid RecHits
590  // assert( im1->recHit()->isValid());
591  bool found(false);
592  for ( TempTrajectory::DataContainer::const_iterator im2=from2; im2!=im2end; --im2 ) {
593  // redundant protection - segments should not contain invalid RecHits
594  // assert (im2->recHit()->isValid());
595  if ( im1->recHitR().hit()->sharesInput(im2->recHitR().hit(), TrackingRecHit::all) ) {
596  found = true;
597  from2 = im2; --from2;
598  break;
599  }
600  }
601  if ( !found ) {
602  allFound = false;
603  break;
604  }
605  }
606  if ( allFound ) { candidates[*i1].invalidate(); statCount.invalid();}
607  }
608  }
609 
610  /* will remove while coping
611  candidates.erase(std::remove_if( candidates.begin(),candidates.end(),
612  [&](TempTrajectory const & t) { return !t.isValid();}),
613  // std::not1(std::mem_fun_ref(&TempTrajectory::isValid))),
614  // boost::bind(&TempTrajectory::isValid,_1)),
615  candidates.end());
616 #ifdef DBG_TSB
617  cout << "TSB: cleanCandidates: reduced from " << sortedCandidates.size()
618  << " to " << candidates.size() << " candidates" << endl;
619 #endif
620 
621 
622  */
623 }
const_iterator rend() const
Definition: bqueue.h:164
int i
Definition: DBlmapReader.cc:9
bool lessByFoundHits(const Trajectory &a, const Trajectory &b)
int j
Definition: DBlmapReader.cc:9
const_iterator rbegin() const
Definition: bqueue.h:163
void TrajectorySegmentBuilder::lockMeasurement ( const TM measurement)
private

mark a hit as used

Definition at line 547 of file TrajectorySegmentBuilder.cc.

References TrajectoryMeasurement::recHit().

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

retrieve compatible hits from a DetGroup

Definition at line 375 of file TrajectorySegmentBuilder.cc.

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

377 {
378  vector<TM> result;
379  //
380  // loop over all dets
381  //
382  if unlikely(theDbgFlg) cout << "TSB::redoMeasurements : nr. of measurements / group =";
383 
384  tracking::TempMeasurements tmps;
385 
386  for (auto const & det : detGroup) {
387 
388  pair<bool, TrajectoryStateOnSurface> compat =
390  traj.lastMeasurement().updatedState(),
392 
393  if unlikely(theDbgFlg && !compat.first) std::cout << " 0";
394 
395  if(!compat.first) continue;
396 
397  MeasurementDetWithData mdet = theLayerMeasurements->idToDet(det.det()->geographicalId());
398  // verify also that first (and only!) not be inactive..
399  if (mdet.measurements(compat.second, theEstimator,tmps) && tmps.hits[0]->isValid() )
400  for (std::size_t i=0; i!=tmps.size(); ++i)
401  result.emplace_back(compat.second,std::move(tmps.hits[i]),tmps.distances[i],&theLayer);
402 
403  if unlikely(theDbgFlg) std::cout << " " << tmps.size();
404  tmps.clear();
405 
406  }
407 
408  if unlikely(theDbgFlg) cout << endl;
409 
410  std::sort( result.begin(), result.end(), TrajMeasLessEstim());
411 
412  return result;
413 }
const MeasurementEstimator & theEstimator
int i
Definition: DBlmapReader.cc:9
const LayerMeasurements * theLayerMeasurements
static std::pair< bool, TrajectoryStateOnSurface > isCompatible(const GeomDet *theDet, const TrajectoryStateOnSurface &ts, const Propagator &prop, const MeasurementEstimator &est)
const TrajectoryMeasurement & lastMeasurement() const
U second(std::pair< T, U > const &p)
#define unlikely(x)
Definition: Likely.h:21
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
std::vector< TrajectoryMeasurement > redoMeasurements(const TempTrajectory &traj, const DetGroup &detGroup) const
retrieve compatible hits from a DetGroup
#define end
Definition: vmac.h:37
bool first
Definition: L1TdeRCT.cc:79
string const
Definition: compareJSON.py:14
return(e1-e2)*(e1-e2)+dp *dp
#define begin
Definition: vmac.h:30
if(dp >Float(M_PI)) dp-
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 70 of file TrajectorySegmentBuilder.cc.

References constexpr, gather_cfg::cout, likely, TrajectoryStateOnSurface::localError(), m, LocalTrajectoryError::matrix(), mergeVDriftHistosByStation::name, and unlikely.

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

References TrackingRecHit::all, newFWLiteAna::found, h, likely, m, query::result, and unlikely.

521 {
522 // if ( !theLockHits ) return measurements;
523 
524  vector<TM> result;
525  result.reserve(measurements.size());
526 
527  //RecHitEqualByChannels recHitEqual(false,true);
528 
529  for ( auto const & m : measurements) {
530  auto const & testHit = m.recHitR();
531  if unlikely( !testHit.isValid() ) continue;
532  bool found(false);
533  if likely( theLockHits ) {
534  for ( auto const & h : theLockedHits) {
535  if ( h->hit()->sharesInput(testHit.hit(), TrackingRecHit::all) ) {
536  found = true;
537  break;
538  }
539  }
540  }
541  if likely( !found ) result.push_back(m);
542  }
543  return result;
544 }
#define unlikely(x)
Definition: Likely.h:21
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
return(e1-e2)*(e1-e2)+dp *dp
#define likely(x)
Definition: Likely.h:20
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 311 of file TrajectorySegmentBuilder.cc.

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

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

Definition at line 333 of file TrajectorySegmentBuilder.cc.

References gather_cfg::cout, and unlikely.

336 {
337  // here we arrive with only valid hits and sorted.
338  //so the best is the first!
339 
340  auto ibest = measurements.begin();
341 
342 #ifdef DBG_TSB
343  // get first
344  while(ibest!=measurements.end() && !ibest->recHit()->isValid()) ++ibest;
345  if ( ibest!=measurements.end() ) {
346  // find real best;
347  for ( auto im=ibest+1;
348  im!=measurements.end(); ++im ) {
349  if ( im->recHitR().isValid() &&
350  im->estimate()<ibest->estimate()
351  )
352  ibest = im;
353  }
354  if unlikely( theDbgFlg )
355  cout << "TSB: found best measurement at "
356  << ibest->recHit()->globalPosition().perp() << " "
357  << ibest->recHit()->globalPosition().phi() << " "
358  << ibest->recHit()->globalPosition().z() << endl;
359 
360  assert(ibest==measurements.begin());
361  }
362 #endif
363 
364  if (!measurements.empty()) {
365  if ( theLockHits ) lockMeasurement(*ibest);
366  candidates.push_back(traj);
367  updateTrajectory(candidates.back(),*ibest);
368  }
369 
370  // keep old trajectorTempy
371  candidates.push_back(traj);
372 }
float float float z
#define unlikely(x)
Definition: Likely.h:21
void lockMeasurement(const TM &measurement)
mark a hit as used
T perp() const
Magnitude of transverse component.
#define begin
Definition: vmac.h:30
tuple cout
Definition: gather_cfg.py:121
void updateTrajectory(TempTrajectory &traj, const TM &tm) const
update of a trajectory with a hit
list at
Definition: asciidump.py:428
Definition: DDAxes.h:10
void TrajectorySegmentBuilder::updateTrajectory ( TempTrajectory traj,
const TM tm 
) const
private

update of a trajectory with a hit

Definition at line 202 of file TrajectorySegmentBuilder.cc.

References TempTrajectory::emplace(), TrajectoryMeasurement::estimate(), TrajectoryMeasurement::layer(), TrajectoryMeasurement::predictedState(), TrajectoryMeasurement::recHit(), and TrajectoryStateOnSurface::update().

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

Definition at line 416 of file TrajectorySegmentBuilder.cc.

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

419 {
420  //
421  // first try to find an inactive hit with dets crossed by the prediction,
422  // then take any inactive hit
423  //
424  // loop over groups
425  for ( int iteration=0; iteration<2; iteration++ ) {
426  for ( vector<TMG>::const_iterator ig=groups.begin(); ig!=groups.end(); ++ig) {
427  // loop over measurements
428  const vector<TM>& measurements = ig->measurements();
429  for ( vector<TM>::const_reverse_iterator im=measurements.rbegin();
430  im!=measurements.rend(); ++im ) {
431  auto const & hit = im->recHitR();
432  if ( hit.getType()==TrackingRecHit::valid ||
433  hit.getType()==TrackingRecHit::missing ) continue;
434  //
435  // check, if the extrapolation traverses the Det or
436  // if 2nd iteration
437  //
438  if ( hit.det() ) {
439  auto const & predState = im->predictedState();
440  if ( iteration>0 ||
441  (predState.isValid() &&
442  hit.det()->surface().bounds().inside(predState.localPosition())) ) {
443  // add the hit
444  /*TempTrajectory newTraj(traj);
445  updateTrajectory(newTraj,*im);
446  candidates.push_back(newTraj); // FIXME: avoid useless copy */
447  candidates.push_back(traj);
448  updateTrajectory(candidates.back(), *im);
450  << "added inactive hit" << endl;
451  return;
452  }
453  }
454  }
455  }
456  }
457  //
458  // No suitable inactive hit: add a missing one
459  //
460  bool found(false);
461  for ( int iteration=0; iteration<2; iteration++ ) {
462  //
463  // loop over groups
464  //
465  for ( vector<TMG>::const_iterator ig=groups.begin();
466  ig!=groups.end(); ++ig) {
467  const vector<TM>& measurements = ig->measurements();
468  for ( vector<TM>::const_reverse_iterator im=measurements.rbegin();
469  im!=measurements.rend(); ++im ) {
470  //
471  // only use invalid hits
472  //
473  auto const & hit = im->recHitR();
474  if likely( hit.isValid() ) continue;
475 
476  //
477  // check, if the extrapolation traverses the Det
478  //
479  auto const & predState = im->predictedState();
480  if(hit.det()){
481  if ( iteration>0 || (predState.isValid() &&
482  hit.det()->surface().bounds().inside(predState.localPosition())) ) {
483  // add invalid hit
484  /*TempTrajectory newTraj(traj);
485  updateTrajectory(newTraj,*im);
486  candidates.push_back(newTraj); // FIXME: avoid useless copy */
487  candidates.push_back(traj);
488  updateTrajectory(candidates.back(), *im);
489  found = true;
490  break;
491  }
492 
493  }else{
494  if ( iteration>0 || (predState.isValid() &&
495  im->layer()->surface().bounds().inside(predState.localPosition())) ){
496  // add invalid hit
497  /*TempTrajectory newTraj(traj);
498  updateTrajectory(newTraj,*im);
499  candidates.push_back(newTraj); // FIXME: avoid useless copy */
500  candidates.push_back(traj);
501  updateTrajectory(candidates.back(), *im);
502  found = true;
503  break;
504  }
505  }
506  }
507  if ( found ) break;
508  }
510  << " did not find invalid hit on 1st iteration" << endl;
511  if ( found ) break;
512  }
513 
514  if unlikely( theDbgFlg && (!found) )
516  << " did not find invalid hit" << endl;
517 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
#define unlikely(x)
Definition: Likely.h:21
tuple iteration
Definition: align_cfg.py:5
return(e1-e2)*(e1-e2)+dp *dp
#define likely(x)
Definition: Likely.h:20
if(dp >Float(M_PI)) dp-
tuple cout
Definition: gather_cfg.py:121
volatile std::atomic< bool > shutdown_flag false
for(const auto &isodef:isoDefs)
void updateTrajectory(TempTrajectory &traj, const TM &tm) const
update of a trajectory with a hit
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 120 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 118 of file TrajectorySegmentBuilder.h.

bool TrajectorySegmentBuilder::theLockHits
private

Definition at line 116 of file TrajectorySegmentBuilder.h.

const TrajectoryStateUpdator& TrajectorySegmentBuilder::theUpdator
private

Definition at line 111 of file TrajectorySegmentBuilder.h.