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()) {
315 lockMeasurement(*im);
327 lockMeasurement(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()))) {
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()))) {
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) {
483 for (
int i = 0;
i != NC; ++
i)