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 "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 "Geometry/RPCGeometry/interface/RPCChamber.h"
00028 #include <deque>
00029 #include "Geometry/RPCGeometry/interface/RPCGeometry.h"
00030
00031 void MuonDetIdAssociator::check_setup() const {
00032 if (geometry_==0) throw cms::Exception("ConfigurationProblem") << "GlobalTrackingGeomtry is not set\n";
00033 if (cscbadchambers_==0) throw cms::Exception("ConfigurationProblem") << "CSCBadChambers is not set\n";
00034 DetIdAssociator::check_setup();
00035 }
00036
00037 const GeomDet* MuonDetIdAssociator::getGeomDet( const DetId& id ) const
00038 {
00039 if (geometry_==0) throw cms::Exception("ConfigurationProblem") << "GlobalTrackingGeomtry is not set\n";
00040 const GeomDet* gd = geometry_->idToDet(id);
00041 if (gd == 0) throw cms::Exception("NoGeometry") << "Cannot find GeomDet for DetID: " << id.rawId() <<"\n";
00042 return gd;
00043 }
00044
00045
00046 GlobalPoint MuonDetIdAssociator::getPosition(const DetId& id) const {
00047 Surface::PositionType point(getGeomDet(id)->surface().position());
00048 return GlobalPoint(point.x(),point.y(),point.z());
00049 }
00050
00051 const std::vector<DetId>& MuonDetIdAssociator::getValidDetIds(unsigned int subDectorIndex) const {
00052 validIds_.clear();
00053 if (geometry_==0) throw cms::Exception("ConfigurationProblem") << "GlobalTrackingGeomtry is not set\n";
00054 if (subDectorIndex!=0) throw cms::Exception("FatalError") <<
00055 "Muon sub-dectors are all handle as one sub-system, but subDetectorIndex is not zero.\n";
00056
00057
00058 if (! geometry_->slaveGeometry(CSCDetId()) ) throw cms::Exception("FatalError") << "Cannnot CSCGeometry\n";
00059 const std::vector<GeomDet*>& geomDetsCSC = geometry_->slaveGeometry(CSCDetId())->dets();
00060 for(std::vector<GeomDet*>::const_iterator it = geomDetsCSC.begin(); it != geomDetsCSC.end(); ++it)
00061 if (CSCChamber* csc = dynamic_cast< CSCChamber*>(*it)) {
00062 if ((! includeBadChambers_) && (cscbadchambers_->isInBadChamber(CSCDetId(csc->id())))) continue;
00063 validIds_.push_back(csc->id());
00064 }
00065
00066
00067 if (! geometry_->slaveGeometry(DTChamberId()) ) throw cms::Exception("FatalError") << "Cannnot DTGeometry\n";
00068 const std::vector<GeomDet*>& geomDetsDT = geometry_->slaveGeometry(DTChamberId())->dets();
00069 for(std::vector<GeomDet*>::const_iterator it = geomDetsDT.begin(); it != geomDetsDT.end(); ++it)
00070 if (DTChamber* dt = dynamic_cast< DTChamber*>(*it)) validIds_.push_back(dt->id());
00071
00072
00073 if (! geometry_->slaveGeometry(RPCDetId()) ) throw cms::Exception("FatalError") << "Cannnot RPCGeometry\n";
00074 const std::vector<GeomDet*>& geomDetsRPC = geometry_->slaveGeometry(RPCDetId())->dets();
00075 for(std::vector<GeomDet*>::const_iterator it = geomDetsRPC.begin(); it != geomDetsRPC.end(); ++it)
00076 if (RPCChamber* rpc = dynamic_cast< RPCChamber*>(*it)) {
00077 std::vector< const RPCRoll*> rolls = (rpc->rolls());
00078 for(std::vector<const RPCRoll*>::iterator r = rolls.begin(); r != rolls.end(); ++r)
00079 validIds_.push_back((*r)->id().rawId());
00080 }
00081
00082 return validIds_;
00083 }
00084
00085 bool MuonDetIdAssociator::insideElement(const GlobalPoint& point, const DetId& id) const {
00086 if (geometry_==0) throw cms::Exception("ConfigurationProblem") << "GlobalTrackingGeomtry is not set\n";
00087 LocalPoint lp = geometry_->idToDet(id)->toLocal(point);
00088 return geometry_->idToDet(id)->surface().bounds().inside(lp);
00089 }
00090
00091 std::pair<DetIdAssociator::const_iterator,DetIdAssociator::const_iterator>
00092 MuonDetIdAssociator::getDetIdPoints(const DetId& id) const
00093 {
00094 points_.clear();
00095 const GeomDet* geomDet = getGeomDet( id );
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108 const Bounds* bounds = &(geometry_->idToDet(id)->surface().bounds());
00109 points_.push_back(geomDet->toGlobal(LocalPoint(+bounds->width()/2,+bounds->length()/2,+bounds->thickness()/2)));
00110 points_.push_back(geomDet->toGlobal(LocalPoint(-bounds->width()/2,+bounds->length()/2,+bounds->thickness()/2)));
00111 points_.push_back(geomDet->toGlobal(LocalPoint(+bounds->width()/2,-bounds->length()/2,+bounds->thickness()/2)));
00112 points_.push_back(geomDet->toGlobal(LocalPoint(-bounds->width()/2,-bounds->length()/2,+bounds->thickness()/2)));
00113 points_.push_back(geomDet->toGlobal(LocalPoint(+bounds->width()/2,+bounds->length()/2,-bounds->thickness()/2)));
00114 points_.push_back(geomDet->toGlobal(LocalPoint(-bounds->width()/2,+bounds->length()/2,-bounds->thickness()/2)));
00115 points_.push_back(geomDet->toGlobal(LocalPoint(+bounds->width()/2,-bounds->length()/2,-bounds->thickness()/2)));
00116 points_.push_back(geomDet->toGlobal(LocalPoint(-bounds->width()/2,-bounds->length()/2,-bounds->thickness()/2)));
00117
00118 return std::pair<const_iterator,const_iterator>(points_.begin(),points_.end());
00119 }
00120
00121 void MuonDetIdAssociator::setGeometry(const DetIdAssociatorRecord& iRecord)
00122 {
00123 edm::ESHandle<GlobalTrackingGeometry> geometryH;
00124 iRecord.getRecord<GlobalTrackingGeometryRecord>().get(geometryH);
00125 setGeometry(geometryH.product());
00126 }