CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  virtual ~HGCalTopology() { }
22 
24  virtual DetId goNorth(const DetId& id) const {
25  return changeXY(id,0,+1);
26  }
27  virtual std::vector<DetId> north(const DetId& id) const {
28  DetId nextId= goNorth(id);
29  std::vector<DetId> vNeighborsDetId;
30  if (! (nextId==DetId(0)))
31  vNeighborsDetId.push_back(DetId(nextId.rawId()));
32  return vNeighborsDetId;
33  }
34 
36  virtual DetId goSouth(const DetId& id) const {
37  return changeXY(id,0,-1);
38  }
39  virtual std::vector<DetId> south(const DetId& id) const {
40  DetId nextId= goSouth(id);
41  std::vector<DetId> vNeighborsDetId;
42  if (! (nextId==DetId(0)))
43  vNeighborsDetId.push_back(DetId(nextId.rawId()));
44  return vNeighborsDetId;
45  }
46 
48  virtual DetId goEast(const DetId& id) const {
49  return changeXY(id,+1,0);
50  }
51  virtual std::vector<DetId> east(const DetId& id) const {
52  DetId nextId=goEast(id);
53  std::vector<DetId> vNeighborsDetId;
54  if (! (nextId==DetId(0)))
55  vNeighborsDetId.push_back(DetId(nextId.rawId()));
56  return vNeighborsDetId;
57  }
58 
60  virtual DetId goWest(const DetId& id) const {
61  return changeXY(id,-1,0);
62  }
63  virtual std::vector<DetId> west(const DetId& id) const {
64  DetId nextId=goWest(id);
65  std::vector<DetId> vNeighborsDetId;
66  if (! (nextId==DetId(0)))
67  vNeighborsDetId.push_back(DetId(nextId.rawId()));
68  return vNeighborsDetId;
69  }
70 
71  virtual std::vector<DetId> up(const DetId& id) const {
72  DetId nextId=changeZ(id,+1);
73  std::vector<DetId> vNeighborsDetId;
74  if (! (nextId==DetId(0)))
75  vNeighborsDetId.push_back(DetId(nextId.rawId()));
76  return vNeighborsDetId;
77  }
78 
79  virtual std::vector<DetId> down(const DetId& id) const {
80  DetId nextId=changeZ(id,-1);
81  std::vector<DetId> vNeighborsDetId;
82  if (! (nextId==DetId(0)))
83  vNeighborsDetId.push_back(DetId(nextId.rawId()));
84  return vNeighborsDetId;
85  }
86 
88  HGCalGeometryMode geomMode() const {return mode_;}
89 
91  virtual uint32_t detId2denseId(const DetId& id) const;
92  virtual DetId denseId2detId(uint32_t denseId) const;
93  virtual uint32_t detId2denseGeomId(const DetId& id) const;
94 
96  virtual bool valid(const DetId& id) const;
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_;
139  std::vector<int> maxcells_;
140  unsigned int kSizeForDenseIndexing;
141 };
142 
143 #endif
std::vector< int > maxcells_
virtual std::vector< DetId > down(const DetId &id) const
Definition: HGCalTopology.h:79
bool validHashIndex(uint32_t ix) const
Definition: HGCalTopology.h:97
virtual std::vector< DetId > west(const DetId &id) const
Definition: HGCalTopology.h:63
unsigned int allGeomModules() const
DetId changeXY(const DetId &id, int nrStepsX, int nrStepsY) const
move the nagivator along x, y
virtual DetId goEast(const DetId &id) const
move the Topology east (positive ix)
Definition: HGCalTopology.h:48
DetId changeZ(const DetId &id, int nrStepsZ) const
move the nagivator along z
virtual std::vector< DetId > south(const DetId &id) const
Definition: HGCalTopology.h:39
virtual std::vector< DetId > up(const DetId &id) const
Definition: HGCalTopology.h:71
bool detectorType() const
virtual std::vector< DetId > north(const DetId &id) const
Definition: HGCalTopology.h:27
ForwardSubdetector
DetId offsetBy(const DetId startId, int nrStepsX, int nrStepsY) const
virtual uint32_t detId2denseId(const DetId &id) const
Dense indexing.
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
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
DetId encode(const DecodedDetId &id_) const
virtual bool valid(const DetId &id) const
Is this a valid cell id.
virtual DetId goSouth(const DetId &id) const
move the Topology south (decrement iy)
Definition: HGCalTopology.h:36
static const int subSectors_
Use subSector in square mode as wafer type in hexagon mode.
virtual DetId goNorth(const DetId &id) const
move the Topology north (increment iy)
Definition: HGCalTopology.h:24
DecodedDetId geomDenseId2decId(const uint32_t &hi) const
ForwardSubdetector subdet_
const HGCalDDDConstants & hdcons_
HGCalGeometryMode
DecodedDetId decode(const DetId &id) const
Definition: DetId.h:18
virtual DetId denseId2detId(uint32_t denseId) const
const HGCalDDDConstants & dddConstants() const
HGCalGeometryMode mode_
ForwardSubdetector subDetector() const
unsigned int totalModules() const
Definition: HGCalTopology.h:99
DetId switchZSide(const DetId startId) const
unsigned int kSizeForDenseIndexing
virtual std::vector< DetId > east(const DetId &id) const
Definition: HGCalTopology.h:51
HGCalGeometryMode geomMode() const
Geometry mode.
Definition: HGCalTopology.h:88
virtual ~HGCalTopology()
virtual destructor
Definition: HGCalTopology.h:21
virtual DetId goWest(const DetId &id) const
move the Topology west (negative ix)
Definition: HGCalTopology.h:60