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--;