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  : theMTDRecHits(), theMTDEventCacheID(0), theEvent(nullptr) {
24  mtdToken_ = iC.consumes<MTDTrackingRecHit>(mtdlabel);
25 }
26 
28 
30  DetId geoId = geomDet->geographicalId();
31  theEvent = &iEvent;
33 
35 
36  // Create the ChamberId
37  DetId detId(geoId.rawId());
38  LogDebug("Track|RecoMTD|MTDDetLayerMeasurements") << "(MTD): " << static_cast<MTDDetId>(detId) << std::endl;
39 
40  // Get the MTD-Segment which relies on this chamber
41  //auto cmp = [](const unsigned one, const unsigned two) -> bool { return one < two; };
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("Track|RecoMTD|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  LogDebug("Track|RecoMTD|MTDDetLayerMeasurements") << "Cannot get MTD RecHits";
64  }
65 }
66 
69  const TrajectoryStateOnSurface& startingState,
70  const Propagator& prop,
71  const MeasurementEstimator& est) {
72  checkEvent();
73  return measurements(layer, startingState, prop, est, *theEvent);
74 }
75 
77  const TrajectoryStateOnSurface& startingState,
78  const Propagator& prop,
79  const MeasurementEstimator& est,
80  const edm::Event& iEvent) {
82 
83  std::vector<DetWithState> dss = layer->compatibleDets(startingState, prop, est);
84  LogDebug("RecoMTD") << "compatibleDets: " << dss.size() << std::endl;
85 
86  for (const auto& dws : dss) {
87  MeasurementContainer detMeasurements = measurements(layer, dws.first, dws.second, est, iEvent);
88  result.insert(result.end(), detMeasurements.begin(), detMeasurements.end());
89  }
90 
91  if (!result.empty())
92  sort(result.begin(), result.end(), TrajMeasLessEstim());
93 
94  return result;
95 }
96 
98  const GeomDet* det,
99  const TrajectoryStateOnSurface& stateOnDet,
100  const MeasurementEstimator& est,
101  const edm::Event& iEvent) {
103 
104  // Get the Segments which relies on the GeomDet given by compatibleDets
106 
107  // Create the Trajectory Measurement
108  for (auto rechit = mtdRecHits.begin(); rechit != mtdRecHits.end(); ++rechit) {
109  MeasurementEstimator::HitReturnType estimate = est.estimate(stateOnDet, **rechit);
110  LogDebug("RecoMTD") << "Dimension: " << (*rechit)->dimension() << " Chi2: " << estimate.second << std::endl;
111  if (estimate.first) {
112  result.push_back(TrajectoryMeasurement(stateOnDet, *rechit, estimate.second, layer));
113  }
114  }
115 
116  if (!result.empty())
117  sort(result.begin(), result.end(), TrajMeasLessEstim());
118 
119  return result;
120 }
121 
123  const TrajectoryStateOnSurface& theStateOnDet,
124  const TrajectoryStateOnSurface& startingState,
125  const Propagator& prop,
126  const MeasurementEstimator& est,
127  const edm::Event& iEvent) {
130  for (const MTDRecHitContainer::value_type& irh : rhs) {
131  MeasurementEstimator::HitReturnType estimate = est.estimate(theStateOnDet, (*irh));
132  if (estimate.first) {
133  result.push_back(TrajectoryMeasurement(theStateOnDet, irh, estimate.second, layer));
134  }
135  }
136 
137  if (!result.empty()) {
138  sort(result.begin(), result.end(), TrajMeasLessEstim());
139  }
140 
141  return result;
142 }
143 
146  const TrajectoryStateOnSurface& theStateOnDet,
147  const TrajectoryStateOnSurface& startingState,
148  const Propagator& prop,
149  const MeasurementEstimator& est) {
150  checkEvent();
151  return fastMeasurements(layer, theStateOnDet, startingState, prop, est, *theEvent);
152 }
153 
154 std::vector<TrajectoryMeasurementGroup> MTDDetLayerMeasurements::groupedMeasurements(
155  const DetLayer* layer,
156  const TrajectoryStateOnSurface& startingState,
157  const Propagator& prop,
158  const MeasurementEstimator& est) {
159  checkEvent();
160  return groupedMeasurements(layer, startingState, prop, est, *theEvent);
161 }
162 
163 std::vector<TrajectoryMeasurementGroup> MTDDetLayerMeasurements::groupedMeasurements(
164  const DetLayer* layer,
165  const TrajectoryStateOnSurface& startingState,
166  const Propagator& prop,
167  const MeasurementEstimator& est,
168  const edm::Event& iEvent) {
169  std::vector<TrajectoryMeasurementGroup> result;
170  // if we want to use the concept of InvalidRecHits,
171  // we can reuse LayerMeasurements from TrackingTools/MeasurementDet
172  std::vector<DetGroup> groups(layer->groupedCompatibleDets(startingState, prop, est));
173 
174  for (const auto& grp : groups) {
175  std::vector<TrajectoryMeasurement> groupMeasurements;
176  for (const auto& detAndStateItr : grp) {
177  std::vector<TrajectoryMeasurement> detMeasurements =
178  measurements(layer, detAndStateItr.det(), detAndStateItr.trajectoryState(), est, iEvent);
179  groupMeasurements.insert(groupMeasurements.end(), detMeasurements.begin(), detMeasurements.end());
180  }
181 
182  if (!groupMeasurements.empty())
183  std::sort(groupMeasurements.begin(), groupMeasurements.end(), TrajMeasLessEstim());
184 
185  result.push_back(TrajectoryMeasurementGroup(groupMeasurements, grp));
186  }
187 
188  return result;
189 }
190 
193 
195  if (!theEvent)
196  throw cms::Exception("MTDDetLayerMeasurements") << "The event has not been set";
197 }
198 
200  MTDRecHitContainer rhs;
201 
202  std::vector<const GeomDet*> gds = layer->basicComponents();
203 
204  for (const GeomDet* igd : gds) {
205  MTDRecHitContainer detHits = recHits(igd, iEvent);
206  rhs.insert(rhs.end(), detHits.begin(), detHits.end());
207  }
208  return rhs;
209 }
210 
212  checkEvent();
213  return recHits(layer, *theEvent);
214 }
TrajMeasLessEstim.h
MeasurementEstimator
Definition: MeasurementEstimator.h:19
MessageLogger.h
GeomDet
Definition: GeomDet.h:27
DetLayer
Definition: DetLayer.h:21
MTDDetLayerMeasurements.h
MTDDetLayerMeasurements::~MTDDetLayerMeasurements
virtual ~MTDDetLayerMeasurements()
Definition: MTDDetLayerMeasurements.cc:27
TrajMeasLessEstim
Definition: TrajMeasLessEstim.h:10
TrajectoryMeasurement.h
MTDDetLayerMeasurements::groupedMeasurements
std::vector< TrajectoryMeasurementGroup > groupedMeasurements(const DetLayer *layer, const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est, const edm::Event &iEvent)
Definition: MTDDetLayerMeasurements.cc:163
MeasurementEstimator::HitReturnType
std::pair< bool, double > HitReturnType
Definition: MeasurementEstimator.h:34
MeasurementEstimator::estimate
virtual HitReturnType estimate(const TrajectoryStateOnSurface &ts, const TrackingRecHit &hit) const =0
Propagator
Definition: Propagator.h:44
DetId
Definition: DetId.h:17
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
MTDDetLayerMeasurements::setEvent
void setEvent(const edm::Event &)
set event
Definition: MTDDetLayerMeasurements.cc:192
Service.h
MTDDetLayerMeasurements::recHits
MTDRecHitContainer recHits(const DetLayer *layer, const edm::Event &iEvent)
returns the rechits which are on the layer
Definition: MTDDetLayerMeasurements.cc:199
MTDDetLayerMeasurements::fastMeasurements
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
Definition: MTDDetLayerMeasurements.cc:122
edm::Event::cacheIdentifier
CacheIdentifier_t cacheIdentifier() const
Definition: Event.cc:37
MTDDetLayerMeasurements::checkEvent
void checkEvent() const
check that the event is set, and throw otherwise
Definition: MTDDetLayerMeasurements.cc:194
MTDDetLayerMeasurements::MeasurementContainer
std::vector< TrajectoryMeasurement > MeasurementContainer
Definition: MTDDetLayerMeasurements.h:32
MTDRecHitPointer
std::shared_ptr< GenericTransientTrackingRecHit > MTDRecHitPointer
Definition: MTDDetLayerMeasurements.cc:18
edm::ConsumesCollector::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: ConsumesCollector.h:55
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:535
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
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
mtdRecHits_cfi.mtdRecHits
mtdRecHits
Definition: mtdRecHits_cfi.py:19
MTDDetLayerMeasurements::checkMTDRecHits
void checkMTDRecHits()
Definition: MTDDetLayerMeasurements.cc:50
MTDDetLayerMeasurements::mtdToken_
edm::EDGetTokenT< MTDTrackingRecHit > mtdToken_
Definition: MTDDetLayerMeasurements.h:102
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
MTDDetLayerMeasurements::measurements
MeasurementContainer measurements(const DetLayer *layer, const GeomDet *det, const TrajectoryStateOnSurface &stateOnDet, const MeasurementEstimator &est, const edm::Event &iEvent)
Definition: MTDDetLayerMeasurements.cc:97
edmPickEvents.event
event
Definition: edmPickEvents.py:273
MTDTrackingRecHit
A 2D TrackerRecHit with time and time error information.
Definition: MTDTrackingRecHit.h:10
iEvent
int iEvent
Definition: GenABIO.cc:224
reco::JetExtendedAssociation::value_type
Container::value_type value_type
Definition: JetExtendedAssociation.h:30
MeasurementContainer
MTDDetLayerMeasurements::MeasurementContainer MeasurementContainer
Definition: MTDDetLayerMeasurements.cc:20
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
TrajectoryMeasurementGroup
Definition: TrajectoryMeasurementGroup.h:17
Exception
Definition: hltDiff.cc:245
MTDDetLayerMeasurements::MTDRecHitContainer
std::vector< GenericTransientTrackingRecHit::RecHitPointer > MTDRecHitContainer
Definition: MTDDetLayerMeasurements.h:34
DetLayer.h
MTDDetLayerMeasurements::theMTDEventCacheID
edm::Event::CacheIdentifier_t theMTDEventCacheID
Definition: MTDDetLayerMeasurements.h:110
MTDRecHitContainer
std::vector< GenericTransientTrackingRecHit::RecHitPointer > MTDRecHitContainer
Definition: MTDDetLayerMeasurements.cc:19
mps_fire.result
result
Definition: mps_fire.py:311
MTDDetLayerMeasurements::theMTDRecHits
edm::Handle< edmNew::DetSetVector< MTDTrackingRecHit > > theMTDRecHits
Definition: MTDDetLayerMeasurements.h:105
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
event
Definition: event.py:1
MTDDetLayerMeasurements::MTDDetLayerMeasurements
MTDDetLayerMeasurements(edm::InputTag mtdlabel, edm::ConsumesCollector &iC)
Definition: MTDDetLayerMeasurements.cc:22
edm::Event
Definition: Event.h:73
GenericTransientTrackingRecHit::build
static RecHitPointer build(const GeomDet *geom, const TrackingRecHit *rh)
Definition: GenericTransientTrackingRecHit.h:35
TrajectoryMeasurement
Definition: TrajectoryMeasurement.h:25
edm::InputTag
Definition: InputTag.h:15
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
MTDDetLayerMeasurements::theEvent
const edm::Event * theEvent
Definition: MTDDetLayerMeasurements.h:112