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 UNLIKELY (mdet.isNull()) {
55  throw MeasurementDetException("MeasurementDet not found");
56  }
57 
58  if (mdet.measurements(ds.second, est, tmps))
59  for (std::size_t i = 0; i != tmps.size(); ++i)
60  result.emplace_back(ds.second, std::move(tmps.hits[i]), tmps.distances[i], &layer);
61  tmps.clear();
62  }
63  // WARNING: we might end up with more than one invalid hit of type 'inactive' in result
64  // to be fixed in order to avoid usless double traj candidates.
65 
66  // sort the final result
67  if (result.size() > 1) {
68  sort(result.begin(), result.end(), TrajMeasLessEstim());
69  }
70 
71  if (!result.empty()) {
72  // invalidMeas on Det of most compatible hit
73  addInvalidMeas(result, result.front().predictedState(), *(result.front().recHit()->det()), layer);
74  } else {
75  // invalid state on first compatible Det
76  addInvalidMeas(result, compatDets.front().second, *(compatDets.front().first), layer);
77  }
78 
79  return result;
80  }
81 
82  void addInvalidMeas(vector<TrajectoryMeasurement>& measVec, const DetGroup& group, const DetLayer& layer) {
83  if (!measVec.empty()) {
84  // invalidMeas on Det of most compatible hit
85  auto const& ts = measVec.front().predictedState();
86  auto toll = measVec.front().recHitR().det()->surface().bounds().significanceInside(
88  measVec.emplace_back(
89  measVec.front().predictedState(),
90  std::make_shared<InvalidTrackingRecHit>(*measVec.front().recHitR().det(), TrackingRecHit::missing),
91  toll,
92  &layer);
93  } else if (!group.empty()) {
94  // invalid state on first compatible Det
95  auto const& ts = group.front().trajectoryState();
96  auto toll = group.front().det()->surface().bounds().significanceInside(ts.localPosition(),
97  ts.localError().positionError());
98  measVec.emplace_back(group.front().trajectoryState(),
99  std::make_shared<InvalidTrackingRecHit>(*group.front().det(), TrackingRecHit::missing),
100  toll,
101  &layer);
102  }
103  }
104 
105 } // namespace
106 
107 // return just valid hits, no sorting (for seeding mostly)
108 std::vector<BaseTrackerRecHit*> LayerMeasurements::recHits(const DetLayer& layer,
109  const TrajectoryStateOnSurface& startingState,
110  const Propagator& prop,
111  const MeasurementEstimator& est) const {
112  std::vector<BaseTrackerRecHit*> result;
113  auto const& compatDets = layer.compatibleDets(startingState, prop, est);
114  if (compatDets.empty())
115  return result;
116  for (auto const& ds : compatDets) {
117  auto mdet = detSystem_.idToDet(ds.first->geographicalId(), data_);
118  mdet.recHits(result, ds.second, est);
119  }
120  return result;
121 }
122 
123 vector<TrajectoryMeasurement> LayerMeasurements::measurements(const DetLayer& layer,
124  const TrajectoryStateOnSurface& startingState,
125  const Propagator& prop,
126  const MeasurementEstimator& est) const {
128 
129  vector<DetWithState> const& compatDets = layer.compatibleDets(startingState, prop, est);
130 
131  if (!compatDets.empty())
132  return get(detSystem_, data_, layer, compatDets, startingState, prop, est);
133 
134  vector<TrajectoryMeasurement> result;
135  pair<bool, TrajectoryStateOnSurface> compat = layer.compatible(startingState, prop, est);
136 
137  if (compat.first) {
138  result.push_back(
139  TrajectoryMeasurement(compat.second,
140  std::make_shared<InvalidTrackingRecHitNoDet>(layer.surface(), TrackingRecHit::inactive),
141  0.F,
142  &layer));
143  LogDebug("LayerMeasurements") << "adding a missing hit.";
144  } else
145  LogDebug("LayerMeasurements") << "adding not measurement.";
146 
147  return result;
148 }
149 
150 vector<TrajectoryMeasurementGroup> LayerMeasurements::groupedMeasurements(const DetLayer& layer,
151  const TrajectoryStateOnSurface& startingState,
152  const Propagator& prop,
153  const MeasurementEstimator& est) const {
154  vector<TrajectoryMeasurementGroup> result;
155 
156  vector<DetGroup>&& groups = layer.groupedCompatibleDets(startingState, prop, est);
157  result.reserve(groups.size());
158 
160  for (auto& grp : groups) {
161  if (grp.empty())
162  continue;
163 
164  vector<TrajectoryMeasurement> tmpVec;
165  for (auto const& det : grp) {
166  MeasurementDetWithData mdet = detSystem_.idToDet(det.det()->geographicalId(), data_);
167  if (mdet.isNull()) {
168  throw MeasurementDetException("MeasurementDet not found");
169  }
170  if (mdet.measurements(det.trajectoryState(), est, tmps))
171  for (std::size_t i = 0; i != tmps.size(); ++i)
172  tmpVec.emplace_back(det.trajectoryState(), std::move(tmps.hits[i]), tmps.distances[i], &layer);
173  tmps.clear();
174  }
175 
176  // sort the final result
177  LogDebug("LayerMeasurements") << "Sorting " << tmpVec.size() << " measurements in this grp.";
178  sort(tmpVec.begin(), tmpVec.end(), TrajMeasLessEstim());
179  addInvalidMeas(tmpVec, grp, layer);
180  result.emplace_back(std::move(tmpVec), std::move(grp));
181  }
182 
183  // if the result is empty check if the layer is compatible (for invalid measurement)
184  if (result.empty()) {
185  pair<bool, TrajectoryStateOnSurface> compat = layer.compatible(startingState, prop, est);
186  if (compat.first) {
187  vector<TrajectoryMeasurement> tmVec;
188  tmVec.emplace_back(compat.second,
189  std::make_shared<InvalidTrackingRecHitNoDet>(layer.surface(), TrackingRecHit::inactive),
190  0.F,
191  &layer);
192  result.emplace_back(std::move(tmVec), DetGroup());
193  }
194  }
195  return result;
196 }
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:123
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:108
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:150
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