28 KFTrajectorySmoother::~KFTrajectorySmoother() {
30 delete theAlongPropagator;
31 delete theOppositePropagator;
38 KFTrajectorySmoother::trajectory(
const Trajectory& aTraj)
const {
42 const Propagator* usePropagator = theAlongPropagator;
44 usePropagator = theOppositePropagator;
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);
181 assert(hit->surface()!=
nullptr);
182 assert( (!(hit)->canImproveWithTrack()) | (
nullptr!=theHitCloner));
183 assert( (!(hit)->canImproveWithTrack()) | (
nullptr!=dynamic_cast<BaseTrackerRecHit const*>(hit.get())));
184 auto preciseHit = theHitCloner->makeShared(hit,combTsos);
185 assert(preciseHit->isValid());
186 assert(preciseHit->geographicalId()!=0U);
187 assert(preciseHit->surface()!=
nullptr);
189 if unlikely(!preciseHit->isValid()){
190 LogTrace(
"TrackFitters") <<
"THE Precise HIT IS NOT VALID: using currTsos = predTsos" <<
"\n";
192 myTraj.push(TM(predTsos, hit, 0, theGeometry->idToLayer(hit->geographicalId()) ));
194 LogTrace(
"TrackFitters") <<
"THE Precise HIT IS VALID: updating currTsos" <<
"\n";
197 currTsos = updator()->
update(predTsos, *preciseHit);
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(),
246 theGeometry->idToLayer(preciseHit->geographicalId()) ),
247 estimator()->estimate(predTsos,*preciseHit).second);
248 else myTraj.push(TM(itm->forwardPredictedState(),
253 estimator()->estimate(predTsos,*preciseHit).second);
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(),
279 theGeometry->idToLayer(hit->geographicalId()) ));
280 else myTraj.push(TM(itm->forwardPredictedState(),
bool empty() const
True if trajectory has no measurements.
void rescaleError(double factor)
unsigned int layer() const
layer id
TrajectorySeed const & seed() const
Access to the seed used to reconstruct the Trajectory.
LocalPoint localPosition() const
GlobalPoint globalPosition() const
virtual PropagationDirection propagationDirection() const GCC11_FINAL
unsigned int layer() const
layer id
PropagationDirection const & direction() const
DataContainer const & measurements() const
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
void update(const LocalTrajectoryParameters &p, const SurfaceType &aSurface, const MagneticField *field, SurfaceSide side=SurfaceSideDefinition::atCenterOfSurface)
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
unsigned int disk() const
disk id
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
unsigned int wheel() const
wheel id
unsigned int layer() const
layer id
GlobalVector globalMomentum() const
Detector det() const
get the detector field from this detid
unsigned int wheel() const
wheel id