CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Attributes
GsfTrajectorySmoother Class Referencefinal

#include <GsfTrajectorySmoother.h>

Inheritance diagram for GsfTrajectorySmoother:
TrajectorySmoother

Public Member Functions

GsfTrajectorySmootherclone () const override
 
const MeasurementEstimatorestimator () const
 
 GsfTrajectorySmoother (const GsfPropagatorWithMaterial &aPropagator, const TrajectoryStateUpdator &aUpdator, const MeasurementEstimator &aEstimator, const MultiTrajectoryStateMerger &merger, float errorRescaling, const bool materialBeforeUpdate=true, const DetLayerGeometry *detLayerGeometry=nullptr)
 
void setHitCloner (TkCloner const *hc) override
 
Trajectory trajectory (const Trajectory &aTraj) const override
 
const TrajectoryStateUpdatorupdator () const
 
 ~GsfTrajectorySmoother () override
 
- Public Member Functions inherited from TrajectorySmoother
virtual TrajectoryContainer trajectories (const Trajectory &traj) const
 
virtual ~TrajectorySmoother ()
 

Private Types

typedef TrajectoryMeasurement TM
 
typedef TrajectoryStateOnSurface TSOS
 

Private Attributes

const DetLayerGeometry dummyGeometry
 
const GsfPropagatorWithMaterialtheAlongPropagator
 
const FullConvolutionWithMaterialtheConvolutor
 
float theErrorRescaling
 
const MeasurementEstimatortheEstimator
 
const DetLayerGeometrytheGeometry
 
const GsfPropagatorAdaptertheGeomPropagator
 
bool theMatBeforeUpdate
 
const MultiTrajectoryStateMergertheMerger
 
const GsfPropagatorWithMaterialtheOppositePropagator
 
bool theTiming
 
const TrajectoryStateUpdatortheUpdator
 

Additional Inherited Members

- Public Types inherited from TrajectorySmoother
typedef std::vector< TrajectoryTrajectoryContainer
 
typedef TrajectoryContainer::iterator TrajectoryIterator
 

Detailed Description

A GSF smoother, similar to KFTrajectorySmoother, but (for testing purposes) without combination with the forward fit.

Definition at line 21 of file GsfTrajectorySmoother.h.

Member Typedef Documentation

◆ TM

Definition at line 24 of file GsfTrajectorySmoother.h.

◆ TSOS

Definition at line 23 of file GsfTrajectorySmoother.h.

Constructor & Destructor Documentation

◆ GsfTrajectorySmoother()

GsfTrajectorySmoother::GsfTrajectorySmoother ( const GsfPropagatorWithMaterial aPropagator,
const TrajectoryStateUpdator aUpdator,
const MeasurementEstimator aEstimator,
const MultiTrajectoryStateMerger merger,
float  errorRescaling,
const bool  materialBeforeUpdate = true,
const DetLayerGeometry detLayerGeometry = nullptr 
)

Constructor with explicit components for propagation, update, chi2 calculation, merging and flag for merging before / after the update (i.e. fully configured). It clones the algorithms.

Definition at line 11 of file GsfTrajectorySmoother.cc.

References alongMomentum, FullConvolutionWithMaterial::clone(), GsfPropagatorWithMaterial::clone(), GsfPropagatorWithMaterial::convolutionWithMaterial(), dummyGeometry, GsfPropagatorWithMaterial::geometricalPropagator(), oppositeToMomentum, AlCaHLTBitMon_ParallelJobs::p, theAlongPropagator, theConvolutor, theGeometry, theGeomPropagator, theMatBeforeUpdate, and theOppositePropagator.

Referenced by clone().

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();
29  p->setPropagationDirection(alongMomentum);
31  p = aPropagator.clone();
32  p->setPropagationDirection(oppositeToMomentum);
34  if (!theMatBeforeUpdate) {
37  }
38 
39  if (!theGeometry)
41 }
GsfPropagatorWithMaterial * clone() const override
virtual TrajectoryStateUpdator * clone() const =0
const GsfPropagatorAdapter * theGeomPropagator
const FullConvolutionWithMaterial * theConvolutor
const DetLayerGeometry * theGeometry
const MultiTrajectoryStateMerger * theMerger
const DetLayerGeometry dummyGeometry
virtual MeasurementEstimator * clone() const =0
FullConvolutionWithMaterial * clone() const
Clone.
const FullConvolutionWithMaterial & convolutionWithMaterial() const
Access to the convolutor and thus to the material effects.
const MeasurementEstimator * theEstimator
const TrajectoryStateUpdator * theUpdator
const Propagator & geometricalPropagator() const
Access to the geometrical propagator.
const GsfPropagatorWithMaterial * theAlongPropagator
const GsfPropagatorWithMaterial * theOppositePropagator

