32 long long totLockHits;
36 totGroup=totSeg=totLockHits=totInvCand=
trunc=0;
38 void incr(
long long g,
long long s,
long long l) {
43 void truncated() { ++
trunc;}
46 std::cout <<
"TrajectorySegmentBuilder stat\nGroup/Seg/Lock/Inv/Trunc "
47 << totGroup<<
'/'<<totSeg<<
'/'<<totLockHits<<
'/'<<totInvCand<<
'/'<<
trunc
50 StatCount() { zero();}
51 ~StatCount() {
print();}
57 void incr(
long long,
long long,
long long){}
61 [[cms::thread_safe]] StatCount statCount;
76 theLockedHits.clear();
77 TempTrajectory startingTrajectory(theFullPropagator.propagationDirection());
82 theLayerMeasurements->groupedMeasurements(theLayer,startingState,theFullPropagator,theEstimator);
85 cout <<
"TSB: number of measurement groups = " << measGroups.size() << endl;
102 bool truncate(
false);
103 for (
auto const & gr : measGroups) {
106 for (
auto const &
m : gr.measurements())
if likely(
m.recHitR().isValid() ) nhit++;
108 if ( nhit>1 ) ncomb *= nhit;
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";
116 statCount.truncated();
122 if unlikely( truncate && ngrp>0 ) measGroups.resize(ngrp-1);
130 for (vector<TMG>::const_iterator ig=measGroups.begin();
131 ig!=measGroups.end(); ++ig) {
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++;
139 if ( ngrp>0 ) ntot *= ngrp;
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();
160 cout <<
typeid(theLayer).
name() << endl;
179 addGroup(startingTrajectory,measGroups.begin(),measGroups.end());
181 if unlikely(theDbgFlg)
cout <<
"TSB: back with " << candidates.size() <<
" candidates" << endl;
187 updateWithInvalidHit(startingTrajectory,measGroups,candidates);
189 if unlikely(theDbgFlg)
cout <<
"TSB: " << candidates.size() <<
" candidates after invalid hit" << endl;
191 statCount.incr(measGroups.size(), candidates.size(), theLockedHits.size());
194 theLockedHits.clear();
204 if (
hit->isValid()) {
205 auto && upState = theUpdator.update( predictedState, *
hit);
206 traj.
emplace(std::move(predictedState), std::move(upState),
230 vector<TMG>::const_iterator
begin,
231 vector<TMG>::const_iterator
end)
233 vector<TempTrajectory>
ret;
236 if unlikely(theDbgFlg)
cout <<
"TSB::addGroup : no groups left" << endl;
243 <<
" first group at " << &(*begin)
250 if ( theMaxCand == 1 ) {
251 auto && firstMeasurements = unlockedMeasurements(begin->measurements());
252 if (!firstMeasurements.empty()) updateCandidatesWithBestHit(traj,std::move(firstMeasurements.front()),updatedTrajectories);
254 updateCandidates(traj,begin->
measurements(),updatedTrajectories);
256 if unlikely(theDbgFlg)
cout <<
"TSB::addGroup : updating with first group - "
257 << updatedTrajectories.size() <<
" trajectories" << endl;
260 auto && meas = redoMeasurements(traj,begin->detGroup());
262 if ( theBestHitOnly ) {
263 updateCandidatesWithBestHit(traj,std::move(meas.front()),
264 updatedTrajectories);
266 updateCandidates(traj,std::move(meas),
267 updatedTrajectories);
269 if unlikely(theDbgFlg)
cout <<
"TSB::addGroup : updating"
270 << updatedTrajectories.size() <<
" trajectories-1" << endl;
275 updatedTrajectories.push_back(traj);
278 if (begin+1 != end) {
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;
288 cleanCandidates(finalTrajectories);
291 int ntf=0;
for (
auto const &
t : finalTrajectories)
if (
t.isValid()) ++ntf;
292 cout <<
"TSB::addGroup : got " << ntf
293 <<
" finalised candidates" << endl;
296 for (
auto &
t : finalTrajectories)
297 if (
t.isValid()) ret.push_back(std::move(
t));
303 ret.reserve(updatedTrajectories.size());
304 for (
auto &
t : updatedTrajectories)
305 if (!
t.empty()) ret.push_back(std::move(
t));
318 const vector<TM>& measurements,
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);
342 if ( theLockHits ) lockMeasurement(measurement);
343 candidates.push_back(traj);
344 updateTrajectory(candidates.back(),std::move(measurement));
347 vector<TrajectoryMeasurement>
355 if unlikely(theDbgFlg)
cout <<
"TSB::redoMeasurements : nr. of measurements / group =";
359 for (
auto const & det : detGroup) {
361 pair<bool, TrajectoryStateOnSurface> compat =
364 theGeomPropagator,theEstimator);
368 if(!compat.first)
continue;
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);
390 const vector<TMG>& groups,
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();
410 auto const & predState = im->predictedState();
412 (predState.isValid() &&
413 hit.det()->surface().bounds().inside(predState.localPosition())) ) {
415 candidates.push_back(traj);
416 updateTrajectory(candidates.back(), *im);
417 if unlikely( theDbgFlg )
cout <<
"TrajectorySegmentBuilder::updateWithInvalidHit "
418 <<
"added inactive hit" << endl;
432 for (
auto const & gr : groups ) {
433 auto const & measurements = gr.measurements();
434 for (
auto im=measurements.rbegin(); im!=measurements.rend(); ++im ) {
436 auto const &
hit = im->recHitR();
440 auto const & predState = im->predictedState();
441 if (
iteration>0 || (predState.isValid() &&
442 hit.surface()->bounds().inside(predState.localPosition())) ) {
444 candidates.push_back(traj);
445 updateTrajectory(candidates.back(), *im);
451 <<
" did not find invalid hit on 1st iteration" << endl;
455 cout <<
"TrajectorySegmentBuilder::updateWithInvalidHit: "
456 <<
" did not find invalid hit" << endl;
459 vector<TrajectoryMeasurement>
465 result.reserve(measurements.size());
469 for (
auto const &
m : measurements) {
470 auto const & testHit =
m.recHitR();
471 if unlikely( !testHit.isValid() )
continue;
473 if likely( theLockHits ) {
474 for (
auto const &
h : theLockedHits) {
481 if likely( !found ) result.push_back(
m);
489 theLockedHits.push_back(measurement.
recHit());
502 if ( candidates.size()<=1 )
return;
505 const int NC = candidates.size();
506 int index[NC];
for (
int i=0;
i!=NC; ++
i) index[
i]=
i;
513 for (
auto i1 = index; i1!=index+NC-1; ++i1) {
516 for (
auto i2=i1+1; i2!=index+NC; ++i2 ) {
518 if ( candidates[*i2].foundHits()==candidates[*i1].foundHits() )
continue;
528 im1!=im1end; --im1 ) {
537 from2 = im2; --from2;
546 if ( allFound ) { candidates[*i1].invalidate(); statCount.invalid();}
const_iterator rend() const
TrajectoryStateOnSurface const & predictedState() const
ConstRecHitPointer const & recHit() const
bool empty() const
True if trajectory has no measurements.
std::vector< TempTrajectory > TempTrajectoryContainer
void cleanCandidates(std::vector< TempTrajectory > &candidates) const
clean a set of candidates
bool lessByFoundHits(const Trajectory &a, const Trajectory &b)
std::string print(const Track &, edm::Verbosity=edm::Concise)
Track print utility.
const DataContainer & measurements() const
std::vector< TrajectoryMeasurement > unlockedMeasurements(const std::vector< TM > &measurements) const
get list of unused hits
TempTrajectoryContainer segments(const TSOS startingState)
new segments within layer
std::vector< TempTrajectory > addGroup(TempTrajectory const &traj, std::vector< TrajectoryMeasurementGroup >::const_iterator begin, std::vector< TrajectoryMeasurementGroup >::const_iterator end)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
const TrajectoryMeasurement & lastMeasurement() const
static std::pair< bool, TrajectoryStateOnSurface > isCompatible(const GeomDet *theDet, const TrajectoryStateOnSurface &ts, const Propagator &prop, const MeasurementEstimator &est)
void updateTrajectory(TempTrajectory &traj, TM tm) const
update of a trajectory with a hit
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
void lockMeasurement(const TM &measurement)
mark a hit as used
std::vector< TrajectoryMeasurement > redoMeasurements(const TempTrajectory &traj, const DetGroup &detGroup) const
retrieve compatible hits from a DetGroup
const DetLayer * layer() const
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
const AlgebraicSymMatrix55 & matrix() const
const LocalTrajectoryError & localError() const
const_iterator rbegin() const
void emplace(Args &&...args)
void updateCandidates(TempTrajectory const &traj, const std::vector< TM > &measurements, TempTrajectoryContainer &candidates)
creation of new candidates from a segment and a collection of hits
TrajectoryStateOnSurface const & updatedState() const
bool measurements(const TrajectoryStateOnSurface &stateOnThisDet, const MeasurementEstimator &est, TempMeasurements &result) const
void updateWithInvalidHit(TempTrajectory &traj, const std::vector< TMG > &groups, TempTrajectoryContainer &candidates) const