41 edm::LogWarning(
"HGCalTriggerGeometry") <<
"WARNING: This HGCal trigger geometry is incomplete.\n" 42 <<
"WARNING: There is no neighbor information.\n";
56 <<
"HGCalTriggerGeometryHexImp1 geometry cannot be initialized with the V9 HGCAL geometry";
65 std::unordered_map<short, short> wafer_to_module_ee;
66 std::unordered_map<short, short> wafer_to_module_fh;
67 std::unordered_map<short, std::map<short, short>> module_to_wafers_ee;
68 std::unordered_map<short, std::map<short, short>> module_to_wafers_fh;
70 if (!l1tModulesMappingStream.is_open())
71 edm::LogError(
"HGCalTriggerGeometry") <<
"Cannot open L1TModulesMapping file\n";
75 for (; l1tModulesMappingStream >> subdet >> wafer >> module;) {
77 wafer_to_module_ee.emplace(wafer, module);
78 auto itr_insert = module_to_wafers_ee.emplace(module, std::map<short, short>());
79 itr_insert.first->second.emplace(wafer, 0);
80 }
else if (subdet == 4) {
81 wafer_to_module_fh.emplace(wafer, module);
82 auto itr_insert = module_to_wafers_fh.emplace(module, std::map<short, short>());
83 itr_insert.first->second.emplace(wafer, 0);
86 <<
"Unsupported subdetector number (" << subdet <<
") in L1TModulesMapping file\n";
88 if (!l1tModulesMappingStream.eof())
89 edm::LogWarning(
"HGCalTriggerGeometry") <<
"Error reading L1TModulesMapping '" << wafer <<
" " << module <<
"' \n";
90 l1tModulesMappingStream.close();
92 std::map<std::pair<short, short>,
short> cells_to_trigger_cells;
93 std::unordered_map<short, short> number_trigger_cells_in_wafers;
95 if (!l1tCellsMappingStream.is_open())
96 edm::LogError(
"HGCalTriggerGeometry") <<
"Cannot open L1TCellsMapping file\n";
99 short triggerCell = 0;
100 for (; l1tCellsMappingStream >> waferType >> cell >> triggerCell;) {
101 cells_to_trigger_cells.emplace(std::make_pair((waferType ? 1 : -1), cell), triggerCell);
102 auto itr_insert = number_trigger_cells_in_wafers.emplace((waferType ? 1 : -1), 0);
103 if (triggerCell + 1 > itr_insert.first->second)
104 itr_insert.first->second = triggerCell + 1;
106 if (!l1tCellsMappingStream.eof())
108 <<
"Error reading L1TCellsMapping'" << waferType <<
" " << cell <<
" " << triggerCell <<
"' \n";
109 l1tCellsMappingStream.close();
114 for (
auto& module_wafers : module_to_wafers_ee) {
116 for (
auto& wafer_offset : module_wafers.second) {
117 wafer_offset.second =
offset;
119 offset += number_trigger_cells_in_wafers.at(wafer_type);
122 for (
auto& module_wafers : module_to_wafers_fh) {
124 for (
auto& wafer_offset : module_wafers.second) {
125 wafer_offset.second =
offset;
127 offset += number_trigger_cells_in_wafers.at(wafer_type);
133 for (
const auto&
id :
eeGeometry()->getValidGeomDetIds()) {
137 short module = wafer_to_module_ee[waferDetId.
wafer()];
138 short triggercell_offset = module_to_wafers_ee.at(module).at(waferDetId.
wafer());
140 for (
int c = 0;
c < nCells;
c++) {
141 short triggerCellId = cells_to_trigger_cells[std::make_pair(waferDetId.
waferType(),
c)];
153 <<
"Trigger cell id requested with a cell field larger than available in HGCalDetId (" 160 triggercell_offset + triggerCellId);
173 for (
const auto&
id :
fhGeometry()->getValidGeomDetIds()) {
177 short module = wafer_to_module_fh[waferDetId.
wafer()];
178 short triggercell_offset = module_to_wafers_fh.at(module).at(waferDetId.
wafer());
180 for (
int c = 0;
c < nCells;
c++) {
181 short triggerCellId = cells_to_trigger_cells[std::make_pair(waferDetId.
waferType(),
c)];
193 <<
"Trigger cell id requested with a cell field larger than available in HGCalDetId (" 200 triggercell_offset + triggerCellId);
222 std::unordered_map<unsigned, list_cells> trigger_cells_to_cells;
224 unsigned cell = cell_triggerCell.first;
225 unsigned triggerCell = cell_triggerCell.second;
226 auto itr_exist = trigger_cells_to_cells.emplace(triggerCell, list_cells());
227 itr_exist.first->second.emplace(cell);
230 for (
const auto& triggerCell_cells : trigger_cells_to_cells) {
231 unsigned triggerCellId = triggerCell_cells.first;
232 list_cells cellIds = triggerCell_cells.second;
235 for (
const auto& cell : cellIds) {
241 GlobalPoint triggerCellPoint(triggerCellVector / cellIds.size());
244 ? triggerCellToModuleItr->second
249 std::make_unique<const HGCalTriggerGeometry::TriggerCell>(
250 triggerCellId, moduleId, triggerCellPoint, list_cells(), cellIds));
257 std::unordered_map<unsigned, list_triggerCells> modules_to_trigger_cells;
259 unsigned triggerCell = triggerCell_module.first;
260 unsigned module = triggerCell_module.second;
261 auto itr_exist = modules_to_trigger_cells.emplace(module, list_triggerCells());
262 itr_exist.first->second.emplace(triggerCell);
265 for (
const auto& module_triggerCell : modules_to_trigger_cells) {
266 unsigned moduleId = module_triggerCell.first;
267 list_triggerCells triggerCellIds = module_triggerCell.second;
268 tc_map_to_cells cellsInTriggerCells;
271 for (
const auto& triggerCell : triggerCellIds) {
272 const auto& cells_in_tc = trigger_cells_to_cells.at(triggerCell);
273 for (
const unsigned cell : cells_in_tc) {
274 cellsInTriggerCells.emplace(triggerCell, cell);
276 moduleVector +=
trigger_cells_.at(triggerCell)->position().basicVector();
278 GlobalPoint modulePoint(moduleVector / triggerCellIds.size());
281 std::make_unique<const HGCalTriggerGeometry::Module>(
282 moduleId, modulePoint, list_triggerCells(), triggerCellIds, cellsInTriggerCells));
std::unordered_set< unsigned > list_type
std::unordered_multimap< unsigned, unsigned > tc_map_type
const HGCalGeometry * eeGeometry() const
const HGCalTopology & eeTopology() const
GlobalPoint getPosition(const DetId &id) const
edm::FileInPath l1tCellsMapping_
void initialize(const edm::ESHandle< CaloGeometry > &) final
static const int kHGCalCellMask
int zside() const
get the z-side of the cell (1/-1)
int numberCellsHexagon(int wafer) const
const HGCalGeometry * fhGeometry() const
geom_map cells_to_trigger_cells_
void buildTriggerCellsAndModules()
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
int wafer() const
get the wafer #
void setCaloGeometry(const edm::ESHandle< CaloGeometry > &geom)
const HGCalDDDConstants & dddConstants() const
geom_map trigger_cells_to_modules_
edm::FileInPath l1tModulesMapping_
trigger_cell_map trigger_cells_
std::string fullPath() const
int waferType() const
get the wafer type
#define DEFINE_EDM_PLUGIN(factory, type, name)
HGCalTriggerGeometryHexImp1(const edm::ParameterSet &conf)
int waferTypeT(int wafer) const
std::unordered_set< unsigned > list_type
const HGCalTopology & fhTopology() const
int layer() const
get the layer #