CMS 3D CMS Logo

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

#include <GsfTrajectoryFitter.h>

Inheritance diagram for GsfTrajectoryFitter:
TrajectoryFitter

Public Member Functions

std::unique_ptr< TrajectoryFitterclone () const override
 
const MeasurementEstimatorestimator () const
 
Trajectory fitOne (const Trajectory &t, fitType type) const override
 
Trajectory fitOne (const TrajectorySeed &aSeed, const RecHitContainer &hits, const TrajectoryStateOnSurface &firstPredTsos, fitType type) const override
 
Trajectory fitOne (const TrajectorySeed &aSeed, const RecHitContainer &hits, fitType type) const override
 
 GsfTrajectoryFitter (const Propagator &aPropagator, const TrajectoryStateUpdator &aUpdator, const MeasurementEstimator &aEstimator, const MultiTrajectoryStateMerger &aMerger, const DetLayerGeometry *detLayerGeometry=nullptr)
 
const MultiTrajectoryStateMergermerger () const
 
const Propagatorpropagator () const
 
void setHitCloner (TkCloner const *hc) override
 
const TrajectoryStateUpdatorupdator () const
 
 ~GsfTrajectoryFitter () override
 
- Public Member Functions inherited from TrajectoryFitter
std::vector< Trajectoryfit (const Trajectory &traj, fitType type=standard) const
 
std::vector< Trajectoryfit (const TrajectorySeed &seed, const RecHitContainer &hits, fitType type=standard) const
 
std::vector< Trajectoryfit (const TrajectorySeed &seed, const RecHitContainer &hits, const TrajectoryStateOnSurface &tsos, fitType type=standard) const
 
virtual ~TrajectoryFitter ()
 

Private Types

typedef TrajectoryMeasurement TM
 
typedef TrajectoryStateOnSurface TSOS
 

Private Attributes

const DetLayerGeometry dummyGeometry
 
const MeasurementEstimatortheEstimator
 
const DetLayerGeometrytheGeometry
 
TkCloner const * theHitCloner = nullptr
 
const MultiTrajectoryStateMergertheMerger
 
const PropagatorthePropagator
 
bool theTiming
 
const TrajectoryStateUpdatortheUpdator
 

Additional Inherited Members

- Public Types inherited from TrajectoryFitter
enum  fitType { standard = 0, looper = 1 }
 
typedef Trajectory::RecHitContainer RecHitContainer
 
typedef TrajectoryFitterRecord Record
 

Detailed Description

A GSF fitter, similar to KFTrajectoryFitter.

Definition at line 20 of file GsfTrajectoryFitter.h.

Member Typedef Documentation

◆ TM

Definition at line 23 of file GsfTrajectoryFitter.h.

◆ TSOS

Definition at line 22 of file GsfTrajectoryFitter.h.

Constructor & Destructor Documentation

◆ GsfTrajectoryFitter()

GsfTrajectoryFitter::GsfTrajectoryFitter ( const Propagator aPropagator,
const TrajectoryStateUpdator aUpdator,
const MeasurementEstimator aEstimator,
const MultiTrajectoryStateMerger aMerger,
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)

Definition at line 14 of file GsfTrajectoryFitter.cc.

References dummyGeometry, and theGeometry.

Referenced by clone().

19  : thePropagator(aPropagator.clone()),
20  theUpdator(aUpdator.clone()),
21  theEstimator(aEstimator.clone()),
22  theMerger(aMerger.clone()),
23  theGeometry(detLayerGeometry) {
24  if (!theGeometry)
26 }
const Propagator * thePropagator
const MultiTrajectoryStateMerger * theMerger
virtual TrajectoryStateUpdator * clone() const =0
virtual Propagator * clone() const =0
const DetLayerGeometry * theGeometry
const MeasurementEstimator * theEstimator
virtual MeasurementEstimator * clone() const =0
MultiTrajectoryStateMerger * clone() const
const TrajectoryStateUpdator * theUpdator
const DetLayerGeometry dummyGeometry

◆ ~GsfTrajectoryFitter()

GsfTrajectoryFitter::~GsfTrajectoryFitter ( )
override

