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 
9 #include <vector>
10 #include <iostream>
11 
13 
14 public:
16  HGCalTopology(const HGCalDDDConstants& hdcons, ForwardSubdetector subdet, bool halfChamber);
17 
19  virtual ~HGCalTopology() { }
20 
22  virtual DetId goNorth(const DetId& id) const {
23  return changeXY(id,0,+1);
24  }
25  virtual std::vector<DetId> north(const DetId& id) const {
26  DetId nextId= goNorth(id);
27  std::vector<DetId> vNeighborsDetId;
28  if (! (nextId==DetId(0)))
29  vNeighborsDetId.push_back(DetId(nextId.rawId()));
30  return vNeighborsDetId;
31  }
32 
34  virtual DetId goSouth(const DetId& id) const {
35  return changeXY(id,0,-1);
36  }
37  virtual std::vector<DetId> south(const DetId& id) const {
38  DetId nextId= goSouth(id);
39  std::vector<DetId> vNeighborsDetId;
40  if (! (nextId==DetId(0)))
41  vNeighborsDetId.push_back(DetId(nextId.rawId()));
42  return vNeighborsDetId;
43  }
44 
46  virtual DetId goEast(const DetId& id) const {
47  return changeXY(id,+1,0);
48  }
49  virtual std::vector<DetId> east(const DetId& id) const {
50  DetId nextId=goEast(id);
51  std::vector<DetId> vNeighborsDetId;
52  if (! (nextId==DetId(0)))
53  vNeighborsDetId.push_back(DetId(nextId.rawId()));
54  return vNeighborsDetId;
55  }
56 
58  virtual DetId goWest(const DetId& id) const {
59  return changeXY(id,-1,0);
60  }
61  virtual std::vector<DetId> west(const DetId& id) const {
62  DetId nextId=goWest(id);
63  std::vector<DetId> vNeighborsDetId;
64  if (! (nextId==DetId(0)))
65  vNeighborsDetId.push_back(DetId(nextId.rawId()));
66  return vNeighborsDetId;
67  }
68 
69  virtual std::vector<DetId> up(const DetId& id) const {
70  DetId nextId=changeZ(id,+1);
71  std::vector<DetId> vNeighborsDetId;
72  if (! (nextId==DetId(0)))
73  vNeighborsDetId.push_back(DetId(nextId.rawId()));
74  return vNeighborsDetId;
75  }
76 
77  virtual std::vector<DetId> down(const DetId& id) const {
78  DetId nextId=changeZ(id,-1);
79  std::vector<DetId> vNeighborsDetId;
80  if (! (nextId==DetId(0)))
81  vNeighborsDetId.push_back(DetId(nextId.rawId()));
82  return vNeighborsDetId;
83  }
84 
86  virtual uint32_t detId2denseId(const DetId& id) const;
87  virtual DetId denseId2detId(uint32_t denseId) const;
88  virtual uint32_t detId2denseGeomId(const DetId& id) const;
89 
91  virtual bool valid(const DetId& id) const;
92  bool validHashIndex(uint32_t ix) const {return (ix < kSizeForDenseIndexing);}
93 
94  unsigned int totalModules() const {return kSizeForDenseIndexing;}
95  unsigned int totalGeomModules() const {return (unsigned int)(2*kHGeomHalf_);}
96 
97  const HGCalDDDConstants& dddConstants () const {return hdcons_;}
98 
101  DetId offsetBy(const DetId startId, int nrStepsX, int nrStepsY) const;
102  DetId switchZSide(const DetId startId) const;
103 
104  static const int subSectors_ = 2;
105 
106  struct DecodedDetId {
107  DecodedDetId() : iCell(0), iLay(0), iSec(0), iSubSec(0), zside(0),
108  subdet(0) {}
110  };
111 
112  DecodedDetId geomDenseId2decId(const uint32_t& hi) const;
113  DecodedDetId decode(const DetId& id) const ;
114  DetId encode(const DecodedDetId& id_) const ;
115 
117  bool detectorType() const { return half_;}
118 private:
119 
121  DetId changeXY(const DetId& id, int nrStepsX, int nrStepsY) const ;
122 
124  DetId changeZ(const DetId& id, int nrStepsZ) const ;
125 
128  bool half_;
130  std::vector<int> maxcells_;
131  unsigned int kSizeForDenseIndexing;
132 };
133 
134 #endif
std::vector< int > maxcells_
virtual std::vector< DetId > down(const DetId &id) const
Definition: HGCalTopology.h:77
bool validHashIndex(uint32_t ix) const
Definition: HGCalTopology.h:92
virtual std::vector< DetId > west(const DetId &id) const
Definition: HGCalTopology.h:61
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:46
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:37
virtual std::vector< DetId > up(const DetId &id) const
Definition: HGCalTopology.h:69
bool detectorType() const
virtual std::vector< DetId > north(const DetId &id) const
Definition: HGCalTopology.h:25
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
Definition: HGCalTopology.h:95
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:34
static const int subSectors_
virtual DetId goNorth(const DetId &id) const
move the Topology north (increment iy)
Definition: HGCalTopology.h:22
DecodedDetId geomDenseId2decId(const uint32_t &hi) const
ForwardSubdetector subdet_
const HGCalDDDConstants & hdcons_
DecodedDetId decode(const DetId &id) const
Definition: DetId.h:18
virtual DetId denseId2detId(uint32_t denseId) const
const HGCalDDDConstants & dddConstants() const
Definition: HGCalTopology.h:97
ForwardSubdetector subDetector() const
unsigned int totalModules() const
Definition: HGCalTopology.h:94
DetId switchZSide(const DetId startId) const
unsigned int kSizeForDenseIndexing
virtual std::vector< DetId > east(const DetId &id) const
Definition: HGCalTopology.h:49
virtual ~HGCalTopology()
virtual destructor
Definition: HGCalTopology.h:19
virtual DetId goWest(const DetId &id) const
move the Topology west (negative ix)
Definition: HGCalTopology.h:58