◆ ~GsfTrajectorySmoother()

GsfTrajectorySmoother::~GsfTrajectorySmoother ( )
override

Definition at line 43 of file GsfTrajectorySmoother.cc.

References theAlongPropagator, theConvolutor, theEstimator, theGeomPropagator, theMerger, theOppositePropagator, and theUpdator.

43  {
44  delete theAlongPropagator;
45  delete theOppositePropagator;
46  delete theGeomPropagator;
47  delete theConvolutor;
48  delete theUpdator;
49  delete theEstimator;
50  delete theMerger;
51 }
const GsfPropagatorAdapter * theGeomPropagator
const FullConvolutionWithMaterial * theConvolutor
const MultiTrajectoryStateMerger * theMerger
const MeasurementEstimator * theEstimator
const TrajectoryStateUpdator * theUpdator
const GsfPropagatorWithMaterial * theAlongPropagator
const GsfPropagatorWithMaterial * theOppositePropagator

Member Function Documentation

◆ clone()

GsfTrajectorySmoother* GsfTrajectorySmoother::clone ( void  ) const
inlineoverridevirtual

Implements TrajectorySmoother.

Definition at line 45 of file GsfTrajectorySmoother.h.

References GsfTrajectorySmoother(), theAlongPropagator, theErrorRescaling, theEstimator, theGeometry, theMatBeforeUpdate, theMerger, and theUpdator.

45  {
46  return new GsfTrajectorySmoother(
48  }
const DetLayerGeometry * theGeometry
const MultiTrajectoryStateMerger * theMerger
const MeasurementEstimator * theEstimator
const TrajectoryStateUpdator * theUpdator
const GsfPropagatorWithMaterial * theAlongPropagator
GsfTrajectorySmoother(const GsfPropagatorWithMaterial &aPropagator, const TrajectoryStateUpdator &aUpdator, const MeasurementEstimator &aEstimator, const MultiTrajectoryStateMerger &merger, float errorRescaling, const bool materialBeforeUpdate=true, const DetLayerGeometry *detLayerGeometry=nullptr)

◆ estimator()

const MeasurementEstimator* GsfTrajectorySmoother::estimator ( void  ) const
inline

Definition at line 43 of file GsfTrajectorySmoother.h.

References theEstimator.

Referenced by trajectory().

43 { return theEstimator; }
const MeasurementEstimator * theEstimator

◆ setHitCloner()

void GsfTrajectorySmoother::setHitCloner ( TkCloner const *  hc)
inlineoverridevirtual

Implements TrajectorySmoother.

Definition at line 50 of file GsfTrajectorySmoother.h.

50 {}

◆ trajectory()

Trajectory GsfTrajectorySmoother::trajectory ( const Trajectory aTraj) const
overridevirtual

Implements TrajectorySmoother.

Definition at line 53 of file GsfTrajectorySmoother.cc.

References alongMomentum, hltPixelTracks_cff::chi2, heavyFlavorValidationHarvestingSequence_cff::combiner, Trajectory::direction(), GCP_Ntuples_cfg::dump, Trajectory::empty(), MeasurementEstimator::estimate(), TrajectoryMeasurement::estimate(), estimator(), TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), DetLayerGeometry::idToLayer(), TrajectoryStateOnSurface::isValid(), LogDebug, Trajectory::measurements(), MultiTrajectoryStateMerger::merge(), TrajectoryStateOnSurface::rescaleError(), edm::second(), Trajectory::seed(), TrajectoryStateOnSurface::surface(), theAlongPropagator, theConvolutor, theErrorRescaling, theGeometry, theGeomPropagator, theMatBeforeUpdate, theMerger, theOppositePropagator, TrajectoryStateUpdator::update(), and updator().

