17 #include <nlohmann/json.hpp> 60 bool validCell(
const unsigned)
const final;
109 bool validCellId(
unsigned det,
unsigned cell_id)
const;
127 hSc_triggercell_size_(conf.getParameter<unsigned>(
"ScintillatorTriggerCellSize")),
128 jsonMappingFile_(conf.getParameter<
edm::FileInPath>(
"JsonMappingFile")) {
129 std::vector<unsigned> tmp_vector = conf.
getParameter<std::vector<unsigned>>(
"DisconnectedLayers");
156 unsigned trigger_layer = 1;
184 unsigned trigger_layer = 1;
201 unsigned trigger_nose_layer = 1;
204 trigger_nose_layer++;
209 unsigned det =
DetId(cell_id).
det();
210 unsigned trigger_cell_id = 0;
223 cell_nose_id.
zside(),
225 cell_nose_id.
layer(),
244 return trigger_cell_id;
252 unsigned det =
DetId(trigger_cell_id).
det();
254 unsigned tc_type = 1;
261 tc_type = trigger_cell_sc_id.
type();
264 int tc_eta = trigger_cell_sc_id.
ietaAbs();
265 int tc_phi = trigger_cell_sc_id.
iphi();
277 tc_type = trigger_cell_trig_id.
type();
280 int waferu = trigger_cell_trig_id.
waferU();
281 int waferv = trigger_cell_trig_id.
waferV();
290 unsigned subdet = trigger_cell_trig_id.
subdet();
291 tc_type = trigger_cell_trig_id.
type();
294 int waferu = trigger_cell_trig_id.
waferU();
295 int waferv = trigger_cell_trig_id.
waferV();
303 const unsigned trigger_cell_id)
const {
304 DetId trigger_cell_det_id(trigger_cell_id);
305 unsigned det = trigger_cell_det_id.
det();
317 cell_det_ids.emplace(cell_id);
327 int type = trigger_cell_nose_id.
type();
328 int waferu = trigger_cell_nose_id.
waferU();
329 int waferv = trigger_cell_nose_id.
waferV();
330 std::vector<int> cellus = trigger_cell_nose_id.
cellU();
331 std::vector<int> cellvs = trigger_cell_nose_id.
cellV();
332 for (
unsigned ic = 0; ic < cellus.size(); ic++) {
334 cell_det_ids.emplace(cell_det_id);
340 unsigned subdet = trigger_cell_trig_id.
subdet();
345 int type = trigger_cell_trig_id.
type();
346 int waferu = trigger_cell_trig_id.
waferU();
347 int waferv = trigger_cell_trig_id.
waferV();
348 std::vector<int> cellus = trigger_cell_trig_id.
cellU();
349 std::vector<int> cellvs = trigger_cell_trig_id.
cellV();
350 for (
unsigned ic = 0; ic < cellus.size(); ic++) {
352 cell_det_ids.emplace(cell_det_id);
363 for (
auto trigger_cell_id : trigger_cells) {
365 cell_det_ids.insert(
cells.begin(),
cells.end());
374 for (
auto trigger_cell_id : trigger_cells) {
376 cell_det_ids.insert(
cells.begin(),
cells.end());
389 int ieta0 = hgc_module_id.
eta();
390 int iphi0 = hgc_module_id.
phi();
396 ieta0 = ieta0 +
split;
402 if (iphi0 > total_tcs) {
403 iphi0 = iphi0 - total_tcs;
413 trigger_cell_det_ids.emplace(trigger_cell_id);
422 for (
auto const&
idx : ids) {
424 trigger_cell_det_ids.emplace(
idx);
430 int moduleU = hgc_module_id.
moduleU();
431 int moduleV = hgc_module_id.
moduleV();
445 for (
const auto& tc_uv : tc_uvs) {
447 subdet, hgc_module_id.
zside(), wafer_type,
layer, moduleU, moduleV, tc_uv.first, tc_uv.second);
449 trigger_cell_det_ids.emplace(trigger_cell_id);
454 return trigger_cell_det_ids;
466 int ieta0 = hgc_module_id.
eta();
467 int iphi0 = hgc_module_id.
phi();
473 ieta0 = ieta0 +
split;
479 if (iphi0 > total_tcs) {
480 iphi0 = iphi0 - total_tcs;
490 trigger_cell_det_ids.emplace(trigger_cell_id);
500 for (
auto const&
idx : ids) {
502 trigger_cell_det_ids.emplace(
idx);
508 int moduleU = hgc_module_id.
moduleU();
509 int moduleV = hgc_module_id.
moduleV();
523 for (
const auto& tc_uv : tc_uvs) {
525 subdet, hgc_module_id.
zside(), wafer_type,
layer, moduleU, moduleV, tc_uv.first, tc_uv.second);
527 trigger_cell_det_ids.emplace(trigger_cell_id);
532 return trigger_cell_det_ids;
536 const unsigned trigger_cell_id)
const {
537 throw cms::Exception(
"FeatureNotImplemented") <<
"Neighbor search is not implemented in HGCalTriggerGeometryV9Imp3";
560 unsigned nWafers = 1;
565 unsigned next_sector = 0;
573 unsigned previous_sector = 2;
575 previous_sector =
sector - 1;
577 return previous_sector;
581 const unsigned stage2_id)
const {
585 for (
const auto& stage1_link : stage1_links) {
593 const unsigned stage1_id)
const {
597 for (
const auto& stage1_link : stage1_links) {
605 const unsigned stage2_id)
const {
609 for (
auto stage2_itr = stage2_itrs.first; stage2_itr != stage2_itrs.second; stage2_itr++) {
610 unsigned label = stage2_itr->second;
612 stage1link_ids.emplace(
620 return stage1link_ids;
628 id.
zside(), HGCalTriggerBackendDetId::BackendType::Stage1FPGA,
id.
sector(), stage1_label);
634 unsigned sector =
id.sector();
644 const unsigned stage1_id)
const {
649 for (
auto stage1_itr = stage1_itrs.first; stage1_itr != stage1_itrs.second; stage1_itr++) {
651 id.
zside(), HGCalTriggerBackendDetId::BackendType::Stage1Link,
id.
sector(), stage1_itr->second));
654 return stage1link_ids;
658 std::vector<unsigned> lpgbt_ids;
662 lpgbt_ids.reserve(stage1_lpgbts.size());
663 for (
const auto& stage1_lpgbt : stage1_lpgbts) {
664 lpgbt_ids.emplace_back(
676 id.
zside(), HGCalTriggerBackendDetId::BackendType::Stage1FPGA,
id.
sector(), stage1_label);
684 for (
auto lpgbt_itr = lpgbt_itrs.first; lpgbt_itr != lpgbt_itrs.second; lpgbt_itr++) {
720 for (
auto module_itr = module_itrs.first; module_itr != module_itrs.second; module_itr++) {
722 id.
zside(), HGCalTriggerBackendDetId::BackendType::LpGBT,
id.
sector(), module_itr->second));
731 unsigned stage1_label =
735 id.
zside(), HGCalTriggerBackendDetId::BackendType::Stage1FPGA,
id.
sector(), stage1_label);
739 unsigned det =
DetId(trigger_cell_det_id).
det();
746 for (
const auto& cell : cell_ids) {
753 for (
const auto& cell : cell_ids) {
760 for (
const auto& cell : cell_ids) {
767 return GlobalPoint(triggerCellVector / cell_ids.size());
777 for (
const auto& cell : cell_ids) {
783 for (
const auto& cell : cell_ids) {
789 for (
const auto& cell : cell_ids) {
797 return GlobalPoint(moduleVector / cell_ids.size());
804 if (!json_input_file.is_open()) {
805 throw cms::Exception(
"MissingDataFile") <<
"Cannot open HGCalTriggerGeometry L1TMapping file\n";
807 json_input_file >> mapping_config;
811 for (
unsigned stage2_id = 0; stage2_id < mapping_config.at(
"Stage2").size(); stage2_id++) {
812 for (
unsigned link_id = 0; link_id < mapping_config.at(
"Stage2").at(stage2_id).at(
"Stage1Links").size();
816 link_id, mapping_config.at(
"Stage2").at(stage2_id).at(
"Stage1Links").at(link_id).at(
"SameSector"));
821 <<
"The mapping input json file does not have the expected structure for the Stage2 block";
825 for (
unsigned link_id = 0; link_id < mapping_config.at(
"Stage1Links").size(); link_id++) {
830 stage1link_to_stage2_.emplace(link_id, mapping_config.at(
"Stage1Links").at(link_id).at(
"Stage2SameSector"));
834 <<
"The mapping input json file does not have the expected structure for the Stage1Links block";
838 for (
unsigned stage1_id = 0; stage1_id < mapping_config.at(
"Stage1").size(); stage1_id++) {
840 for (
auto& link_id : mapping_config.at(
"Stage1").at(stage1_id).at(
"Stage1Links")) {
845 std::vector<unsigned> lpgbt_id_vec;
846 for (
auto& lpgbt_id : mapping_config.at(
"Stage1").at(stage1_id).at(
"lpgbts")) {
847 lpgbt_id_vec.push_back(lpgbt_id);
854 <<
"The mapping input json file does not have the expected structure for the Stage1 block";
858 for (
unsigned lpgbt_id = 0; lpgbt_id < mapping_config.at(
"lpgbt").size(); lpgbt_id++) {
860 unsigned stage1_id = mapping_config.at(
"lpgbt").at(lpgbt_id).at(
"Stage1");
864 for (
auto&
modules : mapping_config.at(
"lpgbt").at(lpgbt_id).at(
"Modules")) {
867 bool isSilicon =
modules.at(
"isSilicon");
874 if (
result.second ==
false &&
875 stage1_id !=
result.first->second) {
876 edm::LogError(
"HGCalTriggerGeometryV9Imp3") <<
"One module is connected to two separate Stage1 FPGAs";
883 <<
"The mapping input json file does not have the expected structure for the lpGBT block";
889 unsigned num_elinks = 0;
890 unsigned layer = mapping_config.at(
"Module").at(
module).at(
"layer");
891 unsigned moduleU = mapping_config.at(
"Module").at(
module).at(
"u");
892 unsigned moduleV = mapping_config.at(
"Module").at(
module).at(
"v");
893 bool isSilicon = mapping_config.at(
"Module").at(
module).at(
"isSilicon");
897 for (
auto& lpgbt : mapping_config.at(
"Module").at(
module).at(
"lpgbts")) {
899 num_elinks += unsigned(lpgbt.at(
"nElinks"));
906 <<
"The mapping input json file does not have the expected structure for the Module block";
909 json_input_file.close();
913 unsigned packed_value = 0;
949 if ((
layer % 2) == 1) {
958 <<
"HGCalTriggerGeometryV9Imp3: trigger sub-detector expected to be silicon";
989 int&
ieta,
int&
iphi,
int tc_eta,
int tc_phi,
unsigned layer)
const {
996 if (tc_eta <=
split) {
1008 bool disconnected =
false;
1012 disconnected =
true;
1015 disconnected =
true;
1017 return disconnected;
1035 bool is_valid =
false;
1036 unsigned det =
DetId(cell_id).
det();
1063 bool is_valid =
false;
1064 for (
const auto cell_id :
cells) {
1065 unsigned det =
DetId(cell_id).
det();
1074 bool is_valid =
false;
geom_set getNeighborsFromTriggerCell(const unsigned) const final
static constexpr unsigned hSc_tcs_per_module_phi_
geom_set getLpgbtsFromModule(const unsigned) const final
GlobalPoint getTriggerCellPosition(const unsigned) const final
HGCalGeomRotation geom_rotation_120_
std::unordered_map< unsigned, unsigned > links_per_module_
HGCalGeomRotation::WaferCentring getWaferCentring(unsigned layer, int subdet) const
unsigned tcEtaphiMappingToSector0(int &tc_ieta, int &tc_iphi) const
std::unordered_map< unsigned, unsigned > stage1link_to_stage1_
int moduleU() const
get the module U
T getParameter(std::string const &) const
void uvMappingFromSector0(WaferCentring waferCentring, int &moduleU, int &moduleV, unsigned sector) const
constexpr int iphi() const
get the phi index
static const int kHGCalTriggerSubdetMask
geom_set getStage2FpgasFromStage1Fpga(const unsigned) const final
std::vector< int > cellV() const
geom_set getTriggerCellsFromModule(const unsigned) const final
geom_ordered_set getOrderedTriggerCellsFromModule(const unsigned) const final
std::vector< int > cellU() const
int layer() const
get the layer #
std::unordered_multimap< unsigned, unsigned > stage1_to_stage1links_
void setEEGeometry(const HGCalGeometry *geom)
bool validTriggerCellFromCells(const unsigned) const
constexpr int ietaAbs() const
std::string fullPath() const
auto module_id(edm::ModuleCallingContext const &mcc)
static constexpr unsigned hSc_back_layers_split_
unsigned getStage1FpgaFromLpgbt(const unsigned) const final
int32_t waferU(const int32_t index)
GlobalPoint getModulePosition(const unsigned) const final
bool valid(const DetId &id) const override
Is this a valid cell id.
const HGCalTopology & eeTopology() const
std::unordered_multimap< unsigned, unsigned > lpgbt_to_modules_
static constexpr int hSc_tc_layer0_min_
unsigned getTriggerCellFromCell(const unsigned) const final
unsigned hSc_triggercell_size_
Global3DPoint GlobalPoint
static const int kHGCalModuleVOffset
int eta() const
get the scintillator panel eta
std::unordered_map< unsigned, unsigned > lpgbt_to_stage1_
int zside() const
get the z-side of the cell (1/-1)
unsigned triggerLayer(const unsigned) const final
edm::FileInPath jsonMappingFile_
std::unordered_multimap< unsigned, unsigned > stage2_to_stage1links_
static const int kHGCalLayerMask
constexpr int zside() const
get the z-side of the cell (1/-1)
std::vector< unsigned > getLpgbtsFromStage1Fpga(const unsigned) const final
Log< level::Error, false > LogError
void setHSiGeometry(const HGCalGeometry *geom)
bool validCell(const unsigned) const final
int zside() const
get the z-side of the cell (1/-1)
unsigned getStage2FpgaFromStage1Link(const unsigned) const final
int detIdWaferType(unsigned det, unsigned layer, short waferU, short waferV) const
std::unordered_map< unsigned, bool > stage1links_samesector_
constexpr Detector det() const
get the detector field from this detid
std::unordered_multimap< unsigned, unsigned > module_to_lpgbts_
static const int kHGCalModuleUOffset
void setNoseGeometry(const HGCalGeometry *geom)
bool validTriggerCell(const unsigned) const final
unsigned getNextSector(const unsigned sector) const
unsigned getModuleSize(const unsigned module_id) const final
int layer() const
get the layer #
geom_ordered_set getOrderedCellsFromModule(const unsigned) const final
ALPAKA_FN_ACC ALPAKA_FN_INLINE uint32_t ietaAbs(uint32_t id)
constexpr int32_t waferV() const
int type() const
get the type
int layer() const
get the layer #
int getTypeHex(int layer, int waferU, int waferV) const
unsigned getModuleFromTriggerCell(const unsigned) const final
unsigned getModuleFromCell(const unsigned) const final
std::vector< HFNoseTriggerDetId > getTriggerDetIds(HFNoseDetId const &id) const
unsigned lastTriggerLayer() const final
void getScintillatoriEtaiPhi(int &ieta, int &iphi, int tc_eta, int tc_phi, unsigned layer) const
bool validCellId(unsigned det, unsigned cell_id) const
bool disconnectedModule(const unsigned) const final
HGCalTriggerSubdetector subdet() const
get the subdetector
constexpr int32_t zside() const
get the z-side of the cell (1/-1)
std::unordered_map< unsigned, std::vector< unsigned > > stage1_to_lpgbts_
void setHScGeometry(const HGCalGeometry *geom)
std::vector< unsigned > trigger_layers_
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
unsigned int layers(bool reco) const
int getTypeTrap(int layer) const
int type() const
get the type
const BasicVectorType & basicVector() const
unsigned getLinksInModule(const unsigned module_id) const final
constexpr int type() const
get/set the type
HGCalTriggerGeometryV9Imp3(const edm::ParameterSet &conf)
unsigned getStage1FpgaFromModule(const unsigned module_id) const final
unsigned last_trigger_layer_
def split(sequence, size)
geom_set getStage1FpgasFromStage2Fpga(const unsigned) const final
static const int kHGCalModuleUMask
unsigned getPreviousSector(const unsigned sector) const
static constexpr int nSectors_
unsigned layerWithOffset(unsigned) const
int type() const
get the type
const HGCalGeometry * hscGeometry() const
int layer() const
get the layer #
int type() const
get the type
std::vector< int > cellU() const
constexpr int32_t triggerCellV() const
std::set< unsigned > geom_ordered_set
constexpr int32_t layer() const
get the layer #
const HGCalTopology & noseTopology() const
std::vector< int > cellV() const
GlobalPoint getPosition(const DetId &id, bool debug=false) const
const HGCalTopology & hscTopology() const
constexpr int layer() const
get the layer #
constexpr int32_t triggerCellU() const
std::unordered_set< unsigned > geom_set
int32_t waferV(const int32_t index)
int moduleV() const
get the module V
geom_set getStage1LinksFromStage2Fpga(const unsigned) const final
geom_set getModulesFromLpgbt(const unsigned) const final
static constexpr unsigned hSc_front_layers_split_
std::unordered_map< unsigned, unsigned > stage1link_to_stage2_
geom_set getCellsFromModule(const unsigned) const final
std::vector< unsigned > trigger_nose_layers_
static const int kHGCalModuleVMask
#define DEFINE_EDM_PLUGIN(factory, type, name)
const HGCalGeometry * noseGeometry() const
unsigned getStage1FpgaFromStage1Link(const unsigned) const final
int zside() const
get the z-side of the module (1/-1)
constexpr int32_t waferU() const
int triggerSubdetId() const
get the trigger sub-detector
geom_set getStage1LinksFromStage1Fpga(const unsigned) const final
constexpr int32_t type() const
get the type
void initialize(const HGCalGeometry *, const HGCalGeometry *, const HGCalGeometry *) final
unsigned uvMappingToSector0(WaferCentring waferCentring, int &moduleU, int &moduleV) const
static const int kHGCalLayerOffset
geom_set getCellsFromTriggerCell(const unsigned) const final
const HGCalGeometry * hsiGeometry() const
static constexpr int ntc_per_wafer_
std::vector< std::pair< int, int > > getTriggerId(int roc, int type) const
static constexpr unsigned hSc_num_panels_per_sector_
const HGCalTopology & hsiTopology() const
int layer() const
get the layer #
std::unordered_map< unsigned, unsigned > module_to_stage1_
const HGCalDDDConstants & dddConstants() const
const HGCalGeometry * eeGeometry() const
static constexpr unsigned hSc_layer_for_split_
int sector() const
get the sector #
unsigned packLayerSubdetWaferId(unsigned layer, int subdet, int waferU, int waferV) const
std::unordered_set< unsigned > disconnected_layers_
void etaphiMappingFromSector0(int &ieta, int &iphi, unsigned sector) const
int phi() const
get the scintillator panel phi
int zside() const
get the z-side of the cell (1/-1)
void unpackLayerSubdetWaferId(unsigned wafer, unsigned &layer, int &subdet, int &waferU, int &waferV) const
static const int kHGCalTriggerSubdetOffset
void layerWithoutOffsetAndSubdetId(unsigned &layer, int &subdetId, bool isSilicon) const