33 long long totLockHits;
37 totGroup=totSeg=totLockHits=totInvCand=trunc=0;
39 void incr(
long long g,
long long s,
long long l) {
44 void truncated() { ++
trunc;}
47 std::cout <<
"TrajectorySegmentBuilder stat\nGroup/Seg/Lock/Inv/Trunc " 48 << totGroup<<
'/'<<totSeg<<
'/'<<totLockHits<<
'/'<<totInvCand<<
'/'<<trunc
51 StatCount() { zero();}
52 ~StatCount() {
print();}
58 void incr(
long long,
long long,
long long){}
77 theLockedHits.clear();
78 TempTrajectory startingTrajectory(theFullPropagator.propagationDirection(),0);
83 theLayerMeasurements->groupedMeasurements(theLayer,startingState,theFullPropagator,theEstimator);
86 cout <<
"TSB: number of measurement groups = " << measGroups.size() << endl;
103 bool truncate(
false);
104 for (
auto const & gr : measGroups) {
107 for (
auto const &
m : gr.measurements())
if likely(
m.recHitR().isValid() ) nhit++;
109 if ( nhit>1 ) ncomb *= nhit;
111 edm::LogInfo(
"TrajectorySegmentBuilder") <<
" found " << measGroups.size()
112 <<
" groups and more than " <<
static_cast<unsigned int>(MAXCOMB)
113 <<
" combinations - limiting to " 114 << (ngrp-1) <<
" groups";
117 statCount.truncated();
123 if unlikely( truncate && ngrp>0 ) measGroups.resize(ngrp-1);
131 for (vector<TMG>::const_iterator ig=measGroups.begin();
132 ig!=measGroups.end(); ++ig) {
134 const vector<TM>& measurements = ig->measurements();
135 for ( vector<TM>::const_iterator im=measurements.begin();
136 im!=measurements.end(); ++im ) {
137 if ( im->recHit()->isValid() ) ngrp++;
140 if ( ngrp>0 ) ntot *= ngrp;
143 cout <<
"TrajectorySegmentBuilder::partialTrajectories:: det ids & hit types / group" << endl;
144 for (vector<TMG>::const_iterator ig=measGroups.begin();
145 ig!=measGroups.end(); ++ig) {
146 const vector<TM>& measurements = ig->measurements();
147 for ( vector<TM>::const_iterator im=measurements.begin();
148 im!=measurements.end(); ++im ) {
149 if ( im!=measurements.begin() )
cout <<
" / ";
150 if ( im->recHit()->det() )
151 cout << im->recHit()->det()->geographicalId().rawId() <<
" " 152 << im->recHit()->getType();
161 cout <<
typeid(theLayer).
name() << endl;
180 addGroup(startingTrajectory,measGroups.begin(),measGroups.end());
182 if unlikely(theDbgFlg)
cout <<
"TSB: back with " << candidates.size() <<
" candidates" << endl;
188 updateWithInvalidHit(startingTrajectory,measGroups,candidates);
190 if unlikely(theDbgFlg)
cout <<
"TSB: " << candidates.size() <<
" candidates after invalid hit" << endl;
192 statCount.incr(measGroups.size(), candidates.size(), theLockedHits.size());
195 theLockedHits.clear();
205 if (
hit->isValid()) {
206 auto && upState = theUpdator.update( predictedState, *
hit);
231 vector<TMG>::const_iterator
begin,
232 vector<TMG>::const_iterator
end)
234 vector<TempTrajectory> ret;
237 if unlikely(theDbgFlg)
cout <<
"TSB::addGroup : no groups left" << endl;
244 <<
" first group at " << &(*begin)
251 if ( theMaxCand == 1 ) {
252 auto && firstMeasurements = unlockedMeasurements(begin->measurements());
253 if (!firstMeasurements.empty()) updateCandidatesWithBestHit(traj,
std::move(firstMeasurements.front()),updatedTrajectories);
255 updateCandidates(traj,begin->
measurements(),updatedTrajectories);
257 if unlikely(theDbgFlg)
cout <<
"TSB::addGroup : updating with first group - " 258 << updatedTrajectories.size() <<
" trajectories" << endl;
261 auto && meas = redoMeasurements(traj,begin->detGroup());
263 if ( theBestHitOnly ) {
264 updateCandidatesWithBestHit(traj,
std::move(meas.front()),
265 updatedTrajectories);
268 updatedTrajectories);
270 if unlikely(theDbgFlg)
cout <<
"TSB::addGroup : updating" 271 << updatedTrajectories.size() <<
" trajectories-1" << endl;
276 updatedTrajectories.push_back(traj);
279 if (begin+1 != end) {
281 for (
auto const & ut : updatedTrajectories) {
282 if unlikely(theDbgFlg)
cout <<
"TSB::addGroup : trying to extend candidate at " 283 << &ut <<
" size " << ut.measurements().size() << endl;
284 vector<TempTrajectory> && finalTrajectories = addGroup(ut,begin+1,end);
285 if unlikely(theDbgFlg)
cout <<
"TSB::addGroup : " << finalTrajectories.size()
286 <<
" finalised candidates before cleaning" << endl;
289 cleanCandidates(finalTrajectories);
292 int ntf=0;
for (
auto const &
t : finalTrajectories)
if (
t.isValid()) ++ntf;
293 cout <<
"TSB::addGroup : got " << ntf
294 <<
" finalised candidates" << endl;
297 for (
auto &
t : finalTrajectories)
304 ret.reserve(updatedTrajectories.size());
305 for (
auto &
t : updatedTrajectories)
319 const vector<TM>& measurements,
325 for (
auto im=measurements.begin();
326 im!=measurements.end(); ++im ) {
327 if ( im->recHit()->isValid() ) {
328 candidates.push_back(traj);
329 updateTrajectory(candidates.back(),*im);
330 if ( theLockHits ) lockMeasurement(*im);
343 if ( theLockHits ) lockMeasurement(measurement);
344 candidates.push_back(traj);
345 updateTrajectory(candidates.back(),
std::move(measurement));
348 vector<TrajectoryMeasurement>
356 if unlikely(theDbgFlg)
cout <<
"TSB::redoMeasurements : nr. of measurements / group =";
360 for (
auto const & det : detGroup) {
362 pair<bool, TrajectoryStateOnSurface> compat =
365 theGeomPropagator,theEstimator);
369 if(!compat.first)
continue;
373 if (mdet.
measurements(compat.second, theEstimator,tmps) && tmps.
hits[0]->isValid() )
374 for (std::size_t
i=0;
i!=tmps.
size(); ++
i)
391 const vector<TMG>& groups,
400 for (
auto const & gr : groups ) {
401 auto const & measurements = gr.measurements();
402 for (
auto im=measurements.rbegin(); im!=measurements.rend(); ++im ) {
403 auto const &
hit = im->recHitR();
411 auto const & predState = im->predictedState();
413 (predState.isValid() &&
414 hit.det()->surface().bounds().inside(predState.localPosition())) ) {
416 candidates.push_back(traj);
417 updateTrajectory(candidates.back(), *im);
418 if unlikely( theDbgFlg )
cout <<
"TrajectorySegmentBuilder::updateWithInvalidHit " 419 <<
"added inactive hit" << endl;
433 for (
auto const & gr : groups ) {
434 auto const & measurements = gr.measurements();
435 for (
auto im=measurements.rbegin(); im!=measurements.rend(); ++im ) {
437 auto const &
hit = im->recHitR();
441 auto const & predState = im->predictedState();
442 if (
iteration>0 || (predState.isValid() &&
443 hit.surface()->bounds().inside(predState.localPosition())) ) {
445 candidates.push_back(traj);
446 updateTrajectory(candidates.back(), *im);
452 <<
" did not find invalid hit on 1st iteration" << endl;
456 cout <<
"TrajectorySegmentBuilder::updateWithInvalidHit: " 457 <<
" did not find invalid hit" << endl;
460 vector<TrajectoryMeasurement>
466 result.reserve(measurements.size());
470 for (
auto const &
m : measurements) {
471 auto const & testHit =
m.recHitR();
472 if unlikely( !testHit.isValid() )
continue;
474 if likely( theLockHits ) {
475 for (
auto const &
h : theLockedHits) {
482 if likely( !found ) result.push_back(
m);
490 theLockedHits.push_back(measurement.
recHit());
503 if ( candidates.size()<=1 )
return;
506 const int NC = candidates.size();
507 int index[NC];
for (
int i=0;
i!=NC; ++
i) index[
i]=
i;
508 std::sort(index,index+NC,[&candidates](
int i,
int j) {
return lessByFoundHits(candidates[i],candidates[j]);});
514 for (
auto i1 = index; i1!=index+NC-1; ++i1) {
517 for (
auto i2=i1+1; i2!=index+NC; ++i2 ) {
519 if ( candidates[*i2].foundHits()==candidates[*i1].foundHits() )
continue;
529 im1!=im1end; --im1 ) {
538 from2 = im2; --from2;
547 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
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
S & print(S &os, JobReport::InputFile const &f)
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
const AlgebraicSymMatrix55 & matrix() const
const LocalTrajectoryError & localError() const
const_iterator rbegin() const
bool lessByFoundHits(const Trajectory &a, const Trajectory &b)
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