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";
85 if (hit->det() && hit->geographicalId()<1000U)
std::cout <<
"Problem 0 det id for " <<
typeid(*hit).name() <<
' ' << hit->det()->geographicalId() << std::endl;
86 if (hit->isValid() && hit->geographicalId()<1000U)
std::cout <<
"Problem 0 det id for " <<
typeid(*hit).name() <<
' ' << hit->det()->geographicalId() << std::endl;
89 if (hitcounter != avtm.size())
90 predTsos = usePropagator->
propagate( currTsos, *(hit->surface()) );
93 LogDebug(
"TrackFitters") <<
"KFTrajectorySmoother: predicted tsos not valid!";
94 if( myTraj.foundHits() >= minHits_ ) {
95 LogDebug(
"TrackFitters") <<
" breaking trajectory" <<
"\n";
97 LogDebug(
"TrackFitters") <<
" killing trajectory" <<
"\n";
107 <<
"----------------- HIT #" << hitcounter <<
" (VALID)-----------------------\n"
108 <<
"HIT IS AT R " << hit->globalPosition().perp() <<
"\n"
109 <<
"HIT IS AT Z " << hit->globalPosition().z() <<
"\n"
110 <<
"HIT IS AT Phi " << hit->globalPosition().phi() <<
"\n"
111 <<
"HIT IS AT Loc " << hit->localPosition() <<
"\n"
112 <<
"WITH LocError " << hit->localPositionError() <<
"\n"
113 <<
"HIT IS AT Glo " << hit->globalPosition() <<
"\n"
114 <<
"SURFACE POSITION: " << hit->surface()->position() <<
"\n"
115 <<
"SURFACE ROTATION: " << hit->surface()->rotation() <<
"\n"
116 <<
"hit geographicalId=" << hit->geographicalId().rawId();
118 DetId hitId = hit->geographicalId();
134 LogTrace(
"TrackFitters") <<
" UNKNOWN TRACKER HIT TYPE ";
144 LogTrace(
"TrackFitters") <<
" UNKNOWN MUON HIT TYPE ";
147 LogTrace(
"TrackFitters") <<
" UNKNOWN HIT TYPE ";
148 #endif //EDM_ML_DEBUG
152 TSOS combTsos,smooTsos;
163 if (hitcounter == avtm.size()) combTsos = itm->forwardPredictedState();
164 else if (hitcounter == 1) combTsos = predTsos;
165 else combTsos =
combiner(predTsos, itm->forwardPredictedState());
169 "KFTrajectorySmoother: combined tsos not valid!\n" <<
172 "TrackingRecHit: " << hit->surface()->toGlobal(hit->localPosition()) <<
"\n" ;
173 if( myTraj.foundHits() >= minHits_ ) {
174 LogDebug(
"TrackFitters") <<
" breaking trajectory" <<
"\n";
176 LogDebug(
"TrackFitters") <<
" killing trajectory" <<
"\n";
182 assert(hit->geographicalId()!=0U);
183 assert(hit->surface()!=
nullptr);
184 assert( (!(hit)->canImproveWithTrack()) | (
nullptr!=theHitCloner));
185 assert( (!(hit)->canImproveWithTrack()) | (
nullptr!=dynamic_cast<BaseTrackerRecHit const*>(hit.get())));
186 auto preciseHit = theHitCloner->makeShared(hit,combTsos);
187 assert(preciseHit->isValid());
188 assert(preciseHit->geographicalId()!=0U);
189 assert(preciseHit->surface()!=
nullptr);
191 if unlikely(!preciseHit->isValid()){
192 LogTrace(
"TrackFitters") <<
"THE Precise HIT IS NOT VALID: using currTsos = predTsos" <<
"\n";
194 myTraj.push(TM(predTsos, hit, 0, theGeometry->idToLayer(hit->geographicalId()) ));
196 LogTrace(
"TrackFitters") <<
"THE Precise HIT IS VALID: updating currTsos" <<
"\n";
199 currTsos = updator()->
update(predTsos, *preciseHit);
203 "Failed updating state with hit. Rolling back to non-updated state.\n" <<
204 "State: " << predTsos <<
206 "Hit local err: " << hit->localPositionError() <<
"\n" <<
207 "Hit global pos: " << hit->globalPosition() <<
"\n" <<
208 "Hit global err: " << hit->globalPositionError().matrix() <<
213 if (hitcounter == avtm.size()) smooTsos = itm->updatedState();
214 else if (hitcounter == 1) smooTsos = currTsos;
215 else smooTsos =
combiner(itm->forwardPredictedState(), currTsos);
218 LogDebug(
"TrackFitters") <<
"KFTrajectorySmoother: smoothed tsos not valid!";
219 if( myTraj.foundHits() >= minHits_ ) {
220 LogDebug(
"TrackFitters") <<
" breaking trajectory" <<
"\n";
222 LogDebug(
"TrackFitters") <<
" killing trajectory" <<
"\n";
229 if (hitcounter != avtm.size()) estimate = estimator()->estimate(combTsos, *preciseHit ).second;
230 else estimate = itm->estimate();
233 <<
"predTsos !" <<
"\n"
235 <<
"currTsos !" <<
"\n"
237 <<
"smooTsos !" <<
"\n"
239 <<
"smoothing estimate (with combTSOS)=" << estimate <<
"\n"
240 <<
"filtering estimate=" << itm->estimate() <<
"\n";
243 if (preciseHit->det()) myTraj.push(TM(itm->forwardPredictedState(),
248 theGeometry->idToLayer(preciseHit->geographicalId()) ),
249 estimator()->estimate(predTsos,*preciseHit).second);
250 else myTraj.push(TM(itm->forwardPredictedState(),
255 estimator()->estimate(predTsos,*preciseHit).second);
260 <<
"----------------- HIT #" << hitcounter <<
" (INVALID)-----------------------";
265 if (hitcounter == avtm.size()) combTsos = itm->forwardPredictedState();
266 else if (hitcounter == 1) combTsos = predTsos;
267 else combTsos =
combiner(predTsos, itm->forwardPredictedState());
271 "KFTrajectorySmoother: combined tsos not valid!";
274 assert( (hit->det()==
nullptr) || hit->geographicalId()!=0U);
276 myTraj.push(TM(itm->forwardPredictedState(),
281 theGeometry->idToLayer(hit->geographicalId()) ));
282 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