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 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)
 
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 9 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().

15  :
16  theAlongPropagator(nullptr),
17  theOppositePropagator(nullptr),
18  theGeomPropagator(nullptr),
19  theConvolutor(nullptr),
20  theUpdator(aUpdator.clone()),
21  theEstimator(aEstimator.clone()),
22  theMerger(aMerger.clone()),
23  theMatBeforeUpdate(materialBeforeUpdate),
24  theErrorRescaling(errorRescaling),
25  theGeometry(detLayerGeometry)
26 {
27  auto p = aPropagator.clone();
28  p->setPropagationDirection(alongMomentum);
30  p = aPropagator.clone();
31  p->setPropagationDirection(oppositeToMomentum);
33  if ( !theMatBeforeUpdate ) {
36  }
37 
39 
40  // static SimpleConfigurable<bool> timeConf(false,"GsfTrajectorySmoother:activateTiming");
41  // theTiming = timeConf.value();
42 }
virtual TrajectoryStateUpdator * clone() const =0
const GsfPropagatorAdapter * theGeomPropagator
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 GsfPropagatorWithMaterial * theAlongPropagator
const Propagator & geometricalPropagator() const
Access to the geometrical propagator.
const GsfPropagatorWithMaterial * theOppositePropagator
virtual GsfPropagatorWithMaterial * clone() const
const FullConvolutionWithMaterial & convolutionWithMaterial() const
Access to the convolutor and thus to the material effects.
GsfTrajectorySmoother::~GsfTrajectorySmoother ( )
virtual

Definition at line 44 of file GsfTrajectorySmoother.cc.

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

44  {
45  delete theAlongPropagator;
46  delete theOppositePropagator;
47  delete theGeomPropagator;
48  delete theConvolutor;
49  delete theUpdator;
50  delete theEstimator;
51  delete theMerger;
52 }
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)
inlinevirtual

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 55 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(), TrajectoryStateOnSurface::rescaleError(), edm::second(), Trajectory::seed(), TrajectoryStateOnSurface::surface(), theAlongPropagator, theConvolutor, theErrorRescaling, theGeometry, theGeomPropagator, theMatBeforeUpdate, theMerger, theOppositePropagator, TrajectoryStateUpdator::update(), and updator().

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