CMS 3D CMS Logo

MuonDetIdAssociator.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: TrackAssociator
4 // Class: MuonDetIdAssociator
5 //
6 /*
7 
8  Description: <one line class summary>
9 
10  Implementation:
11  <Notes on implementation>
12 */
13 //
14 // Original Author: Dmytro Kovalskyi
15 // Created: Fri Apr 21 10:59:41 PDT 2006
16 //
17 //
18 
19 #include "MuonDetIdAssociator.h"
20 // #include "Utilities/Timing/interface/TimerStack.h"
26 #include <deque>
30 
32  if (geometry_ == nullptr)
33  throw cms::Exception("ConfigurationProblem") << "GlobalTrackingGeomtry is not set\n";
34  if (cscbadchambers_ == nullptr)
35  throw cms::Exception("ConfigurationProblem") << "CSCBadChambers is not set\n";
37 }
38 
40  if (geometry_ == nullptr)
41  throw cms::Exception("ConfigurationProblem") << "GlobalTrackingGeomtry is not set\n";
42  const GeomDet* gd = geometry_->idToDet(id);
43  if (gd == nullptr)
44  throw cms::Exception("NoGeometry") << "Cannot find GeomDet for DetID: " << id.rawId() << "\n";
45  return gd;
46 }
47 
50  return GlobalPoint(point.x(), point.y(), point.z());
51 }
52 
53 void MuonDetIdAssociator::getValidDetIds(unsigned int subDectorIndex, std::vector<DetId>& validIds) const {
54  validIds.clear();
55  if (geometry_ == nullptr)
56  throw cms::Exception("ConfigurationProblem") << "GlobalTrackingGeomtry is not set\n";
57  if (subDectorIndex != 0)
58  throw cms::Exception("FatalError")
59  << "Muon sub-dectors are all handle as one sub-system, but subDetectorIndex is not zero.\n";
60 
61  // CSC
63  throw cms::Exception("FatalError") << "Cannnot CSCGeometry\n";
64  auto const& geomDetsCSC = geometry_->slaveGeometry(CSCDetId())->dets();
65  for (auto it = geomDetsCSC.begin(); it != geomDetsCSC.end(); ++it)
66  if (auto csc = dynamic_cast<const CSCChamber*>(*it)) {
68  continue;
69  validIds.push_back(csc->id());
70  }
71 
72  // DT
74  throw cms::Exception("FatalError") << "Cannnot DTGeometry\n";
75  auto const& geomDetsDT = geometry_->slaveGeometry(DTChamberId())->dets();
76  for (auto it = geomDetsDT.begin(); it != geomDetsDT.end(); ++it)
77  if (auto dt = dynamic_cast<const DTChamber*>(*it))
78  validIds.push_back(dt->id());
79 
80  // RPC
82  throw cms::Exception("FatalError") << "Cannnot RPCGeometry\n";
83  auto const& geomDetsRPC = geometry_->slaveGeometry(RPCDetId())->dets();
84  for (auto it = geomDetsRPC.begin(); it != geomDetsRPC.end(); ++it)
85  if (auto rpc = dynamic_cast<const RPCChamber*>(*it)) {
86  std::vector<const RPCRoll*> rolls = (rpc->rolls());
87  for (std::vector<const RPCRoll*>::iterator r = rolls.begin(); r != rolls.end(); ++r)
88  validIds.push_back((*r)->id().rawId());
89  }
90 
91  // GEM
92  if (includeGEM_) {
94  throw cms::Exception("FatalError") << "Cannnot GEMGeometry\n";
95  auto const& geomDetsGEM = geometry_->slaveGeometry(GEMDetId())->dets();
96  for (auto it = geomDetsGEM.begin(); it != geomDetsGEM.end(); ++it) {
97  if (auto gem = dynamic_cast<const GEMSuperChamber*>(*it)) {
98  validIds.push_back(gem->id());
99  }
100  }
101  }
102  // ME0
103  if (includeME0_) {
105  throw cms::Exception("FatalError") << "Cannnot ME0Geometry\n";
106  auto const& geomDetsME0 = geometry_->slaveGeometry(ME0DetId())->dets();
107  for (auto it = geomDetsME0.begin(); it != geomDetsME0.end(); ++it) {
108  if (auto me0 = dynamic_cast<const ME0Chamber*>(*it)) {
109  validIds.push_back(me0->id());
110  }
111  }
112  }
113 }
114 
116  if (geometry_ == nullptr)
117  throw cms::Exception("ConfigurationProblem") << "GlobalTrackingGeomtry is not set\n";
119  return geometry_->idToDet(id)->surface().bounds().inside(lp);
120 }
121 
122 std::pair<DetIdAssociator::const_iterator, DetIdAssociator::const_iterator> MuonDetIdAssociator::getDetIdPoints(
123  const DetId& id, std::vector<GlobalPoint>& points) const {
124  points.clear();
125  points.reserve(8);
126  const GeomDet* geomDet = getGeomDet(id);
127 
128  // the coners of muon detector elements are not stored and can be only calculated
129  // based on methods defined in the interface class Bounds:
130  // width() - x
131  // length() - y
132  // thinkness() - z
133  // NOTE: this convention is implementation specific and can fail. Both
134  // RectangularPlaneBounds and TrapezoidalPlaneBounds use it.
135  // Even though the CSC geomtry is more complicated (trapezoid), it's enough
136  // to estimate which bins should contain this element. For the distance
137  // calculation from the edge, we will use exact geometry to get it right.
138 
139  const Bounds* bounds = &(geometry_->idToDet(id)->surface().bounds());
140  points.push_back(
141  geomDet->toGlobal(LocalPoint(+bounds->width() / 2, +bounds->length() / 2, +bounds->thickness() / 2)));
142  points.push_back(
143  geomDet->toGlobal(LocalPoint(-bounds->width() / 2, +bounds->length() / 2, +bounds->thickness() / 2)));
144  points.push_back(
145  geomDet->toGlobal(LocalPoint(+bounds->width() / 2, -bounds->length() / 2, +bounds->thickness() / 2)));
146  points.push_back(
147  geomDet->toGlobal(LocalPoint(-bounds->width() / 2, -bounds->length() / 2, +bounds->thickness() / 2)));
148  points.push_back(
149  geomDet->toGlobal(LocalPoint(+bounds->width() / 2, +bounds->length() / 2, -bounds->thickness() / 2)));
150  points.push_back(
151  geomDet->toGlobal(LocalPoint(-bounds->width() / 2, +bounds->length() / 2, -bounds->thickness() / 2)));
152  points.push_back(
153  geomDet->toGlobal(LocalPoint(+bounds->width() / 2, -bounds->length() / 2, -bounds->thickness() / 2)));
154  points.push_back(
155  geomDet->toGlobal(LocalPoint(-bounds->width() / 2, -bounds->length() / 2, -bounds->thickness() / 2)));
156 
157  return std::pair<const_iterator, const_iterator>(points.begin(), points.end());
158 }
MuonDetIdAssociator::getValidDetIds
void getValidDetIds(unsigned int, std::vector< DetId > &) const override
Definition: MuonDetIdAssociator.cc:53
Bounds::width
virtual float width() const =0
SteppingHelixPropagator.h
GeomDet
Definition: GeomDet.h:27
HLT_FULL_cff.points
points
Definition: HLT_FULL_cff.py:21453
RPCDetId
Definition: RPCDetId.h:16
RPCChamber.h
Bounds
Definition: Bounds.h:18
TrackingGeometry::dets
virtual const DetContainer & dets() const =0
Returm a vector of all GeomDet (including all GeomDetUnits)
Bounds::length
virtual float length() const =0
MuonDetIdAssociator::insideElement
bool insideElement(const GlobalPoint &point, const DetId &id) const override
Definition: MuonDetIdAssociator.cc:115
dt
float dt
Definition: AMPTWrapper.h:136
DetId
Definition: DetId.h:17
Plane.h
csc
Definition: L1Track.h:19
GeomDet::surface
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
Bounds::inside
virtual bool inside(const Local3DPoint &) const =0
Determine if the point is inside the bounds.
Surface::bounds
const Bounds & bounds() const
Definition: Surface.h:87
MuonDetIdAssociator::includeME0_
bool includeME0_
Definition: MuonDetIdAssociator.h:79
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Point3DBase< float, GlobalTag >
GeomDet::toLocal
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:58
CSCBadChambers::isInBadChamber
bool isInBadChamber(IndexType ichamber) const
Is the chamber with index 'ichamber' flagged as bad?
Definition: CSCBadChambers.cc:4
Bounds::thickness
virtual float thickness() const =0
MuonDetIdAssociator::geometry_
const GlobalTrackingGeometry * geometry_
Definition: MuonDetIdAssociator.h:74
GeomDet::toGlobal
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
mixOne_premix_on_sim_cfi.me0
me0
Definition: mixOne_premix_on_sim_cfi.py:309
GEMDetId
Definition: GEMDetId.h:18
CSCDetId
Definition: CSCDetId.h:26
position
static int position[264][3]
Definition: ReadPGInfo.cc:289
GlobalTrackingGeometry::slaveGeometry
const TrackingGeometry * slaveGeometry(DetId id) const
Return the pointer to the actual geometry for a given DetId.
Definition: GlobalTrackingGeometry.cc:54
MuonDetIdAssociator::check_setup
void check_setup() const override
Definition: MuonDetIdAssociator.cc:31
ME0DetId
Definition: ME0DetId.h:16
gem
Definition: AMC13Event.h:6
MuonDetIdAssociator::cscbadchambers_
const CSCBadChambers * cscbadchambers_
Definition: MuonDetIdAssociator.h:76
alignCSCRings.r
r
Definition: alignCSCRings.py:93
MuonDetIdAssociator::includeBadChambers_
bool includeBadChambers_
Definition: MuonDetIdAssociator.h:77
ME0Geometry.h
GEMGeometry.h
Exception
Definition: hltDiff.cc:245
GlobalTrackingGeometry::idToDet
const GeomDet * idToDet(DetId) const override
Definition: GlobalTrackingGeometry.cc:44
MuonDetIdAssociator::getDetIdPoints
std::pair< const_iterator, const_iterator > getDetIdPoints(const DetId &id, std::vector< GlobalPoint > &points) const override
Definition: MuonDetIdAssociator.cc:122
MuonDetIdAssociator::getPosition
GlobalPoint getPosition(const DetId &id) const override
Definition: MuonDetIdAssociator.cc:48
DTChamber.h
DetIdAssociator::check_setup
virtual void check_setup() const
Definition: DetIdAssociator.cc:371
cms::Exception
Definition: Exception.h:70
MuonDetIdAssociator.h
DTChamberId
Definition: DTChamberId.h:14
MuonDetIdAssociator::getGeomDet
const GeomDet * getGeomDet(const DetId &id) const override
Definition: MuonDetIdAssociator.cc:39
CSCChamber.h
point
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
omtf::DataWord64::rpc
Definition: OmtfDataWord64.h:16
MuonDetIdAssociator::includeGEM_
bool includeGEM_
Definition: MuonDetIdAssociator.h:78
RPCGeometry.h