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