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 
20 #include "MuonDetIdAssociator.h"
21 // #include "Utilities/Timing/interface/TimerStack.h"
27 #include <deque>
31 
33  if (geometry_==0) throw cms::Exception("ConfigurationProblem") << "GlobalTrackingGeomtry is not set\n";
34  if (cscbadchambers_==0) throw cms::Exception("ConfigurationProblem") << "CSCBadChambers is not set\n";
36 }
37 
39 {
40  if (geometry_==0) throw cms::Exception("ConfigurationProblem") << "GlobalTrackingGeomtry is not set\n";
41  const GeomDet* gd = geometry_->idToDet(id);
42  if (gd == 0) throw cms::Exception("NoGeometry") << "Cannot find GeomDet for DetID: " << id.rawId() <<"\n";
43  return gd;
44 }
45 
46 
49  return GlobalPoint(point.x(),point.y(),point.z());
50 }
51 
52 void MuonDetIdAssociator::getValidDetIds(unsigned int subDectorIndex, std::vector<DetId>& validIds) const {
53  validIds.clear();
54  if (geometry_==0) throw cms::Exception("ConfigurationProblem") << "GlobalTrackingGeomtry is not set\n";
55  if (subDectorIndex!=0) throw cms::Exception("FatalError") <<
56  "Muon sub-dectors are all handle as one sub-system, but subDetectorIndex is not zero.\n";
57 
58  // CSC
59  if (! geometry_->slaveGeometry(CSCDetId()) ) throw cms::Exception("FatalError") << "Cannnot CSCGeometry\n";
60  auto const & geomDetsCSC = geometry_->slaveGeometry(CSCDetId())->dets();
61  for(auto it = geomDetsCSC.begin(); it != geomDetsCSC.end(); ++it)
62  if (auto csc = dynamic_cast<const CSCChamber*>(*it)) {
63  if ((! includeBadChambers_) && (cscbadchambers_->isInBadChamber(CSCDetId(csc->id())))) continue;
64  validIds.push_back(csc->id());
65  }
66 
67  // DT
68  if (! geometry_->slaveGeometry(DTChamberId()) ) throw cms::Exception("FatalError") << "Cannnot DTGeometry\n";
69  auto const & geomDetsDT = geometry_->slaveGeometry(DTChamberId())->dets();
70  for(auto it = geomDetsDT.begin(); it != geomDetsDT.end(); ++it)
71  if (auto dt = dynamic_cast<const DTChamber*>(*it)) validIds.push_back(dt->id());
72 
73  // RPC
74  if (! geometry_->slaveGeometry(RPCDetId()) ) throw cms::Exception("FatalError") << "Cannnot RPCGeometry\n";
75  auto const & geomDetsRPC = geometry_->slaveGeometry(RPCDetId())->dets();
76  for(auto it = geomDetsRPC.begin(); it != geomDetsRPC.end(); ++it)
77  if (auto rpc = dynamic_cast<const RPCChamber*>(*it)) {
78  std::vector< const RPCRoll*> rolls = (rpc->rolls());
79  for(std::vector<const RPCRoll*>::iterator r = rolls.begin(); r != rolls.end(); ++r)
80  validIds.push_back((*r)->id().rawId());
81  }
82 
83  // GEM
84  if (includeGEM_){
85  if (! geometry_->slaveGeometry(GEMDetId()) ) throw cms::Exception("FatalError") << "Cannnot GEMGeometry\n";
86  auto const & geomDetsGEM = geometry_->slaveGeometry(GEMDetId())->dets();
87  for(auto it = geomDetsGEM.begin(); it != geomDetsGEM.end(); ++it){
88  if (auto gem = dynamic_cast<const GEMSuperChamber*>(*it)) {
89  validIds.push_back(gem->id());
90  }
91  }
92  }
93  // ME0
94  if (includeME0_){
95  if (! geometry_->slaveGeometry(ME0DetId()) ) throw cms::Exception("FatalError") << "Cannnot ME0Geometry\n";
96  auto const & geomDetsME0 = geometry_->slaveGeometry(ME0DetId())->dets();
97  for(auto it = geomDetsME0.begin(); it != geomDetsME0.end(); ++it){
98  if (auto me0 = dynamic_cast<const ME0Chamber*>(*it)) {
99  validIds.push_back(me0->id());
100  }
101  }
102  }
103 
104 }
105 
107  if (geometry_==0) throw cms::Exception("ConfigurationProblem") << "GlobalTrackingGeomtry is not set\n";
108  LocalPoint lp = geometry_->idToDet(id)->toLocal(point);
109  return geometry_->idToDet(id)->surface().bounds().inside(lp);
110 }
111 
112 std::pair<DetIdAssociator::const_iterator,DetIdAssociator::const_iterator>
113 MuonDetIdAssociator::getDetIdPoints(const DetId& id, std::vector<GlobalPoint>& points) const
114 {
115  points.clear();
116  points.reserve(8);
117  const GeomDet* geomDet = getGeomDet( id );
118 
119  // the coners of muon detector elements are not stored and can be only calculated
120  // based on methods defined in the interface class Bounds:
121  // width() - x
122  // length() - y
123  // thinkness() - z
124  // NOTE: this convention is implementation specific and can fail. Both
125  // RectangularPlaneBounds and TrapezoidalPlaneBounds use it.
126  // Even though the CSC geomtry is more complicated (trapezoid), it's enough
127  // to estimate which bins should contain this element. For the distance
128  // calculation from the edge, we will use exact geometry to get it right.
129 
130  const Bounds* bounds = &(geometry_->idToDet(id)->surface().bounds());
131  points.push_back(geomDet->toGlobal(LocalPoint(+bounds->width()/2,+bounds->length()/2,+bounds->thickness()/2)));
132  points.push_back(geomDet->toGlobal(LocalPoint(-bounds->width()/2,+bounds->length()/2,+bounds->thickness()/2)));
133  points.push_back(geomDet->toGlobal(LocalPoint(+bounds->width()/2,-bounds->length()/2,+bounds->thickness()/2)));
134  points.push_back(geomDet->toGlobal(LocalPoint(-bounds->width()/2,-bounds->length()/2,+bounds->thickness()/2)));
135  points.push_back(geomDet->toGlobal(LocalPoint(+bounds->width()/2,+bounds->length()/2,-bounds->thickness()/2)));
136  points.push_back(geomDet->toGlobal(LocalPoint(-bounds->width()/2,+bounds->length()/2,-bounds->thickness()/2)));
137  points.push_back(geomDet->toGlobal(LocalPoint(+bounds->width()/2,-bounds->length()/2,-bounds->thickness()/2)));
138  points.push_back(geomDet->toGlobal(LocalPoint(-bounds->width()/2,-bounds->length()/2,-bounds->thickness()/2)));
139 
140  return std::pair<const_iterator,const_iterator>(points.begin(),points.end());
141 }
142 
144 {
146  iRecord.getRecord<GlobalTrackingGeometryRecord>().get(geometryH);
147  setGeometry(geometryH.product());
148 }
float dt
Definition: AMPTWrapper.h:126
const CSCBadChambers * cscbadchambers_
virtual float length() const =0
virtual bool insideElement(const GlobalPoint &point, const DetId &id) const override
virtual GlobalPoint getPosition(const DetId &id) const override
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:54
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
T y() const
Definition: PV3DBase.h:63
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:69
const Bounds & bounds() const
Definition: Surface.h:120
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
bool isInBadChamber(IndexType ichamber) const
Is the chamber with index &#39;ichamber&#39; flagged as bad?
virtual float width() const =0
virtual const GeomDet * idToDet(DetId) const
virtual bool inside(const Local3DPoint &) const =0
Determine if the point is inside the bounds.
T z() const
Definition: PV3DBase.h:64
virtual void getValidDetIds(unsigned int, std::vector< DetId > &) const override
const TrackingGeometry * slaveGeometry(DetId id) const
Return the pointer to the actual geometry for a given DetId.
virtual void check_setup() const
virtual const DetContainer & dets() const =0
Returm a vector of all GeomDet (including all GeomDetUnits)
Definition: L1Track.h:19
virtual void check_setup() const override
virtual std::pair< const_iterator, const_iterator > getDetIdPoints(const DetId &id, std::vector< GlobalPoint > &points) const override
Definition: DetId.h:18
virtual float thickness() const =0
virtual const GeomDet * getGeomDet(const DetId &id) const override
static int position[264][3]
Definition: ReadPGInfo.cc:509
const GlobalTrackingGeometry * geometry_
Definition: Bounds.h:22
T x() const
Definition: PV3DBase.h:62
T const * product() const
Definition: ESHandle.h:86
*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 setGeometry(const GlobalTrackingGeometry *ptr)