31 l1tCellsMapping_(conf.getParameter<edm::
FileInPath>(
"L1TCellsMapping")),
32 l1tModulesMapping_(conf.getParameter<edm::
FileInPath>(
"L1TModulesMapping"))
42 edm::LogWarning(
"HGCalTriggerGeometry") <<
"WARNING: This HGCal trigger geometry is incomplete.\n"\
43 <<
"WARNING: There is no neighbor information.\n";
58 std::unordered_map<short, short> wafer_to_module_ee;
59 std::unordered_map<short, short> wafer_to_module_fh;
60 std::unordered_map<short, std::map<short,short>> module_to_wafers_ee;
61 std::unordered_map<short, std::map<short,short>> module_to_wafers_fh;
63 if(!l1tModulesMappingStream.is_open())
edm::LogError(
"HGCalTriggerGeometry") <<
"Cannot open L1TModulesMapping file\n";
67 for(; l1tModulesMappingStream>>subdet>>wafer>>
module; )
71 wafer_to_module_ee.emplace(wafer,module);
72 auto itr_insert = module_to_wafers_ee.emplace(module, std::map<short,short>());
73 itr_insert.first->second.emplace(wafer, 0);
77 wafer_to_module_fh.emplace(wafer,module);
78 auto itr_insert = module_to_wafers_fh.emplace(module, std::map<short,short>());
79 itr_insert.first->second.emplace(wafer, 0);
81 else edm::LogWarning(
"HGCalTriggerGeometry") <<
"Unsupported subdetector number ("<<subdet<<
") in L1TModulesMapping file\n";
83 if(!l1tModulesMappingStream.eof())
edm::LogWarning(
"HGCalTriggerGeometry") <<
"Error reading L1TModulesMapping '"<<wafer<<
" "<<module<<
"' \n";
84 l1tModulesMappingStream.close();
86 std::map<std::pair<short,short>,
short> cells_to_trigger_cells;
87 std::unordered_map<short, short> number_trigger_cells_in_wafers;
89 if(!l1tCellsMappingStream.is_open())
edm::LogError(
"HGCalTriggerGeometry") <<
"Cannot open L1TCellsMapping file\n";
92 short triggerCell = 0;
93 for(; l1tCellsMappingStream>>waferType>>cell>>triggerCell; )
95 cells_to_trigger_cells.emplace(std::make_pair((waferType?1:-1),cell), triggerCell);
96 auto itr_insert = number_trigger_cells_in_wafers.emplace((waferType?1:-1), 0);
97 if(triggerCell+1 > itr_insert.first->second) itr_insert.first->second = triggerCell+1;
99 if(!l1tCellsMappingStream.eof())
edm::LogWarning(
"HGCalTriggerGeometry") <<
"Error reading L1TCellsMapping'"<<waferType<<
" "<<cell<<
" "<<triggerCell<<
"' \n";
100 l1tCellsMappingStream.close();
105 for(
auto& module_wafers : module_to_wafers_ee)
108 for(
auto& wafer_offset : module_wafers.second)
110 wafer_offset.second =
offset;
111 int wafer_type = (esInfo.
topo_ee->dddConstants().waferTypeT(wafer_offset.first)==1?1:-1);
112 offset += number_trigger_cells_in_wafers.at(wafer_type);
115 for(
auto& module_wafers : module_to_wafers_fh)
118 for(
auto& wafer_offset : module_wafers.second)
120 wafer_offset.second =
offset;
121 int wafer_type = (esInfo.
topo_fh->dddConstants().waferTypeT(wafer_offset.first)==1?1:-1);
122 offset += number_trigger_cells_in_wafers.at(wafer_type);
128 for(
const auto&
id : esInfo.
geom_ee->getValidGeomDetIds())
130 if(
id.rawId()==0)
continue;
132 short module = wafer_to_module_ee[waferDetId.
wafer()];
133 short triggercell_offset = module_to_wafers_ee.at(module).at(waferDetId.
wafer());
134 int nCells = esInfo.
topo_ee->dddConstants().numberCellsHexagon(waferDetId.
wafer());
135 for(
int c=0;
c<nCells;
c++)
137 short triggerCellId = cells_to_trigger_cells[std::make_pair(waferDetId.
waferType(),
c)];
151 for(
const auto&
id : esInfo.
geom_fh->getValidGeomDetIds())
153 if(
id.rawId()==0)
continue;
155 short module = wafer_to_module_fh[waferDetId.
wafer()];
156 short triggercell_offset = module_to_wafers_fh.at(module).at(waferDetId.
wafer());
157 int nCells = esInfo.
topo_fh->dddConstants().numberCellsHexagon(waferDetId.
wafer());
158 for(
int c=0;
c<nCells;
c++)
160 short triggerCellId = cells_to_trigger_cells[std::make_pair(waferDetId.
waferType(),
c)];
185 std::unordered_map<unsigned, list_cells> trigger_cells_to_cells;
188 unsigned cell = cell_triggerCell.first;
189 unsigned triggerCell = cell_triggerCell.second;
190 auto itr_exist = trigger_cells_to_cells.emplace(triggerCell, list_cells());
191 itr_exist.first->second.emplace(cell);
194 for(
const auto& triggerCell_cells : trigger_cells_to_cells)
196 unsigned triggerCellId = triggerCell_cells.first;
197 list_cells cellIds = triggerCell_cells.second;
200 for(
const auto& cell : cellIds)
205 GlobalPoint triggerCellPoint( triggerCellVector/cellIds.size() );
210 trigger_cells_.emplace(triggerCellId, std::make_unique<const HGCalTriggerGeometry::TriggerCell>(triggerCellId, moduleId, triggerCellPoint, list_cells(), cellIds));
217 std::unordered_map<unsigned, list_triggerCells> modules_to_trigger_cells;
220 unsigned triggerCell = triggerCell_module.first;
221 unsigned module = triggerCell_module.second;
222 auto itr_exist = modules_to_trigger_cells.emplace(module, list_triggerCells());
223 itr_exist.first->second.emplace(triggerCell);
226 for(
const auto& module_triggerCell : modules_to_trigger_cells)
228 unsigned moduleId = module_triggerCell.first;
229 list_triggerCells triggerCellIds = module_triggerCell.second;
230 tc_map_to_cells cellsInTriggerCells;
233 for(
const auto& triggerCell : triggerCellIds)
235 const auto& cells_in_tc = trigger_cells_to_cells.at(triggerCell);
236 for(
const unsigned cell : cells_in_tc )
238 cellsInTriggerCells.emplace(triggerCell,cell);
240 moduleVector +=
trigger_cells_.at(triggerCell)->position().basicVector();
242 GlobalPoint modulePoint( moduleVector/triggerCellIds.size() );
244 modules_.emplace(moduleId, std::make_unique<const HGCalTriggerGeometry::Module>(moduleId, modulePoint, list_triggerCells(), triggerCellIds, cellsInTriggerCells));
251 "HGCalTriggerGeometryHexImp1");
std::unordered_set< unsigned > list_type
void buildTriggerCellsAndModules(const es_info &)
edm::ESHandle< HGCalTopology > topo_ee
edm::FileInPath l1tCellsMapping_
void fillMaps(const es_info &)
virtual void initialize(const es_info &) overridefinal
static const int kHGCalCellMask
int zside() const
get the z-side of the cell (1/-1)
geom_map cells_to_trigger_cells_
std::unordered_multimap< unsigned, unsigned > tc_map_type
edm::ESHandle< HGCalGeometry > geom_ee
edm::ESHandle< HGCalGeometry > geom_fh
int wafer() const
get the wafer #
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
edm::ESHandle< HGCalTopology > topo_fh
geom_map trigger_cells_to_modules_
edm::FileInPath l1tModulesMapping_
trigger_cell_map trigger_cells_
int waferType() const
get the wafer type
#define DEFINE_EDM_PLUGIN(factory, type, name)
HGCalTriggerGeometryHexImp1(const edm::ParameterSet &conf)
std::string fullPath() const
std::unordered_set< unsigned > list_type
int layer() const
get the layer #