![]() |
![]() |
00001 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h" 00002 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h" 00003 #include "Geometry/CaloGeometry/interface/CaloGeometry.h" 00004 00005 00006 CaloGeometry::CaloGeometry() { 00007 } 00008 00009 int CaloGeometry::makeIndex(DetId::Detector det, int subdet) const { 00010 return (int(det)<<4) | (subdet&0xF); 00011 } 00012 00013 void CaloGeometry::setSubdetGeometry(DetId::Detector det, int subdet, const CaloSubdetectorGeometry* geom) { 00014 int index=makeIndex(det,subdet); 00015 theGeometries_[index]=geom; 00016 } 00017 00018 00019 const CaloSubdetectorGeometry* CaloGeometry::getSubdetectorGeometry(const DetId& id) const { 00020 std::map<int, const CaloSubdetectorGeometry*>::const_iterator i=theGeometries_.find(makeIndex(id.det(),id.subdetId())); 00021 return (i==theGeometries_.end())?(0):(i->second); 00022 } 00023 00024 const CaloSubdetectorGeometry* CaloGeometry::getSubdetectorGeometry(DetId::Detector det, int subdet) const { 00025 std::map<int, const CaloSubdetectorGeometry*>::const_iterator i=theGeometries_.find(makeIndex(det,subdet)); 00026 return (i==theGeometries_.end())?(0):(i->second); 00027 } 00028 00029 static const GlobalPoint notFound(0,0,0); 00030 00031 const GlobalPoint& CaloGeometry::getPosition(const DetId& id) const { 00032 const CaloSubdetectorGeometry* geom=getSubdetectorGeometry(id); 00033 const CaloCellGeometry* cell=(geom==0)?(0):(geom->getGeometry(id)); 00034 return (cell==0)?(notFound):(cell->getPosition()); 00035 } 00036 00037 const CaloCellGeometry* CaloGeometry::getGeometry(const DetId& id) const { 00038 const CaloSubdetectorGeometry* geom=getSubdetectorGeometry(id); 00039 const CaloCellGeometry* cell=(geom==0)?(0):(geom->getGeometry(id)); 00040 return cell; 00041 } 00042 00043 bool CaloGeometry::present(const DetId& id) const { 00044 const CaloSubdetectorGeometry* geom=getSubdetectorGeometry(id); 00045 return (geom==0)?(false):(geom->present(id)); 00046 } 00047 00048 std::vector<DetId> CaloGeometry::getValidDetIds() const { 00049 std::vector<DetId> theList; 00050 std::map<int, const CaloSubdetectorGeometry*>::const_iterator i; 00051 for (i=theGeometries_.begin(); i!=theGeometries_.end(); i++) { 00052 DetId::Detector det=(DetId::Detector)(i->first>>4); 00053 int subdet=i->first&0xF; 00054 std::vector<DetId> aList=i->second->getValidDetIds(det,subdet); 00055 theList.insert(theList.end(),aList.begin(),aList.end()); 00056 } 00057 return theList; 00058 } 00059 00060 std::vector<DetId> CaloGeometry::getValidDetIds(DetId::Detector det, int subdet) const { 00061 std::vector<DetId> theList; 00062 std::map<int, const CaloSubdetectorGeometry*>::const_iterator i=theGeometries_.find(makeIndex(det,subdet)); 00063 if (i!=theGeometries_.end()) { 00064 theList=i->second->getValidDetIds(det,subdet); 00065 } 00066 return theList; 00067 } 00068 00069