CMS 3D CMS Logo

LayerMeasurements.cc
Go to the documentation of this file.
5 
10 
14 
16 
19 
20 #include <algorithm>
21 
22 using namespace std;
23 
24 namespace {
26  inline void addInvalidMeas(std::vector<TrajectoryMeasurement>& result,
27  const TrajectoryStateOnSurface& ts,
28  const GeomDet& det,
29  const DetLayer& layer) {
30  result.emplace_back(ts, std::make_shared<InvalidTrackingRecHit>(det, TrackingRecHit::missing), 0.F, &layer);
31  }
32 
40  inline std::vector<TrajectoryMeasurement> get(MeasurementDetSystem const& detSystem,
42  const DetLayer& layer,
43  std::vector<DetWithState> const& compatDets,
44  const TrajectoryStateOnSurface& ts,
45  const Propagator& prop,
46  const MeasurementEstimator& est) {
47  std::vector<TrajectoryMeasurement> result;
48  typedef TrajectoryMeasurement TM;
49 
51 
52  for (auto const& ds : compatDets) {
53  MeasurementDetWithData mdet = detSystem.idToDet(ds.first->geographicalId(), data);
54  if
55  UNLIKELY(mdet.isNull()) { throw MeasurementDetException("MeasurementDet not found"); }
56 
57  if (mdet.measurements(ds.second, est, tmps))
58  for (std::size_t i = 0; i != tmps.size(); ++i)
59  result.emplace_back(ds.second, std::move(tmps.hits[i]), tmps.distances[i], &layer);
60  tmps.clear();
61  }
62  // WARNING: we might end up with more than one invalid hit of type 'inactive' in result
63  // to be fixed in order to avoid usless double traj candidates.
64 
65  // sort the final result
66  if (result.size() > 1) {
67  sort(result.begin(), result.end(), TrajMeasLessEstim());
68  }
69 
70  if (!result.empty()) {
71  // invalidMeas on Det of most compatible hit
72  addInvalidMeas(result, result.front().predictedState(), *(result.front().recHit()->det()), layer);
73  } else {
74  // invalid state on first compatible Det
75  addInvalidMeas(result, compatDets.front().second, *(compatDets.front().first), layer);
76  }
77 
78  return result;
79  }
80 
81  void addInvalidMeas(vector<TrajectoryMeasurement>& measVec, const DetGroup& group, const DetLayer& layer) {
82  if (!measVec.empty()) {
83  // invalidMeas on Det of most compatible hit
84  auto const& ts = measVec.front().predictedState();
85  auto toll = measVec.front().recHitR().det()->surface().bounds().significanceInside(
87  measVec.emplace_back(
88  measVec.front().predictedState(),
89  std::make_shared<InvalidTrackingRecHit>(*measVec.front().recHitR().det(), TrackingRecHit::missing),
90  toll,
91  &layer);
92  } else if (!group.empty()) {
93  // invalid state on first compatible Det
94  auto const& ts = group.front().trajectoryState();
95  auto toll = group.front().det()->surface().bounds().significanceInside(ts.localPosition(),
96  ts.localError().positionError());
97  measVec.emplace_back(group.front().trajectoryState(),
98  std::make_shared<InvalidTrackingRecHit>(*group.front().det(), TrackingRecHit::missing),
99  toll,
100  &layer);
101  }
102  }
103 
104 } // namespace
105 
106 // return just valid hits, no sorting (for seeding mostly)
107 std::vector<BaseTrackerRecHit*> LayerMeasurements::recHits(const DetLayer& layer,
108  const TrajectoryStateOnSurface& startingState,
109  const Propagator& prop,
110  const MeasurementEstimator& est) const {
111  std::vector<BaseTrackerRecHit*> result;
112  auto const& compatDets = layer.compatibleDets(startingState, prop, est);
113  if (compatDets.empty())
114  return result;
115  for (auto const& ds : compatDets) {
116  auto mdet = detSystem_.idToDet(ds.first->geographicalId(), data_);
117  mdet.recHits(result, ds.second, est);
118  }
119  return result;
120 }
121 
122 vector<TrajectoryMeasurement> LayerMeasurements::measurements(const DetLayer& layer,
123  const TrajectoryStateOnSurface& startingState,
124  const Propagator& prop,
125  const MeasurementEstimator& est) const {
127 
128  vector<DetWithState> const& compatDets = layer.compatibleDets(startingState, prop, est);
129 
130  if (!compatDets.empty())
131  return get(detSystem_, data_, layer, compatDets, startingState, prop, est);
132 
133  vector<TrajectoryMeasurement> result;
134  pair<bool, TrajectoryStateOnSurface> compat = layer.compatible(startingState, prop, est);
135 
136  if (compat.first) {
137  result.push_back(
138  TrajectoryMeasurement(compat.second,
139  std::make_shared<InvalidTrackingRecHitNoDet>(layer.surface(), TrackingRecHit::inactive),
140  0.F,
141  &layer));
142  LogDebug("LayerMeasurements") << "adding a missing hit.";
143  } else
144  LogDebug("LayerMeasurements") << "adding not measurement.";
145 
146  return result;
147 }
148 
149 vector<TrajectoryMeasurementGroup> LayerMeasurements::groupedMeasurements(const DetLayer& layer,
150  const TrajectoryStateOnSurface& startingState,
151  const Propagator& prop,
152  const MeasurementEstimator& est) const {
153  vector<TrajectoryMeasurementGroup> result;
154 
155  vector<DetGroup>&& groups = layer.groupedCompatibleDets(startingState, prop, est);
156  result.reserve(groups.size());
157 
159  for (auto& grp : groups) {
160  if (grp.empty())
161  continue;
162 
163  vector<TrajectoryMeasurement> tmpVec;
164  for (auto const& det : grp) {
165  MeasurementDetWithData mdet = detSystem_.idToDet(det.det()->geographicalId(), data_);
166  if (mdet.isNull()) {
167  throw MeasurementDetException("MeasurementDet not found");
168  }
169  if (mdet.measurements(det.trajectoryState(), est, tmps))
170  for (std::size_t i = 0; i != tmps.size(); ++i)
171  tmpVec.emplace_back(det.trajectoryState(), std::move(tmps.hits[i]), tmps.distances[i], &layer);
172  tmps.clear();
173  }
174 
175  // sort the final result
176  LogDebug("LayerMeasurements") << "Sorting " << tmpVec.size() << " measurements in this grp.";
177  sort(tmpVec.begin(), tmpVec.end(), TrajMeasLessEstim());
178  addInvalidMeas(tmpVec, grp, layer);
179  result.emplace_back(std::move(tmpVec), std::move(grp));
180  }
181 
182  // if the result is empty check if the layer is compatible (for invalid measurement)
183  if (result.empty()) {
184  pair<bool, TrajectoryStateOnSurface> compat = layer.compatible(startingState, prop, est);
185  if (compat.first) {
186  vector<TrajectoryMeasurement> tmVec;
187  tmVec.emplace_back(compat.second,
188  std::make_shared<InvalidTrackingRecHitNoDet>(layer.surface(), TrackingRecHit::inactive),
189  0.F,
190  &layer);
191  result.emplace_back(std::move(tmVec), DetGroup());
192  }
193  }
194  return result;
195 }
Likely.h
Propagator.h
TrajMeasLessEstim.h
MeasurementEstimator
Definition: MeasurementEstimator.h:19
LayerMeasurements::measurements
std::vector< TrajectoryMeasurement > measurements(const DetLayer &layer, const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
Definition: LayerMeasurements.cc:122
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
GeomDet
Definition: GeomDet.h:27
LocalTrajectoryError::positionError
LocalError positionError() const
Definition: LocalTrajectoryError.h:81
DetLayer
Definition: DetLayer.h:21
tracking::TempMeasurements::size
std::size_t size() const
Definition: TempMeasurements.h:20
GeometricSearchDet.h
MeasurementDetException.h
TrajMeasLessEstim
Definition: TrajMeasLessEstim.h:10
TrajectoryMeasurement.h
tracking::TempMeasurements
Definition: TempMeasurements.h:10
TrajectoryMeasurementGroup.h
F
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:163
Propagator
Definition: Propagator.h:44
UNLIKELY
#define UNLIKELY(x)
Definition: Likely.h:21
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
MeasurementDetException
Common base class.
Definition: MeasurementDetException.h:12
DetGroup.h
tracking::TempMeasurements::clear
void clear()
Definition: TempMeasurements.h:15
LayerMeasurements.h
Surface::bounds
const Bounds & bounds() const
Definition: Surface.h:87
MeasurementDetWithData::isNull
bool isNull() const
Definition: MeasurementDetWithData.h:13
MeasurementDetSystem
Definition: MeasurementDetSystem.h:7
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
GeomDet::geographicalId
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
TrajectoryStateOnSurface::localPosition
LocalPoint localPosition() const
Definition: TrajectoryStateOnSurface.h:74
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
LayerMeasurements::recHits
std::vector< BaseTrackerRecHit * > recHits(const DetLayer &layer, const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
Definition: LayerMeasurements.cc:107
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
TrackingRecHit::missing
Definition: TrackingRecHit.h:47
MeasurementDetWithData::recHits
RecHitContainer recHits(const TrajectoryStateOnSurface &tsos) const
Definition: MeasurementDetWithData.h:23
DetWithState
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
Definition: RPCRecHitFilter.h:58
GeometricSearchDet::DetWithState
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
Definition: GeometricSearchDet.h:19
get
#define get
MeasurementDetSystem.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
LayerMeasurements::groupedMeasurements
std::vector< TrajectoryMeasurementGroup > groupedMeasurements(const DetLayer &layer, const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
Definition: LayerMeasurements.cc:149
MeasurementDetWithData
Definition: MeasurementDetWithData.h:6
DetLayer.h
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
TrajectoryStateOnSurface::surface
const SurfaceType & surface() const
Definition: TrajectoryStateOnSurface.h:78
DetGroup
Definition: DetGroup.h:41
Bounds::significanceInside
virtual float significanceInside(const Local3DPoint &, const LocalError &) const
Definition: Bounds.cc:4
TrackingRecHit::inactive
Definition: TrackingRecHit.h:48
mps_fire.result
result
Definition: mps_fire.py:311
MeasurementDetSystem::idToDet
virtual MeasurementDetWithData idToDet(const DetId &id, const MeasurementTrackerEvent &data) const =0
tracking::TempMeasurements::distances
Distances distances
Definition: TempMeasurements.h:41
TrajectoryStateOnSurface::localError
const LocalTrajectoryError & localError() const
Definition: TrajectoryStateOnSurface.h:77
TrajectoryMeasurement
Definition: TrajectoryMeasurement.h:25
MeasurementDetWithData::measurements
bool measurements(const TrajectoryStateOnSurface &stateOnThisDet, const MeasurementEstimator &est, TempMeasurements &result) const
Definition: MeasurementDetWithData.h:54
MeasurementDet.h
InvalidTransientRecHit.h
HLTSiStripMonitoring_cff.MeasurementTrackerEvent
MeasurementTrackerEvent
Definition: HLTSiStripMonitoring_cff.py:224
tracking::TempMeasurements::hits
RecHitContainer hits
Definition: TempMeasurements.h:40
watchdog.group
group
Definition: watchdog.py:82