CMS 3D CMS Logo

GsfTrajectoryFitter.cc
Go to the documentation of this file.
2 
8 
11 
13 
15  const TrajectoryStateUpdator& aUpdator,
16  const MeasurementEstimator& aEstimator,
17  const MultiTrajectoryStateMerger& aMerger,
18  const DetLayerGeometry* detLayerGeometry)
19  : thePropagator(aPropagator.clone()),
20  theUpdator(aUpdator.clone()),
21  theEstimator(aEstimator.clone()),
22  theMerger(aMerger.clone()),
23  theGeometry(detLayerGeometry) {
24  if (!theGeometry)
26 }
27 
29  delete thePropagator;
30  delete theUpdator;
31  delete theEstimator;
32  delete theMerger;
33 }
34 
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 }
44 
46  edm::LogError("GsfTrajectoryFitter") << "GsfTrajectoryFitter::fit(TrajectorySeed, vector<RecHit>) not implemented";
47 
48  return Trajectory();
49 }
50 
52  const RecHitContainer& hits,
53  const TrajectoryStateOnSurface& firstPredTsos,
54  fitType) const {
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  auto preciseHit = theHitCloner->makeShared(*ihit, predTsos);
125  dump(*preciseHit, hitcounter, "GsfTrackFitters");
126  currTsos = updator()->update(predTsos, *preciseHit);
127  if (!predTsos.isValid() || !currTsos.isValid()) {
128  edm::LogError("InvalidState") << "inside hit";
129  return Trajectory();
130  }
131  auto chi2 = estimator()->estimate(predTsos, *preciseHit).second;
132  myTraj.push(TM(predTsos, currTsos, preciseHit, chi2, theGeometry->idToLayer(preciseHit->geographicalId())));
133  LogDebug("GsfTrackFitters") << "added measurement with chi2 " << chi2;
134  } else {
135  currTsos = predTsos;
136  if (!predTsos.isValid()) {
137  edm::LogError("InvalidState") << "inside invalid hit";
138  return Trajectory();
139  }
140  myTraj.push(TM(predTsos, *ihit, 0., theGeometry->idToLayer((*ihit)->geographicalId())));
141  }
142  dump(predTsos, "predTsos", "GsfTrackFitters");
143  dump(currTsos, "currTsos", "GsfTrackFitters");
144  }
145  return myTraj;
146 }
MeasurementEstimator
Definition: MeasurementEstimator.h:19
GsfTrajectoryFitter::estimator
const MeasurementEstimator * estimator() const
Definition: GsfTrajectoryFitter.h:46
MessageLogger.h
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
GsfTrajectoryFitter.h
GsfTrajectoryFitter::updator
const TrajectoryStateUpdator * updator() const
Definition: GsfTrajectoryFitter.h:45
cms::cuda::assert
assert(be >=bs)
DetLayerGeometry::idToLayer
virtual const DetLayer * idToLayer(const DetId &detId) const
Definition: DetLayerGeometry.h:33
TransientTrackingRecHit.h
MultiTrajectoryStateMerger::merge
TrajectoryStateOnSurface merge(const TrajectoryStateOnSurface &tsos) const
Definition: MultiTrajectoryStateMerger.cc:4
TrajectoryMeasurement::updatedState
TrajectoryStateOnSurface const & updatedState() const
Definition: TrajectoryMeasurement.h:184
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
Trajectory::foundHits
int foundHits() const
Definition: Trajectory.h:206
hltPixelTracks_cff.chi2
chi2
Definition: hltPixelTracks_cff.py:25
TrajectoryStateWithArbitraryError
Definition: TrajectoryStateWithArbitraryError.h:15
GsfTrajectoryFitter::~GsfTrajectoryFitter
~GsfTrajectoryFitter() override
Definition: GsfTrajectoryFitter.cc:28
MeasurementEstimator::estimate
virtual HitReturnType estimate(const TrajectoryStateOnSurface &ts, const TrackingRecHit &hit) const =0
Propagator
Definition: Propagator.h:44
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
GsfTrajectoryFitter::theEstimator
const MeasurementEstimator * theEstimator
Definition: GsfTrajectoryFitter.h:59
clone
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
GsfTrajectoryFitter::theGeometry
const DetLayerGeometry * theGeometry
Definition: GsfTrajectoryFitter.h:63
TrajectoryStateWithArbitraryError.h
GsfTrajectoryFitter::fitOne
Trajectory fitOne(const Trajectory &t, fitType type) const override
Definition: GsfTrajectoryFitter.cc:35
TrajectoryStateUpdator::update
virtual TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TrackingRecHit &) const =0
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:39
DetLayerGeometry
Definition: DetLayerGeometry.h:18
FrontierConditions_GlobalTag_cff.dump
dump
Definition: FrontierConditions_GlobalTag_cff.py:12
MultiTrajectoryStateMerger.h
TkCloner.h
TkCloner::makeShared
TrackingRecHit::ConstRecHitPointer makeShared(TrackingRecHit::ConstRecHitPointer const &hit, TrajectoryStateOnSurface const &tsos) const
Definition: TkCloner.h:24
DebugHelpers.h
GsfTrajectoryFitter::TM
TrajectoryMeasurement TM
Definition: GsfTrajectoryFitter.h:23
Propagator::propagate
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:50
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
Trajectory::push
void push(const TrajectoryMeasurement &tm)
Definition: Trajectory.cc:50
GsfTrajectoryFitter::theUpdator
const TrajectoryStateUpdator * theUpdator
Definition: GsfTrajectoryFitter.h:58
BaseTrackerRecHit.h
Trajectory::recHits
ConstRecHitContainer recHits() const
Definition: Trajectory.h:186
Trajectory::firstMeasurement
TrajectoryMeasurement const & firstMeasurement() const
Definition: Trajectory.h:166
GsfTrajectoryFitter::GsfTrajectoryFitter
GsfTrajectoryFitter(const Propagator &aPropagator, const TrajectoryStateUpdator &aUpdator, const MeasurementEstimator &aEstimator, const MultiTrajectoryStateMerger &aMerger, const DetLayerGeometry *detLayerGeometry=nullptr)
Definition: GsfTrajectoryFitter.cc:14
Trajectory
Definition: Trajectory.h:38
Trajectory::seed
TrajectorySeed const & seed() const
Access to the seed used to reconstruct the Trajectory.
Definition: Trajectory.h:263
GsfTrajectoryFitter::merger
const MultiTrajectoryStateMerger * merger() const
Definition: GsfTrajectoryFitter.h:47
TrajectorySeed
Definition: TrajectorySeed.h:18
GsfTrajectoryFitter::propagator
const Propagator * propagator() const
Definition: GsfTrajectoryFitter.h:44
TrajectoryStateOnSurface::surface
const SurfaceType & surface() const
Definition: TrajectoryStateOnSurface.h:78
BoundPlane.h
GsfTrajectoryFitter::thePropagator
const Propagator * thePropagator
Definition: GsfTrajectoryFitter.h:57
TrajectoryStateUpdator
Definition: TrajectoryStateUpdator.h:14
TrajectoryMeasurement
Definition: TrajectoryMeasurement.h:25
MultiTrajectoryStateMerger
Definition: MultiTrajectoryStateMerger.h:13
GsfTrajectoryFitter::theHitCloner
TkCloner const * theHitCloner
Definition: GsfTrajectoryFitter.h:61
GsfTrajectoryFitter::dummyGeometry
const DetLayerGeometry dummyGeometry
Definition: GsfTrajectoryFitter.h:62
TrajectoryFitter::RecHitContainer
Trajectory::RecHitContainer RecHitContainer
Definition: TrajectoryFitter.h:24
TrajectoryStateOnSurface::isValid
bool isValid() const
Definition: TrajectoryStateOnSurface.h:54
GsfTrajectoryFitter::theMerger
const MultiTrajectoryStateMerger * theMerger
Definition: GsfTrajectoryFitter.h:60
Trajectory::empty
bool empty() const
True if trajectory has no measurements.
Definition: Trajectory.h:233
TrajectoryFitter::fitType
fitType
Definition: TrajectoryFitter.h:21