Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:07:42

0001 #include "Geometry/CaloTopology/interface/CaloSubdetectorTopology.h"
0002 #include "Geometry/CaloTopology/interface/CaloTopology.h"
0003 
0004 CaloTopology::CaloTopology() {}
0005 
0006 CaloTopology::~CaloTopology() = default;
0007 
0008 int CaloTopology::makeIndex(DetId::Detector det, int subdet) const { return (int(det) << 4) | (subdet & 0xF); }
0009 
0010 void CaloTopology::setSubdetTopology(DetId::Detector det,
0011                                      int subdet,
0012                                      std::unique_ptr<const CaloSubdetectorTopology> geom) {
0013   int index = makeIndex(det, subdet);
0014   theTopologies_[index] = std::move(geom);
0015 }
0016 
0017 const CaloSubdetectorTopology* CaloTopology::getSubdetectorTopology(const DetId& id) const {
0018   auto i = theTopologies_.find(makeIndex(id.det(), id.subdetId()));
0019   return (i == theTopologies_.end()) ? (nullptr) : (i->second.get());
0020 }
0021 
0022 const CaloSubdetectorTopology* CaloTopology::getSubdetectorTopology(DetId::Detector det, int subdet) const {
0023   auto i = theTopologies_.find(makeIndex(det, subdet));
0024   return (i == theTopologies_.end()) ? (nullptr) : (i->second.get());
0025 }
0026 
0027 static const std::vector<DetId> emptyDetIdVector;
0028 
0029 std::vector<DetId> CaloTopology::east(const DetId& id) const {
0030   const CaloSubdetectorTopology* topology = getSubdetectorTopology(id);
0031   return (topology == nullptr) ? (emptyDetIdVector) : (topology->east(id));
0032 }
0033 
0034 std::vector<DetId> CaloTopology::west(const DetId& id) const {
0035   const CaloSubdetectorTopology* topology = getSubdetectorTopology(id);
0036   return (topology == nullptr) ? (emptyDetIdVector) : (topology->west(id));
0037 }
0038 
0039 std::vector<DetId> CaloTopology::north(const DetId& id) const {
0040   const CaloSubdetectorTopology* topology = getSubdetectorTopology(id);
0041   return (topology == nullptr) ? (emptyDetIdVector) : (topology->north(id));
0042 }
0043 
0044 std::vector<DetId> CaloTopology::south(const DetId& id) const {
0045   const CaloSubdetectorTopology* topology = getSubdetectorTopology(id);
0046   return (topology == nullptr) ? (emptyDetIdVector) : (topology->south(id));
0047 }
0048 
0049 std::vector<DetId> CaloTopology::up(const DetId& id) const {
0050   const CaloSubdetectorTopology* topology = getSubdetectorTopology(id);
0051   return (topology == nullptr) ? (emptyDetIdVector) : (topology->up(id));
0052 }
0053 
0054 std::vector<DetId> CaloTopology::down(const DetId& id) const {
0055   const CaloSubdetectorTopology* topology = getSubdetectorTopology(id);
0056   return (topology == nullptr) ? (emptyDetIdVector) : (topology->down(id));
0057 }
0058 
0059 std::vector<DetId> CaloTopology::getNeighbours(const DetId& id, const CaloDirection& dir) const {
0060   const CaloSubdetectorTopology* topology = getSubdetectorTopology(id);
0061   return (topology == nullptr) ? (emptyDetIdVector) : (topology->getNeighbours(id, dir));
0062 }
0063 
0064 std::vector<DetId> CaloTopology::getWindow(const DetId& id, const int& northSouthSize, const int& eastWestSize) const {
0065   const CaloSubdetectorTopology* topology = getSubdetectorTopology(id);
0066   return (topology == nullptr) ? (emptyDetIdVector) : (topology->getWindow(id, northSouthSize, eastWestSize));
0067 }
0068 
0069 std::vector<DetId> CaloTopology::getAllNeighbours(const DetId& id) const {
0070   const CaloSubdetectorTopology* topology = getSubdetectorTopology(id);
0071   return (topology == nullptr) ? (emptyDetIdVector) : (topology->getAllNeighbours(id));
0072 }
0073 
0074 bool CaloTopology::valid(const DetId& id) const {
0075   const CaloSubdetectorTopology* geom = getSubdetectorTopology(id);
0076   return (geom == nullptr) ? (false) : (geom->valid(id));
0077 }