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 DetIdAssociator::check_setup();
00032 }
00033
00034 const GeomDet* MuonDetIdAssociator::getGeomDet( const DetId& id ) const
00035 {
00036 if (geometry_==0) throw cms::Exception("ConfigurationProblem") << "GlobalTrackingGeomtry is not set\n";
00037 const GeomDet* gd = geometry_->idToDet(id);
00038 if (gd == 0) throw cms::Exception("NoGeometry") << "Cannot find GeomDet for DetID: " << id.rawId() <<"\n";
00039 return gd;
00040 }
00041
00042
00043 GlobalPoint MuonDetIdAssociator::getPosition(const DetId& id) const {
00044 Surface::PositionType point(getGeomDet(id)->surface().position());
00045 return GlobalPoint(point.x(),point.y(),point.z());
00046 }
00047
00048 std::set<DetId> MuonDetIdAssociator::getASetOfValidDetIds() const {
00049 std::set<DetId> setOfValidIds;
00050 if (geometry_==0) throw cms::Exception("ConfigurationProblem") << "GlobalTrackingGeomtry is not set\n";
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072 if (! geometry_->slaveGeometry(CSCDetId()) ) throw cms::Exception("FatalError") << "Cannnot CSCGeometry\n";
00073 std::vector<GeomDet*> geomDetsCSC = geometry_->slaveGeometry(CSCDetId())->dets();
00074 for(std::vector<GeomDet*>::const_iterator it = geomDetsCSC.begin(); it != geomDetsCSC.end(); ++it)
00075 if (CSCChamber* csc = dynamic_cast< CSCChamber*>(*it)) setOfValidIds.insert(csc->id());
00076
00077
00078 if (! geometry_->slaveGeometry(DTChamberId()) ) throw cms::Exception("FatalError") << "Cannnot DTGeometry\n";
00079 std::vector<GeomDet*> geomDetsDT = geometry_->slaveGeometry(DTChamberId())->dets();
00080 for(std::vector<GeomDet*>::const_iterator it = geomDetsDT.begin(); it != geomDetsDT.end(); ++it)
00081 if (DTChamber* dt = dynamic_cast< DTChamber*>(*it)) setOfValidIds.insert(dt->id());
00082
00083 return setOfValidIds;
00084 }
00085
00086 bool MuonDetIdAssociator::insideElement(const GlobalPoint& point, const DetId& id) const {
00087 if (geometry_==0) throw cms::Exception("ConfigurationProblem") << "GlobalTrackingGeomtry is not set\n";
00088 LocalPoint lp = geometry_->idToDet(id)->toLocal(point);
00089 return geometry_->idToDet(id)->surface().bounds().inside(lp);
00090 }
00091
00092 std::vector<GlobalPoint> MuonDetIdAssociator::getDetIdPoints(const DetId& id) const {
00093 std::vector<GlobalPoint> points;
00094 const GeomDet* geomDet = getGeomDet( id );
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107 const Bounds* bounds = &(geometry_->idToDet(id)->surface().bounds());
00108 points.push_back(geomDet->toGlobal(LocalPoint(+bounds->width()/2,+bounds->length()/2,+bounds->thickness()/2)));
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
00117 return points;
00118 }