53  {
54  if (aTraj.empty())
55  return Trajectory();
56 
57  const Propagator* usePropagator = theAlongPropagator;
58  if (aTraj.direction() == alongMomentum) {
59  usePropagator = theOppositePropagator;
60  }
61  if (not usePropagator) {
62  usePropagator = theGeomPropagator;
63  }
64 
65  Trajectory myTraj(aTraj.seed(), usePropagator->propagationDirection());
66 
67  std::vector<TM> const& avtm = aTraj.measurements();
68 
69  TSOS predTsos = avtm.back().forwardPredictedState();
71 
72  if (!predTsos.isValid()) {
73  edm::LogInfo("GsfTrackFitters") << "GsfTrajectorySmoother: predicted tsos of last measurement not valid!";
74  return Trajectory();
75  }
76  TSOS currTsos;
77 
78  //first smoothed tm is last fitted
79  if (avtm.back().recHit()->isValid()) {
80  {
81  // TimeMe t(*updateTimer,false);
82  currTsos = updator()->update(predTsos, *avtm.back().recHit());
83  }
84 
85  if (!currTsos.isValid()) {
86  edm::LogInfo("GsfTrajectorySmoother") << "GsfTrajectorySmoother: tsos not valid after update!";
87  return Trajectory();
88  }
89 
90  //check validity
91  if (!avtm.back().forwardPredictedState().isValid() || !predTsos.isValid() ||
92  !avtm.back().updatedState().isValid()) {
93  edm::LogError("InvalidState") << "first hit";
94  return Trajectory();
95  }
96 
97  myTraj.push(TM(avtm.back().forwardPredictedState(),
98  predTsos,
99  avtm.back().updatedState(),
100  avtm.back().recHit(),
101  avtm.back().estimate(),
102  theGeometry->idToLayer(avtm.back().recHit()->geographicalId())),
103  avtm.back().estimate());
104  } else {
105  currTsos = predTsos;
106  //check validity
107  if (!avtm.back().forwardPredictedState().isValid()) {
108  edm::LogError("InvalidState") << "first hit on invalid hit";
109  return Trajectory();
110  }
111 
112  myTraj.push(TM(avtm.back().forwardPredictedState(),
113  avtm.back().recHit(),
114  0.,
115  theGeometry->idToLayer(avtm.back().recHit()->geographicalId())));
116  }
117 
119 
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());
123  if (predTsos.isValid() && theConvolutor && theMatBeforeUpdate)
124  predTsos = (*theConvolutor)(predTsos, usePropagator->propagationDirection());
125  if (!predTsos.isValid()) {
126  edm::LogInfo("GsfTrackFitters") << "GsfTrajectorySmoother: predicted tsos not valid!";
127  return Trajectory();
128  }
129  if (theMerger)
130  predTsos = theMerger->merge(predTsos);
131 
132  if (!predTsos.isValid()) {
133  return Trajectory();
134  }
135 
136  if ((*itm).recHit()->isValid()) {
137  //update
138  currTsos = updator()->update(predTsos, *(*itm).recHit());
139 
140  if (currTsos.isValid() && theConvolutor && !theMatBeforeUpdate)
141  currTsos = (*theConvolutor)(currTsos, usePropagator->propagationDirection());
142  if (!currTsos.isValid()) {
143  edm::LogInfo("GsfTrackFitters") << "GsfTrajectorySmoother: tsos not valid after update / material effects!";
144  return Trajectory();
145  }
146  //3 different possibilities to calculate smoothed state:
147  //1: update combined predictions with hit
148  //2: combine fwd-prediction with bwd-filter
149  //3: combine bwd-prediction with fwd-filter
150  TSOS combTsos = combiner(predTsos, (*itm).forwardPredictedState());
151  if (!combTsos.isValid()) {
152  LogDebug("GsfTrackFitters") << "KFTrajectorySmoother: combined tsos not valid!\n"
153  << "pred Tsos pos: " << predTsos.globalPosition() << "\n"
154  << "pred Tsos mom: " << predTsos.globalMomentum() << "\n"
155  << "TrackingRecHit: "
156  << (*itm).recHit()->surface()->toGlobal((*itm).recHit()->localPosition()) << "\n";
157  return Trajectory();
158  }
159 
160  TSOS smooTsos = combiner((*itm).updatedState(), predTsos);
161 
162  if (!smooTsos.isValid()) {
163  LogDebug("GsfTrackFitters") << "KFTrajectorySmoother: smoothed tsos not valid!";
164  return Trajectory();
165  }
166 
167  if (!(*itm).forwardPredictedState().isValid() || !predTsos.isValid() || !smooTsos.isValid()) {
168  edm::LogError("InvalidState") << "inside hits with combination.";
169  return Trajectory();
170  }
171 
172  auto chi2 = estimator()->estimate(combTsos, *(*itm).recHit()).second;
173  myTraj.push(TM((*itm).forwardPredictedState(),
174  predTsos,
175  smooTsos,
176  (*itm).recHit(),
177  chi2,
178  theGeometry->idToLayer((*itm).recHit()->geographicalId())),
179  (*itm).estimate());
180  LogDebug("GsfTrackFitters") << "added measurement #" << hitcounter-- << " with chi2 " << chi2;
181  dump(predTsos, "predTsos", "GsfTrackFitters");
182  dump(smooTsos, "smooTsos", "GsfTrackFitters");
183 
184  } else {
185  currTsos = predTsos;
186  TSOS combTsos = combiner(predTsos, (*itm).forwardPredictedState());
187 
188  if (!combTsos.isValid()) {
189  LogDebug("GsfTrackFitters") << "KFTrajectorySmoother: combined tsos not valid!";
190  return Trajectory();
191  }
192 
193  if (!(*itm).forwardPredictedState().isValid() || !predTsos.isValid() || !combTsos.isValid()) {
194  edm::LogError("InvalidState") << "inside hits with invalid rechit.";
195  return Trajectory();
196  }
197 
198  myTraj.push(TM((*itm).forwardPredictedState(),
199  predTsos,
200  combTsos,
201  (*itm).recHit(),
202  0.,
203  theGeometry->idToLayer((*itm).recHit()->geographicalId())));
204  LogDebug("GsfTrackFitters") << "added invalid measurement #" << hitcounter--;
205  dump(predTsos, "predTsos", "GsfTrackFitters");
206  dump(combTsos, "smooTsos", "GsfTrackFitters");
207  }
208  if (theMerger)
209  currTsos = theMerger->merge(currTsos);
210 
211  if (!currTsos.isValid()) {
212  return Trajectory();
213  }
214  dump(currTsos, "currTsos", "GsfTrackFitters");
215  }
216 
217  //last smoothed tm is last filtered
218  predTsos = usePropagator->propagate(currTsos, *avtm.front().recHit()->surface());
219  if (predTsos.isValid() && theConvolutor && theMatBeforeUpdate)
220  predTsos = (*theConvolutor)(predTsos, usePropagator->propagationDirection());
221  if (!predTsos.isValid()) {
222  edm::LogInfo("GsfTrackFitters") << "GsfTrajectorySmoother: predicted tsos not valid!";
223  return Trajectory();
224  }
225  if (theMerger)
226  predTsos = theMerger->merge(predTsos);
227 
228  if (avtm.front().recHit()->isValid()) {
229  //update
230  currTsos = updator()->update(predTsos, *avtm.front().recHit());
231  if (currTsos.isValid() && theConvolutor && !theMatBeforeUpdate)
232  currTsos = (*theConvolutor)(currTsos, usePropagator->propagationDirection());
233  if (!currTsos.isValid()) {
234  edm::LogInfo("GsfTrackFitters") << "GsfTrajectorySmoother: tsos not valid after update / material effects!";
235  return Trajectory();
236  }
237 
238  if (!avtm.front().forwardPredictedState().isValid() || !predTsos.isValid() || !currTsos.isValid()) {
239  edm::LogError("InvalidState") << "last hit";
240  return Trajectory();
241  }
242 
243  auto chi2 = estimator()->estimate(predTsos, *avtm.front().recHit()).second;
244  myTraj.push(TM(avtm.front().forwardPredictedState(),
245  predTsos,
246  currTsos,
247  avtm.front().recHit(),
248  chi2,
249  theGeometry->idToLayer(avtm.front().recHit()->geographicalId())),
250  avtm.front().estimate());
251  LogDebug("GsfTrackFitters") << "added measurement #" << hitcounter-- << " with chi2 " << chi2;
252  dump(predTsos, "predTsos", "GsfTrackFitters");
253  dump(currTsos, "smooTsos", "GsfTrackFitters");
254 
255  } else {
256  if (!avtm.front().forwardPredictedState().isValid()) {
257  edm::LogError("InvalidState") << "last invalid hit";
258  return Trajectory();
259  }
260  myTraj.push(TM(avtm.front().forwardPredictedState(),
261  avtm.front().recHit(),
262  0.,
263  theGeometry->idToLayer(avtm.front().recHit()->geographicalId())));
264  LogDebug("GsfTrackFitters") << "added invalid measurement #" << hitcounter--;
265  }
266 
267  return myTraj;
268 }
virtual const DetLayer * idToLayer(const DetId &detId) const
const GsfPropagatorAdapter * theGeomPropagator
const TrajectoryStateUpdator * updator() const
TrajectoryMeasurement TM
Log< level::Error, false > LogError
const FullConvolutionWithMaterial * theConvolutor
const DetLayerGeometry * theGeometry
DataContainer const & measurements() const
Definition: Trajectory.h:178
U second(std::pair< T, U > const &p)
virtual TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TrackingRecHit &) const =0
const MultiTrajectoryStateMerger * theMerger
GlobalPoint globalPosition() const
PropagationDirection const & direction() const
Definition: Trajectory.cc:133
TrajectoryStateOnSurface merge(const TrajectoryStateOnSurface &tsos) const
virtual HitReturnType estimate(const TrajectoryStateOnSurface &ts, const TrackingRecHit &hit) const =0
Log< level::Info, false > LogInfo
const MeasurementEstimator * estimator() const
TrajectorySeed const & seed() const
Access to the seed used to reconstruct the Trajectory.
Definition: Trajectory.h:263
bool empty() const
True if trajectory has no measurements.
Definition: Trajectory.h:233
GlobalVector globalMomentum() const
const GsfPropagatorWithMaterial * theAlongPropagator
const GsfPropagatorWithMaterial * theOppositePropagator
#define LogDebug(id)

