16 const bool materialBeforeUpdate,
18 : theAlongPropagator(nullptr),
19 theOppositePropagator(nullptr),
20 theGeomPropagator(nullptr),
21 theConvolutor(nullptr),
22 theUpdator(aUpdator.
clone()),
23 theEstimator(aEstimator.
clone()),
24 theMerger(aMerger.
clone()),
25 theMatBeforeUpdate(materialBeforeUpdate),
27 theGeometry(detLayerGeometry) {
28 auto p = aPropagator.
clone();
61 if (not usePropagator) {
65 Trajectory myTraj(aTraj.
seed(), usePropagator->propagationDirection());
69 TSOS predTsos = avtm.back().forwardPredictedState();
73 edm::LogInfo(
"GsfTrackFitters") <<
"GsfTrajectorySmoother: predicted tsos of last measurement not valid!";
79 if (avtm.back().recHit()->isValid()) {
82 currTsos =
updator()->
update(predTsos, *avtm.back().recHit());
86 edm::LogInfo(
"GsfTrajectorySmoother") <<
"GsfTrajectorySmoother: tsos not valid after update!";
91 if (!avtm.back().forwardPredictedState().isValid() || !predTsos.
isValid() ||
92 !avtm.back().updatedState().isValid()) {
97 myTraj.push(
TM(avtm.back().forwardPredictedState(),
99 avtm.back().updatedState(),
100 avtm.back().recHit(),
101 avtm.back().estimate(),
107 if (!avtm.back().forwardPredictedState().isValid()) {
112 myTraj.push(
TM(avtm.back().forwardPredictedState(),
113 avtm.back().recHit(),
120 int hitcounter = avtm.size() - 1;
121 for (std::vector<TM>::const_reverse_iterator itm = avtm.rbegin() + 1; itm < avtm.rend() - 1; ++itm) {
122 predTsos = usePropagator->propagate(currTsos, *(*itm).recHit()->
surface());
124 predTsos = (*
theConvolutor)(predTsos, usePropagator->propagationDirection());
126 edm::LogInfo(
"GsfTrackFitters") <<
"GsfTrajectorySmoother: predicted tsos not valid!";
136 if ((*itm).recHit()->isValid()) {
141 currTsos = (*
theConvolutor)(currTsos, usePropagator->propagationDirection());
143 edm::LogInfo(
"GsfTrackFitters") <<
"GsfTrajectorySmoother: tsos not valid after update / material effects!";
150 TSOS combTsos =
combiner(predTsos, (*itm).forwardPredictedState());
152 LogDebug(
"GsfTrackFitters") <<
"KFTrajectorySmoother: combined tsos not valid!\n" 155 <<
"TrackingRecHit: " 156 << (*itm).recHit()->surface()->toGlobal((*itm).recHit()->localPosition()) <<
"\n";
160 TSOS smooTsos =
combiner((*itm).updatedState(), predTsos);
163 LogDebug(
"GsfTrackFitters") <<
"KFTrajectorySmoother: smoothed tsos not valid!";
167 if (!(*itm).forwardPredictedState().isValid() || !predTsos.
isValid() || !smooTsos.
isValid()) {
168 edm::LogError(
"InvalidState") <<
"inside hits with combination.";
173 myTraj.push(
TM((*itm).forwardPredictedState(),
180 LogDebug(
"GsfTrackFitters") <<
"added measurement #" << hitcounter-- <<
" with chi2 " <<
chi2;
181 dump(predTsos,
"predTsos",
"GsfTrackFitters");
182 dump(smooTsos,
"smooTsos",
"GsfTrackFitters");
186 TSOS combTsos =
combiner(predTsos, (*itm).forwardPredictedState());
189 LogDebug(
"GsfTrackFitters") <<
"KFTrajectorySmoother: combined tsos not valid!";
193 if (!(*itm).forwardPredictedState().isValid() || !predTsos.
isValid() || !combTsos.
isValid()) {
194 edm::LogError(
"InvalidState") <<
"inside hits with invalid rechit.";
198 myTraj.push(
TM((*itm).forwardPredictedState(),
204 LogDebug(
"GsfTrackFitters") <<
"added invalid measurement #" << hitcounter--;
205 dump(predTsos,
"predTsos",
"GsfTrackFitters");
206 dump(combTsos,
"smooTsos",
"GsfTrackFitters");
214 dump(currTsos,
"currTsos",
"GsfTrackFitters");
218 predTsos = usePropagator->propagate(currTsos, *avtm.front().recHit()->
surface());
220 predTsos = (*
theConvolutor)(predTsos, usePropagator->propagationDirection());
222 edm::LogInfo(
"GsfTrackFitters") <<
"GsfTrajectorySmoother: predicted tsos not valid!";
228 if (avtm.front().recHit()->isValid()) {
230 currTsos =
updator()->
update(predTsos, *avtm.front().recHit());
232 currTsos = (*
theConvolutor)(currTsos, usePropagator->propagationDirection());
234 edm::LogInfo(
"GsfTrackFitters") <<
"GsfTrajectorySmoother: tsos not valid after update / material effects!";
238 if (!avtm.front().forwardPredictedState().isValid() || !predTsos.
isValid() || !currTsos.
isValid()) {
244 myTraj.push(
TM(avtm.front().forwardPredictedState(),
247 avtm.front().recHit(),
251 LogDebug(
"GsfTrackFitters") <<
"added measurement #" << hitcounter-- <<
" with chi2 " <<
chi2;
252 dump(predTsos,
"predTsos",
"GsfTrackFitters");
253 dump(currTsos,
"smooTsos",
"GsfTrackFitters");
256 if (!avtm.front().forwardPredictedState().isValid()) {
260 myTraj.push(
TM(avtm.front().forwardPredictedState(),
261 avtm.front().recHit(),
264 LogDebug(
"GsfTrackFitters") <<
"added invalid measurement #" << hitcounter--;
GsfPropagatorWithMaterial * clone() const override
void rescaleError(double factor)
virtual const DetLayer * idToLayer(const DetId &detId) const
const GsfPropagatorAdapter * theGeomPropagator
const TrajectoryStateUpdator * updator() const
Log< level::Error, false > LogError
const SurfaceType & surface() const
const FullConvolutionWithMaterial * theConvolutor
const DetLayerGeometry * theGeometry
DataContainer const & measurements() const
U second(std::pair< T, U > const &p)
virtual TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TrackingRecHit &) const =0
const MultiTrajectoryStateMerger * theMerger
GlobalPoint globalPosition() const
const DetLayerGeometry dummyGeometry
~GsfTrajectorySmoother() override
PropagationDirection const & direction() const
FullConvolutionWithMaterial * clone() const
Clone.
TrajectoryStateOnSurface merge(const TrajectoryStateOnSurface &tsos) const
const FullConvolutionWithMaterial & convolutionWithMaterial() const
Access to the convolutor and thus to the material effects.
virtual HitReturnType estimate(const TrajectoryStateOnSurface &ts, const TrackingRecHit &hit) const =0
const MeasurementEstimator * theEstimator
Log< level::Info, false > LogInfo
Trajectory trajectory(const Trajectory &aTraj) const override
const MeasurementEstimator * estimator() const
TrajectorySeed const & seed() const
Access to the seed used to reconstruct the Trajectory.
const TrajectoryStateUpdator * theUpdator
const Propagator & geometricalPropagator() const
Access to the geometrical propagator.
bool empty() const
True if trajectory has no measurements.
GlobalVector globalMomentum() const
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
const GsfPropagatorWithMaterial * theAlongPropagator
const GsfPropagatorWithMaterial * theOppositePropagator
GsfTrajectorySmoother(const GsfPropagatorWithMaterial &aPropagator, const TrajectoryStateUpdator &aUpdator, const MeasurementEstimator &aEstimator, const MultiTrajectoryStateMerger &merger, float errorRescaling, const bool materialBeforeUpdate=true, const DetLayerGeometry *detLayerGeometry=nullptr)