Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-07 04:36:28

0001 #ifndef GEOMETRY_CALOTOPOLOGY_ECALENDCAPTOPOLOGY_H
0002 #define GEOMETRY_CALOTOPOLOGY_ECALENDCAPTOPOLOGY_H 1
0003 
0004 #include "DataFormats/EcalDetId/interface/EEDetId.h"
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 #include "Geometry/CaloTopology/interface/CaloSubdetectorTopology.h"
0007 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0008 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
0009 #include <utility>
0010 #include <vector>
0011 #include <iostream>
0012 
0013 class EcalEndcapTopology final : public CaloSubdetectorTopology {
0014 public:
0015   /// create a new Topology
0016   EcalEndcapTopology() : theGeom_(nullptr) {}
0017 
0018   /// virtual destructor
0019   ~EcalEndcapTopology() override {}
0020 
0021   /// create a new Topology from geometry
0022   EcalEndcapTopology(CaloGeometry const& theGeom) {
0023     theGeom_ = theGeom.getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
0024   }
0025 
0026   /// move the Topology north (increment iy)
0027   DetId goNorth(const DetId& id) const override { return incrementIy(EEDetId(id)); }
0028   std::vector<DetId> north(const DetId& id) const override {
0029     EEDetId nextId = goNorth(id);
0030     std::vector<DetId> vNeighborsDetId;
0031     if (!(nextId == EEDetId(0)))
0032       vNeighborsDetId.emplace_back(DetId(nextId.rawId()));
0033     return vNeighborsDetId;
0034   }
0035 
0036   /// move the Topology south (decrement iy)
0037   DetId goSouth(const DetId& id) const override { return decrementIy(EEDetId(id)); }
0038   std::vector<DetId> south(const DetId& id) const override {
0039     EEDetId nextId = goSouth(id);
0040     std::vector<DetId> vNeighborsDetId;
0041     if (!(nextId == EEDetId(0)))
0042       vNeighborsDetId.emplace_back(DetId(nextId.rawId()));
0043     return vNeighborsDetId;
0044   }
0045 
0046   /// move the Topology east (positive ix)
0047   DetId goEast(const DetId& id) const override { return incrementIx(EEDetId(id)); }
0048   std::vector<DetId> east(const DetId& id) const override {
0049     EEDetId nextId = goEast(id);
0050     std::vector<DetId> vNeighborsDetId;
0051     if (!(nextId == EEDetId(0)))
0052       vNeighborsDetId.emplace_back(DetId(nextId.rawId()));
0053     return vNeighborsDetId;
0054   }
0055 
0056   /// move the Topology west (negative ix)
0057   DetId goWest(const DetId& id) const override { return decrementIx(EEDetId(id)); }
0058   std::vector<DetId> west(const DetId& id) const override {
0059     EEDetId nextId = goWest(id);
0060     std::vector<DetId> vNeighborsDetId;
0061     if (!(nextId == EEDetId(0)))
0062       vNeighborsDetId.emplace_back(DetId(nextId.rawId()));
0063     return vNeighborsDetId;
0064   }
0065 
0066   std::vector<DetId> up(const DetId& /*id*/) const override {
0067     edm::LogVerbatim("CaloTopology") << "EcalBarrelTopology::up() not yet implemented";
0068     std::vector<DetId> vNeighborsDetId;
0069     return vNeighborsDetId;
0070   }
0071 
0072   std::vector<DetId> down(const DetId& /*id*/) const override {
0073     edm::LogVerbatim("CaloTopology") << "EcalBarrelTopology::down() not yet implemented";
0074     std::vector<DetId> vNeighborsDetId;
0075     return vNeighborsDetId;
0076   }
0077 
0078 private:
0079   /// move the nagivator to larger ix
0080   EEDetId incrementIx(const EEDetId& id) const;
0081 
0082   /// move the nagivator to smaller ix
0083   EEDetId decrementIx(const EEDetId& id) const;
0084 
0085   /// move the nagivator to larger iy
0086   EEDetId incrementIy(const EEDetId& id) const;
0087 
0088   /// move the nagivator to smaller iy
0089   EEDetId decrementIy(const EEDetId& id) const;
0090 
0091   const CaloSubdetectorGeometry* theGeom_;
0092 };
0093 
0094 #endif