CMS 3D CMS Logo

HGCalTopology.h
Go to the documentation of this file.
1 #ifndef Geometry_CaloTopology_HGCalTopology_h
2 #define Geometry_CaloTopology_HGCalTopology_h 1
3 
11 #include <vector>
12 #include <iostream>
13 
15 
16 public:
18  HGCalTopology(const HGCalDDDConstants& hdcons, ForwardSubdetector subdet, bool halfChamber);
19 
21  ~HGCalTopology() override { }
22 
24  DetId goNorth(const DetId& id) const override {
25  return changeXY(id,0,+1);
26  }
27  std::vector<DetId> north(const DetId& id) const override {
28  DetId nextId= goNorth(id);
29  std::vector<DetId> vNeighborsDetId;
30  if (! (nextId==DetId(0)))
31  vNeighborsDetId.emplace_back(nextId);
32  return vNeighborsDetId;
33  }
34 
36  DetId goSouth(const DetId& id) const override {
37  return changeXY(id,0,-1);
38  }
39  std::vector<DetId> south(const DetId& id) const override {
40  DetId nextId= goSouth(id);
41  std::vector<DetId> vNeighborsDetId;
42  if (! (nextId==DetId(0)))
43  vNeighborsDetId.emplace_back(nextId);
44  return vNeighborsDetId;
45  }
46 
48  DetId goEast(const DetId& id) const override {
49  return changeXY(id,+1,0);
50  }
51  std::vector<DetId> east(const DetId& id) const override {
52  DetId nextId=goEast(id);
53  std::vector<DetId> vNeighborsDetId;
54  if (! (nextId==DetId(0)))
55  vNeighborsDetId.emplace_back(nextId);
56  return vNeighborsDetId;
57  }
58 
60  DetId goWest(const DetId& id) const override {
61  return changeXY(id,-1,0);
62  }
63  std::vector<DetId> west(const DetId& id) const override {
64  DetId nextId=goWest(id);
65  std::vector<DetId> vNeighborsDetId;
66  if (! (nextId==DetId(0)))
67  vNeighborsDetId.emplace_back(nextId);
68  return vNeighborsDetId;
69  }
70 
71  std::vector<DetId> up(const DetId& id) const override {
72  DetId nextId=changeZ(id,+1);
73  std::vector<DetId> vNeighborsDetId;
74  if (! (nextId==DetId(0)))
75  vNeighborsDetId.emplace_back(nextId);
76  return vNeighborsDetId;
77  }
78 
79  std::vector<DetId> down(const DetId& id) const override {
80  DetId nextId=changeZ(id,-1);
81  std::vector<DetId> vNeighborsDetId;
82  if (! (nextId==DetId(0)))
83  vNeighborsDetId.emplace_back(nextId);
84  return vNeighborsDetId;
85  }
86 
89 
91  uint32_t detId2denseId(const DetId& id) const override;
92  DetId denseId2detId(uint32_t denseId) const override;
93  virtual uint32_t detId2denseGeomId(const DetId& id) const;
94 
96  bool valid(const DetId& id) const override;
97  bool validHashIndex(uint32_t ix) const {return (ix < kSizeForDenseIndexing);}
98 
99  unsigned int totalModules() const {return kSizeForDenseIndexing;}
100  unsigned int totalGeomModules() const {return (unsigned int)(2*kHGeomHalf_);}
101  unsigned int allGeomModules() const;
102 
103  const HGCalDDDConstants& dddConstants () const {return hdcons_;}
104 
107  DetId offsetBy(const DetId startId, int nrStepsX, int nrStepsY) const;
108  DetId switchZSide(const DetId startId) const;
109 
111  static const int subSectors_ = 2;
112 
113  struct DecodedDetId {
114  DecodedDetId() : iCell(0), iLay(0), iSec(0), iSubSec(0), zside(0),
115  subdet(0) {}
117  };
118 
119  DecodedDetId geomDenseId2decId(const uint32_t& hi) const;
120  DecodedDetId decode(const DetId& id) const ;
121  DetId encode(const DecodedDetId& id_) const ;
122 
124  bool detectorType() const { return half_;}
125 private:
126 
128  DetId changeXY(const DetId& id, int nrStepsX, int nrStepsY) const ;
129 
131  DetId changeZ(const DetId& id, int nrStepsZ) const ;
132 
135 
137  bool half_;
140  std::vector<int> maxcells_;
141  unsigned int kSizeForDenseIndexing;
142 };
143 
144 #endif
HGCalGeometryMode::GeometryMode geomMode() const
Geometry mode.
Definition: HGCalTopology.h:88
std::vector< int > maxcells_
bool validHashIndex(uint32_t ix) const
Definition: HGCalTopology.h:97
unsigned int allGeomModules() const
DetId changeXY(const DetId &id, int nrStepsX, int nrStepsY) const
move the nagivator along x, y
DetId changeZ(const DetId &id, int nrStepsZ) const
move the nagivator along z
HGCalGeometryMode::GeometryMode mode_
DetId goNorth(const DetId &id) const override
move the Topology north (increment iy)
Definition: HGCalTopology.h:24
bool detectorType() const
std::vector< DetId > west(const DetId &id) const override
Definition: HGCalTopology.h:63
DetId denseId2detId(uint32_t denseId) const override
DetId goEast(const DetId &id) const override
move the Topology east (positive ix)
Definition: HGCalTopology.h:48
ForwardSubdetector
DetId offsetBy(const DetId startId, int nrStepsX, int nrStepsY) const
HGCalTopology(const HGCalDDDConstants &hdcons, ForwardSubdetector subdet, bool halfChamber)
create a new Topology
Definition: HGCalTopology.cc:6
unsigned int totalGeomModules() const
virtual uint32_t detId2denseGeomId(const DetId &id) const
~HGCalTopology() override
virtual destructor
Definition: HGCalTopology.h:21
std::vector< DetId > east(const DetId &id) const override
Definition: HGCalTopology.h:51
DetId encode(const DecodedDetId &id_) const
std::vector< DetId > north(const DetId &id) const override
Definition: HGCalTopology.h:27
static const int subSectors_
Use subSector in square mode as wafer type in hexagon mode.
uint32_t detId2denseId(const DetId &id) const override
Dense indexing.
DecodedDetId geomDenseId2decId(const uint32_t &hi) const
ForwardSubdetector subdet_
const HGCalDDDConstants & hdcons_
DecodedDetId decode(const DetId &id) const
std::vector< DetId > up(const DetId &id) const override
Definition: HGCalTopology.h:71
Definition: DetId.h:18
const HGCalDDDConstants & dddConstants() const
ForwardSubdetector subDetector() const
std::vector< DetId > south(const DetId &id) const override
Definition: HGCalTopology.h:39
unsigned int totalModules() const
Definition: HGCalTopology.h:99
DetId switchZSide(const DetId startId) const
DetId goSouth(const DetId &id) const override
move the Topology south (decrement iy)
Definition: HGCalTopology.h:36
std::vector< DetId > down(const DetId &id) const override
Definition: HGCalTopology.h:79
DetId goWest(const DetId &id) const override
move the Topology west (negative ix)
Definition: HGCalTopology.h:60
unsigned int kSizeForDenseIndexing
bool valid(const DetId &id) const override
Is this a valid cell id.