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!";
132 if ((*itm).recHit()->isValid()) {
137 currTsos = (*
theConvolutor)(currTsos, usePropagator->propagationDirection());
139 edm::LogInfo(
"GsfTrackFitters") <<
"GsfTrajectorySmoother: tsos not valid after update / material effects!";
146 TSOS combTsos =
combiner(predTsos, (*itm).forwardPredictedState());
148 LogDebug(
"GsfTrackFitters") <<
"KFTrajectorySmoother: combined tsos not valid!\n" 151 <<
"TrackingRecHit: " 152 << (*itm).recHit()->surface()->toGlobal((*itm).recHit()->localPosition()) <<
"\n";
156 TSOS smooTsos =
combiner((*itm).updatedState(), predTsos);
159 LogDebug(
"GsfTrackFitters") <<
"KFTrajectorySmoother: smoothed tsos not valid!";
163 if (!(*itm).forwardPredictedState().isValid() || !predTsos.
isValid() || !smooTsos.
isValid()) {
164 edm::LogError(
"InvalidState") <<
"inside hits with combination.";
169 myTraj.push(
TM((*itm).forwardPredictedState(),
176 LogDebug(
"GsfTrackFitters") <<
"added measurement #" << hitcounter-- <<
" with chi2 " <<
chi2;
177 dump(predTsos,
"predTsos",
"GsfTrackFitters");
178 dump(smooTsos,
"smooTsos",
"GsfTrackFitters");
182 TSOS combTsos =
combiner(predTsos, (*itm).forwardPredictedState());
185 LogDebug(
"GsfTrackFitters") <<
"KFTrajectorySmoother: combined tsos not valid!";
189 if (!(*itm).forwardPredictedState().isValid() || !predTsos.
isValid() || !combTsos.
isValid()) {
190 edm::LogError(
"InvalidState") <<
"inside hits with invalid rechit.";
194 myTraj.push(
TM((*itm).forwardPredictedState(),
200 LogDebug(
"GsfTrackFitters") <<
"added invalid measurement #" << hitcounter--;
201 dump(predTsos,
"predTsos",
"GsfTrackFitters");
202 dump(combTsos,
"smooTsos",
"GsfTrackFitters");
207 dump(currTsos,
"currTsos",
"GsfTrackFitters");
211 predTsos = usePropagator->propagate(currTsos, *avtm.front().recHit()->
surface());
213 predTsos = (*
theConvolutor)(predTsos, usePropagator->propagationDirection());
215 edm::LogInfo(
"GsfTrackFitters") <<
"GsfTrajectorySmoother: predicted tsos not valid!";
221 if (avtm.front().recHit()->isValid()) {
223 currTsos =
updator()->
update(predTsos, *avtm.front().recHit());
225 currTsos = (*
theConvolutor)(currTsos, usePropagator->propagationDirection());
227 edm::LogInfo(
"GsfTrackFitters") <<
"GsfTrajectorySmoother: tsos not valid after update / material effects!";
231 if (!avtm.front().forwardPredictedState().isValid() || !predTsos.
isValid() || !currTsos.
isValid()) {
237 myTraj.push(
TM(avtm.front().forwardPredictedState(),
240 avtm.front().recHit(),
244 LogDebug(
"GsfTrackFitters") <<
"added measurement #" << hitcounter-- <<
" with chi2 " <<
chi2;
245 dump(predTsos,
"predTsos",
"GsfTrackFitters");
246 dump(currTsos,
"smooTsos",
"GsfTrackFitters");
249 if (!avtm.front().forwardPredictedState().isValid()) {
253 myTraj.push(
TM(avtm.front().forwardPredictedState(),
254 avtm.front().recHit(),
257 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)