CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
HGCalTriggerGeometryHexImp1 Class Reference
Inheritance diagram for HGCalTriggerGeometryHexImp1:
HGCalTriggerGeometryGenericMapping HGCalTriggerGeometryBase

Public Member Functions

 HGCalTriggerGeometryHexImp1 (const edm::ParameterSet &conf)
 
void initialize (const CaloGeometry *) final
 
void initialize (const HGCalGeometry *, const HGCalGeometry *, const HGCalGeometry *) final
 
- Public Member Functions inherited from HGCalTriggerGeometryGenericMapping
bool disconnectedModule (const unsigned module_id) const final
 
geom_set getCellsFromModule (const unsigned cell_det_id) const final
 
geom_set getCellsFromTriggerCell (const unsigned cell_det_id) const final
 
unsigned getLinksInModule (const unsigned module_id) const final
 
unsigned getModuleFromCell (const unsigned cell_det_id) const final
 
unsigned getModuleFromTriggerCell (const unsigned trigger_cell_det_id) const final
 
GlobalPoint getModulePosition (const unsigned module_det_id) const final
 
unsigned getModuleSize (const unsigned module_id) const final
 
geom_set getNeighborsFromTriggerCell (const unsigned trigger_cell_det_id) const final
 
geom_ordered_set getOrderedCellsFromModule (const unsigned cell_det_id) const final
 
geom_ordered_set getOrderedTriggerCellsFromModule (const unsigned trigger_cell_det_id) const final
 
unsigned getTriggerCellFromCell (const unsigned cell_det_id) const final
 
GlobalPoint getTriggerCellPosition (const unsigned trigger_cell_det_id) const final
 
geom_set getTriggerCellsFromModule (const unsigned trigger_cell_det_id) const final
 
 HGCalTriggerGeometryGenericMapping (const edm::ParameterSet &conf)
 
unsigned lastTriggerLayer () const final
 
void reset () final
 
unsigned triggerLayer (const unsigned id) const final
 
bool validTriggerCell (const unsigned trigger_cell_det_id) const final
 
 ~HGCalTriggerGeometryGenericMapping () override
 
- Public Member Functions inherited from HGCalTriggerGeometryBase
const HcalGeometrybhGeometry () const
 
const HcalTopologybhTopology () const
 
const CaloGeometrycaloGeometry () const
 
const HGCalGeometryeeGeometry () const
 
const HGCalTopologyeeTopology () const
 
const HGCalGeometryfhGeometry () const
 
const HGCalTopologyfhTopology () const
 
 HGCalTriggerGeometryBase (const edm::ParameterSet &conf)
 
const HGCalGeometryhscGeometry () const
 
const HGCalTopologyhscTopology () const
 
const HGCalGeometryhsiGeometry () const
 
const HGCalTopologyhsiTopology () const
 
bool isV9Geometry () const
 
const std::string & name () const
 
virtual ~HGCalTriggerGeometryBase ()
 

Private Member Functions

void buildTriggerCellsAndModules ()
 
void fillMaps ()
 

Private Attributes

edm::FileInPath l1tCellsMapping_
 
edm::FileInPath l1tModulesMapping_
 

Additional Inherited Members

- Public Types inherited from HGCalTriggerGeometryGenericMapping
typedef std::unordered_map< unsigned, std::unique_ptr< const HGCalTriggerGeometry::Module > > module_map
 
typedef std::unordered_map< unsigned, std::unique_ptr< const HGCalTriggerGeometry::TriggerCell > > trigger_cell_map
 
- Public Types inherited from HGCalTriggerGeometryBase
typedef std::unordered_map< unsigned, unsigned > geom_map
 
typedef std::set< unsigned > geom_ordered_set
 
typedef std::unordered_set< unsigned > geom_set
 
- Protected Member Functions inherited from HGCalTriggerGeometryBase
void setCaloGeometry (const CaloGeometry *geom)
 
void setEEGeometry (const HGCalGeometry *geom)
 
void setHScGeometry (const HGCalGeometry *geom)
 
void setHSiGeometry (const HGCalGeometry *geom)
 
- Protected Attributes inherited from HGCalTriggerGeometryGenericMapping
geom_map cells_to_trigger_cells_
 
module_map modules_
 
trigger_cell_map trigger_cells_
 
geom_map trigger_cells_to_modules_
 

Detailed Description

