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 // $Id: MuonDetIdAssociator.cc,v 1.3 2011/10/02 21:20:05 dmytro Exp $
17 //
18 //
19 
20 
21 #include "MuonDetIdAssociator.h"
22 // #include "Utilities/Timing/interface/TimerStack.h"
28 #include <deque>
30 
32  if (geometry_==0) throw cms::Exception("ConfigurationProblem") << "GlobalTrackingGeomtry is not set\n";
33  if (cscbadchambers_==0) throw cms::Exception("ConfigurationProblem") << "CSCBadChambers is not set\n";
35 }
36 
38 {
39  if (geometry_==0) throw cms::Exception("ConfigurationProblem") << "GlobalTrackingGeomtry is not set\n";
40  const GeomDet* gd = geometry_->idToDet(id);
41  if (gd == 0) throw cms::Exception("NoGeometry") << "Cannot find GeomDet for DetID: " << id.rawId() <<"\n";
42  return gd;
43 }
44 
45 
48  return GlobalPoint(point.x(),point.y(),point.z());
49 }
50 
51 const std::vector<DetId>& MuonDetIdAssociator::getValidDetIds(unsigned int subDectorIndex) const {
52  validIds_.clear();
53  if (geometry_==0) throw cms::Exception("ConfigurationProblem") << "GlobalTrackingGeomtry is not set\n";
54  if (subDectorIndex!=0) throw cms::Exception("FatalError") <<
55  "Muon sub-dectors are all handle as one sub-system, but subDetectorIndex is not zero.\n";
56 
57  // CSC
58  if (! geometry_->slaveGeometry(CSCDetId()) ) throw cms::Exception("FatalError") << "Cannnot CSCGeometry\n";
59  const std::vector<GeomDet*>& geomDetsCSC = geometry_->slaveGeometry(CSCDetId())->dets();
60  for(std::vector<GeomDet*>::const_iterator it = geomDetsCSC.begin(); it != geomDetsCSC.end(); ++it)
61  if (CSCChamber* csc = dynamic_cast< CSCChamber*>(*it)) {
62  if ((! includeBadChambers_) && (cscbadchambers_->isInBadChamber(CSCDetId(csc->id())))) continue;
63  validIds_.push_back(csc->id());
64  }
65 
66  // DT
67  if (! geometry_->slaveGeometry(DTChamberId()) ) throw cms::Exception("FatalError") << "Cannnot DTGeometry\n";
68  const std::vector<GeomDet*>& geomDetsDT = geometry_->slaveGeometry(DTChamberId())->dets();
69  for(std::vector<GeomDet*>::const_iterator it = geomDetsDT.begin(); it != geomDetsDT.end(); ++it)
70  if (DTChamber* dt = dynamic_cast< DTChamber*>(*it)) validIds_.push_back(dt->id());
71 
72  // RPC
73  if (! geometry_->slaveGeometry(RPCDetId()) ) throw cms::Exception("FatalError") << "Cannnot RPCGeometry\n";
74  const std::vector<GeomDet*>& geomDetsRPC = geometry_->slaveGeometry(RPCDetId())->dets();
75  for(std::vector<GeomDet*>::const_iterator it = geomDetsRPC.begin(); it != geomDetsRPC.end(); ++it)
76  if (RPCChamber* rpc = dynamic_cast< RPCChamber*>(*it)) {
77  std::vector< const RPCRoll*> rolls = (rpc->rolls());
78  for(std::vector<const RPCRoll*>::iterator r = rolls.begin(); r != rolls.end(); ++r)
79  validIds_.push_back((*r)->id().rawId());
80  }
81 
82  return validIds_;
83 }
84 
86  if (geometry_==0) throw cms::Exception("ConfigurationProblem") << "GlobalTrackingGeomtry is not set\n";
87  LocalPoint lp = geometry_->idToDet(id)->toLocal(point);
88  return geometry_->idToDet(id)->surface().bounds().inside(lp);
89 }
90 
91 std::pair<DetIdAssociator::const_iterator,DetIdAssociator::const_iterator>
93 {
94  points_.clear();
95  const GeomDet* geomDet = getGeomDet( id );
96 
97  // the coners of muon detector elements are not stored and can be only calculated
98  // based on methods defined in the interface class Bounds:
99  // width() - x
100  // length() - y
101  // thinkness() - z
102  // NOTE: this convention is implementation specific and can fail. Both
103  // RectangularPlaneBounds and TrapezoidalPlaneBounds use it.
104  // Even though the CSC geomtry is more complicated (trapezoid), it's enough
105  // to estimate which bins should contain this element. For the distance
106  // calculation from the edge, we will use exact geometry to get it right.
107 
108  const Bounds* bounds = &(geometry_->idToDet(id)->surface().bounds());
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  points_.push_back(geomDet->toGlobal(LocalPoint(-bounds->width()/2,-bounds->length()/2,-bounds->thickness()/2)));
117 
118  return std::pair<const_iterator,const_iterator>(points_.begin(),points_.end());
119 }
120 
122 {
124  iRecord.getRecord<GlobalTrackingGeometryRecord>().get(geometryH);
125  setGeometry(geometryH.product());
126 }
bool isInBadChamber(const CSCDetId &id) const
Is the gven chamber flagged as bad?
float dt
Definition: AMPTWrapper.h:126
const CSCBadChambers * cscbadchambers_
virtual float length() const =0
virtual const std::vector< DetId > & getValidDetIds(unsigned int) const
virtual bool inside(const Local3DPoint &) const =0
Determine if the point is inside the bounds.
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:47
virtual GlobalPoint getPosition(const DetId &id) const
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
T y() const
Definition: PV3DBase.h:62
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:62
virtual void check_setup() const
std::vector< DetId > validIds_
virtual bool insideElement(const GlobalPoint &point, const DetId &id) const
virtual float thickness() const =0
virtual const GeomDet * idToDet(DetId) const
virtual const GeomDet * getGeomDet(const DetId &id) const
std::vector< GlobalPoint > points_
T z() const
Definition: PV3DBase.h:63
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:20
const Bounds & bounds() const
Definition: BoundSurface.h:89
T const * product() const
Definition: ESHandle.h:62
const BoundPlane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
static int position[264][3]
Definition: ReadPGInfo.cc:509
const GlobalTrackingGeometry * geometry_
virtual std::pair< const_iterator, const_iterator > getDetIdPoints(const DetId &id) const
Definition: Bounds.h:18
T x() const
Definition: PV3DBase.h:61
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)