File indexing completed on 2024-04-06 12:14:18
0001 #ifndef Geometry_CaloTopology_HGCalTBTopology_h
0002 #define Geometry_CaloTopology_HGCalTBTopology_h 1
0003
0004 #include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h"
0005 #include "DataFormats/DetId/interface/DetId.h"
0006 #include "Geometry/CaloTopology/interface/CaloSubdetectorTopology.h"
0007 #include "Geometry/HGCalCommonData/interface/HGCalGeometryMode.h"
0008 #include "Geometry/HGCalTBCommonData/interface/HGCalTBDDDConstants.h"
0009 #include <vector>
0010 #include <iostream>
0011
0012 class HGCalTBTopology : public CaloSubdetectorTopology {
0013 public:
0014
0015 HGCalTBTopology(const HGCalTBDDDConstants* hdcons, int subdet);
0016
0017
0018 ~HGCalTBTopology() override;
0019
0020
0021 DetId goNorth(const DetId& id) const override { return changeXY(id, 0, +1); }
0022 std::vector<DetId> north(const DetId& id) const override {
0023 DetId nextId = goNorth(id);
0024 std::vector<DetId> vNeighborsDetId;
0025 if (!(nextId == DetId(0)))
0026 vNeighborsDetId.emplace_back(nextId);
0027 return vNeighborsDetId;
0028 }
0029
0030
0031 DetId goSouth(const DetId& id) const override { return changeXY(id, 0, -1); }
0032 std::vector<DetId> south(const DetId& id) const override {
0033 DetId nextId = goSouth(id);
0034 std::vector<DetId> vNeighborsDetId;
0035 if (!(nextId == DetId(0)))
0036 vNeighborsDetId.emplace_back(nextId);
0037 return vNeighborsDetId;
0038 }
0039
0040
0041 DetId goEast(const DetId& id) const override { return changeXY(id, +1, 0); }
0042 std::vector<DetId> east(const DetId& id) const override {
0043 DetId nextId = goEast(id);
0044 std::vector<DetId> vNeighborsDetId;
0045 if (!(nextId == DetId(0)))
0046 vNeighborsDetId.emplace_back(nextId);
0047 return vNeighborsDetId;
0048 }
0049
0050
0051 DetId goWest(const DetId& id) const override { return changeXY(id, -1, 0); }
0052 std::vector<DetId> west(const DetId& id) const override {
0053 DetId nextId = goWest(id);
0054 std::vector<DetId> vNeighborsDetId;
0055 if (!(nextId == DetId(0)))
0056 vNeighborsDetId.emplace_back(nextId);
0057 return vNeighborsDetId;
0058 }
0059
0060 std::vector<DetId> up(const DetId& id) const override {
0061 DetId nextId = changeZ(id, +1);
0062 std::vector<DetId> vNeighborsDetId;
0063 if (!(nextId == DetId(0)))
0064 vNeighborsDetId.emplace_back(nextId);
0065 return vNeighborsDetId;
0066 }
0067
0068 std::vector<DetId> down(const DetId& id) const override {
0069 DetId nextId = changeZ(id, -1);
0070 std::vector<DetId> vNeighborsDetId;
0071 if (!(nextId == DetId(0)))
0072 vNeighborsDetId.emplace_back(nextId);
0073 return vNeighborsDetId;
0074 }
0075
0076 std::vector<DetId> neighbors(DetId id) const;
0077
0078
0079 HGCalGeometryMode::GeometryMode geomMode() const { return mode_; }
0080
0081 unsigned int totalModules() const { return kSizeForDenseIndexing; }
0082 unsigned int totalGeomModules() const { return (unsigned int)(2 * kHGeomHalf_); }
0083 unsigned int allGeomModules() const;
0084
0085
0086 DetId denseId2detId(uint32_t denseId) const override;
0087 uint32_t detId2denseId(const DetId& id) const override;
0088 virtual uint32_t detId2denseGeomId(const DetId& id) const;
0089
0090
0091 bool valid(const DetId& id) const override;
0092 bool validHashIndex(uint32_t ix) const { return (ix < kSizeForDenseIndexing); }
0093
0094 const HGCalTBDDDConstants& dddConstants() const { return *hdcons_; }
0095
0096
0097
0098 DetId offsetBy(const DetId startId, int nrStepsX, int nrStepsY) const;
0099 DetId switchZSide(const DetId startId) const;
0100
0101
0102 static const int subSectors_ = 2;
0103
0104 struct DecodedDetId {
0105 DecodedDetId() : iCell1(0), iCell2(0), iLay(0), iSec1(0), iSec2(0), iType(0), zSide(0), det(0) {}
0106 int iCell1, iCell2, iLay, iSec1, iSec2, iType, zSide, det;
0107 };
0108
0109 DecodedDetId geomDenseId2decId(const uint32_t& hi) const;
0110 DecodedDetId decode(const DetId& id) const;
0111 DetId encode(const DecodedDetId& id_) const;
0112
0113 DetId::Detector detector() const { return det_; }
0114 ForwardSubdetector subDetector() const { return subdet_; }
0115 bool detectorType() const { return false; }
0116
0117 private:
0118
0119 DetId changeXY(const DetId& id, int nrStepsX, int nrStepsY) const;
0120
0121
0122 DetId changeZ(const DetId& id, int nrStepsZ) const;
0123
0124 const HGCalTBDDDConstants* hdcons_;
0125 HGCalGeometryMode::GeometryMode mode_;
0126
0127 DetId::Detector det_;
0128 ForwardSubdetector subdet_;
0129 int sectors_, layers_, cells_, types_, firstLay_;
0130 int kHGhalf_, kHGeomHalf_, kHGhalfType_;
0131 unsigned int kSizeForDenseIndexing;
0132 };
0133
0134 #endif