CMS 3D CMS Logo

MTDDetLayerMeasurements.cc
Go to the documentation of this file.
1 
10 
13 
17 
18 typedef std::shared_ptr<GenericTransientTrackingRecHit> MTDRecHitPointer;
19 typedef std::vector<GenericTransientTrackingRecHit::RecHitPointer> MTDRecHitContainer;
21 
23  : theMTDToken(iC.consumes<MTDTrackingRecHit>(mtdlabel)),
24  theMTDRecHits(),
25  theMTDEventCacheID(0),
26  theEvent(nullptr) {}
27 
29 
31  DetId geoId = geomDet->geographicalId();
32  theEvent = &iEvent;
34 
36 
37  // Create the ChamberId
38  DetId detId(geoId.rawId());
39  LogDebug("MTDDetLayerMeasurements") << "(MTD): " << static_cast<MTDDetId>(detId) << std::endl;
40 
41  // Get the MTD-Segment which relies on this chamber
42  auto detset = (*theMTDRecHits)[detId];
43 
44  for (const auto& rechit : detset)
45  result.push_back(GenericTransientTrackingRecHit::build(geomDet, &rechit));
46 
47  return result;
48 }
49 
51  LogDebug("MTDDetLayerMeasurements") << "Checking MTD RecHits";
52  checkEvent();
53  auto cacheID = theEvent->cacheIdentifier();
54  if (cacheID == theMTDEventCacheID)
55  return;
56 
57  {
59  theMTDEventCacheID = cacheID;
60  }
61  if (!theMTDRecHits.isValid()) {
62  throw cms::Exception("MTDDetLayerMeasurements") << "Cannot get MTD RecHits";
63  }
64 }
65 
66 template <class T>
68  if (!result.empty()) {
69  sort(result.begin(), result.end(), TrajMeasLessEstim());
70  }
71 
72  return result;
73 }
74 
77  const TrajectoryStateOnSurface& startingState,
78  const Propagator& prop,
79  const MeasurementEstimator& est) {
80  checkEvent();
81  return measurements(layer, startingState, prop, est, *theEvent);
82 }
83 
85  const TrajectoryStateOnSurface& startingState,
86  const Propagator& prop,
87  const MeasurementEstimator& est,
88  const edm::Event& iEvent) {
90 
91  const auto& dss = layer->compatibleDets(startingState, prop, est);
92  LogDebug("MTDDetLayerMeasurements") << "compatibleDets: " << dss.size() << std::endl;
93 
94  for (const auto& dws : dss) {
95  MeasurementContainer detMeasurements = measurements(layer, dws.first, dws.second, est, iEvent);
96  result.insert(result.end(), detMeasurements.begin(), detMeasurements.end());
97  }
98 
99  return sortResult(result);
100 }
101 
103  const GeomDet* det,
104  const TrajectoryStateOnSurface& stateOnDet,
105  const MeasurementEstimator& est,
106  const edm::Event& iEvent) {
108 
109  // Get the Segments which relies on the GeomDet given by compatibleDets
111 
112  // Create the Trajectory Measurement
113  for (const auto& rechit : mtdRecHits) {
114  MeasurementEstimator::HitReturnType estimate = est.estimate(stateOnDet, *rechit);
115  LogDebug("RecoMTD") << "Dimension: " << rechit->dimension() << " Chi2: " << estimate.second << std::endl;
116  if (estimate.first) {
117  result.push_back(TrajectoryMeasurement(stateOnDet, rechit, estimate.second, layer));
118  }
119  }
120 
121  return sortResult(result);
122 }
123 
125  const TrajectoryStateOnSurface& theStateOnDet,
126  const TrajectoryStateOnSurface& startingState,
127  const Propagator& prop,
128  const MeasurementEstimator& est,
129  const edm::Event& iEvent) {
132  for (const auto& irh : rhs) {
133  MeasurementEstimator::HitReturnType estimate = est.estimate(theStateOnDet, (*irh));
134  if (estimate.first) {
135  result.push_back(TrajectoryMeasurement(theStateOnDet, irh, estimate.second, layer));
136  }
137  }
138 
139  return sortResult(result);
140 }
141 
144  const TrajectoryStateOnSurface& theStateOnDet,
145  const TrajectoryStateOnSurface& startingState,
146  const Propagator& prop,
147  const MeasurementEstimator& est) {
148  checkEvent();
149  return fastMeasurements(layer, theStateOnDet, startingState, prop, est, *theEvent);
150 }
151 
152 std::vector<TrajectoryMeasurementGroup> MTDDetLayerMeasurements::groupedMeasurements(
153  const DetLayer* layer,
154  const TrajectoryStateOnSurface& startingState,
155  const Propagator& prop,
156  const MeasurementEstimator& est) {
157  checkEvent();
158  return groupedMeasurements(layer, startingState, prop, est, *theEvent);
159 }
160 
161 std::vector<TrajectoryMeasurementGroup> MTDDetLayerMeasurements::groupedMeasurements(
162  const DetLayer* layer,
163  const TrajectoryStateOnSurface& startingState,
164  const Propagator& prop,
165  const MeasurementEstimator& est,
166  const edm::Event& iEvent) {
167  std::vector<TrajectoryMeasurementGroup> result;
168  // if we want to use the concept of InvalidRecHits,
169  // we can reuse LayerMeasurements from TrackingTools/MeasurementDet
170  std::vector<DetGroup> groups(layer->groupedCompatibleDets(startingState, prop, est));
171 
172  for (const auto& grp : groups) {
173  std::vector<TrajectoryMeasurement> groupMeasurements;
174  for (const auto& detAndStateItr : grp) {
175  std::vector<TrajectoryMeasurement> detMeasurements =
176  measurements(layer, detAndStateItr.det(), detAndStateItr.trajectoryState(), est, iEvent);
177  groupMeasurements.insert(groupMeasurements.end(), detMeasurements.begin(), detMeasurements.end());
178  }
179 
180  result.push_back(TrajectoryMeasurementGroup(sortResult(groupMeasurements), grp));
181  }
182 
183  return result;
184 }
185 
188 
190  if (!theEvent)
191  throw cms::Exception("MTDDetLayerMeasurements") << "The event has not been set";
192 }
193 
195  MTDRecHitContainer rhs;
196 
197  std::vector<const GeomDet*> gds = layer->basicComponents();
198 
199  for (const GeomDet* igd : gds) {
200  MTDRecHitContainer detHits = recHits(igd, iEvent);
201  rhs.insert(rhs.end(), detHits.begin(), detHits.end());
202  }
203  return rhs;
204 }
205 
207  checkEvent();
208  return recHits(layer, *theEvent);
209 }
uint8_t geoId(const VFATFrame &frame)
retrieve the GEO information for this channel
MTDRecHitContainer recHits(const DetLayer *layer, const edm::Event &iEvent)
returns the rechits which are on the layer
std::vector< TrajectoryMeasurement > MeasurementContainer
edm::Event::CacheIdentifier_t theMTDEventCacheID
MTDDetLayerMeasurements::MeasurementContainer MeasurementContainer
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:540
std::vector< TrajectoryMeasurementGroup > groupedMeasurements(const DetLayer *layer, const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est, const edm::Event &iEvent)
std::vector< GenericTransientTrackingRecHit::RecHitPointer > MTDRecHitContainer
Detector identifier base class for the MIP Timing Layer.
Definition: MTDDetId.h:21
constexpr std::array< uint8_t, layerIndexSize > layer
void setEvent(const edm::Event &)
set event
MeasurementContainer fastMeasurements(const DetLayer *layer, const TrajectoryStateOnSurface &theStateOnDet, const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est, const edm::Event &iEvent)
faster version in case the TrajectoryState on the surface of the GeomDet is already available ...
void checkEvent() const
check that the event is set, and throw otherwise
int iEvent
Definition: GenABIO.cc:224
static RecHitPointer build(const GeomDet *geom, const TrackingRecHit *rh)
MeasurementContainer measurements(const DetLayer *layer, const GeomDet *det, const TrajectoryStateOnSurface &stateOnDet, const MeasurementEstimator &est, const edm::Event &iEvent)
edm::Handle< edmNew::DetSetVector< MTDTrackingRecHit > > theMTDRecHits
edm::EDGetTokenT< MTDTrackingRecHit > theMTDToken
virtual HitReturnType estimate(const TrajectoryStateOnSurface &ts, const TrackingRecHit &hit) const =0
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
MTDDetLayerMeasurements(const edm::InputTag &mtdlabel, edm::ConsumesCollector &iC)
CacheIdentifier_t cacheIdentifier() const
Definition: Event.cc:37
Definition: DetId.h:17
A 2D TrackerRecHit with time and time error information.
std::vector< GenericTransientTrackingRecHit::RecHitPointer > MTDRecHitContainer
bool isValid() const
Definition: HandleBase.h:70
std::pair< bool, double > HitReturnType
std::shared_ptr< GenericTransientTrackingRecHit > MTDRecHitPointer
long double T
Definition: event.py:1
#define LogDebug(id)