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 
9 #include <vector>
10 #include <iostream>
11 
13 
14 public:
16  HGCalTopology(const HGCalDDDConstants& hdcons, int subdet);
17 
19  ~HGCalTopology() override { }
20 
22  DetId goNorth(const DetId& id) const override {
23  return changeXY(id,0,+1);
24  }
25  std::vector<DetId> north(const DetId& id) const override {
26  DetId nextId= goNorth(id);
27  std::vector<DetId> vNeighborsDetId;
28  if (! (nextId==DetId(0)))
29  vNeighborsDetId.emplace_back(nextId);
30  return vNeighborsDetId;
31  }
32 
34  DetId goSouth(const DetId& id) const override {
35  return changeXY(id,0,-1);
36  }
37  std::vector<DetId> south(const DetId& id) const override {
38  DetId nextId= goSouth(id);
39  std::vector<DetId> vNeighborsDetId;
40  if (! (nextId==DetId(0)))
41  vNeighborsDetId.emplace_back(nextId);
42  return vNeighborsDetId;
43  }
44 
46  DetId goEast(const DetId& id) const override {
47  return changeXY(id,+1,0);
48  }
49  std::vector<DetId> east(const DetId& id) const override {
50  DetId nextId=goEast(id);
51  std::vector<DetId> vNeighborsDetId;
52  if (! (nextId==DetId(0)))
53  vNeighborsDetId.emplace_back(nextId);
54  return vNeighborsDetId;
55  }
56 
58  DetId goWest(const DetId& id) const override {
59  return changeXY(id,-1,0);
60  }
61  std::vector<DetId> west(const DetId& id) const override {
62  DetId nextId=goWest(id);
63  std::vector<DetId> vNeighborsDetId;
64  if (! (nextId==DetId(0)))
65  vNeighborsDetId.emplace_back(nextId);
66  return vNeighborsDetId;
67  }
68 
69  std::vector<DetId> up(const DetId& id) const override {
70  DetId nextId=changeZ(id,+1);
71  std::vector<DetId> vNeighborsDetId;
72  if (! (nextId==DetId(0)))
73  vNeighborsDetId.emplace_back(nextId);
74  return vNeighborsDetId;
75  }
76 
77  std::vector<DetId> down(const DetId& id) const override {
78  DetId nextId=changeZ(id,-1);
79  std::vector<DetId> vNeighborsDetId;
80  if (! (nextId==DetId(0)))
81  vNeighborsDetId.emplace_back(nextId);
82  return vNeighborsDetId;
83  }
84 
87 
89  uint32_t detId2denseId(const DetId& id) const override;
90  DetId denseId2detId(uint32_t denseId) const override;
91  virtual uint32_t detId2denseGeomId(const DetId& id) const;
92 
94  bool valid(const DetId& id) const override;
95  bool validHashIndex(uint32_t ix) const {return (ix < kSizeForDenseIndexing);}
96 
97  unsigned int totalModules() const {return kSizeForDenseIndexing;}
98  unsigned int totalGeomModules() const {return (unsigned int)(2*kHGeomHalf_);}
99  unsigned int allGeomModules() const;
100 
101  const HGCalDDDConstants& dddConstants () const {return hdcons_;}
102 
105  DetId offsetBy(const DetId startId, int nrStepsX, int nrStepsY) const;
106  DetId switchZSide(const DetId startId) const;
107 
109  static const int subSectors_ = 2;
110 
111  struct DecodedDetId {
112  DecodedDetId() : iCell1(0), iCell2(0), iLay(0), iSec1(0), iSec2(0),
113  iType(0), zSide(0), det(0) {}
115  };
116 
117  DecodedDetId geomDenseId2decId(const uint32_t& hi) const;
118  DecodedDetId decode(const DetId& id) const ;
119  DetId encode(const DecodedDetId& id_) const ;
120 
121  DetId::Detector detector() const { return det_;}
123  bool detectorType() const { return false;}
124  bool isHFNose() const {
125  return (((det_ == DetId::Forward) &&
126  (subdet_ == ForwardSubdetector::HFNose)) ? true : false);
127  }
128 private:
129 
131  DetId changeXY(const DetId& id, int nrStepsX, int nrStepsY) const ;
132 
134  DetId changeZ(const DetId& id, int nrStepsZ) const ;
135 
138 
144  unsigned int kSizeForDenseIndexing;
145 };
146 
147 #endif
HGCalGeometryMode::GeometryMode geomMode() const
Geometry mode.
Definition: HGCalTopology.h:86
bool validHashIndex(uint32_t ix) const
Definition: HGCalTopology.h:95
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:22
bool detectorType() const
std::vector< DetId > west(const DetId &id) const override
Definition: HGCalTopology.h:61
DetId denseId2detId(uint32_t denseId) const override
DetId goEast(const DetId &id) const override
move the Topology east (positive ix)
Definition: HGCalTopology.h:46
ForwardSubdetector
DetId::Detector det_
DetId offsetBy(const DetId startId, int nrStepsX, int nrStepsY) const
unsigned int totalGeomModules() const
Definition: HGCalTopology.h:98
virtual uint32_t detId2denseGeomId(const DetId &id) const
~HGCalTopology() override
virtual destructor
Definition: HGCalTopology.h:19
std::vector< DetId > east(const DetId &id) const override
Definition: HGCalTopology.h:49
DetId encode(const DecodedDetId &id_) const
std::vector< DetId > north(const DetId &id) const override
Definition: HGCalTopology.h:25
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_
bool isHFNose() const
DecodedDetId decode(const DetId &id) const
std::vector< DetId > up(const DetId &id) const override
Definition: HGCalTopology.h:69
Definition: DetId.h:18
const HGCalDDDConstants & dddConstants() const
Detector
Definition: DetId.h:26
ForwardSubdetector subDetector() const
std::vector< DetId > south(const DetId &id) const override
Definition: HGCalTopology.h:37
unsigned int totalModules() const
Definition: HGCalTopology.h:97
DetId switchZSide(const DetId startId) const
DetId goSouth(const DetId &id) const override
move the Topology south (decrement iy)
Definition: HGCalTopology.h:34
std::vector< DetId > down(const DetId &id) const override
Definition: HGCalTopology.h:77
DetId goWest(const DetId &id) const override
move the Topology west (negative ix)
Definition: HGCalTopology.h:58
unsigned int kSizeForDenseIndexing
bool valid(const DetId &id) const override
Is this a valid cell id.
DetId::Detector detector() const
HGCalTopology(const HGCalDDDConstants &hdcons, int subdet)
create a new Topology