44 edm::LogWarning(
"HGCalTriggerGeometry") <<
"WARNING: This HGCal trigger geometry is incomplete.\n"\
45 <<
"WARNING: There is no neighbor information.\n";
61 <<
"HGCalTriggerGeometryHexImp1 geometry cannot be initialized with the V9 HGCAL geometry";
72 std::unordered_map<short, short> wafer_to_module_ee;
73 std::unordered_map<short, short> wafer_to_module_fh;
74 std::unordered_map<short, std::map<short,short>> module_to_wafers_ee;
75 std::unordered_map<short, std::map<short,short>> module_to_wafers_fh;
77 if(!l1tModulesMappingStream.is_open())
edm::LogError(
"HGCalTriggerGeometry") <<
"Cannot open L1TModulesMapping file\n";
81 for(; l1tModulesMappingStream>>subdet>>wafer>>module; )
85 wafer_to_module_ee.emplace(wafer,module);
86 auto itr_insert = module_to_wafers_ee.emplace(module, std::map<short,short>());
87 itr_insert.first->second.emplace(wafer, 0);
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);
95 else edm::LogWarning(
"HGCalTriggerGeometry") <<
"Unsupported subdetector number ("<<subdet<<
") in L1TModulesMapping file\n";
97 if(!l1tModulesMappingStream.eof())
edm::LogWarning(
"HGCalTriggerGeometry") <<
"Error reading L1TModulesMapping '"<<wafer<<
" "<<module<<
"' \n";
98 l1tModulesMappingStream.close();
100 std::map<std::pair<short,short>,
short> cells_to_trigger_cells;
101 std::unordered_map<short, short> number_trigger_cells_in_wafers;
103 if(!l1tCellsMappingStream.is_open())
edm::LogError(
"HGCalTriggerGeometry") <<
"Cannot open L1TCellsMapping file\n";
106 short triggerCell = 0;
107 for(; l1tCellsMappingStream>>waferType>>cell>>triggerCell; )
109 cells_to_trigger_cells.emplace(std::make_pair((waferType?1:-1),cell), triggerCell);
110 auto itr_insert = number_trigger_cells_in_wafers.emplace((waferType?1:-1), 0);
111 if(triggerCell+1 > itr_insert.first->second) itr_insert.first->second = triggerCell+1;
113 if(!l1tCellsMappingStream.eof())
edm::LogWarning(
"HGCalTriggerGeometry") <<
"Error reading L1TCellsMapping'"<<waferType<<
" "<<cell<<
" "<<triggerCell<<
"' \n";
114 l1tCellsMappingStream.close();
119 for(
auto& module_wafers : module_to_wafers_ee)
122 for(
auto& wafer_offset : module_wafers.second)
124 wafer_offset.second =
offset;
126 offset += number_trigger_cells_in_wafers.at(wafer_type);
129 for(
auto& module_wafers : module_to_wafers_fh)
132 for(
auto& wafer_offset : module_wafers.second)
134 wafer_offset.second =
offset;
136 offset += number_trigger_cells_in_wafers.at(wafer_type);
142 for(
const auto&
id :
eeGeometry()->getValidGeomDetIds())
144 if(
id.rawId()==0)
continue;
146 short module = wafer_to_module_ee[waferDetId.
wafer()];
147 short triggercell_offset = module_to_wafers_ee.at(module).at(waferDetId.
wafer());
149 for(
int c=0;
c<nCells;
c++)
151 short triggerCellId = cells_to_trigger_cells[std::make_pair(waferDetId.
waferType(),
c)];
165 for(
const auto&
id :
fhGeometry()->getValidGeomDetIds())
167 if(
id.rawId()==0)
continue;
169 short module = wafer_to_module_fh[waferDetId.
wafer()];
170 short triggercell_offset = module_to_wafers_fh.at(module).at(waferDetId.
wafer());
172 for(
int c=0;
c<nCells;
c++)
174 short triggerCellId = cells_to_trigger_cells[std::make_pair(waferDetId.
waferType(),
c)];
199 std::unordered_map<unsigned, list_cells> trigger_cells_to_cells;
202 unsigned cell = cell_triggerCell.first;
203 unsigned triggerCell = cell_triggerCell.second;
204 auto itr_exist = trigger_cells_to_cells.emplace(triggerCell, list_cells());
205 itr_exist.first->second.emplace(cell);
208 for(
const auto& triggerCell_cells : trigger_cells_to_cells)
210 unsigned triggerCellId = triggerCell_cells.first;
211 list_cells cellIds = triggerCell_cells.second;
214 for(
const auto& cell : cellIds)
219 GlobalPoint triggerCellPoint( triggerCellVector/cellIds.size() );
224 trigger_cells_.emplace(triggerCellId, std::make_unique<const HGCalTriggerGeometry::TriggerCell>(triggerCellId, moduleId, triggerCellPoint, list_cells(), cellIds));
231 std::unordered_map<unsigned, list_triggerCells> modules_to_trigger_cells;
234 unsigned triggerCell = triggerCell_module.first;
235 unsigned module = triggerCell_module.second;
236 auto itr_exist = modules_to_trigger_cells.emplace(module, list_triggerCells());
237 itr_exist.first->second.emplace(triggerCell);
240 for(
const auto& module_triggerCell : modules_to_trigger_cells)
242 unsigned moduleId = module_triggerCell.first;
243 list_triggerCells triggerCellIds = module_triggerCell.second;
244 tc_map_to_cells cellsInTriggerCells;
247 for(
const auto& triggerCell : triggerCellIds)
249 const auto& cells_in_tc = trigger_cells_to_cells.at(triggerCell);
250 for(
const unsigned cell : cells_in_tc )
252 cellsInTriggerCells.emplace(triggerCell,cell);
254 moduleVector +=
trigger_cells_.at(triggerCell)->position().basicVector();
256 GlobalPoint modulePoint( moduleVector/triggerCellIds.size() );
258 modules_.emplace(moduleId, std::make_unique<const HGCalTriggerGeometry::Module>(moduleId, modulePoint, list_triggerCells(), triggerCellIds, cellsInTriggerCells));
265 "HGCalTriggerGeometryHexImp1");
std::unordered_set< unsigned > list_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_
std::unordered_multimap< unsigned, unsigned > tc_map_type
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 #