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())
100 LIKELY(
m.recHitR().isValid()) nhit++;
107 <<
" found " << measGroups.size() <<
" groups and more than " << static_cast<unsigned int>(MAXCOMB)
108 <<
" combinations - limiting to " << (ngrp - 1) <<
" groups";
111 statCount.truncated();
118 UNLIKELY(truncate && ngrp > 0) measGroups.resize(ngrp - 1);
125 for (vector<TMG>::const_iterator ig = measGroups.begin(); ig != measGroups.end(); ++ig) {
127 const vector<TM>& measurements = ig->measurements();
128 for (vector<TM>::const_iterator im = measurements.begin(); im != measurements.end(); ++im) {
129 if (im->recHit()->isValid())
137 cout <<
"TrajectorySegmentBuilder::partialTrajectories:: det ids & hit types / group" << endl;
138 for (vector<TMG>::const_iterator ig = measGroups.begin(); ig != measGroups.end(); ++ig) {
139 const vector<TM>& measurements = ig->measurements();
140 for (vector<TM>::const_iterator im = measurements.begin(); im != measurements.end(); ++im) {
141 if (im != measurements.begin())
143 if (im->recHit()->det())
144 cout << im->recHit()->det()->geographicalId().rawId() <<
" " << im->recHit()->getType();
152 cout <<
typeid(theLayer).
name() << endl;
179 updateWithInvalidHit(startingTrajectory, measGroups,
candidates);
184 statCount.incr(measGroups.size(),
candidates.size(), theLockedHits.size());
186 theLockedHits.clear();
195 if (
hit->isValid()) {
196 auto&& upState = theUpdator.update(predictedState, *
hit);
217 vector<TMG>::const_iterator
begin,
218 vector<TMG>::const_iterator
end) {
219 vector<TempTrajectory>
ret;
223 UNLIKELY(theDbgFlg)
cout <<
"TSB::addGroup : no groups left" << endl;
237 updatedTrajectories.reserve(2);
239 if (theMaxCand == 1) {
240 auto&& firstMeasurements = unlockedMeasurements(
begin->measurements());
241 if (!firstMeasurements.empty())
242 updateCandidatesWithBestHit(traj,
std::move(firstMeasurements.front()), updatedTrajectories);
244 updateCandidates(traj,
begin->measurements(), updatedTrajectories);
248 cout <<
"TSB::addGroup : updating with first group - " << updatedTrajectories.size() <<
" trajectories" << endl;
250 auto&& meas = redoMeasurements(traj,
begin->detGroup());
252 if (theBestHitOnly) {
253 updateCandidatesWithBestHit(traj,
std::move(meas.front()), updatedTrajectories);
255 updateCandidates(traj,
std::move(meas), updatedTrajectories);
259 cout <<
"TSB::addGroup : updating" << updatedTrajectories.size() <<
" trajectories-1" << endl;
264 updatedTrajectories.push_back(traj);
268 for (
auto const& ut : updatedTrajectories) {
271 cout <<
"TSB::addGroup : trying to extend candidate at " << &ut <<
" size " << ut.measurements().size() << endl;
272 vector<TempTrajectory>&& finalTrajectories = addGroup(ut,
begin + 1,
end);
275 cout <<
"TSB::addGroup : " << finalTrajectories.size() <<
" finalised candidates before cleaning" << endl;
278 cleanCandidates(finalTrajectories);
283 for (
auto const&
t : finalTrajectories)
286 cout <<
"TSB::addGroup : got " << ntf <<
" finalised candidates" << endl;
289 for (
auto&
t : finalTrajectories)
297 ret.reserve(updatedTrajectories.size());
298 for (
auto&
t : updatedTrajectories)
312 const vector<TM>& measurements,
317 for (
auto im = measurements.begin(); im != measurements.end(); ++im) {
318 if (im->recHit()->isValid()) {
322 lockMeasurement(*im);
334 lockMeasurement(measurement);
346 UNLIKELY(theDbgFlg)
cout <<
"TSB::redoMeasurements : nr. of measurements / group =";
350 for (
auto const& det : detGroup) {
362 if (mdet.
measurements(compat.second, theEstimator, tmps) && tmps.
hits[0]->isValid())
363 for (std::size_t
i = 0;
i != tmps.
size(); ++
i)
380 const vector<TMG>& groups,
388 for (
auto const& gr : groups) {
389 auto const& measurements = gr.measurements();
390 for (
auto im = measurements.rbegin(); im != measurements.rend(); ++im) {
391 auto const&
hit = im->recHitR();
399 auto const& predState = im->predictedState();
401 (predState.isValid() &&
hit.det()->surface().bounds().inside(predState.localPosition()))) {
407 cout <<
"TrajectorySegmentBuilder::updateWithInvalidHit "
408 <<
"added inactive hit" << endl;
422 for (
auto const& gr : groups) {
423 auto const& measurements = gr.measurements();
424 for (
auto im = measurements.rbegin(); im != measurements.rend(); ++im) {
426 auto const&
hit = im->recHitR();
431 auto const& predState = im->predictedState();
432 if (
iteration > 0 || (predState.isValid() &&
hit.surface()->bounds().inside(predState.localPosition()))) {
442 cout <<
"TrajectorySegmentBuilder::updateWithInvalidHit: "
443 <<
" did not find invalid hit on 1st iteration" << endl;
448 cout <<
"TrajectorySegmentBuilder::updateWithInvalidHit: "
449 <<
" did not find invalid hit" << endl;
456 result.reserve(measurements.size());
460 for (
auto const&
m : measurements) {
461 auto const& testHit =
m.recHitR();
463 UNLIKELY(!testHit.isValid())
continue;
467 for (
auto const&
h : theLockedHits) {
494 for (
int i = 0;
i != NC; ++
i)