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

virtual 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=0)
 
virtual void setHitCloner (TkCloner const *hc) override
 
virtual Trajectory trajectory (const Trajectory &aTraj) const override
 
const TrajectoryStateUpdatorupdator () const
 
virtual ~GsfTrajectorySmoother ()
 
- 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

Definition at line 26 of file GsfTrajectorySmoother.h.

Definition at line 25 of file GsfTrajectorySmoother.h.

Constructor & Destructor Documentation

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

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 12 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  :
19  theAlongPropagator(nullptr),
20  theOppositePropagator(nullptr),
21  theGeomPropagator(nullptr),
22  theConvolutor(nullptr),
23  theUpdator(aUpdator.clone()),
24  theEstimator(aEstimator.clone()),
25  theMerger(aMerger.clone()),
26  theMatBeforeUpdate(materialBeforeUpdate),
28  theGeometry(detLayerGeometry)
29 {
30  auto p = aPropagator.clone();
31  p->setPropagationDirection(alongMomentum);
33  p = aPropagator.clone();
34  p->setPropagationDirection(oppositeToMomentum);
36  if ( !theMatBeforeUpdate ) {
39  }
40 
42 
43 }
const GsfPropagatorAdapter * theGeomPropagator
FullConvolutionWithMaterial * clone() const
Clone.
const FullConvolutionWithMaterial * theConvolutor
virtual GsfPropagatorWithMaterial * clone() const override
const DetLayerGeometry * theGeometry
const MultiTrajectoryStateMerger * theMerger
const DetLayerGeometry dummyGeometry
virtual MeasurementEstimator * clone() const =0
const MeasurementEstimator * theEstimator
const TrajectoryStateUpdator * theUpdator
const GsfPropagatorWithMaterial * theAlongPropagator
const Propagator & geometricalPropagator() const
Access to the geometrical propagator.
virtual TrajectoryStateUpdator * clone() const =0
const GsfPropagatorWithMaterial * theOppositePropagator
const FullConvolutionWithMaterial & convolutionWithMaterial() const
Access to the convolutor and thus to the material effects.
GsfTrajectorySmoother::~GsfTrajectorySmoother ( )
virtual

Definition at line 45 of file GsfTrajectorySmoother.cc.

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

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

Member Function Documentation

virtual GsfTrajectorySmoother* GsfTrajectorySmoother::clone ( void  ) const
inlineoverridevirtual

Implements TrajectorySmoother.

Definition at line 48 of file GsfTrajectorySmoother.h.

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

49  {
52  }
GsfTrajectorySmoother(const GsfPropagatorWithMaterial &aPropagator, const TrajectoryStateUpdator &aUpdator, const MeasurementEstimator &aEstimator, const MultiTrajectoryStateMerger &merger, float errorRescaling, const bool materialBeforeUpdate=true, const DetLayerGeometry *detLayerGeometry=0)
const DetLayerGeometry * theGeometry
const MultiTrajectoryStateMerger * theMerger
const MeasurementEstimator * theEstimator
const TrajectoryStateUpdator * theUpdator
const GsfPropagatorWithMaterial * theAlongPropagator
const MeasurementEstimator* GsfTrajectorySmoother::estimator ( void  ) const
inline

Definition at line 46 of file GsfTrajectorySmoother.h.

References theEstimator.

Referenced by trajectory().

46 {return theEstimator;}
const MeasurementEstimator * theEstimator
virtual void GsfTrajectorySmoother::setHitCloner ( TkCloner const *  hc)
inlineoverridevirtual

Implements TrajectorySmoother.

Definition at line 54 of file GsfTrajectorySmoother.h.

54  {
55  }
Trajectory GsfTrajectorySmoother::trajectory ( const Trajectory aTraj) const
overridevirtual

Implements TrajectorySmoother.

Definition at line 56 of file GsfTrajectorySmoother.cc.

References alongMomentum, HiEvtPlane_cfi::chi2, Trajectory::direction(), FrontierConditions_GlobalTag_cff::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().

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

Definition at line 45 of file GsfTrajectorySmoother.h.

References theUpdator.

Referenced by trajectory().

45 {return theUpdator;}
const TrajectoryStateUpdator * theUpdator

Member Data Documentation

const DetLayerGeometry GsfTrajectorySmoother::dummyGeometry
private

Definition at line 71 of file GsfTrajectorySmoother.h.

Referenced by GsfTrajectorySmoother().

const GsfPropagatorWithMaterial* GsfTrajectorySmoother::theAlongPropagator
private
const FullConvolutionWithMaterial* GsfTrajectorySmoother::theConvolutor
private
float GsfTrajectorySmoother::theErrorRescaling
private

Definition at line 69 of file GsfTrajectorySmoother.h.

Referenced by clone(), and trajectory().

const MeasurementEstimator* GsfTrajectorySmoother::theEstimator
private

Definition at line 64 of file GsfTrajectorySmoother.h.

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

const DetLayerGeometry* GsfTrajectorySmoother::theGeometry
private

Definition at line 72 of file GsfTrajectorySmoother.h.

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

const GsfPropagatorAdapter* GsfTrajectorySmoother::theGeomPropagator
private
bool GsfTrajectorySmoother::theMatBeforeUpdate
private

Definition at line 68 of file GsfTrajectorySmoother.h.

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

const MultiTrajectoryStateMerger* GsfTrajectorySmoother::theMerger
private

Definition at line 65 of file GsfTrajectorySmoother.h.

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

const GsfPropagatorWithMaterial* GsfTrajectorySmoother::theOppositePropagator
private
bool GsfTrajectorySmoother::theTiming
private

Definition at line 67 of file GsfTrajectorySmoother.h.

const TrajectoryStateUpdator* GsfTrajectorySmoother::theUpdator
private

Definition at line 63 of file GsfTrajectorySmoother.h.

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