◆ updator()

const TrajectoryStateUpdator* GsfTrajectorySmoother::updator ( ) const
inline

Definition at line 42 of file GsfTrajectorySmoother.h.

References theUpdator.

Referenced by trajectory().

42 { return theUpdator; }
const TrajectoryStateUpdator * theUpdator

Member Data Documentation

◆ dummyGeometry

const DetLayerGeometry GsfTrajectorySmoother::dummyGeometry
private

Definition at line 65 of file GsfTrajectorySmoother.h.

Referenced by GsfTrajectorySmoother().

◆ theAlongPropagator

const GsfPropagatorWithMaterial* GsfTrajectorySmoother::theAlongPropagator
private

◆ theConvolutor

const FullConvolutionWithMaterial* GsfTrajectorySmoother::theConvolutor
private

◆ theErrorRescaling

float GsfTrajectorySmoother::theErrorRescaling
private

Definition at line 63 of file GsfTrajectorySmoother.h.

Referenced by clone(), and trajectory().

◆ theEstimator

const MeasurementEstimator* GsfTrajectorySmoother::theEstimator
private

Definition at line 58 of file GsfTrajectorySmoother.h.

Referenced by clone(), estimator(), and ~GsfTrajectorySmoother().

◆ theGeometry

const DetLayerGeometry* GsfTrajectorySmoother::theGeometry
private

