Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "TrackingTools/TrackAssociator/interface/MuonDetIdAssociator.h"
00022
00023 #include "TrackPropagation/SteppingHelixPropagator/interface/SteppingHelixPropagator.h"
00024 #include "DataFormats/GeometrySurface/interface/Plane.h"
00025 #include "Geometry/DTGeometry/interface/DTChamber.h"
00026 #include "Geometry/CSCGeometry/interface/CSCChamber.h"
00027 #include <deque>
00028
00029 void MuonDetIdAssociator::check_setup() const {
00030 if (geometry_==0) throw cms::Exception("ConfigurationProblem") << "GlobalTrackingGeomtry is not set\n";
00031 if (cscbadchambers_==0) throw cms::Exception("ConfigurationProblem") << "CSCBadChambers is not set\n";
00032 DetIdAssociator::check_setup();
00033 }
00034
00035 const GeomDet* MuonDetIdAssociator::getGeomDet( const DetId& id ) const
00036 {
00037 if (geometry_==0) throw cms::Exception("ConfigurationProblem") << "GlobalTrackingGeomtry is not set\n";
00038 const GeomDet* gd = geometry_->idToDet(id);
00039 if (gd == 0) throw cms::Exception("NoGeometry") << "Cannot find GeomDet for DetID: " << id.rawId() <<"\n";
00040 return gd;
00041 }
00042
00043
00044 GlobalPoint MuonDetIdAssociator::getPosition(const DetId& id) const {
00045 Surface::PositionType point(getGeomDet(id)->surface().position());
00046 return GlobalPoint(point.x(),point.y(),point.z());
00047 }
00048
00049 const std::vector<DetId>& MuonDetIdAssociator::getValidDetIds(unsigned int subDectorIndex) const {
00050 validIds_.clear();
00051 if (geometry_==0) throw cms::Exception("ConfigurationProblem") << "GlobalTrackingGeomtry is not set\n";
00052 if (subDectorIndex!=0) throw cms::Exception("FatalError") <<
00053 "Muon sub-dectors are all handle as one sub-system, but subDetectorIndex is not zero.\n";
00054
00055
00056 if (! geometry_->slaveGeometry(CSCDetId()) ) throw cms::Exception("FatalError") << "Cannnot CSCGeometry\n";
00057 const std::vector<GeomDet*>& geomDetsCSC = geometry_->slaveGeometry(CSCDetId())->dets();
00058 for(std::vector<GeomDet*>::const_iterator it = geomDetsCSC.begin(); it != geomDetsCSC.end(); ++it)
00059 if (CSCChamber* csc = dynamic_cast< CSCChamber*>(*it)) {
00060 if ((! includeBadChambers_) && (cscbadchambers_->isInBadChamber(CSCDetId(csc->id())))) continue;
00061 validIds_.push_back(csc->id());
00062 }
00063
00064
00065 if (! geometry_->slaveGeometry(DTChamberId()) ) throw cms::Exception("FatalError") << "Cannnot DTGeometry\n";
00066 const std::vector<GeomDet*>& geomDetsDT = geometry_->slaveGeometry(DTChamberId())->dets();
00067 for(std::vector<GeomDet*>::const_iterator it = geomDetsDT.begin(); it != geomDetsDT.end(); ++it)
00068 if (DTChamber* dt = dynamic_cast< DTChamber*>(*it)) validIds_.push_back(dt->id());
00069
00070 return validIds_;
00071 }
00072
00073 bool MuonDetIdAssociator::insideElement(const GlobalPoint& point, const DetId& id) const {
00074 if (geometry_==0) throw cms::Exception("ConfigurationProblem") << "GlobalTrackingGeomtry is not set\n";
00075 LocalPoint lp = geometry_->idToDet(id)->toLocal(point);
00076 return geometry_->idToDet(id)->surface().bounds().inside(lp);
00077 }
00078
00079 std::pair<DetIdAssociator::const_iterator,DetIdAssociator::const_iterator>
00080 MuonDetIdAssociator::getDetIdPoints(const DetId& id) const
00081 {
00082 points_.clear();
00083 const GeomDet* geomDet = getGeomDet( id );
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096 const Bounds* bounds = &(geometry_->idToDet(id)->surface().bounds());
00097 points_.push_back(geomDet->toGlobal(LocalPoint(+bounds->width()/2,+bounds->length()/2,+bounds->thickness()/2)));
00098 points_.push_back(geomDet->toGlobal(LocalPoint(-bounds->width()/2,+bounds->length()/2,+bounds->thickness()/2)));
00099 points_.push_back(geomDet->toGlobal(LocalPoint(+bounds->width()/2,-bounds->length()/2,+bounds->thickness()/2)));
00100 points_.push_back(geomDet->toGlobal(LocalPoint(-bounds->width()/2,-bounds->length()/2,+bounds->thickness()/2)));
00101 points_.push_back(geomDet->toGlobal(LocalPoint(+bounds->width()/2,+bounds->length()/2,-bounds->thickness()/2)));
00102 points_.push_back(geomDet->toGlobal(LocalPoint(-bounds->width()/2,+bounds->length()/2,-bounds->thickness()/2)));
00103 points_.push_back(geomDet->toGlobal(LocalPoint(+bounds->width()/2,-bounds->length()/2,-bounds->thickness()/2)));
00104 points_.push_back(geomDet->toGlobal(LocalPoint(-bounds->width()/2,-bounds->length()/2,-bounds->thickness()/2)));
00105
00106 return std::pair<const_iterator,const_iterator>(points_.begin(),points_.end());
00107 }
00108
00109 void MuonDetIdAssociator::setGeometry(const DetIdAssociatorRecord& iRecord)
00110 {
00111 edm::ESHandle<GlobalTrackingGeometry> geometryH;
00112 iRecord.getRecord<GlobalTrackingGeometryRecord>().get(geometryH);
00113 setGeometry(geometryH.product());
00114 }