Definition at line 28 of file GsfTrajectoryFitter.cc.

References theEstimator, theMerger, thePropagator, and theUpdator.

28  {
29  delete thePropagator;
30  delete theUpdator;
31  delete theEstimator;
32  delete theMerger;
33 }
const Propagator * thePropagator
const MultiTrajectoryStateMerger * theMerger
const MeasurementEstimator * theEstimator
const TrajectoryStateUpdator * theUpdator

Member Function Documentation

◆ clone()

std::unique_ptr<TrajectoryFitter> GsfTrajectoryFitter::clone ( void  ) const
inlineoverridevirtual

Implements TrajectoryFitter.

Definition at line 49 of file GsfTrajectoryFitter.h.

References GsfTrajectoryFitter(), theEstimator, theGeometry, theMerger, thePropagator, and theUpdator.

49  {
50  return std::unique_ptr<TrajectoryFitter>(
52  }
const Propagator * thePropagator
const MultiTrajectoryStateMerger * theMerger
const DetLayerGeometry * theGeometry
const MeasurementEstimator * theEstimator
GsfTrajectoryFitter(const Propagator &aPropagator, const TrajectoryStateUpdator &aUpdator, const MeasurementEstimator &aEstimator, const MultiTrajectoryStateMerger &aMerger, const DetLayerGeometry *detLayerGeometry=nullptr)
const TrajectoryStateUpdator * theUpdator

◆ estimator()

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

Definition at line 46 of file GsfTrajectoryFitter.h.

References theEstimator.

Referenced by fitOne().

46 { return theEstimator; }
const MeasurementEstimator * theEstimator

◆ fitOne() [1/3]

Trajectory GsfTrajectoryFitter::fitOne ( const Trajectory t,
fitType  type 
) const
overridevirtual

Implements TrajectoryFitter.

Definition at line 35 of file GsfTrajectoryFitter.cc.

References Trajectory::empty(), Trajectory::firstMeasurement(), Trajectory::recHits(), Trajectory::seed(), and TrajectoryMeasurement::updatedState().

35  {
36  if (aTraj.empty())
37  return Trajectory();
38 
39  TM const& firstTM = aTraj.firstMeasurement();
40  TSOS firstTsos = TrajectoryStateWithArbitraryError()(firstTM.updatedState());
41 
42  return fitOne(aTraj.seed(), aTraj.recHits(), firstTsos, type);
43 }
Trajectory fitOne(const Trajectory &t, fitType type) const override
TrajectoryMeasurement TM

◆ fitOne() [2/3]

Trajectory GsfTrajectoryFitter::fitOne ( const TrajectorySeed aSeed,
const RecHitContainer hits,
const TrajectoryStateOnSurface firstPredTsos,
fitType  type 
) const
overridevirtual

Implements TrajectoryFitter.

Definition at line 51 of file GsfTrajectoryFitter.cc.

References cms::cuda::assert(), hltPixelTracks_cff::chi2, GCP_Ntuples_cfg::dump, MeasurementEstimator::estimate(), estimator(), Trajectory::foundHits(), hfClusterShapes_cfi::hits, DetLayerGeometry::idToLayer(), TrajectoryStateOnSurface::isValid(), LogDebug, TkCloner::makeShared(), MultiTrajectoryStateMerger::merge(), merger(), Propagator::propagate(), propagator(), Trajectory::push(), TrajectoryStateOnSurface::surface(), theGeometry, theHitCloner, TrajectoryStateUpdator::update(), and updator().

54  {
55  if (hits.empty())
56  return Trajectory();
57 
58  Trajectory myTraj(aSeed, propagator()->propagationDirection());
59 
60  TSOS predTsos(firstPredTsos);
61  if (!predTsos.isValid()) {
62  edm::LogInfo("GsfTrackFitters") << "GsfTrajectoryFitter: predicted tsos of first measurement not valid!";
63  return Trajectory();
64  }
65 
66  TSOS currTsos;
67  if (hits.front()->isValid()) {
68  auto const& ihit = hits.front();
69  //update
70  assert((!(ihit)->canImproveWithTrack()) | (nullptr != theHitCloner));
71  assert((!(ihit)->canImproveWithTrack()) | (nullptr != dynamic_cast<BaseTrackerRecHit const*>(ihit.get())));
72  auto preciseHit = theHitCloner->makeShared(ihit, predTsos);
73  dump(*preciseHit, 1, "GsfTrackFitters");
74  { currTsos = updator()->update(predTsos, *preciseHit); }
75  if (!predTsos.isValid() || !currTsos.isValid()) {
76  edm::LogError("InvalidState") << "first hit";
77  return Trajectory();
78  }
79  myTraj.push(TM(predTsos, currTsos, preciseHit, 0., theGeometry->idToLayer(preciseHit->geographicalId())),
80  estimator()->estimate(predTsos, *preciseHit).second);
81  } else {
82  currTsos = predTsos;
83  if (!predTsos.isValid()) {
84  edm::LogError("InvalidState") << "first invalid hit";
85  return Trajectory();
86  }
87  myTraj.push(TM(predTsos, hits.front(), 0., theGeometry->idToLayer((hits.front())->geographicalId())));
88  }
89 
90  int hitcounter = 1;
91  for (RecHitContainer::const_iterator ihit = hits.begin() + 1; ihit != hits.end(); ihit++) {
92  ++hitcounter;
93 
94  //
95  // temporary protection copied from KFTrajectoryFitter.
96  //
97  if ((**ihit).isValid() == false && (**ihit).det() == nullptr) {
98  LogDebug("GsfTrackFitters") << " Error: invalid hit with no GeomDet attached .... skipping";
99  continue;
100  }
101 
102  {
103  // TimeMe t(*propTimer,false);
104  predTsos = propagator()->propagate(currTsos, (**ihit).det()->surface());
105  }
106  if (!predTsos.isValid()) {
107  if (myTraj.foundHits() >= 3) {
108  edm::LogInfo("GsfTrackFitters") << "GsfTrajectoryFitter: predicted tsos not valid! \n"
109  << "Returning trajectory with " << myTraj.foundHits() << " found hits.";
110  return myTraj;
111  } else {
112  edm::LogInfo("GsfTrackFitters") << "GsfTrajectoryFitter: predicted tsos not valid after " << myTraj.foundHits()
113  << " hits, discarding candidate!";
114  return Trajectory();
115  }
116  }
117  if (merger())
118  predTsos = merger()->merge(predTsos);
119 
120  if ((**ihit).isValid()) {
121  //update
122  assert((!(*ihit)->canImproveWithTrack()) | (nullptr != theHitCloner));
123  assert((!(*ihit)->canImproveWithTrack()) | (nullptr != dynamic_cast<BaseTrackerRecHit const*>((*ihit).get())));
124  if (!predTsos.isValid()) {
125  return Trajectory();
126  }
127  auto preciseHit = theHitCloner->makeShared(*ihit, predTsos);
128  dump(*preciseHit, hitcounter, "GsfTrackFitters");
129  currTsos = updator()->update(predTsos, *preciseHit);
130  if (!predTsos.isValid() || !currTsos.isValid()) {
131  edm::LogError("InvalidState") << "inside hit";
132  return Trajectory();
133  }
134  auto chi2 = estimator()->estimate(predTsos, *preciseHit).second;
135  myTraj.push(TM(predTsos, currTsos, preciseHit, chi2, theGeometry->idToLayer(preciseHit->geographicalId())));
136  LogDebug("GsfTrackFitters") << "added measurement with chi2 " << chi2;
137  } else {
138  currTsos = predTsos;
139  if (!predTsos.isValid()) {
140  edm::LogError("InvalidState") << "inside invalid hit";
141  return Trajectory();
142  }
143  myTraj.push(TM(predTsos, *ihit, 0., theGeometry->idToLayer((*ihit)->geographicalId())));
144  }
145  dump(predTsos, "predTsos", "GsfTrackFitters");
146  dump(currTsos, "currTsos", "GsfTrackFitters");
147  }
148  return myTraj;
149 }
virtual const DetLayer * idToLayer(const DetId &detId) const
const MeasurementEstimator * estimator() const
const TrajectoryStateUpdator * updator() const
const DetLayerGeometry * theGeometry
Log< level::Error, false > LogError
assert(be >=bs)
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:50
const Propagator * propagator() const
virtual TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TrackingRecHit &) const =0
TrajectoryMeasurement TM
TrajectoryStateOnSurface merge(const TrajectoryStateOnSurface &tsos) const
const MultiTrajectoryStateMerger * merger() const
virtual HitReturnType estimate(const TrajectoryStateOnSurface &ts, const TrackingRecHit &hit) const =0
TrackingRecHit::ConstRecHitPointer makeShared(TrackingRecHit::ConstRecHitPointer const &hit, TrajectoryStateOnSurface const &tsos) const
Definition: TkCloner.h:24
Log< level::Info, false > LogInfo
#define LogDebug(id)
TkCloner const * theHitCloner

