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  if (gem->id().station() == 0)
99  validIds.push_back(gem->id());
100  else
101  for (auto ch : gem->chambers())
102  validIds.push_back(ch->id());
103  }
104  }
105  }
106  // ME0
107  if (includeME0_) {
109  throw cms::Exception("FatalError") << "Cannnot ME0Geometry\n";
110  auto const& geomDetsME0 = geometry_->slaveGeometry(ME0DetId())->dets();
111  for (auto it = geomDetsME0.begin(); it != geomDetsME0.end(); ++it) {
112  if (auto me0 = dynamic_cast<const ME0Chamber*>(*it)) {
113  validIds.push_back(me0->id());
114  }
115  }
116  }
117 }
118 
120  if (geometry_ == nullptr)
121  throw cms::Exception("ConfigurationProblem") << "GlobalTrackingGeomtry is not set\n";
123  return geometry_->idToDet(id)->surface().bounds().inside(lp);
124 }
125 
126 std::pair<DetIdAssociator::const_iterator, DetIdAssociator::const_iterator> MuonDetIdAssociator::getDetIdPoints(
127  const DetId& id, std::vector<GlobalPoint>& points) const {
128  points.clear();
129  points.reserve(8);
130  const GeomDet* geomDet = getGeomDet(id);
131 
132  // the coners of muon detector elements are not stored and can be only calculated
133  // based on methods defined in the interface class Bounds:
134  // width() - x
135  // length() - y
136  // thinkness() - z
137  // NOTE: this convention is implementation specific and can fail. Both
138  // RectangularPlaneBounds and TrapezoidalPlaneBounds use it.
139  // Even though the CSC geomtry is more complicated (trapezoid), it's enough
140  // to estimate which bins should contain this element. For the distance
141  // calculation from the edge, we will use exact geometry to get it right.
142 
143  const Bounds* bounds = &(geometry_->idToDet(id)->surface().bounds());
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  points.push_back(
157  geomDet->toGlobal(LocalPoint(+bounds->width() / 2, -bounds->length() / 2, -bounds->thickness() / 2)));
158  points.push_back(
159  geomDet->toGlobal(LocalPoint(-bounds->width() / 2, -bounds->length() / 2, -bounds->thickness() / 2)));
160 
161  return std::pair<const_iterator, const_iterator>(points.begin(), points.end());
162 }
float dt
Definition: AMPTWrapper.h:136
const CSCBadChambers * cscbadchambers_
virtual bool inside(const Local3DPoint &) const =0
Determine if the point is inside the bounds.
const TrackingGeometry * slaveGeometry(DetId id) const
Return the pointer to the actual geometry for a given DetId.
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:58
const GeomDet * getGeomDet(const DetId &id) const override
std::pair< const_iterator, const_iterator > getDetIdPoints(const DetId &id, std::vector< GlobalPoint > &points) const override
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
const GeomDet * idToDet(DetId) const override
bool insideElement(const GlobalPoint &point, const DetId &id) const override
GlobalPoint getPosition(const DetId &id) const override
Definition: L1Track.h:19
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
virtual const DetContainer & dets() const =0
Returm a vector of all GeomDet (including all GeomDetUnits)
Definition: DetId.h:17
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
bool isInBadChamber(IndexType ichamber) const
Is the chamber with index &#39;ichamber&#39; flagged as bad?
static int position[264][3]
Definition: ReadPGInfo.cc:289
const GlobalTrackingGeometry * geometry_
void check_setup() const override
void getValidDetIds(unsigned int, std::vector< DetId > &) const override
Definition: Bounds.h:18
*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
virtual void check_setup() const
const Bounds & bounds() const
Definition: Surface.h:87