31 l1tCellsMapping_(conf.getParameter<
edm::FileInPath>(
"L1TCellsMapping")),
32 l1tModulesMapping_(conf.getParameter<
edm::FileInPath>(
"L1TModulesMapping"))
40 edm::LogWarning(
"HGCalTriggerGeometry") <<
"WARNING: This HGCal trigger geometry is incomplete.\n"
41 <<
"WARNING: There is no neighbor information.\n";
55 <<
"HGCalTriggerGeometryHexImp1 geometry cannot be initialized with the V9 HGCAL geometry";
66 <<
"HGCalTriggerGeometryHexImp1 geometry cannot be initialized with the V9 HGCAL+NOSE geometry";
75 std::unordered_map<short, short> wafer_to_module_ee;
76 std::unordered_map<short, short> wafer_to_module_fh;
77 std::unordered_map<short, std::map<short, short>> module_to_wafers_ee;
78 std::unordered_map<short, std::map<short, short>> module_to_wafers_fh;
80 if (!l1tModulesMappingStream.is_open())
81 edm::LogError(
"HGCalTriggerGeometry") <<
"Cannot open L1TModulesMapping file\n";
85 for (; l1tModulesMappingStream >> subdet >> wafer >>
module;) {
87 wafer_to_module_ee.emplace(wafer,
module);
88 auto itr_insert = module_to_wafers_ee.emplace(
module, std::map<short, short>());
89 itr_insert.first->second.emplace(wafer, 0);
90 }
else if (subdet == 4) {
91 wafer_to_module_fh.emplace(wafer,
module);
92 auto itr_insert = module_to_wafers_fh.emplace(
module, std::map<short, short>());
93 itr_insert.first->second.emplace(wafer, 0);
96 <<
"Unsupported subdetector number (" << subdet <<
") in L1TModulesMapping file\n";
98 if (!l1tModulesMappingStream.eof())
99 edm::LogWarning(
"HGCalTriggerGeometry") <<
"Error reading L1TModulesMapping '" << wafer <<
" " <<
module <<
"' \n";
100 l1tModulesMappingStream.close();
102 std::map<std::pair<short, short>,
short> cells_to_trigger_cells;
103 std::unordered_map<short, short> number_trigger_cells_in_wafers;
105 if (!l1tCellsMappingStream.is_open())
106 edm::LogError(
"HGCalTriggerGeometry") <<
"Cannot open L1TCellsMapping file\n";
109 short triggerCell = 0;
110 for (; l1tCellsMappingStream >> waferType >> cell >> triggerCell;) {
111 cells_to_trigger_cells.emplace(std::make_pair((waferType ? 1 : -1), cell), triggerCell);
112 auto itr_insert = number_trigger_cells_in_wafers.emplace((waferType ? 1 : -1), 0);
113 if (triggerCell + 1 > itr_insert.first->second)
114 itr_insert.first->second = triggerCell + 1;
116 if (!l1tCellsMappingStream.eof())
118 <<
"Error reading L1TCellsMapping'" << waferType <<
" " << cell <<
" " << triggerCell <<
"' \n";
119 l1tCellsMappingStream.close();
124 for (
auto& module_wafers : module_to_wafers_ee) {
126 for (
auto& wafer_offset : module_wafers.second) {
127 wafer_offset.second =
offset;
129 offset += number_trigger_cells_in_wafers.at(wafer_type);
132 for (
auto& module_wafers : module_to_wafers_fh) {
134 for (
auto& wafer_offset : module_wafers.second) {
135 wafer_offset.second =
offset;
137 offset += number_trigger_cells_in_wafers.at(wafer_type);
143 for (
const auto&
id :
eeGeometry()->getValidGeomDetIds()) {
147 short module = wafer_to_module_ee[waferDetId.
wafer()];
148 short triggercell_offset = module_to_wafers_ee.at(
module).at(waferDetId.
wafer());
150 for (
int c = 0;
c < nCells;
c++) {
151 short triggerCellId = cells_to_trigger_cells[std::make_pair(waferDetId.
waferType(),
c)];
163 <<
"Trigger cell id requested with a cell field larger than available in HGCalDetId ("
170 triggercell_offset + triggerCellId);
183 for (
const auto&
id :
fhGeometry()->getValidGeomDetIds()) {
187 short module = wafer_to_module_fh[waferDetId.
wafer()];
188 short triggercell_offset = module_to_wafers_fh.at(
module).at(waferDetId.
wafer());
190 for (
int c = 0;
c < nCells;
c++) {
191 short triggerCellId = cells_to_trigger_cells[std::make_pair(waferDetId.
waferType(),
c)];
203 <<
"Trigger cell id requested with a cell field larger than available in HGCalDetId ("
210 triggercell_offset + triggerCellId);
232 std::unordered_map<unsigned, list_cells> trigger_cells_to_cells;
234 unsigned cell = cell_triggerCell.first;
235 unsigned triggerCell = cell_triggerCell.second;
236 auto itr_exist = trigger_cells_to_cells.emplace(triggerCell, list_cells());
237 itr_exist.first->second.emplace(cell);
239 for (
const auto& triggerCell_cells : trigger_cells_to_cells) {
240 unsigned triggerCellId = triggerCell_cells.first;
241 list_cells cellIds = triggerCell_cells.second;
244 for (
const auto& cell : cellIds) {
250 GlobalPoint triggerCellPoint(triggerCellVector / cellIds.size());
253 ? triggerCellToModuleItr->second
257 std::make_unique<const HGCalTriggerGeometry::TriggerCell>(
258 triggerCellId, moduleId, triggerCellPoint, list_cells(), cellIds));
265 std::unordered_map<unsigned, list_triggerCells> modules_to_trigger_cells;
267 unsigned triggerCell = triggerCell_module.first;
268 unsigned module = triggerCell_module.second;
269 auto itr_exist = modules_to_trigger_cells.emplace(
module, list_triggerCells());
270 itr_exist.first->second.emplace(triggerCell);
272 for (
const auto& module_triggerCell : modules_to_trigger_cells) {
273 unsigned moduleId = module_triggerCell.first;
274 list_triggerCells triggerCellIds = module_triggerCell.second;
275 tc_map_to_cells cellsInTriggerCells;
278 for (
const auto& triggerCell : triggerCellIds) {
279 const auto& cells_in_tc = trigger_cells_to_cells.at(triggerCell);
280 for (
const unsigned cell : cells_in_tc) {
281 cellsInTriggerCells.emplace(triggerCell, cell);
283 moduleVector +=
trigger_cells_.at(triggerCell)->position().basicVector();
285 GlobalPoint modulePoint(moduleVector / triggerCellIds.size());
288 std::make_unique<const HGCalTriggerGeometry::Module>(
289 moduleId, modulePoint, list_triggerCells(), triggerCellIds, cellsInTriggerCells));