Definition at line 12 of file HGCalTriggerGeometryHexImp1.cc.

Constructor & Destructor Documentation

HGCalTriggerGeometryHexImp1::HGCalTriggerGeometryHexImp1 ( const edm::ParameterSet conf)

Definition at line 28 of file HGCalTriggerGeometryHexImp1.cc.

30  l1tCellsMapping_(conf.getParameter<edm::FileInPath>("L1TCellsMapping")),
31  l1tModulesMapping_(conf.getParameter<edm::FileInPath>("L1TModulesMapping"))
32 /*****************************************************************/
33 {}
T getParameter(std::string const &) const
HGCalTriggerGeometryGenericMapping(const edm::ParameterSet &conf)

Member Function Documentation

void HGCalTriggerGeometryHexImp1::buildTriggerCellsAndModules ( )
private

Definition at line 213 of file HGCalTriggerGeometryHexImp1.cc.

References HGCalTriggerGeometryGenericMapping::cells_to_trigger_cells_, DEFINE_EDM_PLUGIN, HGCalTriggerGeometryBase::eeGeometry(), HGCalTriggerGeometryBase::fhGeometry(), HGCalGeometry::getPosition(), HGCEE, HGCalTriggerGeometryGenericMapping::modules_, DetId::subdetId(), HGCalTriggerGeometryGenericMapping::trigger_cells_, and HGCalTriggerGeometryGenericMapping::trigger_cells_to_modules_.

Referenced by initialize().

215 {
216  //
217  // Build trigger cells and fill map
219  // make list of cells in trigger cells
220  std::unordered_map<unsigned, list_cells> trigger_cells_to_cells;
221  for (const auto& cell_triggerCell : cells_to_trigger_cells_) {
222  unsigned cell = cell_triggerCell.first;
223  unsigned triggerCell = cell_triggerCell.second;
224  auto itr_exist = trigger_cells_to_cells.emplace(triggerCell, list_cells());
225  itr_exist.first->second.emplace(cell);
226  //trigger_cells_to_cells.at(triggerCell).emplace(cell);
227  }
228  for (const auto& triggerCell_cells : trigger_cells_to_cells) {
229  unsigned triggerCellId = triggerCell_cells.first;
230  list_cells cellIds = triggerCell_cells.second;
231  // Position: barycenter of the trigger cell.
232  Basic3DVector<float> triggerCellVector(0., 0., 0.);
233  for (const auto& cell : cellIds) {
234  HGCalDetId cellDetId(cell);
235  triggerCellVector += (cellDetId.subdetId() == ForwardSubdetector::HGCEE ? eeGeometry()->getPosition(cellDetId)
236  : fhGeometry()->getPosition(cellDetId))
237  .basicVector();
238  }
239  GlobalPoint triggerCellPoint(triggerCellVector / cellIds.size());
240  const auto& triggerCellToModuleItr = trigger_cells_to_modules_.find(triggerCellId);
241  unsigned moduleId = (triggerCellToModuleItr != trigger_cells_to_modules_.end()
242  ? triggerCellToModuleItr->second
243  : 0); // 0 if the trigger cell doesn't belong to a module
244  //unsigned moduleId = trigger_cells_to_modules_.at(triggercellId);
245  // FIXME: empty neighbours
246  trigger_cells_.emplace(triggerCellId,
247  std::make_unique<const HGCalTriggerGeometry::TriggerCell>(
248  triggerCellId, moduleId, triggerCellPoint, list_cells(), cellIds));
249  }
250  //
251  // Build modules and fill map
252  typedef HGCalTriggerGeometry::Module::list_type list_triggerCells;
253  typedef HGCalTriggerGeometry::Module::tc_map_type tc_map_to_cells;
254  // make list of trigger cells in modules
255  std::unordered_map<unsigned, list_triggerCells> modules_to_trigger_cells;
256  for (const auto& triggerCell_module : trigger_cells_to_modules_) {
257  unsigned triggerCell = triggerCell_module.first;
258  unsigned module = triggerCell_module.second;
259  auto itr_exist = modules_to_trigger_cells.emplace(module, list_triggerCells());
260  itr_exist.first->second.emplace(triggerCell);
261  //modules_to_trigger_cells.at(module).emplace(triggerCell);
262  }
263  for (const auto& module_triggerCell : modules_to_trigger_cells) {
264  unsigned moduleId = module_triggerCell.first;
265  list_triggerCells triggerCellIds = module_triggerCell.second;
266  tc_map_to_cells cellsInTriggerCells;
267  // Position: barycenter of the module, from trigger cell positions
268  Basic3DVector<float> moduleVector(0., 0., 0.);
269  for (const auto& triggerCell : triggerCellIds) {
270  const auto& cells_in_tc = trigger_cells_to_cells.at(triggerCell);
271  for (const unsigned cell : cells_in_tc) {
272  cellsInTriggerCells.emplace(triggerCell, cell);
273  }
274  moduleVector += trigger_cells_.at(triggerCell)->position().basicVector();
275  }
276  GlobalPoint modulePoint(moduleVector / triggerCellIds.size());
277  // FIXME: empty neighbours
278  modules_.emplace(moduleId,
279  std::make_unique<const HGCalTriggerGeometry::Module>(
280  moduleId, modulePoint, list_triggerCells(), triggerCellIds, cellsInTriggerCells));
281  }
282 }
std::unordered_set< unsigned > list_type
std::unordered_multimap< unsigned, unsigned > tc_map_type
const HGCalGeometry * eeGeometry() const
GlobalPoint getPosition(const DetId &id) const
const HGCalGeometry * fhGeometry() const
Definition: vlib.h:198
void HGCalTriggerGeometryHexImp1::fillMaps ( )
private