◆ fitOne() [3/3]

Trajectory GsfTrajectoryFitter::fitOne ( const TrajectorySeed aSeed,
const RecHitContainer hits,
fitType  type 
) const
overridevirtual

Implements TrajectoryFitter.

Definition at line 45 of file GsfTrajectoryFitter.cc.

45  {
46  edm::LogError("GsfTrajectoryFitter") << "GsfTrajectoryFitter::fit(TrajectorySeed, vector<RecHit>) not implemented";
47 
48  return Trajectory();
49 }
Log< level::Error, false > LogError

◆ merger()

const MultiTrajectoryStateMerger* GsfTrajectoryFitter::merger ( ) const
inline

Definition at line 47 of file GsfTrajectoryFitter.h.

References theMerger.

Referenced by fitOne().

47 { return theMerger; }
const MultiTrajectoryStateMerger * theMerger

◆ propagator()

const Propagator* GsfTrajectoryFitter::propagator ( ) const
inline

Definition at line 44 of file GsfTrajectoryFitter.h.

References thePropagator.

Referenced by fitOne().

44 { return thePropagator; }
const Propagator * thePropagator

◆ setHitCloner()

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

Implements TrajectoryFitter.

Definition at line 54 of file GsfTrajectoryFitter.h.

References theHitCloner.

