CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MuonDetLayerMeasurements.cc
Go to the documentation of this file.
1 
9 
12 
16 
17 
18 
21 
22 
23 
25  edm::InputTag csclabel,
26  edm::InputTag rpclabel,
28  bool enableDT, bool enableCSC, bool enableRPC):
29  enableDTMeasurement(enableDT),
30  enableCSCMeasurement(enableCSC),
31  enableRPCMeasurement(enableRPC),
32  theDTRecHits(),
33  theCSCRecHits(),
34  theRPCRecHits(),
35  theDTEventCacheID(0),
36  theCSCEventCacheID(0),
37  theRPCEventCacheID(0),
38  theEvent(0)
39 {
40 
42  cscToken_ = iC.consumes<CSCSegmentCollection>(csclabel);
43  rpcToken_ = iC.consumes<RPCRecHitCollection>(rpclabel);
44 
45 
46  static int procInstance(0);
47  std::ostringstream sDT;
48  sDT<<"MuonDetLayerMeasurements::checkDTRecHits::" << procInstance;
49  // theDTCheckName = sDT.str();
50  std::ostringstream sRPC;
51  sRPC<<"MuonDetLayerMeasurements::checkRPCRecHits::" << procInstance;
52  //theRPCCheckName = sRPC.str();
53  std::ostringstream sCSC;
54  sCSC<<"MuonDetLayerMeasurements::checkCSCRecHits::" << procInstance;
55  //theCSCCheckName = sCSC.str();
56  procInstance++;
57 }
58 
60 
62  const edm::Event& iEvent)
63 {
64  DetId geoId = geomDet->geographicalId();
65  theEvent = &iEvent;
67 
68  if (geoId.subdetId() == MuonSubdetId::DT) {
70  {
72 
73  // Create the ChamberId
74  DTChamberId chamberId(geoId.rawId());
75  // LogTrace("Muon|RecoMuon|MuonDetLayerMeasurements") << "(DT): "<<chamberId<<std::endl;
76 
77  // Get the DT-Segment which relies on this chamber
78  DTRecSegment4DCollection::range range = theDTRecHits->get(chamberId);
79 
80  // Create the MuonTransientTrackingRechit
81  for (DTRecSegment4DCollection::const_iterator rechit = range.first;
82  rechit!=range.second;++rechit)
83  result.push_back(MuonTransientTrackingRecHit::specificBuild(geomDet,&*rechit));
84  }
85  }
86 
87  else if (geoId.subdetId() == MuonSubdetId::CSC) {
89  {
91 
92  // Create the chamber Id
93  CSCDetId chamberId(geoId.rawId());
94  // LogTrace("Muon|RecoMuon|MuonDetLayerMeasurements") << "(CSC): "<<chamberId<<std::endl;
95 
96  // Get the CSC-Segment which relies on this chamber
97  CSCSegmentCollection::range range = theCSCRecHits->get(chamberId);
98 
99  // Create the MuonTransientTrackingRecHit
100  for (CSCSegmentCollection::const_iterator rechit = range.first;
101  rechit!=range.second; ++rechit)
102  result.push_back(MuonTransientTrackingRecHit::specificBuild(geomDet,&*rechit));
103  }
104  }
105 
106  else if (geoId.subdetId() == MuonSubdetId::RPC) {
108  {
109  checkRPCRecHits();
110 
111  // Create the chamber Id
112  RPCDetId chamberId(geoId.rawId());
113  // LogTrace("Muon|RecoMuon|MuonDetLayerMeasurements") << "(RPC): "<<chamberId<<std::endl;
114 
115  // Get the RPC-Segment which relies on this chamber
116  RPCRecHitCollection::range range = theRPCRecHits->get(chamberId);
117 
118  // Create the MuonTransientTrackingRecHit
119  for (RPCRecHitCollection::const_iterator rechit = range.first;
120  rechit!=range.second; ++rechit)
121  result.push_back(MuonTransientTrackingRecHit::specificBuild(geomDet,&*rechit));
122  }
123  }
124  else {
125  // wrong type
126  throw cms::Exception("MuonDetLayerMeasurements") << "The DetLayer with det " << geoId.det() << " subdet " << geoId.subdetId() << " is not a valid Muon DetLayer. ";
127  }
128  return result;
129 }
130 
131 
133 {
134  checkEvent();
135  auto const cacheID = theEvent->cacheIdentifier();
136  if (cacheID == theDTEventCacheID) return;
137 
138  {
140  }
141  if(!theDTRecHits.isValid())
142  {
143  throw cms::Exception("MuonDetLayerMeasurements") << "Cannot get DT RecHits";
144  }
145 }
146 
147 
149 {
150  checkEvent();
151  auto cacheID = theEvent->cacheIdentifier();
152  if (cacheID == theCSCEventCacheID) return;
153 
154  {
156  theCSCEventCacheID = cacheID;
157  }
158  if(!theCSCRecHits.isValid())
159  {
160  throw cms::Exception("MuonDetLayerMeasurements") << "Cannot get CSC RecHits";
161  }
162 }
163 
164 
166 {
167  checkEvent();
168  auto cacheID = theEvent->cacheIdentifier();
169  if (cacheID == theRPCEventCacheID) return;
170 
171  {
173  theRPCEventCacheID = cacheID;
174  }
175  if(!theRPCRecHits.isValid())
176  {
177  throw cms::Exception("MuonDetLayerMeasurements") << "Cannot get RPC RecHits";
178  }
179 }
180 
181 
185  const TrajectoryStateOnSurface& startingState,
186  const Propagator& prop,
187  const MeasurementEstimator& est) {
188  checkEvent();
189  return measurements(layer, startingState, prop, est, *theEvent);
190 }
191 
192 
195  const TrajectoryStateOnSurface& startingState,
196  const Propagator& prop,
197  const MeasurementEstimator& est,
198  const edm::Event& iEvent) {
199 
201 
202  std::vector<DetWithState> dss = layer->compatibleDets(startingState, prop, est);
203  LogTrace("RecoMuon")<<"compatibleDets: "<<dss.size()<<std::endl;
204 
205  for(std::vector<DetWithState>::const_iterator detWithStateItr = dss.begin();
206  detWithStateItr != dss.end(); ++detWithStateItr){
207 
208  MeasurementContainer detMeasurements
209  = measurements(layer, detWithStateItr->first,
210  detWithStateItr->second, est, iEvent);
211  result.insert(result.end(), detMeasurements.begin(), detMeasurements.end());
212  }
213 
214  if (!result.empty()) sort( result.begin(), result.end(), TrajMeasLessEstim());
215 
216  return result;
217 }
218 
219 
222  const GeomDet* det,
223  const TrajectoryStateOnSurface& stateOnDet,
224  const MeasurementEstimator& est,
225  const edm::Event& iEvent) {
227 
228  // Get the Segments which relies on the GeomDet given by compatibleDets
229  MuonRecHitContainer muonRecHits = recHits(det, iEvent);
230 
231  // Create the Trajectory Measurement
232  for(MuonRecHitContainer::const_iterator rechit = muonRecHits.begin();
233  rechit != muonRecHits.end(); ++rechit) {
234 
235  MeasurementEstimator::HitReturnType estimate = est.estimate(stateOnDet,**rechit);
236  LogTrace("RecoMuon")<<"Dimension: "<<(*rechit)->dimension()
237  <<" Chi2: "<<estimate.second<<std::endl;
238  if (estimate.first) {
239  result.push_back(TrajectoryMeasurement(stateOnDet, rechit->get(),
240  estimate.second,layer));
241  }
242  }
243 
244  if (!result.empty()) sort( result.begin(), result.end(), TrajMeasLessEstim());
245 
246  return result;
247 }
248 
249 
250 
253  const TrajectoryStateOnSurface& theStateOnDet,
254  const TrajectoryStateOnSurface& startingState,
255  const Propagator& prop,
256  const MeasurementEstimator& est,
257  const edm::Event& iEvent) {
259  MuonRecHitContainer rhs = recHits(layer, iEvent);
260  for (MuonRecHitContainer::const_iterator irh = rhs.begin(); irh!=rhs.end(); irh++) {
261  MeasurementEstimator::HitReturnType estimate = est.estimate(theStateOnDet, (**irh));
262  if (estimate.first)
263  {
264  result.push_back(TrajectoryMeasurement(theStateOnDet,(*irh).get(),
265  estimate.second,layer));
266  }
267  }
268 
269  if (!result.empty()) {
270  sort( result.begin(), result.end(), TrajMeasLessEstim());
271  }
272 
273  return result;
274 }
275 
279  const TrajectoryStateOnSurface& theStateOnDet,
280  const TrajectoryStateOnSurface& startingState,
281  const Propagator& prop,
282  const MeasurementEstimator& est) {
283  checkEvent();
284  return fastMeasurements(layer, theStateOnDet, startingState, prop, est, *theEvent);
285 }
286 
287 
288 std::vector<TrajectoryMeasurementGroup>
290  const TrajectoryStateOnSurface& startingState,
291  const Propagator& prop,
292  const MeasurementEstimator& est) {
293  checkEvent();
294  return groupedMeasurements(layer, startingState, prop, est, *theEvent);
295 }
296 
297 
298 std::vector<TrajectoryMeasurementGroup>
300  const TrajectoryStateOnSurface& startingState,
301  const Propagator& prop,
302  const MeasurementEstimator& est,
303  const edm::Event& iEvent) {
304 
305  std::vector<TrajectoryMeasurementGroup> result;
306  // if we want to use the concept of InvalidRecHits,
307  // we can reuse LayerMeasurements from TrackingTools/MeasurementDet
308  std::vector<DetGroup> groups(layer->groupedCompatibleDets(startingState, prop, est));
309 
310  // this should be fixed either in RecoMuon/MeasurementDet/MuonDetLayerMeasurements or
311  // RecoMuon/DetLayers/MuRingForwardDoubleLayer
312  // and removed the reverse operation in StandAloneMuonFilter::findBestMeasurements
313 
314  for (std::vector<DetGroup>::const_iterator grp=groups.begin(); grp!=groups.end(); ++grp) {
315 
316  std::vector<TrajectoryMeasurement> groupMeasurements;
317  for (DetGroup::const_iterator detAndStateItr=grp->begin();
318  detAndStateItr !=grp->end(); ++detAndStateItr) {
319 
320  std::vector<TrajectoryMeasurement> detMeasurements
321  = measurements(layer, detAndStateItr->det(), detAndStateItr->trajectoryState(), est, iEvent);
322  groupMeasurements.insert(groupMeasurements.end(), detMeasurements.begin(), detMeasurements.end());
323  }
324 
325  if (!groupMeasurements.empty())
326  std::sort( groupMeasurements.begin(), groupMeasurements.end(), TrajMeasLessEstim());
327 
328  result.push_back(TrajectoryMeasurementGroup(groupMeasurements, *grp));
329  }
330 
331  return result;
332 }
333 
336  theEvent = &event;
337 }
338 
339 
341  if(!theEvent)
342  throw cms::Exception("MuonDetLayerMeasurements") << "The event has not been set";
343 }
344 
346  const edm::Event& iEvent) {
348 
349  std::vector <const GeomDet*> gds = layer->basicComponents();
350 
351  for (std::vector<const GeomDet*>::const_iterator igd = gds.begin();
352  igd != gds.end(); igd++) {
353  MuonRecHitContainer detHits = recHits(*igd, iEvent);
354  rhs.insert(rhs.end(), detHits.begin(), detHits.end());
355  }
356  return rhs;
357 }
358 
360 {
361  checkEvent();
362  return recHits(layer, *theEvent);
363 }
364 
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::pair< const_iterator, const_iterator > range
iterator range
Definition: RangeMap.h:50
MuonTransientTrackingRecHit::MuonRecHitPointer MuonRecHitPointer
virtual std::vector< DetGroup > groupedCompatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
edm::Handle< DTRecSegment4DCollection > theDTRecHits
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
virtual HitReturnType estimate(const TrajectoryStateOnSurface &ts, const TransientTrackingRecHit &hit) const =0
edm::Event::CacheIdentifier_t theDTEventCacheID
edm::EDGetTokenT< DTRecSegment4DCollection > dtToken_
edm::Handle< CSCSegmentCollection > theCSCRecHits
std::vector< TrajectoryMeasurementGroup > groupedMeasurements(const DetLayer *layer, const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est, const edm::Event &iEvent)
virtual std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
edm::EDGetTokenT< CSCSegmentCollection > cscToken_
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
int iEvent
Definition: GenABIO.cc:243
static const int CSC
Definition: MuonSubdetId.h:13
MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer
MuonRecHitContainer recHits(const DetLayer *layer, const edm::Event &iEvent)
returns the rechits which are on the layer
edm::Event::CacheIdentifier_t theRPCEventCacheID
tuple result
Definition: query.py:137
CacheIdentifier_t cacheIdentifier() const
Definition: Event.cc:35
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:72
MuonDetLayerMeasurements(edm::InputTag dtlabel, edm::InputTag csclabel, edm::InputTag rpclabel, edm::ConsumesCollector &iC, bool enableDT=true, bool enableCSC=true, bool enableRPC=true)
edm::Handle< RPCRecHitCollection > theRPCRecHits
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:76
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
MeasurementContainer measurements(const DetLayer *layer, const GeomDet *det, const TrajectoryStateOnSurface &stateOnDet, const MeasurementEstimator &est, const edm::Event &iEvent)
#define LogTrace(id)
Definition: DetId.h:18
std::pair< bool, double > HitReturnType
std::vector< TrajectoryMeasurement > MeasurementContainer
edm::Event::CacheIdentifier_t theCSCEventCacheID
virtual const std::vector< const GeomDet * > & basicComponents() const =0
void setEvent(const edm::Event &)
set event
edm::EDGetTokenT< RPCRecHitCollection > rpcToken_
static const int RPC
Definition: MuonSubdetId.h:14
MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer
static const int DT
Definition: MuonSubdetId.h:12
void checkEvent() const
check that the event is set, and throw otherwise
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
static MuonRecHitPointer specificBuild(const GeomDet *geom, const TrackingRecHit *rh)
std::vector< MuonRecHitPointer > MuonRecHitContainer
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 ...