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 
11 
14 
19 
20 
23 
24 
25 
27  edm::InputTag csclabel,
28  edm::InputTag rpclabel,
29  bool enableDT, bool enableCSC, bool enableRPC):
30  theDTRecHitLabel(dtlabel),
31  theCSCRecHitLabel(csclabel),
32  theRPCRecHitLabel(rpclabel),
33  enableDTMeasurement(enableDT),
34  enableCSCMeasurement(enableCSC),
35  enableRPCMeasurement(enableRPC),
36  theDTRecHits(),
37  theCSCRecHits(),
38  theRPCRecHits(),
39  theDTEventID(),
40  theCSCEventID(),
41  theRPCEventID(),
42  theEvent(0){
43  static int procInstance(0);
44  std::ostringstream sDT;
45  sDT<<"MuonDetLayerMeasurements::checkDTRecHits::" << procInstance;
46  theDTCheckName = sDT.str();
47  std::ostringstream sRPC;
48  sRPC<<"MuonDetLayerMeasurements::checkRPCRecHits::" << procInstance;
49  theRPCCheckName = sRPC.str();
50  std::ostringstream sCSC;
51  sCSC<<"MuonDetLayerMeasurements::checkCSCRecHits::" << procInstance;
52  theCSCCheckName = sCSC.str();
53  procInstance++;
54 }
55 
57 
59  const edm::Event& iEvent)
60 {
61  DetId geoId = geomDet->geographicalId();
62  theEvent = &iEvent;
64 
65  if (geoId.subdetId() == MuonSubdetId::DT) {
67  {
69 
70  // Create the ChamberId
71  DTChamberId chamberId(geoId.rawId());
72  // LogTrace("Muon|RecoMuon|MuonDetLayerMeasurements") << "(DT): "<<chamberId<<std::endl;
73 
74  // Get the DT-Segment which relies on this chamber
75  DTRecSegment4DCollection::range range = theDTRecHits->get(chamberId);
76 
77  // Create the MuonTransientTrackingRechit
78  for (DTRecSegment4DCollection::const_iterator rechit = range.first;
79  rechit!=range.second;++rechit)
80  result.push_back(MuonTransientTrackingRecHit::specificBuild(geomDet,&*rechit));
81  }
82  }
83 
84  else if (geoId.subdetId() == MuonSubdetId::CSC) {
86  {
88 
89  // Create the chamber Id
90  CSCDetId chamberId(geoId.rawId());
91  // LogTrace("Muon|RecoMuon|MuonDetLayerMeasurements") << "(CSC): "<<chamberId<<std::endl;
92 
93  // Get the CSC-Segment which relies on this chamber
94  CSCSegmentCollection::range range = theCSCRecHits->get(chamberId);
95 
96  // Create the MuonTransientTrackingRecHit
97  for (CSCSegmentCollection::const_iterator rechit = range.first;
98  rechit!=range.second; ++rechit)
99  result.push_back(MuonTransientTrackingRecHit::specificBuild(geomDet,&*rechit));
100  }
101  }
102 
103  else if (geoId.subdetId() == MuonSubdetId::RPC) {
105  {
106  checkRPCRecHits();
107 
108  // Create the chamber Id
109  RPCDetId chamberId(geoId.rawId());
110  // LogTrace("Muon|RecoMuon|MuonDetLayerMeasurements") << "(RPC): "<<chamberId<<std::endl;
111 
112  // Get the RPC-Segment which relies on this chamber
113  RPCRecHitCollection::range range = theRPCRecHits->get(chamberId);
114 
115  // Create the MuonTransientTrackingRecHit
116  for (RPCRecHitCollection::const_iterator rechit = range.first;
117  rechit!=range.second; ++rechit)
118  result.push_back(MuonTransientTrackingRecHit::specificBuild(geomDet,&*rechit));
119  }
120  }
121  else {
122  // wrong type
123  throw cms::Exception("MuonDetLayerMeasurements") << "The DetLayer with det " << geoId.det() << " subdet " << geoId.subdetId() << " is not a valid Muon DetLayer. ";
124  }
125  return result;
126 }
127 
128 
130 {
131  checkEvent();
132  if (!edm::Service<UpdaterService>()->checkOnce(theDTCheckName)) return;
133 
134  {
135  theDTEventID = theEvent->id();
137  }
138  if(!theDTRecHits.isValid())
139  {
140  throw cms::Exception("MuonDetLayerMeasurements") << "Cannot get DT RecHits";
141  }
142 }
143 
144 
146 {
147  checkEvent();
148  if (!edm::Service<UpdaterService>()->checkOnce(theCSCCheckName)) return;
149 
150  {
153  }
154  if(!theCSCRecHits.isValid())
155  {
156  throw cms::Exception("MuonDetLayerMeasurements") << "Cannot get CSC RecHits";
157  }
158 }
159 
160 
162 {
163  checkEvent();
164  if (!edm::Service<UpdaterService>()->checkOnce(theRPCCheckName)) return;
165 
166  {
169  }
170  if(!theRPCRecHits.isValid())
171  {
172  throw cms::Exception("MuonDetLayerMeasurements") << "Cannot get RPC RecHits";
173  }
174 }
175 
176 
180  const TrajectoryStateOnSurface& startingState,
181  const Propagator& prop,
182  const MeasurementEstimator& est) {
183  checkEvent();
184  return measurements(layer, startingState, prop, est, *theEvent);
185 }
186 
187 
190  const TrajectoryStateOnSurface& startingState,
191  const Propagator& prop,
192  const MeasurementEstimator& est,
193  const edm::Event& iEvent) {
194 
196 
197  std::vector<DetWithState> dss = layer->compatibleDets(startingState, prop, est);
198  LogTrace("RecoMuon")<<"compatibleDets: "<<dss.size()<<std::endl;
199 
200  for(std::vector<DetWithState>::const_iterator detWithStateItr = dss.begin();
201  detWithStateItr != dss.end(); ++detWithStateItr){
202 
203  MeasurementContainer detMeasurements
204  = measurements(layer, detWithStateItr->first,
205  detWithStateItr->second, est, iEvent);
206  result.insert(result.end(), detMeasurements.begin(), detMeasurements.end());
207  }
208 
209  if (!result.empty()) sort( result.begin(), result.end(), TrajMeasLessEstim());
210 
211  return result;
212 }
213 
214 
217  const GeomDet* det,
218  const TrajectoryStateOnSurface& stateOnDet,
219  const MeasurementEstimator& est,
220  const edm::Event& iEvent) {
222 
223  // Get the Segments which relies on the GeomDet given by compatibleDets
224  MuonRecHitContainer muonRecHits = recHits(det, iEvent);
225 
226  // Create the Trajectory Measurement
227  for(MuonRecHitContainer::const_iterator rechit = muonRecHits.begin();
228  rechit != muonRecHits.end(); ++rechit) {
229 
230  MeasurementEstimator::HitReturnType estimate = est.estimate(stateOnDet,**rechit);
231  LogTrace("RecoMuon")<<"Dimension: "<<(*rechit)->dimension()
232  <<" Chi2: "<<estimate.second<<std::endl;
233  if (estimate.first) {
234  result.push_back(TrajectoryMeasurement(stateOnDet, rechit->get(),
235  estimate.second,layer));
236  }
237  }
238 
239  if (!result.empty()) sort( result.begin(), result.end(), TrajMeasLessEstim());
240 
241  return result;
242 }
243 
244 
245 
248  const TrajectoryStateOnSurface& theStateOnDet,
249  const TrajectoryStateOnSurface& startingState,
250  const Propagator& prop,
251  const MeasurementEstimator& est,
252  const edm::Event& iEvent) {
254  MuonRecHitContainer rhs = recHits(layer, iEvent);
255  for (MuonRecHitContainer::const_iterator irh = rhs.begin(); irh!=rhs.end(); irh++) {
256  MeasurementEstimator::HitReturnType estimate = est.estimate(theStateOnDet, (**irh));
257  if (estimate.first)
258  {
259  result.push_back(TrajectoryMeasurement(theStateOnDet,(*irh).get(),
260  estimate.second,layer));
261  }
262  }
263 
264  if (!result.empty()) {
265  sort( result.begin(), result.end(), TrajMeasLessEstim());
266  }
267 
268  return result;
269 }
270 
274  const TrajectoryStateOnSurface& theStateOnDet,
275  const TrajectoryStateOnSurface& startingState,
276  const Propagator& prop,
277  const MeasurementEstimator& est) {
278  checkEvent();
279  return fastMeasurements(layer, theStateOnDet, startingState, prop, est, *theEvent);
280 }
281 
282 
283 std::vector<TrajectoryMeasurementGroup>
285  const TrajectoryStateOnSurface& startingState,
286  const Propagator& prop,
287  const MeasurementEstimator& est) {
288  checkEvent();
289  return groupedMeasurements(layer, startingState, prop, est, *theEvent);
290 }
291 
292 
293 std::vector<TrajectoryMeasurementGroup>
295  const TrajectoryStateOnSurface& startingState,
296  const Propagator& prop,
297  const MeasurementEstimator& est,
298  const edm::Event& iEvent) {
299 
300  std::vector<TrajectoryMeasurementGroup> result;
301  // if we want to use the concept of InvalidRecHits,
302  // we can reuse LayerMeasurements from TrackingTools/MeasurementDet
303  std::vector<DetGroup> groups(layer->groupedCompatibleDets(startingState, prop, est));
304 
305  // this should be fixed either in RecoMuon/MeasurementDet/MuonDetLayerMeasurements or
306  // RecoMuon/DetLayers/MuRingForwardDoubleLayer
307  // and removed the reverse operation in StandAloneMuonFilter::findBestMeasurements
308 
309  for (std::vector<DetGroup>::const_iterator grp=groups.begin(); grp!=groups.end(); ++grp) {
310 
311  std::vector<TrajectoryMeasurement> groupMeasurements;
312  for (DetGroup::const_iterator detAndStateItr=grp->begin();
313  detAndStateItr !=grp->end(); ++detAndStateItr) {
314 
315  std::vector<TrajectoryMeasurement> detMeasurements
316  = measurements(layer, detAndStateItr->det(), detAndStateItr->trajectoryState(), est, iEvent);
317  groupMeasurements.insert(groupMeasurements.end(), detMeasurements.begin(), detMeasurements.end());
318  }
319 
320  if (!groupMeasurements.empty())
321  std::sort( groupMeasurements.begin(), groupMeasurements.end(), TrajMeasLessEstim());
322 
323  result.push_back(TrajectoryMeasurementGroup(groupMeasurements, *grp));
324  }
325 
326  return result;
327 }
328 
331  theEvent = &event;
332 }
333 
334 
336  if(!theEvent)
337  throw cms::Exception("MuonDetLayerMeasurements") << "The event has not been set";
338 }
339 
341  const edm::Event& iEvent) {
343 
344  std::vector <const GeomDet*> gds = layer->basicComponents();
345 
346  for (std::vector<const GeomDet*>::const_iterator igd = gds.begin();
347  igd != gds.end(); igd++) {
348  MuonRecHitContainer detHits = recHits(*igd, iEvent);
349  rhs.insert(rhs.end(), detHits.begin(), detHits.end());
350  }
351  return rhs;
352 }
353 
355 {
356  checkEvent();
357  return recHits(layer, *theEvent);
358 }
359 
MuonDetLayerMeasurements(edm::InputTag dtlabel, edm::InputTag csclabel, edm::InputTag rpclabel, bool enableDT=true, bool enableCSC=true, bool enableRPC=true)
std::pair< const_iterator, const_iterator > range
iterator range
Definition: RangeMap.h:52
MuonTransientTrackingRecHit::MuonRecHitPointer MuonRecHitPointer
virtual std::vector< DetGroup > groupedCompatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
edm::Handle< DTRecSegment4DCollection > theDTRecHits
virtual HitReturnType estimate(const TrajectoryStateOnSurface &ts, const TransientTrackingRecHit &hit) const =0
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
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:45
int iEvent
Definition: GenABIO.cc:243
static const int CSC
Definition: MuonSubdetId.h:15
MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer
MuonRecHitContainer recHits(const DetLayer *layer, const edm::Event &iEvent)
returns the rechits which are on the layer
tuple result
Definition: query.py:137
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:72
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:39
MeasurementContainer measurements(const DetLayer *layer, const GeomDet *det, const TrajectoryStateOnSurface &stateOnDet, const MeasurementEstimator &est, const edm::Event &iEvent)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
#define LogTrace(id)
Definition: DetId.h:20
std::pair< bool, double > HitReturnType
std::vector< TrajectoryMeasurement > MeasurementContainer
virtual const std::vector< const GeomDet * > & basicComponents() const =0
void setEvent(const edm::Event &)
set event
edm::EventID id() const
Definition: EventBase.h:56
static const int RPC
Definition: MuonSubdetId.h:16
MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer
static const int DT
Definition: MuonSubdetId.h:14
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:37
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 ...