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 //#include <iostream>
7 //#include <unordered_set>
8 //#include <unordered_map>
9 
10 //#include "DataFormats/GeometryVector/interface/GlobalPoint.h"
11 
12 //#include "FWCore/ParameterSet/interface/ParameterSet.h"
13 //#include "FWCore/Framework/interface/ESHandle.h"
14 
15 //#include "Geometry/HGCalGeometry/interface/HGCalGeometry.h"
16 //#include "Geometry/CaloTopology/interface/HGCalTopology.h"
17 
18 /*******
19  *
20  * class: HGCalTriggerGeometryGenericMapping
21  * author: L.Gray (FNAL)
22  * date: 26 July, 2015
23  *
24  * This class is the base class for all HGCal trigger geometry definitions.
25  * Typically this is just a ganging of cells and nearest-neighbour relationships.
26  *
27  * Classes for TriggerCells and Modules are defined. They are containers for
28  * maps relating modules to modules and trigger cells to trigger cells and
29  * raw HGC cells.
30  *
31  * It is up to the user of the class to define what these mappings are through the
32  * initialize() function. This function takes the full HGC geometry as input and
33  * creates all the necessary maps for navigating the trigger system. All of the
34  * containers for parts of the map are available through protected members of the base
35  * class.
36  *
37  * All unsigned ints used here are DetIds, or will become them once we sort out the
38  * full nature of the trigger detids.
39  *******/
40 
42 
44  class TriggerCell {
45  public:
46  typedef std::unordered_set<unsigned> list_type;
47 
48  TriggerCell(unsigned tc_id, unsigned mod_id, const GlobalPoint& pos,
49  const list_type& neighbs, const list_type& comps) :
50  trigger_cell_id_(tc_id),
51  module_id_(mod_id),
52  position_(pos),
53  neighbours_(neighbs),
54  components_(comps)
55  {}
57 
58 
59  unsigned triggerCellId() const { return trigger_cell_id_; }
60  unsigned moduleId() const { return module_id_; }
61 
62  bool containsCell(const unsigned cell) const {
63  return ( components_.find(cell) != components_.end() );
64  }
65 
66  const GlobalPoint& position() const { return position_; }
67 
68  const std::unordered_set<unsigned>& neighbours() const { return neighbours_; }
69  const std::unordered_set<unsigned>& components() const { return components_; }
70 
71  private:
72  unsigned trigger_cell_id_; // the ID of this trigger cell
73  unsigned module_id_; // module this TC belongs to
75  list_type neighbours_; // neighbouring trigger cells
76  list_type components_; // contained HGC cells
77  };
78 
79  class Module {
80  public:
81  typedef std::unordered_set<unsigned> list_type;
82  typedef std::unordered_multimap<unsigned,unsigned> tc_map_type;
83 
84  Module(unsigned mod_id, const GlobalPoint& pos,
85  const list_type& neighbs, const list_type& comps,
86  const tc_map_type& tc_comps):
87  module_id_(mod_id),
88  position_(pos),
89  neighbours_(neighbs),
90  components_(comps),
91  tc_components_(tc_comps)
92  {}
93  ~Module() {}
94 
95  unsigned moduleId() const { return module_id_; }
96 
97  bool containsTriggerCell(const unsigned trig_cell) const {
98  return ( components_.find(trig_cell) != components_.end() );
99  }
100 
101  bool containsCell(const unsigned cell) const {
102  for( const auto& value : tc_components_ ) {
103  if( value.second == cell ) return true;
104  }
105  return false;
106  }
107 
108  const GlobalPoint& position() const { return position_; }
109 
110  const list_type& neighbours() const { return neighbours_; }
111  const list_type& components() const { return components_; }
112 
113  const tc_map_type& triggerCellComponents() const { return tc_components_; }
114 
115  private:
116  unsigned module_id_; // module this TC belongs to
118  list_type neighbours_; // neighbouring Modules
119  list_type components_; // contained HGC trigger cells
120  tc_map_type tc_components_; // cells contained by trigger cells
121  };
122 }
123 
125  public:
126 
127  typedef std::unordered_map<unsigned,std::unique_ptr<const HGCalTriggerGeometry::Module> > module_map;
128  typedef std::unordered_map<unsigned,std::unique_ptr<const HGCalTriggerGeometry::TriggerCell> > trigger_cell_map;
129 
132 
133  // non-const access to the geometry class
134  //virtual void initialize( const es_info& ) = 0;
135  virtual void reset() override final;
136 
137  // const access to the geometry class
138  // all of the get*From* functions return nullptr if the thing you
139  // ask for doesn't exist
140  //const std::unique_ptr<const HGCalTriggerGeometry::TriggerCell>& getTriggerCellFromCell( const unsigned cell_det_id ) const;
141  //const std::unique_ptr<const HGCalTriggerGeometry::Module>& getModuleFromCell( const unsigned cell_det_id ) const;
142  //const std::unique_ptr<const HGCalTriggerGeometry::Module>& getModuleFromTriggerCell( const unsigned trigger_cell_det_id ) const;
143 
144  //const geom_map& cellsToTriggerCellsMap() const { return cells_to_trigger_cells_; }
145  //const geom_map& triggerCellsToModulesMap() const { return trigger_cells_to_modules_; }
146 
147  //const module_map& modules() const { return modules_; }
148  //const trigger_cell_map& triggerCells() const { return trigger_cells_; }
149 
150  virtual unsigned getTriggerCellFromCell( const unsigned cell_det_id ) const override final;
151  virtual unsigned getModuleFromCell( const unsigned cell_det_id ) const override final;
152  virtual unsigned getModuleFromTriggerCell( const unsigned trigger_cell_det_id ) const override final;
153 
154  virtual geom_set getCellsFromTriggerCell( const unsigned cell_det_id ) const override final;
155  virtual geom_set getCellsFromModule( const unsigned cell_det_id ) const override final;
156  virtual geom_set getTriggerCellsFromModule( const unsigned trigger_cell_det_id ) const override final;
157 
158  virtual geom_ordered_set getOrderedCellsFromModule( const unsigned cell_det_id ) const override final;
159  virtual geom_ordered_set getOrderedTriggerCellsFromModule( const unsigned trigger_cell_det_id ) const override final;
160 
161  virtual GlobalPoint getTriggerCellPosition(const unsigned trigger_cell_det_id) const override final;
162  virtual GlobalPoint getModulePosition(const unsigned module_det_id) const override final;
163 
164 
165  protected:
168 
169  module_map modules_;
170  trigger_cell_map trigger_cells_;
171 
172 };
173 
174 
175 #endif
std::unordered_set< unsigned > list_type
const tc_map_type & triggerCellComponents() const
std::unordered_map< unsigned, unsigned > geom_map
Module(unsigned mod_id, const GlobalPoint &pos, const list_type &neighbs, const list_type &comps, const tc_map_type &tc_comps)
std::unordered_multimap< unsigned, unsigned > tc_map_type
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
std::unordered_map< unsigned, std::unique_ptr< const HGCalTriggerGeometry::Module > > module_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