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;
256 unsigned module_id = 0;
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();
313 int ieta = ietaAbs * trigger_cell_sc_id.
zside();
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());
371 const unsigned module_id)
const {
374 for (
auto trigger_cell_id : trigger_cells) {
376 cell_det_ids.insert(
cells.begin(),
cells.end());
382 const unsigned module_id)
const {
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;
408 for (
int ietaAbs = ieta0; ietaAbs < ieta0 + (
int)hSc_tcs_per_module_eta; ietaAbs++) {
409 int ieta = ietaAbs * hgc_module_id.
zside();
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;
458 const unsigned module_id)
const {
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;
485 for (
int ietaAbs = ieta0; ietaAbs < ieta0 + (
int)hSc_tcs_per_module_eta; ietaAbs++) {
486 int ieta = ietaAbs * hgc_module_id.
zside();
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;
662 for (
auto stage1_itr = stage1_itrs.first; stage1_itr != stage1_itrs.second; stage1_itr++) {
664 id.
zside(), HGCalTriggerBackendDetId::BackendType::LpGBT,
id.
sector(), stage1_itr->second));
675 id.
zside(), HGCalTriggerBackendDetId::BackendType::Stage1FPGA,
id.
sector(), stage1_label);
683 for (
auto lpgbt_itr = lpgbt_itrs.first; lpgbt_itr != lpgbt_itrs.second; lpgbt_itr++) {
719 for (
auto module_itr = module_itrs.first; module_itr != module_itrs.second; module_itr++) {
721 id.
zside(), HGCalTriggerBackendDetId::BackendType::LpGBT,
id.
sector(), module_itr->second));
730 unsigned stage1_label =
734 id.
zside(), HGCalTriggerBackendDetId::BackendType::Stage1FPGA,
id.
sector(), stage1_label);
738 unsigned det =
DetId(trigger_cell_det_id).
det();
745 for (
const auto& cell : cell_ids) {
752 for (
const auto& cell : cell_ids) {
759 for (
const auto& cell : cell_ids) {
766 return GlobalPoint(triggerCellVector / cell_ids.size());
776 for (
const auto& cell : cell_ids) {
782 for (
const auto& cell : cell_ids) {
788 for (
const auto& cell : cell_ids) {
796 return GlobalPoint(moduleVector / cell_ids.size());
803 if (!json_input_file.is_open()) {
804 throw cms::Exception(
"MissingDataFile") <<
"Cannot open HGCalTriggerGeometry L1TMapping file\n";
806 json_input_file >> mapping_config;
810 for (
unsigned stage2_id = 0; stage2_id < mapping_config.at(
"Stage2").size(); stage2_id++) {
811 for (
unsigned link_id = 0; link_id < mapping_config.at(
"Stage2").at(stage2_id).at(
"Stage1Links").size();
815 link_id, mapping_config.at(
"Stage2").at(stage2_id).at(
"Stage1Links").at(link_id).at(
"SameSector"));
820 <<
"The mapping input json file does not have the expected structure for the Stage2 block";
824 for (
unsigned link_id = 0; link_id < mapping_config.at(
"Stage1Links").size(); link_id++) {
829 stage1link_to_stage2_.emplace(link_id, mapping_config.at(
"Stage1Links").at(link_id).at(
"Stage2SameSector"));
833 <<
"The mapping input json file does not have the expected structure for the Stage1Links block";
837 for (
unsigned stage1_id = 0; stage1_id < mapping_config.at(
"Stage1").size(); stage1_id++) {
839 for (
auto& link_id : mapping_config.at(
"Stage1").at(stage1_id).at(
"Stage1Links")) {
844 for (
auto& lpgbt_id : mapping_config.at(
"Stage1").at(stage1_id).at(
"lpgbts")) {
851 <<
"The mapping input json file does not have the expected structure for the Stage1 block";
855 for (
unsigned lpgbt_id = 0; lpgbt_id < mapping_config.at(
"lpgbt").size(); lpgbt_id++) {
857 unsigned stage1_id = mapping_config.at(
"lpgbt").at(lpgbt_id).at(
"Stage1");
861 for (
auto&
modules : mapping_config.at(
"lpgbt").at(lpgbt_id).at(
"Modules")) {
864 bool isSilicon =
modules.at(
"isSilicon");
871 if (
result.second ==
false &&
872 stage1_id !=
result.first->second) {
873 edm::LogError(
"HGCalTriggerGeometryV9Imp3") <<
"One module is connected to two separate Stage1 FPGAs";
880 <<
"The mapping input json file does not have the expected structure for the lpGBT block";
886 unsigned num_elinks = 0;
887 unsigned layer = mapping_config.at(
"Module").at(
module).at(
"layer");
888 unsigned moduleU = mapping_config.at(
"Module").at(
module).at(
"u");
889 unsigned moduleV = mapping_config.at(
"Module").at(
module).at(
"v");
890 bool isSilicon = mapping_config.at(
"Module").at(
module).at(
"isSilicon");
894 for (
auto& lpgbt : mapping_config.at(
"Module").at(
module).at(
"lpgbts")) {
896 num_elinks += unsigned(lpgbt.at(
"nElinks"));
903 <<
"The mapping input json file does not have the expected structure for the Module block";
906 json_input_file.close();
910 unsigned packed_value = 0;
946 if ((
layer % 2) == 1) {
955 <<
"HGCalTriggerGeometryV9Imp3: trigger sub-detector expected to be silicon";
986 int&
ieta,
int&
iphi,
int tc_eta,
int tc_phi,
unsigned layer)
const {
993 if (tc_eta <=
split) {
1005 bool disconnected =
false;
1009 disconnected =
true;
1012 disconnected =
true;
1014 return disconnected;
1032 bool is_valid =
false;
1033 unsigned det =
DetId(cell_id).
det();
1060 bool is_valid =
false;
1061 for (
const auto cell_id :
cells) {
1062 unsigned det =
DetId(cell_id).
det();
1071 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
geom_set getLpgbtsFromStage1Fpga(const unsigned) const final
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
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
std::string fullPath() const
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
int type() const
get/set the type
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
int layer() const
get the layer #
int type() const
get the type
int layer() const
get the layer #
int getTypeHex(int layer, int waferU, int waferV) const
int iphi() const
get the phi index
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
int layer() const
get the layer #
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 zside() const
get the z-side of the cell (1/-1)
int getTypeTrap(int layer) const
int type() const
get the type
const BasicVectorType & basicVector() const
unsigned getLinksInModule(const unsigned module_id) const final
HGCalTriggerGeometryV9Imp3(const edm::ParameterSet &conf)
unsigned getStage1FpgaFromModule(const unsigned module_id) const final
unsigned last_trigger_layer_
def split(sequence, size)
std::unordered_multimap< unsigned, unsigned > stage1_to_lpgbts_
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
int zside() const
get the z-side of the cell (1/-1)
const HGCalGeometry * hscGeometry() const
int layer() const
get the layer #
int type() const
get the type
std::vector< int > cellU() const
std::set< unsigned > geom_ordered_set
const HGCalTopology & noseTopology() const
std::vector< int > cellV() const
GlobalPoint getPosition(const DetId &id, bool debug=false) const
const HGCalTopology & hscTopology() 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)
int type() const
get the type
int triggerSubdetId() const
get the trigger sub-detector
geom_set getStage1LinksFromStage1Fpga(const unsigned) const final
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