CMS 3D CMS Logo

HGCalTriggerGeometryGenericMapping.h
Go to the documentation of this file.
1 #ifndef __L1Trigger_L1THGCal_HGCalTriggerGeometryGenericMapping_h__
2 #define __L1Trigger_L1THGCal_HGCalTriggerGeometryGenericMapping_h__
3 
5 
6 /*******
7  *
8  * class: HGCalTriggerGeometryGenericMapping
9  * author: L.Gray (FNAL)
10  * date: 26 July, 2015
11  *
12  * This class is the base class for all HGCal trigger geometry definitions.
13  * Typically this is just a ganging of cells and nearest-neighbour relationships.
14  *
15  * Classes for TriggerCells and Modules are defined. They are containers for
16  * maps relating modules to modules and trigger cells to trigger cells and
17  * raw HGC cells.
18  *
19  * It is up to the user of the class to define what these mappings are through the
20  * initialize() function. This function takes the full HGC geometry as input and
21  * creates all the necessary maps for navigating the trigger system. All of the
22  * containers for parts of the map are available through protected members of the base
23  * class.
24  *
25  * All unsigned ints used here are DetIds, or will become them once we sort out the
26  * full nature of the trigger detids.
27  *******/
28 
30 
32  class TriggerCell {
33  public:
34  typedef std::unordered_set<unsigned> list_type;
35 
37  unsigned tc_id, unsigned mod_id, const GlobalPoint& pos, const list_type& neighbs, const list_type& comps)
38  : trigger_cell_id_(tc_id), module_id_(mod_id), position_(pos), neighbours_(neighbs), components_(comps) {}
40 
41  unsigned triggerCellId() const { return trigger_cell_id_; }
42  unsigned moduleId() const { return module_id_; }
43 
44  bool containsCell(const unsigned cell) const { return (components_.find(cell) != components_.end()); }
45 
46  const GlobalPoint& position() const { return position_; }
47 
48  const std::unordered_set<unsigned>& neighbours() const { return neighbours_; }
49  const std::unordered_set<unsigned>& components() const { return components_; }
50 
51  private:
52  unsigned trigger_cell_id_; // the ID of this trigger cell
53  unsigned module_id_; // module this TC belongs to
55  list_type neighbours_; // neighbouring trigger cells
56  list_type components_; // contained HGC cells
57  };
58 
59  class Module {
60  public:
61  typedef std::unordered_set<unsigned> list_type;
62  typedef std::unordered_multimap<unsigned, unsigned> tc_map_type;
63 
64  Module(unsigned mod_id,
65  const GlobalPoint& pos,
66  const list_type& neighbs,
67  const list_type& comps,
68  const tc_map_type& tc_comps)
69  : module_id_(mod_id), position_(pos), neighbours_(neighbs), components_(comps), tc_components_(tc_comps) {}
70  ~Module() {}
71 
72  unsigned moduleId() const { return module_id_; }
73 
74  bool containsTriggerCell(const unsigned trig_cell) const {
75  return (components_.find(trig_cell) != components_.end());
76  }
77 
78  bool containsCell(const unsigned cell) const {
79  for (const auto& value : tc_components_) {
80  if (value.second == cell)
81  return true;
82  }
83  return false;
84  }
85 
86  const GlobalPoint& position() const { return position_; }
87 
88  const list_type& neighbours() const { return neighbours_; }
89  const list_type& components() const { return components_; }
90 
91  const tc_map_type& triggerCellComponents() const { return tc_components_; }
92 
93  private:
94  unsigned module_id_; // module this TC belongs to
96  list_type neighbours_; // neighbouring Modules
97  list_type components_; // contained HGC trigger cells
98  tc_map_type tc_components_; // cells contained by trigger cells
99  };
100 } // namespace HGCalTriggerGeometry
101 
103 public:
104  typedef std::unordered_map<unsigned, std::unique_ptr<const HGCalTriggerGeometry::Module> > module_map;
105  typedef std::unordered_map<unsigned, std::unique_ptr<const HGCalTriggerGeometry::TriggerCell> > trigger_cell_map;
106 
109 
110  // non-const access to the geometry class
111  void reset() final;
112 
113  unsigned getTriggerCellFromCell(const unsigned cell_det_id) const final;
114  unsigned getModuleFromCell(const unsigned cell_det_id) const final;
115  unsigned getModuleFromTriggerCell(const unsigned trigger_cell_det_id) const final;
116 
117  geom_set getCellsFromTriggerCell(const unsigned cell_det_id) const final;
118  geom_set getCellsFromModule(const unsigned cell_det_id) const final;
119  geom_set getTriggerCellsFromModule(const unsigned trigger_cell_det_id) const final;
120 
121  geom_ordered_set getOrderedCellsFromModule(const unsigned cell_det_id) const final;
122  geom_ordered_set getOrderedTriggerCellsFromModule(const unsigned trigger_cell_det_id) const final;
123 
124  geom_set getNeighborsFromTriggerCell(const unsigned trigger_cell_det_id) const final;
125 
126  GlobalPoint getTriggerCellPosition(const unsigned trigger_cell_det_id) const final;
127  GlobalPoint getModulePosition(const unsigned module_det_id) const final;
128 
129  bool validTriggerCell(const unsigned trigger_cell_det_id) const final;
130  bool disconnectedModule(const unsigned module_id) const final;
131  unsigned triggerLayer(const unsigned id) const final;
132 
133 protected:
136 
137  module_map modules_;
138  trigger_cell_map trigger_cells_;
139 };
140 
141 #endif
std::unordered_set< unsigned > list_type
const tc_map_type & triggerCellComponents() const
std::unordered_multimap< unsigned, unsigned > tc_map_type
Module(unsigned mod_id, const GlobalPoint &pos, const list_type &neighbs, const list_type &comps, const tc_map_type &tc_comps)
std::unordered_map< unsigned, std::unique_ptr< const HGCalTriggerGeometry::Module > > module_map
Definition: value.py:1
TriggerCell(unsigned tc_id, unsigned mod_id, const GlobalPoint &pos, const list_type &neighbs, const list_type &comps)
const std::unordered_set< unsigned > & neighbours() const
std::unordered_map< unsigned, std::unique_ptr< const HGCalTriggerGeometry::TriggerCell > > trigger_cell_map
bool containsTriggerCell(const unsigned trig_cell) const
std::set< unsigned > geom_ordered_set
std::unordered_set< unsigned > geom_set
bool containsCell(const unsigned cell) const
void reset(double vett[256])
Definition: TPedValues.cc:11
const std::unordered_set< unsigned > & components() const