31 long long totLockHits;
34 void zero() { totGroup = totSeg = totLockHits = totInvCand =
trunc = 0; }
35 void incr(
long long g,
long long s,
long long l) {
40 void truncated() { ++
trunc; }
41 void invalid() { ++totInvCand; }
43 std::cout <<
"TrajectorySegmentBuilder stat\nGroup/Seg/Lock/Inv/Trunc " << totGroup <<
'/' << totSeg <<
'/' 44 << totLockHits <<
'/' << totInvCand <<
'/' <<
trunc << std::endl;
46 StatCount() {
zero(); }
47 ~StatCount() {
print(); }
53 void incr(
long long,
long long,
long long) {}
68 theLockedHits.clear();
69 TempTrajectory startingTrajectory(theFullPropagator.propagationDirection(), 0);
74 theLayerMeasurements->groupedMeasurements(theLayer, startingState, theFullPropagator, theEstimator);
77 cout <<
"TSB: number of measurement groups = " << measGroups.size() << endl;
94 for (
auto const& gr : measGroups) {
97 for (
auto const&
m : gr.measurements())
98 if LIKELY (
m.recHitR().isValid())
105 <<
" found " << measGroups.size() <<
" groups and more than " <<
static_cast<unsigned int>(MAXCOMB)
106 <<
" combinations - limiting to " << (ngrp - 1) <<
" groups";
109 statCount.truncated();
116 measGroups.resize(ngrp - 1);
123 for (vector<TMG>::const_iterator ig = measGroups.begin(); ig != measGroups.end(); ++ig) {
125 const vector<TM>& measurements = ig->measurements();
126 for (vector<TM>::const_iterator im = measurements.begin(); im != measurements.end(); ++im) {
127 if (im->recHit()->isValid())
135 cout <<
"TrajectorySegmentBuilder::partialTrajectories:: det ids & hit types / group" << endl;
136 for (vector<TMG>::const_iterator ig = measGroups.begin(); ig != measGroups.end(); ++ig) {
137 const vector<TM>& measurements = ig->measurements();
138 for (vector<TM>::const_iterator im = measurements.begin(); im != measurements.end(); ++im) {
139 if (im != measurements.begin())
141 if (im->recHit()->det())
142 cout << im->recHit()->det()->geographicalId().rawId() <<
" " << im->recHit()->getType();
150 cout <<
typeid(theLayer).
name() << endl;
171 cout <<
"TSB: back with " <<
candidates.size() <<
" candidates" << endl;
177 updateWithInvalidHit(startingTrajectory, measGroups,
candidates);
180 cout <<
"TSB: " <<
candidates.size() <<
" candidates after invalid hit" << endl;
182 statCount.incr(measGroups.size(),
candidates.size(), theLockedHits.size());
184 theLockedHits.clear();
193 if (
hit->isValid()) {
194 auto&& upState = theUpdator.update(predictedState, *
hit);
215 vector<TMG>::const_iterator begin,
216 vector<TMG>::const_iterator end) {
217 vector<TempTrajectory>
ret;
221 cout <<
"TSB::addGroup : no groups left" << endl;
234 updatedTrajectories.reserve(2);
236 if (theMaxCand == 1) {
237 auto&& firstMeasurements = unlockedMeasurements(begin->measurements());
238 if (!firstMeasurements.empty())
239 updateCandidatesWithBestHit(traj,
std::move(firstMeasurements.front()), updatedTrajectories);
241 updateCandidates(traj, begin->measurements(), updatedTrajectories);
244 cout <<
"TSB::addGroup : updating with first group - " << updatedTrajectories.size() <<
" trajectories" << endl;
246 auto&& meas = redoMeasurements(traj, begin->detGroup());
248 if (theBestHitOnly) {
249 updateCandidatesWithBestHit(traj,
std::move(meas.front()), updatedTrajectories);
251 updateCandidates(traj, meas, updatedTrajectories);
254 cout <<
"TSB::addGroup : updating" << updatedTrajectories.size() <<
" trajectories-1" << endl;
259 updatedTrajectories.push_back(traj);
261 if (begin + 1 != end) {
263 for (
auto const& ut : updatedTrajectories) {
265 cout <<
"TSB::addGroup : trying to extend candidate at " << &ut <<
" size " << ut.measurements().size() << endl;
266 vector<TempTrajectory>&& finalTrajectories = addGroup(ut, begin + 1, end);
268 cout <<
"TSB::addGroup : " << finalTrajectories.size() <<
" finalised candidates before cleaning" << endl;
271 cleanCandidates(finalTrajectories);
275 for (
auto const&
t : finalTrajectories)
278 cout <<
"TSB::addGroup : got " << ntf <<
" finalised candidates" << endl;
281 for (
auto&
t : finalTrajectories)
289 ret.reserve(updatedTrajectories.size());
290 for (
auto&
t : updatedTrajectories)
304 const vector<TM>& measurements,
309 for (
auto im = measurements.begin(); im != measurements.end(); ++im) {
310 if (im->recHit()->isValid()) {
314 lockMeasurement(*im);
326 lockMeasurement(measurement);
338 cout <<
"TSB::redoMeasurements : nr. of measurements / group =";
342 for (
auto const& det : detGroup) {
346 if UNLIKELY (theDbgFlg && !compat.first)
354 if (mdet.
measurements(compat.second, theEstimator, tmps) && tmps.
hits[0]->isValid())
355 for (std::size_t
i = 0;
i != tmps.
size(); ++
i)
372 const vector<TMG>& groups,
380 for (
auto const& gr : groups) {
381 auto const& measurements = gr.measurements();
382 for (
auto im = measurements.rbegin(); im != measurements.rend(); ++im) {
383 auto const&
hit = im->recHitR();
391 auto const& predState = im->predictedState();
393 (predState.isValid() &&
hit.det()->surface().bounds().inside(predState.localPosition()))) {
398 cout <<
"TrajectorySegmentBuilder::updateWithInvalidHit " 399 <<
"added inactive hit" << endl;
413 for (
auto const& gr : groups) {
414 auto const& measurements = gr.measurements();
415 for (
auto im = measurements.rbegin(); im != measurements.rend(); ++im) {
417 auto const&
hit = im->recHitR();
422 auto const& predState = im->predictedState();
423 if (
iteration > 0 || (predState.isValid() &&
hit.surface()->bounds().inside(predState.localPosition()))) {
432 cout <<
"TrajectorySegmentBuilder::updateWithInvalidHit: " 433 <<
" did not find invalid hit on 1st iteration" << endl;
437 cout <<
"TrajectorySegmentBuilder::updateWithInvalidHit: " 438 <<
" did not find invalid hit" << endl;
445 result.reserve(measurements.size());
449 for (
auto const&
m : measurements) {
450 auto const& testHit =
m.recHitR();
455 for (
auto const&
h : theLockedHits) {
482 for (
int i = 0;
i != NC; ++
i)
void emplace(Args &&... args)
const_iterator rbegin() const
TrajectoryStateOnSurface const & predictedState() const
const LocalTrajectoryError & localError() const
std::vector< TempTrajectory > TempTrajectoryContainer
bool measurements(const TrajectoryStateOnSurface &stateOnThisDet, const MeasurementEstimator &est, TempMeasurements &result) const
ret
prodAgent to be discontinued
TempTrajectoryContainer segments(const TSOS startingState)
new segments within layer
const DataContainer & measurements() const
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
static std::pair< bool, TrajectoryStateOnSurface > isCompatible(const GeomDet *theDet, const TrajectoryStateOnSurface &ts, const Propagator &prop, const MeasurementEstimator &est)
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
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
const TrajectoryMeasurement & lastMeasurement() const
void updateWithInvalidHit(TempTrajectory &traj, const std::vector< TMG > &groups, TempTrajectoryContainer &candidates) const
void updateTrajectory(TempTrajectory &traj, TM tm) const
update of a trajectory with a hit
void cleanCandidates(std::vector< TempTrajectory > &candidates) const
clean a set of candidates
std::vector< TrajectoryMeasurement > redoMeasurements(const TempTrajectory &traj, const DetGroup &detGroup) const
retrieve compatible hits from a DetGroup
Log< level::Info, false > LogInfo
TrajectoryStateOnSurface const & updatedState() const
const AlgebraicSymMatrix55 & matrix() const
void updateCandidates(TempTrajectory const &traj, const std::vector< TM > &measurements, TempTrajectoryContainer &candidates)
creation of new candidates from a segment and a collection of hits
const_iterator rend() const
std::vector< TrajectoryMeasurement > unlockedMeasurements(const std::vector< TM > &measurements) const
get list of unused hits
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
const DetLayer * layer() const
ConstRecHitPointer const & recHit() const
bool empty() const
True if trajectory has no measurements.