CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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>
29 
31  if (geometry_==0) throw cms::Exception("ConfigurationProblem") << "GlobalTrackingGeomtry is not set\n";
32  if (cscbadchambers_==0) throw cms::Exception("ConfigurationProblem") << "CSCBadChambers is not set\n";
34 }
35 
37 {
38  if (geometry_==0) throw cms::Exception("ConfigurationProblem") << "GlobalTrackingGeomtry is not set\n";
39  const GeomDet* gd = geometry_->idToDet(id);
40  if (gd == 0) throw cms::Exception("NoGeometry") << "Cannot find GeomDet for DetID: " << id.rawId() <<"\n";
41  return gd;
42 }
43 
44 
47  return GlobalPoint(point.x(),point.y(),point.z());
48 }
49 
50 void MuonDetIdAssociator::getValidDetIds(unsigned int subDectorIndex, std::vector<DetId>& validIds) const {
51  validIds.clear();
52  if (geometry_==0) throw cms::Exception("ConfigurationProblem") << "GlobalTrackingGeomtry is not set\n";
53  if (subDectorIndex!=0) throw cms::Exception("FatalError") <<
54  "Muon sub-dectors are all handle as one sub-system, but subDetectorIndex is not zero.\n";
55 
56  // CSC
57  if (! geometry_->slaveGeometry(CSCDetId()) ) throw cms::Exception("FatalError") << "Cannnot CSCGeometry\n";
58  auto const & geomDetsCSC = geometry_->slaveGeometry(CSCDetId())->dets();
59  for(auto it = geomDetsCSC.begin(); it != geomDetsCSC.end(); ++it)
60  if (auto csc = dynamic_cast<const CSCChamber*>(*it)) {
61  if ((! includeBadChambers_) && (cscbadchambers_->isInBadChamber(CSCDetId(csc->id())))) continue;
62  validIds.push_back(csc->id());
63  }
64 
65  // DT
66  if (! geometry_->slaveGeometry(DTChamberId()) ) throw cms::Exception("FatalError") << "Cannnot DTGeometry\n";
67  auto const & geomDetsDT = geometry_->slaveGeometry(DTChamberId())->dets();
68  for(auto it = geomDetsDT.begin(); it != geomDetsDT.end(); ++it)
69  if (auto dt = dynamic_cast<const DTChamber*>(*it)) validIds.push_back(dt->id());
70 
71  // RPC
72  if (! geometry_->slaveGeometry(RPCDetId()) ) throw cms::Exception("FatalError") << "Cannnot RPCGeometry\n";
73  auto const & geomDetsRPC = geometry_->slaveGeometry(RPCDetId())->dets();
74  for(auto it = geomDetsRPC.begin(); it != geomDetsRPC.end(); ++it)
75  if (auto rpc = dynamic_cast<const RPCChamber*>(*it)) {
76  std::vector< const RPCRoll*> rolls = (rpc->rolls());
77  for(std::vector<const RPCRoll*>::iterator r = rolls.begin(); r != rolls.end(); ++r)
78  validIds.push_back((*r)->id().rawId());
79  }
80 
81 }
82 
84  if (geometry_==0) throw cms::Exception("ConfigurationProblem") << "GlobalTrackingGeomtry is not set\n";
85  LocalPoint lp = geometry_->idToDet(id)->toLocal(point);
86  return geometry_->idToDet(id)->surface().bounds().inside(lp);
87 }
88 
89 std::pair<DetIdAssociator::const_iterator,DetIdAssociator::const_iterator>
90 MuonDetIdAssociator::getDetIdPoints(const DetId& id, std::vector<GlobalPoint>& points) const
91 {
92  points.clear();
93  points.reserve(8);
94  const GeomDet* geomDet = getGeomDet( id );
95 
96  // the coners of muon detector elements are not stored and can be only calculated
97  // based on methods defined in the interface class Bounds:
98  // width() - x
99  // length() - y
100  // thinkness() - z
101  // NOTE: this convention is implementation specific and can fail. Both
102  // RectangularPlaneBounds and TrapezoidalPlaneBounds use it.
103  // Even though the CSC geomtry is more complicated (trapezoid), it's enough
104  // to estimate which bins should contain this element. For the distance
105  // calculation from the edge, we will use exact geometry to get it right.
106 
107  const Bounds* bounds = &(geometry_->idToDet(id)->surface().bounds());
108  points.push_back(geomDet->toGlobal(LocalPoint(+bounds->width()/2,+bounds->length()/2,+bounds->thickness()/2)));
109  points.push_back(geomDet->toGlobal(LocalPoint(-bounds->width()/2,+bounds->length()/2,+bounds->thickness()/2)));
110  points.push_back(geomDet->toGlobal(LocalPoint(+bounds->width()/2,-bounds->length()/2,+bounds->thickness()/2)));
111  points.push_back(geomDet->toGlobal(LocalPoint(-bounds->width()/2,-bounds->length()/2,+bounds->thickness()/2)));
112  points.push_back(geomDet->toGlobal(LocalPoint(+bounds->width()/2,+bounds->length()/2,-bounds->thickness()/2)));
113  points.push_back(geomDet->toGlobal(LocalPoint(-bounds->width()/2,+bounds->length()/2,-bounds->thickness()/2)));
114  points.push_back(geomDet->toGlobal(LocalPoint(+bounds->width()/2,-bounds->length()/2,-bounds->thickness()/2)));
115  points.push_back(geomDet->toGlobal(LocalPoint(-bounds->width()/2,-bounds->length()/2,-bounds->thickness()/2)));
116 
117  return std::pair<const_iterator,const_iterator>(points.begin(),points.end());
118 }
119 
121 {
123  iRecord.getRecord<GlobalTrackingGeometryRecord>().get(geometryH);
124  setGeometry(geometryH.product());
125 }
float dt
Definition: AMPTWrapper.h:126
const CSCBadChambers * cscbadchambers_
virtual float length() const =0
virtual bool inside(const Local3DPoint &) const =0
Determine if the point is inside the bounds.
virtual const GeomDet * getGeomDet(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:47
virtual std::pair< const_iterator, const_iterator > getDetIdPoints(const DetId &id, std::vector< GlobalPoint > &points) const override
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:62
const Bounds & bounds() const
Definition: Surface.h:128
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
virtual bool insideElement(const GlobalPoint &point, const DetId &id) const override
bool isInBadChamber(IndexType ichamber) const
Is the chamber with index &#39;ichamber&#39; flagged as bad?
virtual float thickness() const =0
virtual const GeomDet * idToDet(DetId) const
T z() const
Definition: PV3DBase.h:64
virtual GlobalPoint getPosition(const DetId &id) 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: DetId.h:18
T const * product() const
Definition: ESHandle.h:62
static int position[264][3]
Definition: ReadPGInfo.cc:509
const GlobalTrackingGeometry * geometry_
virtual void check_setup() const override
virtual void getValidDetIds(unsigned int, std::vector< DetId > &) const override
Definition: Bounds.h:22
T x() const
Definition: PV3DBase.h:62
virtual float width() const =0
*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)