54 { theHitCloner = hc; }
TkCloner const * theHitCloner

◆ updator()

const TrajectoryStateUpdator* GsfTrajectoryFitter::updator ( ) const
inline

Definition at line 45 of file GsfTrajectoryFitter.h.

References theUpdator.

Referenced by fitOne().

45 { return theUpdator; }
const TrajectoryStateUpdator * theUpdator

Member Data Documentation

◆ dummyGeometry

const DetLayerGeometry GsfTrajectoryFitter::dummyGeometry
private

Definition at line 62 of file GsfTrajectoryFitter.h.

Referenced by GsfTrajectoryFitter().

◆ theEstimator

const MeasurementEstimator* GsfTrajectoryFitter::theEstimator
private

Definition at line 59 of file GsfTrajectoryFitter.h.

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

◆ theGeometry

const DetLayerGeometry* GsfTrajectoryFitter::theGeometry
private

Definition at line 63 of file GsfTrajectoryFitter.h.

Referenced by clone(), fitOne(), and GsfTrajectoryFitter().

◆ theHitCloner

TkCloner const* GsfTrajectoryFitter::theHitCloner = nullptr
private

Definition at line 61 of file GsfTrajectoryFitter.h.

Referenced by fitOne(), and setHitCloner().

◆ theMerger

const MultiTrajectoryStateMerger* GsfTrajectoryFitter::theMerger
private

Definition at line 60 of file GsfTrajectoryFitter.h.

Referenced by clone(), merger(), and ~GsfTrajectoryFitter().

◆ thePropagator

const Propagator* GsfTrajectoryFitter::thePropagator
private

Definition at line 57 of file GsfTrajectoryFitter.h.

Referenced by clone(), propagator(), and ~GsfTrajectoryFitter().

◆ theTiming

bool GsfTrajectoryFitter::theTiming
private

Definition at line 65 of file GsfTrajectoryFitter.h.

◆ theUpdator

const TrajectoryStateUpdator* GsfTrajectoryFitter::theUpdator
private

Definition at line 58 of file GsfTrajectoryFitter.h.

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