42 edm::LogWarning(
"HGCalTriggerGeometry") <<
"WARNING: This HGCal trigger geometry is incomplete.\n"\
43 <<
"WARNING: There is no neighbor information.\n";
59 std::unordered_map<short, short> wafer_to_module_ee;
60 std::unordered_map<short, short> wafer_to_module_fh;
61 std::unordered_map<short, std::map<short,short>> module_to_wafers_ee;
62 std::unordered_map<short, std::map<short,short>> module_to_wafers_fh;
64 if(!l1tModulesMappingStream.is_open())
edm::LogError(
"HGCalTriggerGeometry") <<
"Cannot open L1TModulesMapping file\n";
68 for(; l1tModulesMappingStream>>subdet>>wafer>>
module; )
72 wafer_to_module_ee.emplace(wafer,module);
73 auto itr_insert = module_to_wafers_ee.emplace(module, std::map<short,short>());
74 itr_insert.first->second.emplace(wafer, 0);
78 wafer_to_module_fh.emplace(wafer,module);
79 auto itr_insert = module_to_wafers_fh.emplace(module, std::map<short,short>());
80 itr_insert.first->second.emplace(wafer, 0);
82 else edm::LogWarning(
"HGCalTriggerGeometry") <<
"Unsupported subdetector number ("<<subdet<<
") in L1TModulesMapping file\n";
84 if(!l1tModulesMappingStream.eof())
edm::LogWarning(
"HGCalTriggerGeometry") <<
"Error reading L1TModulesMapping '"<<wafer<<
" "<<module<<
"' \n";
85 l1tModulesMappingStream.close();
87 std::map<std::pair<short,short>,
short> cells_to_trigger_cells;
88 std::unordered_map<short, short> number_trigger_cells_in_wafers;
90 if(!l1tCellsMappingStream.is_open())
edm::LogError(
"HGCalTriggerGeometry") <<
"Cannot open L1TCellsMapping file\n";
93 short triggerCell = 0;
94 for(; l1tCellsMappingStream>>waferType>>cell>>triggerCell; )
96 cells_to_trigger_cells.emplace(std::make_pair((waferType?1:-1),cell), triggerCell);
97 auto itr_insert = number_trigger_cells_in_wafers.emplace((waferType?1:-1), 0);
98 if(triggerCell+1 > itr_insert.first->second) itr_insert.first->second = triggerCell+1;
100 if(!l1tCellsMappingStream.eof())
edm::LogWarning(
"HGCalTriggerGeometry") <<
"Error reading L1TCellsMapping'"<<waferType<<
" "<<cell<<
" "<<triggerCell<<
"' \n";
101 l1tCellsMappingStream.close();
106 for(
auto& module_wafers : module_to_wafers_ee)
109 for(
auto& wafer_offset : module_wafers.second)
111 wafer_offset.second =
offset;
113 offset += number_trigger_cells_in_wafers.at(wafer_type);
116 for(
auto& module_wafers : module_to_wafers_fh)
119 for(
auto& wafer_offset : module_wafers.second)
121 wafer_offset.second =
offset;
123 offset += number_trigger_cells_in_wafers.at(wafer_type);
129 for(
const auto&
id :
eeGeometry()->getValidGeomDetIds())
131 if(
id.rawId()==0)
continue;
133 short module = wafer_to_module_ee[waferDetId.
wafer()];
134 short triggercell_offset = module_to_wafers_ee.at(module).at(waferDetId.
wafer());
136 for(
int c=0;
c<nCells;
c++)
138 short triggerCellId = cells_to_trigger_cells[std::make_pair(waferDetId.
waferType(),
c)];
152 for(
const auto&
id :
fhGeometry()->getValidGeomDetIds())
154 if(
id.rawId()==0)
continue;
156 short module = wafer_to_module_fh[waferDetId.
wafer()];
157 short triggercell_offset = module_to_wafers_fh.at(module).at(waferDetId.
wafer());
159 for(
int c=0;
c<nCells;
c++)
161 short triggerCellId = cells_to_trigger_cells[std::make_pair(waferDetId.
waferType(),
c)];
186 std::unordered_map<unsigned, list_cells> trigger_cells_to_cells;
189 unsigned cell = cell_triggerCell.first;
190 unsigned triggerCell = cell_triggerCell.second;
191 auto itr_exist = trigger_cells_to_cells.emplace(triggerCell, list_cells());
192 itr_exist.first->second.emplace(cell);
195 for(
const auto& triggerCell_cells : trigger_cells_to_cells)
197 unsigned triggerCellId = triggerCell_cells.first;
198 list_cells cellIds = triggerCell_cells.second;
201 for(
const auto& cell : cellIds)
206 GlobalPoint triggerCellPoint( triggerCellVector/cellIds.size() );
211 trigger_cells_.emplace(triggerCellId, std::make_unique<const HGCalTriggerGeometry::TriggerCell>(triggerCellId, moduleId, triggerCellPoint, list_cells(), cellIds));
218 std::unordered_map<unsigned, list_triggerCells> modules_to_trigger_cells;
221 unsigned triggerCell = triggerCell_module.first;
222 unsigned module = triggerCell_module.second;
223 auto itr_exist = modules_to_trigger_cells.emplace(module, list_triggerCells());
224 itr_exist.first->second.emplace(triggerCell);
227 for(
const auto& module_triggerCell : modules_to_trigger_cells)
229 unsigned moduleId = module_triggerCell.first;
230 list_triggerCells triggerCellIds = module_triggerCell.second;
231 tc_map_to_cells cellsInTriggerCells;
234 for(
const auto& triggerCell : triggerCellIds)
236 const auto& cells_in_tc = trigger_cells_to_cells.at(triggerCell);
237 for(
const unsigned cell : cells_in_tc )
239 cellsInTriggerCells.emplace(triggerCell,cell);
241 moduleVector +=
trigger_cells_.at(triggerCell)->position().basicVector();
243 GlobalPoint modulePoint( moduleVector/triggerCellIds.size() );
245 modules_.emplace(moduleId, std::make_unique<const HGCalTriggerGeometry::Module>(moduleId, modulePoint, list_triggerCells(), triggerCellIds, cellsInTriggerCells));
252 "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()
int wafer() const
get the wafer #
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
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 #