CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/Geometry/CaloTopology/src/CaloTopology.cc

Go to the documentation of this file.
00001 #include "Geometry/CaloTopology/interface/CaloSubdetectorTopology.h"
00002 #include "Geometry/CaloTopology/interface/CaloTopology.h"
00003 
00004 
00005 CaloTopology::CaloTopology() {
00006 }
00007 
00008 CaloTopology::~CaloTopology() 
00009 {
00010    for( TopMap::iterator i ( theTopologies_.begin() ) ;
00011         i != theTopologies_.end() ; ++i )
00012    {
00013       delete i->second ;
00014    }
00015 }
00016 
00017 int CaloTopology::makeIndex(DetId::Detector det, int subdet) const {
00018   return (int(det)<<4) | (subdet&0xF);
00019 }
00020 
00021 void CaloTopology::setSubdetTopology(DetId::Detector det, int subdet, const CaloSubdetectorTopology* geom) {
00022   int index=makeIndex(det,subdet);
00023   theTopologies_[index]=geom;
00024 }
00025 
00026 const CaloSubdetectorTopology* CaloTopology::getSubdetectorTopology(const DetId& id) const {
00027   std::map<int, const CaloSubdetectorTopology*>::const_iterator i=theTopologies_.find(makeIndex(id.det(),id.subdetId()));
00028   return (i==theTopologies_.end())?(0):(i->second);
00029 }
00030 
00031 const CaloSubdetectorTopology* CaloTopology::getSubdetectorTopology(DetId::Detector det, int subdet) const {
00032     std::map<int, const CaloSubdetectorTopology*>::const_iterator i=theTopologies_.find(makeIndex(det,subdet));
00033     return (i==theTopologies_.end())?(0):(i->second);
00034 }
00035 
00036 static const std::vector<DetId> emptyDetIdVector;
00037 
00038 std::vector<DetId> CaloTopology::east(const DetId& id) const {
00039   const CaloSubdetectorTopology* topology=getSubdetectorTopology(id);
00040   return (topology==0) ? (emptyDetIdVector):(topology->east(id));
00041 }
00042 
00043 std::vector<DetId> CaloTopology::west(const DetId& id) const {
00044   const CaloSubdetectorTopology* topology=getSubdetectorTopology(id);
00045   return (topology==0) ? (emptyDetIdVector):(topology->west(id));
00046 }
00047 
00048 std::vector<DetId> CaloTopology::north(const DetId& id) const {
00049   const CaloSubdetectorTopology* topology=getSubdetectorTopology(id);
00050   return (topology==0) ? (emptyDetIdVector):(topology->north(id));
00051 }
00052 
00053 std::vector<DetId> CaloTopology::south(const DetId& id) const {
00054   const CaloSubdetectorTopology* topology=getSubdetectorTopology(id);
00055   return (topology==0) ? (emptyDetIdVector):(topology->south(id));
00056 }
00057 
00058 std::vector<DetId> CaloTopology::up(const DetId& id) const {
00059   const CaloSubdetectorTopology* topology=getSubdetectorTopology(id);
00060   return (topology==0) ? (emptyDetIdVector):(topology->up(id));
00061 }
00062 
00063 std::vector<DetId> CaloTopology::down(const DetId& id) const {
00064     const CaloSubdetectorTopology* topology=getSubdetectorTopology(id);
00065     return (topology==0) ? (emptyDetIdVector):(topology->down(id));
00066 }
00067 
00068 std::vector<DetId> CaloTopology::getNeighbours(const DetId& id,const CaloDirection& dir) const {
00069     const CaloSubdetectorTopology* topology=getSubdetectorTopology(id);
00070     return (topology==0) ? (emptyDetIdVector):(topology->getNeighbours(id,dir));
00071 }
00072 
00073 std::vector<DetId> CaloTopology::getWindow(const DetId& id, const int& northSouthSize, const int& eastWestSize) const {
00074     const CaloSubdetectorTopology* topology=getSubdetectorTopology(id);
00075     return (topology==0) ? (emptyDetIdVector):(topology->getWindow(id,northSouthSize, eastWestSize));
00076 }
00077 
00078 std::vector<DetId> CaloTopology::getAllNeighbours(const DetId& id) const {
00079     const CaloSubdetectorTopology* topology=getSubdetectorTopology(id);
00080     return (topology==0) ? (emptyDetIdVector):(topology->getAllNeighbours(id));
00081 }
00082 
00083 bool CaloTopology::valid(const DetId& id) const {
00084   const CaloSubdetectorTopology* geom=getSubdetectorTopology(id);
00085   return (geom==0)?(false):(geom->valid(id));
00086 }
00087