Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:14:18

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