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): " << 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
105  MTDRecHitContainer mtdRecHits = recHits(det, iEvent);
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) {
129  MTDRecHitContainer rhs = recHits(layer, iEvent);
130  for (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 }
#define LogDebug(id)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
MTDRecHitContainer recHits(const DetLayer *layer, const edm::Event &iEvent)
returns the rechits which are on the layer
std::vector< TrajectoryMeasurement > MeasurementContainer
void checkEvent() const
check that the event is set, and throw otherwise
virtual std::vector< DetGroup > groupedCompatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
virtual const std::vector< const GeomDet * > & basicComponents() const =0
edm::Event::CacheIdentifier_t theMTDEventCacheID
#define nullptr
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
MTDDetLayerMeasurements::MeasurementContainer MeasurementContainer
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
virtual std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
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 ...
int iEvent
Definition: GenABIO.cc:224
static RecHitPointer build(const GeomDet *geom, const TrackingRecHit *rh)
CacheIdentifier_t cacheIdentifier() const
Definition: Event.cc:33
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
MeasurementContainer measurements(const DetLayer *layer, const GeomDet *det, const TrajectoryStateOnSurface &stateOnDet, const MeasurementEstimator &est, const edm::Event &iEvent)
edm::Handle< edmNew::DetSetVector< MTDTrackingRecHit > > theMTDRecHits
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
bool isValid() const
Definition: HandleBase.h:70
edm::EDGetTokenT< MTDTrackingRecHit > mtdToken_
Definition: DetId.h:17
MTDDetLayerMeasurements(edm::InputTag mtdlabel, edm::ConsumesCollector &iC)
A 2D TrackerRecHit with time and time error information.
std::vector< GenericTransientTrackingRecHit::RecHitPointer > MTDRecHitContainer
virtual HitReturnType estimate(const TrajectoryStateOnSurface &ts, const TrackingRecHit &hit) const =0
std::pair< bool, double > HitReturnType
std::shared_ptr< GenericTransientTrackingRecHit > MTDRecHitPointer
Definition: event.py:1