Definition at line 66 of file GsfTrajectorySmoother.h.

Referenced by clone(), GsfTrajectorySmoother(), and trajectory().

◆ theGeomPropagator

const GsfPropagatorAdapter* GsfTrajectorySmoother::theGeomPropagator
private

◆ theMatBeforeUpdate

bool GsfTrajectorySmoother::theMatBeforeUpdate
private

Definition at line 62 of file GsfTrajectorySmoother.h.

Referenced by clone(), GsfTrajectorySmoother(), and trajectory().

◆ theMerger

const MultiTrajectoryStateMerger* GsfTrajectorySmoother::theMerger
private

Definition at line 59 of file GsfTrajectorySmoother.h.

Referenced by clone(), trajectory(), and ~GsfTrajectorySmoother().

◆ theOppositePropagator

const GsfPropagatorWithMaterial* GsfTrajectorySmoother::theOppositePropagator
private

◆ theTiming

bool GsfTrajectorySmoother::theTiming
private

Definition at line 61 of file GsfTrajectorySmoother.h.

◆ theUpdator

const TrajectoryStateUpdator* GsfTrajectorySmoother::theUpdator
private

Definition at line 57 of file GsfTrajectorySmoother.h.

Referenced by clone(), updator(), and ~GsfTrajectorySmoother().