Definition at line 58 of file HGCalTriggerGeometryHexImp1.cc.

References HltBtagPostValidation_cff::c, HGCalTriggerGeometryGenericMapping::cells_to_trigger_cells_, HGCalTopology::dddConstants(), HGCalTriggerGeometryBase::eeGeometry(), HGCalTriggerGeometryBase::eeTopology(), HGCalTriggerGeometryBase::fhGeometry(), HGCalTriggerGeometryBase::fhTopology(), edm::FileInPath::fullPath(), HGCalDetId::kHGCalCellMask, l1tCellsMapping_, l1tModulesMapping_, HGCalDetId::layer(), HGCalDDDConstants::numberCellsHexagon(), hltrates_dqm_sourceclient-live_cfg::offset, DetId::subdetId(), HGCalTriggerGeometryGenericMapping::trigger_cells_to_modules_, HGCalDetId::wafer(), HGCalDetId::waferType(), HGCalDDDConstants::waferTypeT(), and HGCalDetId::zside().

Referenced by initialize().

60 {
61  //
62  // read module mapping file
63  std::unordered_map<short, short> wafer_to_module_ee;
64  std::unordered_map<short, short> wafer_to_module_fh;
65  std::unordered_map<short, std::map<short, short>> module_to_wafers_ee;
66  std::unordered_map<short, std::map<short, short>> module_to_wafers_fh;
67  std::ifstream l1tModulesMappingStream(l1tModulesMapping_.fullPath());
68  if (!l1tModulesMappingStream.is_open())
69  edm::LogError("HGCalTriggerGeometry") << "Cannot open L1TModulesMapping file\n";
70  short subdet = 0;
71  short wafer = 0;
72  short module = 0;
73  for (; l1tModulesMappingStream >> subdet >> wafer >> module;) {
74  if (subdet == 3) {
75  wafer_to_module_ee.emplace(wafer, module);
76  auto itr_insert = module_to_wafers_ee.emplace(module, std::map<short, short>());
77  itr_insert.first->second.emplace(wafer, 0);
78  } else if (subdet == 4) {
79  wafer_to_module_fh.emplace(wafer, module);
80  auto itr_insert = module_to_wafers_fh.emplace(module, std::map<short, short>());
81  itr_insert.first->second.emplace(wafer, 0);
82  } else
83  edm::LogWarning("HGCalTriggerGeometry")
84  << "Unsupported subdetector number (" << subdet << ") in L1TModulesMapping file\n";
85  }
86  if (!l1tModulesMappingStream.eof())
87  edm::LogWarning("HGCalTriggerGeometry") << "Error reading L1TModulesMapping '" << wafer << " " << module << "' \n";
88  l1tModulesMappingStream.close();
89  // read trigger cell mapping file
90  std::map<std::pair<short, short>, short> cells_to_trigger_cells;
91  std::unordered_map<short, short> number_trigger_cells_in_wafers; // the map key is the wafer type
92  std::ifstream l1tCellsMappingStream(l1tCellsMapping_.fullPath());
93  if (!l1tCellsMappingStream.is_open())
94  edm::LogError("HGCalTriggerGeometry") << "Cannot open L1TCellsMapping file\n";
95  short waferType = 0;
96  short cell = 0;
97  short triggerCell = 0;
98  for (; l1tCellsMappingStream >> waferType >> cell >> triggerCell;) {
99  cells_to_trigger_cells.emplace(std::make_pair((waferType ? 1 : -1), cell), triggerCell);
100  auto itr_insert = number_trigger_cells_in_wafers.emplace((waferType ? 1 : -1), 0);
101  if (triggerCell + 1 > itr_insert.first->second)
102  itr_insert.first->second = triggerCell + 1;
103  }
104  if (!l1tCellsMappingStream.eof())
105  edm::LogWarning("HGCalTriggerGeometry")
106  << "Error reading L1TCellsMapping'" << waferType << " " << cell << " " << triggerCell << "' \n";
107  l1tCellsMappingStream.close();
108  // For each wafer compute the trigger cell offset according to the wafer position inside
109  // the module. The first wafer will have an offset equal to 0, the second an offset equal to the
110  // number of trigger cells in the first wafer, etc.
111  short offset = 0;
112  for (auto& module_wafers : module_to_wafers_ee) {
113  offset = 0;
114  for (auto& wafer_offset : module_wafers.second) {
115  wafer_offset.second = offset;
116  int wafer_type = (eeTopology().dddConstants().waferTypeT(wafer_offset.first) == 1 ? 1 : -1);
117  offset += number_trigger_cells_in_wafers.at(wafer_type);
118  }
119  }
120  for (auto& module_wafers : module_to_wafers_fh) {
121  offset = 0;
122  for (auto& wafer_offset : module_wafers.second) {
123  wafer_offset.second = offset;
124  int wafer_type = (fhTopology().dddConstants().waferTypeT(wafer_offset.first) == 1 ? 1 : -1);
125  offset += number_trigger_cells_in_wafers.at(wafer_type);
126  }
127  }
128  //
129  // Loop over HGC cells
130  // EE
131  for (const auto& id : eeGeometry()->getValidGeomDetIds()) {
132  if (id.rawId() == 0)
133  continue;
134  HGCalDetId waferDetId(id);
135  short module = wafer_to_module_ee[waferDetId.wafer()];
136  short triggercell_offset = module_to_wafers_ee.at(module).at(waferDetId.wafer());
137  int nCells = eeTopology().dddConstants().numberCellsHexagon(waferDetId.wafer());
138  for (int c = 0; c < nCells; c++) {
139  short triggerCellId = cells_to_trigger_cells[std::make_pair(waferDetId.waferType(), c)];
140  // Fill cell -> trigger cell mapping
141  HGCalDetId cellDetId(ForwardSubdetector(waferDetId.subdetId()),
142  waferDetId.zside(),
143  waferDetId.layer(),
144  waferDetId.waferType(),
145  waferDetId.wafer(),
146  c);
147  // The module id is used instead of the wafer id for the trigger cells
148  // Since there are several wafers per module, an offset is applied on the HGCalDetId::cell field
149  if (triggercell_offset + triggerCellId >= HGCalDetId::kHGCalCellMask)
150  edm::LogError("HGCalTriggerGeometry")
151  << "Trigger cell id requested with a cell field larger than available in HGCalDetId ("
152  << triggercell_offset + triggerCellId << " >= " << HGCalDetId::kHGCalCellMask << ")\n";
153  HGCalDetId triggerCellDetId(ForwardSubdetector(waferDetId.subdetId()),
154  waferDetId.zside(),
155  waferDetId.layer(),
156  waferDetId.waferType(),
157  module,
158  triggercell_offset + triggerCellId);
159  cells_to_trigger_cells_.emplace(cellDetId, triggerCellDetId);
160  // Fill trigger cell -> module mapping
161  HGCalDetId moduleDetId(ForwardSubdetector(waferDetId.subdetId()),
162  waferDetId.zside(),
163  waferDetId.layer(),
164  waferDetId.waferType(),
165  module,
167  trigger_cells_to_modules_.emplace(triggerCellDetId, moduleDetId);
168  }
169  }
170  // FH
171  for (const auto& id : fhGeometry()->getValidGeomDetIds()) {
172  if (id.rawId() == 0)
173  continue;
174  HGCalDetId waferDetId(id);
175  short module = wafer_to_module_fh[waferDetId.wafer()];
176  short triggercell_offset = module_to_wafers_fh.at(module).at(waferDetId.wafer());
177  int nCells = fhTopology().dddConstants().numberCellsHexagon(waferDetId.wafer());
178  for (int c = 0; c < nCells; c++) {
179  short triggerCellId = cells_to_trigger_cells[std::make_pair(waferDetId.waferType(), c)];
180  // Fill cell -> trigger cell mapping
181  HGCalDetId cellDetId(ForwardSubdetector(waferDetId.subdetId()),
182  waferDetId.zside(),
183  waferDetId.layer(),
184  waferDetId.waferType(),
185  waferDetId.wafer(),
186  c);
187  // The module id is used instead of the wafer id for the trigger cells
188  // Since there are several wafers per module, an offset is applied on the HGCalDetId::cell field
189  if (triggercell_offset + triggerCellId >= HGCalDetId::kHGCalCellMask)
190  edm::LogError("HGCalTriggerGeometry")
191  << "Trigger cell id requested with a cell field larger than available in HGCalDetId ("
192  << triggercell_offset + triggerCellId << " >= " << HGCalDetId::kHGCalCellMask << ")\n";
193  HGCalDetId triggerCellDetId(ForwardSubdetector(waferDetId.subdetId()),
194  waferDetId.zside(),
195  waferDetId.layer(),
196  waferDetId.waferType(),
197  module,
198  triggercell_offset + triggerCellId);
199  cells_to_trigger_cells_.emplace(cellDetId, triggerCellDetId);
200  // Fill trigger cell -> module mapping
201  HGCalDetId moduleDetId(ForwardSubdetector(waferDetId.subdetId()),
202  waferDetId.zside(),
203  waferDetId.layer(),
204  waferDetId.waferType(),
205  module,
207  trigger_cells_to_modules_.emplace(triggerCellDetId, moduleDetId);
208  }
209  }
210 }
const HGCalGeometry * eeGeometry() const
const HGCalTopology & eeTopology() const
ForwardSubdetector
static const int kHGCalCellMask
Definition: HGCalDetId.h:11
int numberCellsHexagon(int wafer) const
const HGCalGeometry * fhGeometry() const
const HGCalDDDConstants & dddConstants() const
Definition: HGCalTopology.h:96
std::string fullPath() const
Definition: FileInPath.cc:163
int waferTypeT(int wafer) const
Definition: vlib.h:198
const HGCalTopology & fhTopology() const
void HGCalTriggerGeometryHexImp1::initialize ( const CaloGeometry calo_geometry)
finalvirtual

Implements HGCalTriggerGeometryBase.

Definition at line 36 of file HGCalTriggerGeometryHexImp1.cc.

References buildTriggerCellsAndModules(), fillMaps(), and HGCalTriggerGeometryBase::setCaloGeometry().

38 {
39  edm::LogWarning("HGCalTriggerGeometry") << "WARNING: This HGCal trigger geometry is incomplete.\n"
40  << "WARNING: There is no neighbor information.\n";
41 
42  setCaloGeometry(calo_geometry);
43  fillMaps();
45 }
void setCaloGeometry(const CaloGeometry *geom)
void HGCalTriggerGeometryHexImp1::initialize ( const HGCalGeometry hgc_ee_geometry,
const HGCalGeometry hgc_hsi_geometry,
const HGCalGeometry hgc_hsc_geometry 
)
finalvirtual

Implements HGCalTriggerGeometryBase.

Definition at line 48 of file HGCalTriggerGeometryHexImp1.cc.

References Exception.

52 {
53  throw cms::Exception("BadGeometry")
54  << "HGCalTriggerGeometryHexImp1 geometry cannot be initialized with the V9 HGCAL geometry";
55 }

Member Data Documentation

edm::FileInPath HGCalTriggerGeometryHexImp1::l1tCellsMapping_
private

Definition at line 20 of file HGCalTriggerGeometryHexImp1.cc.

Referenced by fillMaps().

edm::FileInPath HGCalTriggerGeometryHexImp1::l1tModulesMapping_
private

Definition at line 21 of file HGCalTriggerGeometryHexImp1.cc.

Referenced by fillMaps().