32 long long totLockHits;
35 void zero() { totGroup = totSeg = totLockHits = totInvCand =
trunc = 0; }
36 void incr(
long long g,
long long s,
long long l) {
41 void truncated() { ++
trunc; }
42 void invalid() { ++totInvCand; }
44 std::cout <<
"TrajectorySegmentBuilder stat\nGroup/Seg/Lock/Inv/Trunc " << totGroup <<
'/' << totSeg <<
'/'
45 << totLockHits <<
'/' << totInvCand <<
'/' <<
trunc << std::endl;
47 StatCount() {
zero(); }
48 ~StatCount() {
print(); }
54 void incr(
long long,
long long,
long long) {}
69 theLockedHits.clear();
70 TempTrajectory startingTrajectory(theFullPropagator.propagationDirection(), 0);
75 theLayerMeasurements->groupedMeasurements(theLayer, startingState, theFullPropagator, theEstimator);
78 cout <<
"TSB: number of measurement groups = " << measGroups.size() << endl;
91 constexpr
long long MAXCOMB = 100000000;
95 for (
auto const& gr : measGroups) {
98 for (
auto const&
m : gr.measurements())
99 if LIKELY (
m.recHitR().isValid())
106 <<
" found " << measGroups.size() <<
" groups and more than " <<
static_cast<unsigned int>(MAXCOMB)
107 <<
" combinations - limiting to " << (ngrp - 1) <<
" groups";
110 statCount.truncated();
117 measGroups.resize(ngrp - 1);
124 for (vector<TMG>::const_iterator ig = measGroups.begin(); ig != measGroups.end(); ++ig) {
126 const vector<TM>& measurements = ig->measurements();
127 for (vector<TM>::const_iterator im = measurements.begin(); im != measurements.end(); ++im) {
128 if (im->recHit()->isValid())
136 cout <<
"TrajectorySegmentBuilder::partialTrajectories:: det ids & hit types / group" << endl;
137 for (vector<TMG>::const_iterator ig = measGroups.begin(); ig != measGroups.end(); ++ig) {
138 const vector<TM>& measurements = ig->measurements();
139 for (vector<TM>::const_iterator im = measurements.begin(); im != measurements.end(); ++im) {
140 if (im != measurements.begin())
142 if (im->recHit()->det())
143 cout << im->recHit()->det()->geographicalId().rawId() <<
" " << im->recHit()->getType();
151 cout <<
typeid(theLayer).
name() << endl;
172 cout <<
"TSB: back with " << candidates.size() <<
" candidates" << endl;
178 updateWithInvalidHit(startingTrajectory, measGroups, candidates);
181 cout <<
"TSB: " << candidates.size() <<
" candidates after invalid hit" << endl;
183 statCount.incr(measGroups.size(), candidates.size(), theLockedHits.size());
185 theLockedHits.clear();
194 if (
hit->isValid()) {
195 auto&& upState = theUpdator.update(predictedState, *
hit);
216 vector<TMG>::const_iterator
begin,
217 vector<TMG>::const_iterator
end) {
218 vector<TempTrajectory>
ret;
222 cout <<
"TSB::addGroup : no groups left" << endl;
235 updatedTrajectories.reserve(2);
237 if (theMaxCand == 1) {
238 auto&& firstMeasurements = unlockedMeasurements(begin->measurements());
239 if (!firstMeasurements.empty())
240 updateCandidatesWithBestHit(traj,
std::move(firstMeasurements.front()), updatedTrajectories);
242 updateCandidates(traj, begin->
measurements(), updatedTrajectories);
245 cout <<
"TSB::addGroup : updating with first group - " << updatedTrajectories.size() <<
" trajectories" << endl;
247 auto&& meas = redoMeasurements(traj, begin->detGroup());
249 if (theBestHitOnly) {
250 updateCandidatesWithBestHit(traj,
std::move(meas.front()), updatedTrajectories);
252 updateCandidates(traj, meas, updatedTrajectories);
255 cout <<
"TSB::addGroup : updating" << updatedTrajectories.size() <<
" trajectories-1" << endl;
260 updatedTrajectories.push_back(traj);
262 if (begin + 1 != end) {
264 for (
auto const& ut : updatedTrajectories) {
266 cout <<
"TSB::addGroup : trying to extend candidate at " << &ut <<
" size " << ut.measurements().size() << endl;
267 vector<TempTrajectory>&& finalTrajectories = addGroup(ut, begin + 1, end);
269 cout <<
"TSB::addGroup : " << finalTrajectories.size() <<
" finalised candidates before cleaning" << endl;
272 cleanCandidates(finalTrajectories);
276 for (
auto const&
t : finalTrajectories)
279 cout <<
"TSB::addGroup : got " << ntf <<
" finalised candidates" << endl;
282 for (
auto&
t : finalTrajectories)
290 ret.reserve(updatedTrajectories.size());
291 for (
auto&
t : updatedTrajectories)
305 const vector<TM>& measurements,
310 for (
auto im = measurements.begin(); im != measurements.end(); ++im) {
311 if (im->recHit()->isValid()) {
312 candidates.push_back(traj);
313 updateTrajectory(candidates.back(), *im);
315 lockMeasurement(*im);
327 lockMeasurement(measurement);
328 candidates.push_back(traj);
329 updateTrajectory(candidates.back(),
std::move(measurement));
339 cout <<
"TSB::redoMeasurements : nr. of measurements / group =";
343 for (
auto const& det : detGroup) {
347 if UNLIKELY (theDbgFlg && !compat.first)
355 if (mdet.
measurements(compat.second, theEstimator, tmps) && tmps.
hits[0]->isValid())
356 for (std::size_t
i = 0;
i != tmps.
size(); ++
i)
373 const vector<TMG>& groups,
381 for (
auto const& gr : groups) {
382 auto const& measurements = gr.measurements();
383 for (
auto im = measurements.rbegin(); im != measurements.rend(); ++im) {
384 auto const&
hit = im->recHitR();
392 auto const& predState = im->predictedState();
394 (predState.isValid() &&
hit.det()->surface().bounds().inside(predState.localPosition()))) {
396 candidates.push_back(traj);
397 updateTrajectory(candidates.back(), *im);
399 cout <<
"TrajectorySegmentBuilder::updateWithInvalidHit "
400 <<
"added inactive hit" << endl;
414 for (
auto const& gr : groups) {
415 auto const& measurements = gr.measurements();
416 for (
auto im = measurements.rbegin(); im != measurements.rend(); ++im) {
418 auto const&
hit = im->recHitR();
423 auto const& predState = im->predictedState();
424 if (
iteration > 0 || (predState.isValid() &&
hit.surface()->bounds().inside(predState.localPosition()))) {
426 candidates.push_back(traj);
427 updateTrajectory(candidates.back(), *im);
433 cout <<
"TrajectorySegmentBuilder::updateWithInvalidHit: "
434 <<
" did not find invalid hit on 1st iteration" << endl;
438 cout <<
"TrajectorySegmentBuilder::updateWithInvalidHit: "
439 <<
" did not find invalid hit" << endl;
446 result.reserve(measurements.size());
450 for (
auto const&
m : measurements) {
451 auto const& testHit =
m.recHitR();
456 for (
auto const&
h : theLockedHits) {
477 if (candidates.size() <= 1)
481 const int NC = candidates.size();
483 for (
int i = 0;
i != NC; ++
i)
485 std::sort(index, index + NC, [&candidates](
int i,
int j) {
return lessByFoundHits(candidates[i], candidates[j]); });
491 for (
auto i1 = index; i1 != index + NC - 1; ++i1) {
494 for (
auto i2 = i1 + 1; i2 != index + NC; ++i2) {
496 if (candidates[*i2].foundHits() == candidates[*i1].foundHits())
528 candidates[*i1].invalidate();
const_iterator rend() const
tuple ret
prodAgent to be discontinued
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
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
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
const DetLayer * layer() const
const AlgebraicSymMatrix55 & matrix() const
const LocalTrajectoryError & localError() const
const_iterator rbegin() const
Log< level::Info, false > LogInfo
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
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
bool measurements(const TrajectoryStateOnSurface &stateOnThisDet, const MeasurementEstimator &est, TempMeasurements &result) const
void updateWithInvalidHit(TempTrajectory &traj, const std::vector< TMG > &groups, TempTrajectoryContainer &candidates) const