51 myTraj.reserve(avtm.size());
56 LogDebug(
"TrackFitters") <<
"KFTrajectorySmoother::trajectories starting with " << avtm.size() <<
" HITS\n";
57 for (
unsigned int j=0;
j<avtm.size();
j++) {
58 if (avtm[
j].recHit()->det())
59 LogTrace(
"TrackFitters") <<
"hit #:" <<
j+1 <<
" rawId=" << avtm[
j].recHit()->det()->geographicalId().rawId()
60 <<
" validity=" << avtm[
j].recHit()->isValid();
62 LogTrace(
"TrackFitters") <<
"hit #:" <<
j+1 <<
" Hit with no Det information";
64 #endif // EDM_ML_DEBUG
67 TSOS predTsos = avtm.back().forwardPredictedState();
73 unsigned int hitcounter = avtm.size();
74 for(std::vector<TM>::const_reverse_iterator itm = avtm.rbegin(); itm != (avtm.rend()); ++itm,--hitcounter) {
81 LogDebug(
"TrackFitters") <<
" Error: invalid hit with no GeomDet attached .... skipping";
87 if (hitcounter != avtm.size())
88 predTsos = usePropagator->
propagate( currTsos, *(hit->surface()) );
91 LogDebug(
"TrackFitters") <<
"KFTrajectorySmoother: predicted tsos not valid!";
92 if( myTraj.foundHits() >=
minHits_ ) {
93 LogDebug(
"TrackFitters") <<
" breaking trajectory" <<
"\n";
95 LogDebug(
"TrackFitters") <<
" killing trajectory" <<
"\n";
105 <<
"----------------- HIT #" << hitcounter <<
" (VALID)-----------------------\n"
106 <<
"HIT IS AT R " << hit->globalPosition().perp() <<
"\n"
107 <<
"HIT IS AT Z " << hit->globalPosition().z() <<
"\n"
108 <<
"HIT IS AT Phi " << hit->globalPosition().phi() <<
"\n"
109 <<
"HIT IS AT Loc " << hit->localPosition() <<
"\n"
110 <<
"WITH LocError " << hit->localPositionError() <<
"\n"
111 <<
"HIT IS AT Glo " << hit->globalPosition() <<
"\n"
112 <<
"SURFACE POSITION: " << hit->surface()->position() <<
"\n"
113 <<
"SURFACE ROTATION: " << hit->surface()->rotation() <<
"\n"
114 <<
"hit geographicalId=" << hit->geographicalId().rawId();
116 DetId hitId = hit->geographicalId();
132 LogTrace(
"TrackFitters") <<
" UNKNOWN TRACKER HIT TYPE ";
142 LogTrace(
"TrackFitters") <<
" UNKNOWN MUON HIT TYPE ";
145 LogTrace(
"TrackFitters") <<
" UNKNOWN HIT TYPE ";
146 #endif //EDM_ML_DEBUG
150 TSOS combTsos,smooTsos;
161 if (hitcounter == avtm.size()) combTsos = itm->forwardPredictedState();
162 else if (hitcounter == 1) combTsos = predTsos;
163 else combTsos =
combiner(predTsos, itm->forwardPredictedState());
167 "KFTrajectorySmoother: combined tsos not valid!\n" <<
170 "TrackingRecHit: " << hit->surface()->toGlobal(hit->localPosition()) <<
"\n" ;
171 if( myTraj.foundHits() >=
minHits_ ) {
172 LogDebug(
"TrackFitters") <<
" breaking trajectory" <<
"\n";
174 LogDebug(
"TrackFitters") <<
" killing trajectory" <<
"\n";
180 assert( (hit->geographicalId()!=0U) | (!hit->canImproveWithTrack()) );
181 assert(hit->surface()!=
nullptr);
183 assert( (!(hit)->canImproveWithTrack()) | (
nullptr!=dynamic_cast<BaseTrackerRecHit const*>(hit.get())));
185 assert(preciseHit->isValid());
186 assert( (preciseHit->geographicalId()!=0U) | (!preciseHit->canImproveWithTrack()) );
187 assert(preciseHit->surface()!=
nullptr);
189 if unlikely(!preciseHit->isValid()){
190 LogTrace(
"TrackFitters") <<
"THE Precise HIT IS NOT VALID: using currTsos = predTsos" <<
"\n";
194 LogTrace(
"TrackFitters") <<
"THE Precise HIT IS VALID: updating currTsos" <<
"\n";
201 "Failed updating state with hit. Rolling back to non-updated state.\n" <<
202 "State: " << predTsos <<
204 "Hit local err: " << hit->localPositionError() <<
"\n" <<
205 "Hit global pos: " << hit->globalPosition() <<
"\n" <<
206 "Hit global err: " << hit->globalPositionError().matrix() <<
211 if (hitcounter == avtm.size()) smooTsos = itm->updatedState();
212 else if (hitcounter == 1) smooTsos = currTsos;
213 else smooTsos =
combiner(itm->forwardPredictedState(), currTsos);
216 LogDebug(
"TrackFitters") <<
"KFTrajectorySmoother: smoothed tsos not valid!";
217 if( myTraj.foundHits() >=
minHits_ ) {
218 LogDebug(
"TrackFitters") <<
" breaking trajectory" <<
"\n";
220 LogDebug(
"TrackFitters") <<
" killing trajectory" <<
"\n";
227 if (hitcounter != avtm.size()) estimate =
estimator()->
estimate(combTsos, *preciseHit ).second;
228 else estimate = itm->estimate();
231 <<
"predTsos !" <<
"\n"
233 <<
"currTsos !" <<
"\n"
235 <<
"smooTsos !" <<
"\n"
237 <<
"smoothing estimate (with combTSOS)=" << estimate <<
"\n"
238 <<
"filtering estimate=" << itm->estimate() <<
"\n";
241 if (preciseHit->det()) myTraj.push(
TM(itm->forwardPredictedState(),
248 else myTraj.push(
TM(itm->forwardPredictedState(),
258 <<
"----------------- HIT #" << hitcounter <<
" (INVALID)-----------------------";
263 if (hitcounter == avtm.size()) combTsos = itm->forwardPredictedState();
264 else if (hitcounter == 1) combTsos = predTsos;
265 else combTsos =
combiner(predTsos, itm->forwardPredictedState());
269 "KFTrajectorySmoother: combined tsos not valid!";
272 assert( (hit->det()==
nullptr) || hit->geographicalId()!=0U);
274 myTraj.push(
TM(itm->forwardPredictedState(),
280 else myTraj.push(
TM(itm->forwardPredictedState(),
bool empty() const
True if trajectory has no measurements.
void rescaleError(double factor)
virtual FreeTrajectoryState propagate(const FreeTrajectoryState &ftsStart, const GlobalPoint &pDest) const final
unsigned int layer() const
layer id
virtual PropagationDirection propagationDirection() const
virtual Trajectory trajectory(const Trajectory &aTraj) const override
TrajectorySeed const & seed() const
Access to the seed used to reconstruct the Trajectory.
virtual ~KFTrajectorySmoother()
const DetLayerGeometry * theGeometry
LocalPoint localPosition() const
GlobalPoint globalPosition() const
unsigned int layer() const
layer id
PropagationDirection const & direction() const
DataContainer const & measurements() const
virtual TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TrackingRecHit &) const =0
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
const MeasurementEstimator * estimator() const
const MeasurementEstimator * theEstimator
const TrajectoryStateUpdator * theUpdator
virtual HitReturnType estimate(const TrajectoryStateOnSurface &ts, const TrackingRecHit &hit) const =0
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
unsigned int disk() const
disk id
const TrajectoryStateUpdator * updator() const
TrackingRecHit *operator()[[cms TrackingRecHit::ConstRecHitPointer makeShared(TrackingRecHit::ConstRecHitPointer const &hit, TrajectoryStateOnSurface const &tsos) const
unsigned int wheel() const
wheel id
unsigned int layer() const
layer id
GlobalVector globalMomentum() const
const Propagator * theAlongPropagator
const Propagator * theOppositePropagator
virtual const DetLayer * idToLayer(const DetId &detId) const
Detector det() const
get the detector field from this detid
TkCloner const * theHitCloner
unsigned int wheel() const
wheel id