32 long long totLockHits;
36 totGroup=totSeg=totLockHits=totInvCand=trunc=0;
38 void incr(
long long g,
long long s,
long long l) {
43 void truncated() { ++
trunc;}
46 std::cout <<
"TrajectorySegmentBuilder stat\nGroup/Seg/Lock/Inv/Trunc " 47 << totGroup<<
'/'<<totSeg<<
'/'<<totLockHits<<
'/'<<totInvCand<<
'/'<<trunc
50 StatCount() { zero();}
51 ~StatCount() {
print();}
57 void incr(
long long,
long long,
long long){}
76 theLockedHits.clear();
77 TempTrajectory startingTrajectory(theFullPropagator.propagationDirection(),0);
82 theLayerMeasurements->groupedMeasurements(theLayer,startingState,theFullPropagator,theEstimator);
85 cout <<
"TSB: number of measurement groups = " << measGroups.size() << endl;
102 bool truncate(
false);
103 for (
auto const & gr : measGroups) {
106 for (
auto const &
m : gr.measurements())
if LIKELY(
m.recHitR().isValid() ) nhit++;
108 if ( nhit>1 ) ncomb *= nhit;
110 edm::LogInfo(
"TrajectorySegmentBuilder") <<
" found " << measGroups.size()
111 <<
" groups and more than " <<
static_cast<unsigned int>(MAXCOMB)
112 <<
" combinations - limiting to " 113 << (ngrp-1) <<
" groups";
116 statCount.truncated();
122 if UNLIKELY( truncate && ngrp>0 ) measGroups.resize(ngrp-1);
130 for (vector<TMG>::const_iterator ig=measGroups.begin();
131 ig!=measGroups.end(); ++ig) {
133 const vector<TM>& measurements = ig->measurements();
134 for ( vector<TM>::const_iterator im=measurements.begin();
135 im!=measurements.end(); ++im ) {
136 if ( im->recHit()->isValid() ) ngrp++;
139 if ( ngrp>0 ) ntot *= ngrp;
142 cout <<
"TrajectorySegmentBuilder::partialTrajectories:: det ids & hit types / group" << endl;
143 for (vector<TMG>::const_iterator ig=measGroups.begin();
144 ig!=measGroups.end(); ++ig) {
145 const vector<TM>& measurements = ig->measurements();
146 for ( vector<TM>::const_iterator im=measurements.begin();
147 im!=measurements.end(); ++im ) {
148 if ( im!=measurements.begin() )
cout <<
" / ";
149 if ( im->recHit()->det() )
150 cout << im->recHit()->det()->geographicalId().rawId() <<
" " 151 << im->recHit()->getType();
160 cout <<
typeid(theLayer).
name() << endl;
180 if UNLIKELY(theDbgFlg)
cout <<
"TSB: back with " << candidates.size() <<
" candidates" << endl;
186 updateWithInvalidHit(startingTrajectory,measGroups,candidates);
188 if UNLIKELY(theDbgFlg)
cout <<
"TSB: " << candidates.size() <<
" candidates after invalid hit" << endl;
190 statCount.incr(measGroups.size(), candidates.size(), theLockedHits.size());
193 theLockedHits.clear();
203 if (
hit->isValid()) {
204 auto && upState = theUpdator.update( predictedState, *
hit);
229 vector<TMG>::const_iterator
begin,
230 vector<TMG>::const_iterator
end)
232 vector<TempTrajectory> ret;
235 if UNLIKELY(theDbgFlg)
cout <<
"TSB::addGroup : no groups left" << endl;
242 <<
" first group at " << &(*begin)
249 if ( theMaxCand == 1 ) {
250 auto && firstMeasurements = unlockedMeasurements(begin->measurements());
251 if (!firstMeasurements.empty()) updateCandidatesWithBestHit(traj,
std::move(firstMeasurements.front()),updatedTrajectories);
253 updateCandidates(traj,begin->
measurements(),updatedTrajectories);
255 if UNLIKELY(theDbgFlg)
cout <<
"TSB::addGroup : updating with first group - " 256 << updatedTrajectories.size() <<
" trajectories" << endl;
259 auto && meas = redoMeasurements(traj,begin->detGroup());
261 if ( theBestHitOnly ) {
262 updateCandidatesWithBestHit(traj,
std::move(meas.front()),
263 updatedTrajectories);
266 updatedTrajectories);
268 if UNLIKELY(theDbgFlg)
cout <<
"TSB::addGroup : updating" 269 << updatedTrajectories.size() <<
" trajectories-1" << endl;
274 updatedTrajectories.push_back(traj);
277 if (begin+1 != end) {
279 for (
auto const & ut : updatedTrajectories) {
280 if UNLIKELY(theDbgFlg)
cout <<
"TSB::addGroup : trying to extend candidate at " 281 << &ut <<
" size " << ut.measurements().size() << endl;
282 vector<TempTrajectory> && finalTrajectories = addGroup(ut,begin+1,end);
283 if UNLIKELY(theDbgFlg)
cout <<
"TSB::addGroup : " << finalTrajectories.size()
284 <<
" finalised candidates before cleaning" << endl;
287 cleanCandidates(finalTrajectories);
290 int ntf=0;
for (
auto const &
t : finalTrajectories)
if (
t.isValid()) ++ntf;
291 cout <<
"TSB::addGroup : got " << ntf
292 <<
" finalised candidates" << endl;
295 for (
auto &
t : finalTrajectories)
302 ret.reserve(updatedTrajectories.size());
303 for (
auto &
t : updatedTrajectories)
317 const vector<TM>& measurements,
323 for (
auto im=measurements.begin();
324 im!=measurements.end(); ++im ) {
325 if ( im->recHit()->isValid() ) {
326 candidates.push_back(traj);
327 updateTrajectory(candidates.back(),*im);
328 if ( theLockHits ) lockMeasurement(*im);
341 if ( theLockHits ) lockMeasurement(measurement);
342 candidates.push_back(traj);
343 updateTrajectory(candidates.back(),
std::move(measurement));
346 vector<TrajectoryMeasurement>
354 if UNLIKELY(theDbgFlg)
cout <<
"TSB::redoMeasurements : nr. of measurements / group =";
358 for (
auto const & det : detGroup) {
360 pair<bool, TrajectoryStateOnSurface> compat =
363 theGeomPropagator,theEstimator);
367 if(!compat.first)
continue;
371 if (mdet.
measurements(compat.second, theEstimator,tmps) && tmps.
hits[0]->isValid() )
372 for (std::size_t
i=0;
i!=tmps.
size(); ++
i)
389 const vector<TMG>& groups,
398 for (
auto const & gr : groups ) {
399 auto const & measurements = gr.measurements();
400 for (
auto im=measurements.rbegin(); im!=measurements.rend(); ++im ) {
401 auto const &
hit = im->recHitR();
409 auto const & predState = im->predictedState();
411 (predState.isValid() &&
412 hit.det()->surface().bounds().inside(predState.localPosition())) ) {
414 candidates.push_back(traj);
415 updateTrajectory(candidates.back(), *im);
416 if UNLIKELY( theDbgFlg )
cout <<
"TrajectorySegmentBuilder::updateWithInvalidHit " 417 <<
"added inactive hit" << endl;
431 for (
auto const & gr : groups ) {
432 auto const & measurements = gr.measurements();
433 for (
auto im=measurements.rbegin(); im!=measurements.rend(); ++im ) {
435 auto const &
hit = im->recHitR();
439 auto const & predState = im->predictedState();
440 if (
iteration>0 || (predState.isValid() &&
441 hit.surface()->bounds().inside(predState.localPosition())) ) {
443 candidates.push_back(traj);
444 updateTrajectory(candidates.back(), *im);
450 <<
" did not find invalid hit on 1st iteration" << endl;
454 cout <<
"TrajectorySegmentBuilder::updateWithInvalidHit: " 455 <<
" did not find invalid hit" << endl;
458 vector<TrajectoryMeasurement>
464 result.reserve(measurements.size());
468 for (
auto const &
m : measurements) {
469 auto const & testHit =
m.recHitR();
470 if UNLIKELY( !testHit.isValid() )
continue;
472 if LIKELY( theLockHits ) {
473 for (
auto const &
h : theLockedHits) {
480 if LIKELY( !found ) result.push_back(
m);
488 theLockedHits.push_back(measurement.
recHit());
501 if ( candidates.size()<=1 )
return;
504 const int NC = candidates.size();
505 int index[NC];
for (
int i=0;
i!=NC; ++
i) index[
i]=
i;
506 std::sort(index,index+NC,[&candidates](
int i,
int j) {
return lessByFoundHits(candidates[i],candidates[j]);});
512 for (
auto i1 = index; i1!=index+NC-1; ++i1) {
515 for (
auto i2=i1+1; i2!=index+NC; ++i2 ) {
517 if ( candidates[*i2].foundHits()==candidates[*i1].foundHits() )
continue;
527 im1!=im1end; --im1 ) {
536 from2 = im2; --from2;
545 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.
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
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