Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-06-26 02:09:32

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