CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Types | Private Attributes
GsfTrajectorySmoother Class Reference

#include <GsfTrajectorySmoother.h>

Inheritance diagram for GsfTrajectorySmoother:
TrajectorySmoother

Public Member Functions

virtual GsfTrajectorySmootherclone () const
 
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)
 
const Propagatorpropagator () const
 
virtual std::vector< Trajectorytrajectories (const Trajectory &aTraj) const
 
const TrajectoryStateUpdatorupdator () const
 
virtual ~GsfTrajectorySmoother ()
 
- Public Member Functions inherited from TrajectorySmoother
virtual ~TrajectorySmoother ()
 

Private Types

typedef TrajectoryMeasurement TM
 
typedef TrajectoryStateOnSurface TSOS
 

Private Attributes

const DetLayerGeometry dummyGeometry
 
const FullConvolutionWithMaterialtheConvolutor
 
float theErrorRescaling
 
const MeasurementEstimatortheEstimator
 
const DetLayerGeometrytheGeometry
 
const GsfPropagatorAdaptertheGeomPropagator
 
bool theMatBeforeUpdate
 
const MultiTrajectoryStateMergertheMerger
 
GsfPropagatorWithMaterialthePropagator
 
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 9 of file GsfTrajectorySmoother.cc.

References FullConvolutionWithMaterial::clone(), GsfPropagatorWithMaterial::convolutionWithMaterial(), dummyGeometry, GsfPropagatorWithMaterial::geometricalPropagator(), theConvolutor, theGeometry, theGeomPropagator, theMatBeforeUpdate, and thePropagator.

Referenced by clone().

15  :
16  thePropagator(aPropagator.clone()),
18  theConvolutor(0),
19  theUpdator(aUpdator.clone()),
20  theEstimator(aEstimator.clone()),
21  theMerger(aMerger.clone()),
22  theMatBeforeUpdate(materialBeforeUpdate),
23  theErrorRescaling(errorRescaling),
24  theGeometry(detLayerGeometry)
25 {
26  if ( !theMatBeforeUpdate ) {
29  }
30 
32 
33  // static SimpleConfigurable<bool> timeConf(false,"GsfTrajectorySmoother:activateTiming");
34  // theTiming = timeConf.value();
35 }
virtual TrajectoryStateUpdator * clone() const =0
const GsfPropagatorAdapter * theGeomPropagator
GsfPropagatorWithMaterial * thePropagator
FullConvolutionWithMaterial * clone() const
Clone.
const FullConvolutionWithMaterial * theConvolutor
const DetLayerGeometry * theGeometry
const MultiTrajectoryStateMerger * theMerger
const DetLayerGeometry dummyGeometry
virtual MeasurementEstimator * clone() const =0
const MeasurementEstimator * theEstimator
const TrajectoryStateUpdator * theUpdator
const Propagator & geometricalPropagator() const
Access to the geometrical propagator.
virtual GsfPropagatorWithMaterial * clone() const
const FullConvolutionWithMaterial & convolutionWithMaterial() const
Access to the convolutor and thus to the material effects.
GsfTrajectorySmoother::~GsfTrajectorySmoother ( )
virtual

Definition at line 37 of file GsfTrajectorySmoother.cc.

References theConvolutor, theEstimator, theGeomPropagator, theMerger, thePropagator, and theUpdator.

37  {
38  delete thePropagator;
39  delete theGeomPropagator;
40  delete theConvolutor;
41  delete theUpdator;
42  delete theEstimator;
43  delete theMerger;
44 }
const GsfPropagatorAdapter * theGeomPropagator
GsfPropagatorWithMaterial * thePropagator
const FullConvolutionWithMaterial * theConvolutor
const MultiTrajectoryStateMerger * theMerger
const MeasurementEstimator * theEstimator
const TrajectoryStateUpdator * theUpdator

Member Function Documentation

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

Implements TrajectorySmoother.

Definition at line 54 of file GsfTrajectorySmoother.h.

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

55  {
58  }
GsfPropagatorWithMaterial * thePropagator
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 MeasurementEstimator* GsfTrajectorySmoother::estimator ( void  ) const
inline

Definition at line 52 of file GsfTrajectorySmoother.h.

References theEstimator.

Referenced by trajectories().

52 {return theEstimator;}
const MeasurementEstimator * theEstimator
const Propagator* GsfTrajectorySmoother::propagator ( void  ) const
inline

propagator used (full propagator, if material effects are applied before the update, otherwise purely geometrical part)

Definition at line 47 of file GsfTrajectorySmoother.h.

References theGeomPropagator, and thePropagator.

Referenced by trajectories().

47  {
48  if ( thePropagator) return thePropagator;
49  else return theGeomPropagator;
50  }
const GsfPropagatorAdapter * theGeomPropagator
GsfPropagatorWithMaterial * thePropagator
std::vector< Trajectory > GsfTrajectorySmoother::trajectories ( const Trajectory aTraj) const
virtual

Implements TrajectorySmoother.

Definition at line 47 of file GsfTrajectorySmoother.cc.

References alongMomentum, heavyFlavorValidationHarvestingSequence_cff::combiner, Trajectory::direction(), Trajectory::empty(), MeasurementEstimator::estimate(), TrajectoryMeasurement::estimate(), estimator(), TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), DetLayerGeometry::idToLayer(), TrajectoryStateOnSurface::isValid(), LogDebug, Trajectory::measurements(), MultiTrajectoryStateMerger::merge(), oppositeToMomentum, Propagator::propagate(), Propagator::propagationDirection(), propagator(), TrajectoryStateOnSurface::rescaleError(), edm::second(), Trajectory::seed(), GsfPropagatorWithMaterial::setPropagationDirection(), TrajectoryStateOnSurface::surface(), theConvolutor, theErrorRescaling, theGeometry, theMatBeforeUpdate, theMerger, thePropagator, TrajectoryStateUpdator::update(), and updator().

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

Definition at line 51 of file GsfTrajectorySmoother.h.

References theUpdator.

Referenced by trajectories().

51 {return theUpdator;}
const TrajectoryStateUpdator * theUpdator

Member Data Documentation

const DetLayerGeometry GsfTrajectorySmoother::dummyGeometry
private

Definition at line 72 of file GsfTrajectorySmoother.h.

Referenced by GsfTrajectorySmoother().

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

Definition at line 70 of file GsfTrajectorySmoother.h.

Referenced by clone(), and trajectories().

const MeasurementEstimator* GsfTrajectorySmoother::theEstimator
private

Definition at line 65 of file GsfTrajectorySmoother.h.

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

const DetLayerGeometry* GsfTrajectorySmoother::theGeometry
private

Definition at line 73 of file GsfTrajectorySmoother.h.

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

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

Definition at line 69 of file GsfTrajectorySmoother.h.

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

const MultiTrajectoryStateMerger* GsfTrajectorySmoother::theMerger
private

Definition at line 66 of file GsfTrajectorySmoother.h.

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

GsfPropagatorWithMaterial* GsfTrajectorySmoother::thePropagator
private
bool GsfTrajectorySmoother::theTiming
private

Definition at line 68 of file GsfTrajectorySmoother.h.

const TrajectoryStateUpdator* GsfTrajectorySmoother::theUpdator
private

Definition at line 64 of file GsfTrajectorySmoother.h.

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