Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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