11 #include "oneapi/tbb/concurrent_unordered_set.h" 57 bool validCell(
const unsigned)
const final;
94 bool validCellId(
unsigned det,
unsigned cell_id)
const;
108 hSc_triggercell_size_(conf.getParameter<unsigned>(
"ScintillatorTriggerCellSize")),
109 hSc_module_size_(conf.getParameter<unsigned>(
"ScintillatorModuleSize")),
110 hSc_links_per_module_(conf.getParameter<unsigned>(
"ScintillatorLinksPerModule")),
111 l1tModulesMapping_(conf.getParameter<
edm::FileInPath>(
"L1TModulesMapping")),
112 l1tLinksMapping_(conf.getParameter<
edm::FileInPath>(
"L1TLinksMapping")) {
113 const unsigned ntc_per_wafer = 48;
118 std::vector<unsigned> tmp_vector = conf.
getParameter<std::vector<unsigned>>(
"DisconnectedModules");
120 tmp_vector = conf.
getParameter<std::vector<unsigned>>(
"DisconnectedLayers");
140 unsigned trigger_layer = 1;
168 unsigned trigger_layer = 1;
185 unsigned trigger_nose_layer = 1;
188 trigger_nose_layer++;
193 unsigned det =
DetId(cell_id).
det();
194 unsigned trigger_cell_id = 0;
207 cell_nose_id.
zside(),
209 cell_nose_id.
layer(),
228 return trigger_cell_id;
236 unsigned det =
DetId(trigger_cell_id).
det();
238 unsigned subdet_old = 0;
240 unsigned tc_type = 1;
246 tc_type = trigger_cell_sc_id.
type();
259 tc_type = trigger_cell_trig_id.
type();
262 int waferu = trigger_cell_trig_id.
waferU();
263 int waferv = trigger_cell_trig_id.
waferV();
271 unsigned subdet = trigger_cell_trig_id.
subdet();
277 int waferu = trigger_cell_trig_id.
waferU();
278 int waferv = trigger_cell_trig_id.
waferV();
280 unsigned packed_wafer =
packLayerWaferId(layer_with_offset, waferu, waferv);
286 if (insert_itr.second) {
288 <<
"Found missing wafer (layer=" << layer_with_offset <<
" u=" << waferu <<
" v=" << waferv
289 <<
") in trigger modules mapping";
292 module = module_itr->second;
302 const unsigned trigger_cell_id)
const {
303 DetId trigger_cell_det_id(trigger_cell_id);
304 unsigned det = trigger_cell_det_id.
det();
316 cell_det_ids.emplace(cell_id);
326 int type = trigger_cell_nose_id.
type();
327 int waferu = trigger_cell_nose_id.
waferU();
328 int waferv = trigger_cell_nose_id.
waferV();
329 std::vector<int> cellus = trigger_cell_nose_id.
cellU();
330 std::vector<int> cellvs = trigger_cell_nose_id.
cellV();
331 for (
unsigned ic = 0; ic < cellus.size(); ic++) {
333 cell_det_ids.emplace(cell_det_id);
339 unsigned subdet = trigger_cell_trig_id.
subdet();
344 int type = trigger_cell_trig_id.
type();
345 int waferu = trigger_cell_trig_id.
waferU();
346 int waferv = trigger_cell_trig_id.
waferV();
347 std::vector<int> cellus = trigger_cell_trig_id.
cellU();
348 std::vector<int> cellvs = trigger_cell_trig_id.
cellV();
349 for (
unsigned ic = 0; ic < cellus.size(); ic++) {
351 cell_det_ids.emplace(cell_det_id);
361 for (
auto trigger_cell_id : trigger_cells) {
363 cell_det_ids.insert(
cells.begin(),
cells.end());
372 for (
auto trigger_cell_id : trigger_cells) {
374 cell_det_ids.insert(
cells.begin(),
cells.end());
382 unsigned det = module_det_id.
det();
396 trigger_cell_det_ids.emplace(trigger_cell_id);
405 for (
auto const&
idx : ids) {
407 trigger_cell_det_ids.emplace(
idx);
417 for (
auto wafer_itr = wafer_itrs.first; wafer_itr != wafer_itrs.second; wafer_itr++) {
432 for (
const auto& tc_uv : tc_uvs) {
434 subdet, module_si_id.
zside(), wafer_type,
layer, waferu, waferv, tc_uv.first, tc_uv.second);
436 trigger_cell_det_ids.emplace(trigger_cell_id);
442 return trigger_cell_det_ids;
448 unsigned det = module_det_id.
det();
460 trigger_cell_det_ids.emplace(trigger_cell_id);
469 for (
auto const&
idx : ids) {
471 trigger_cell_det_ids.emplace(
idx);
481 for (
auto wafer_itr = wafer_itrs.first; wafer_itr != wafer_itrs.second; wafer_itr++) {
496 for (
const auto& tc_uv : tc_uvs) {
498 subdet, module_si_id.
zside(), wafer_type,
layer, waferu, waferv, tc_uv.first, tc_uv.second);
499 trigger_cell_det_ids.emplace(trigger_cell_id);
504 return trigger_cell_det_ids;
508 const unsigned trigger_cell_id)
const {
509 throw cms::Exception(
"FeatureNotImplemented") <<
"Neighbor search is not implemented in HGCalTriggerGeometryV9Imp2";
535 unsigned nWafers = 1;
552 unsigned det =
DetId(trigger_cell_det_id).
det();
558 for (
const auto& cell : cell_ids) {
565 for (
const auto& cell : cell_ids) {
572 for (
const auto& cell : cell_ids) {
579 return GlobalPoint(triggerCellVector / cell_ids.size());
583 unsigned det =
DetId(module_det_id).
det();
589 for (
const auto& cell : cell_ids) {
595 for (
const auto& cell : cell_ids) {
601 for (
const auto& cell : cell_ids) {
609 return GlobalPoint(moduleVector / cell_ids.size());
615 if (!l1tModulesMappingStream.is_open()) {
616 throw cms::Exception(
"MissingDataFile") <<
"Cannot open HGCalTriggerGeometry L1TModulesMapping file\n";
623 for (; l1tModulesMappingStream >>
layer >> waferu >> waferv >>
module;) {
627 if (!l1tModulesMappingStream.eof()) {
629 <<
"Error reading L1TModulesMapping '" <<
layer <<
" " << waferu <<
" " << waferv <<
" " <<
module <<
"' \n";
631 l1tModulesMappingStream.close();
634 if (!l1tLinksMappingStream.is_open()) {
635 throw cms::Exception(
"MissingDataFile") <<
"Cannot open HGCalTriggerGeometry L1TLinksMapping file\n";
638 const short max_modules_60deg_sector = 127;
643 if (
module > max_modules_60deg_sector)
647 if (!l1tLinksMappingStream.eof()) {
649 <<
"Error reading L1TLinksMapping '" <<
layer <<
" " <<
module <<
" " <<
links <<
"' \n";
651 l1tLinksMappingStream.close();
655 unsigned packed_value = 0;
656 unsigned waferUsign = (
waferU >= 0) ? 0 : 1;
657 unsigned waferVsign = (
waferV >= 0) ? 0 : 1;
666 unsigned packed_value = 0;
672 unsigned waferUsign = (
waferU >= 0) ? 0 : 1;
673 unsigned waferVsign = (
waferV >= 0) ? 0 : 1;
684 unsigned packed_value = 0;
710 bool disconnected =
false;
733 bool is_valid =
false;
734 unsigned det =
DetId(cell_id).
det();
761 bool is_valid =
false;
762 for (
const auto cell_id :
cells) {
763 unsigned det =
DetId(cell_id).
det();
772 bool is_valid =
false;
848 return stage1link_ids;
852 unsigned stage1_id = 0;
857 unsigned stage2_id = 0;
863 return stage1link_ids;
867 std::vector<unsigned> lpgbt_ids;
872 unsigned stage1_id = 0;
887 unsigned stage1_id = 0;
geom_set getStage2FpgasFromStage1Fpga(const unsigned) const final
unsigned triggerLayer(const unsigned) const final
unsigned getModuleFromCell(const unsigned) const final
bool validTriggerCell(const unsigned) const final
T getParameter(std::string const &) const
constexpr int iphi() const
get the phi index
int wafer() const
get the wafer #
std::vector< int > cellV() const
static const int kHGCalLayerOffset
geom_ordered_set getOrderedTriggerCellsFromModule(const unsigned) const final
std::vector< int > cellU() const
int layer() const
get the layer #
unsigned hSc_wafers_per_module_
static const int kHGCalLayerMask
void setEEGeometry(const HGCalGeometry *geom)
constexpr int ietaAbs() const
std::string fullPath() const
unsigned lastTriggerLayer() const final
auto module_id(edm::ModuleCallingContext const &mcc)
int32_t waferU(const int32_t index)
tbb::concurrent_unordered_set< unsigned > cache_missing_wafers_
std::vector< unsigned > trigger_layers_
geom_set getNeighborsFromTriggerCell(const unsigned) const final
bool valid(const DetId &id) const override
Is this a valid cell id.
const HGCalTopology & eeTopology() const
unsigned hSc_triggercell_size_
Global3DPoint GlobalPoint
geom_set getModulesFromLpgbt(const unsigned) const final
std::pair< int, int > getREtaRange(int lay) const
geom_set getLpgbtsFromModule(const unsigned) const final
std::unordered_map< unsigned, unsigned > links_per_module_
int zside() const
get the z-side of the cell (1/-1)
unsigned packLayerModuleId(unsigned layer, unsigned wafer) const
bool validTriggerCellFromCells(const unsigned) const
std::unordered_map< unsigned, unsigned > wafer_to_module_
constexpr int zside() const
get the z-side of the cell (1/-1)
static const HFNoseDetId getModule(HFNoseDetId const &id)
static const int kSubdetOffset
void setHSiGeometry(const HGCalGeometry *geom)
int zside() const
get the z-side of the cell (1/-1)
constexpr Detector det() const
get the detector field from this detid
void setNoseGeometry(const HGCalGeometry *geom)
int detIdWaferType(unsigned det, unsigned layer, short waferU, short waferV) const
int layer() const
get the layer #
static const int kHGCalCellMask
ALPAKA_FN_ACC ALPAKA_FN_INLINE uint32_t ietaAbs(uint32_t id)
constexpr int32_t waferV() const
static constexpr uint32_t kHGCalWaferUMask
unsigned packWaferId(int waferU, int waferV) const
unsigned getStage1FpgaFromLpgbt(const unsigned) const final
GlobalPoint getPosition(const DetId &id, bool cog, bool debug) const
int layer() const
get the layer #
int getTypeHex(int layer, int waferU, int waferV) const
std::vector< HFNoseTriggerDetId > getTriggerDetIds(HFNoseDetId const &id) const
GlobalPoint getModulePosition(const unsigned) const final
static const int kSubdetMask
unsigned getModuleSize(const unsigned module_id) const final
unsigned layerWithOffset(unsigned) const
unsigned getModuleFromTriggerCell(const unsigned) const final
unsigned packLayerWaferId(unsigned layer, int waferU, int waferV) const
HGCalTriggerSubdetector subdet() const
get the subdetector
static constexpr uint32_t kHGCalWaferVOffset
std::unordered_set< unsigned > disconnected_modules_
constexpr int32_t zside() const
get the z-side of the cell (1/-1)
unsigned getTriggerCellFromCell(const unsigned) const final
Abs< T >::type abs(const T &t)
HGCalTriggerGeometryV9Imp2(const edm::ParameterSet &conf)
void setHScGeometry(const HGCalGeometry *geom)
int zside() const
get the z-side of the cell (1/-1)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
geom_set getStage1LinksFromStage2Fpga(const unsigned) const final
unsigned int layers(bool reco) const
edm::FileInPath l1tLinksMapping_
static constexpr uint32_t kHGCalWaferUOffset
int type() const
get the type
const BasicVectorType & basicVector() const
constexpr int type() const
get/set the type
std::vector< unsigned > trigger_nose_layers_
static constexpr uint32_t kHGCalWaferVSignMask
unsigned hSc_links_per_module_
unsigned getStage2FpgaFromStage1Link(const unsigned) const final
static constexpr uint32_t kHGCalLayerOffset
bool validCell(const unsigned) const final
unsigned getStage1FpgaFromModule(const unsigned module_id) const final
unsigned getStage1FpgaFromStage1Link(const unsigned) const final
constexpr uint32_t rawId() const
get the raw id
int type() const
get the type
const HGCalGeometry * hscGeometry() const
unsigned last_trigger_layer_
int layer() const
get the layer #
GlobalPoint getTriggerCellPosition(const unsigned) const final
static const int kHGCalWaferOffset
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 #
std::vector< unsigned > getLpgbtsFromStage1Fpga(const unsigned) const final
const HGCalTopology & noseTopology() const
geom_set getStage1FpgasFromStage2Fpga(const unsigned) const final
std::vector< int > cellV() const
static constexpr uint32_t kHGCalLayerMask
bool validCellId(unsigned det, unsigned cell_id) const
std::unordered_set< unsigned > disconnected_layers_
const HGCalTopology & hscTopology() const
constexpr int layer() const
get the layer #
constexpr int32_t triggerCellU() const
std::unordered_set< unsigned > geom_set
std::unordered_multimap< unsigned, unsigned > module_to_wafers_
int32_t waferV(const int32_t index)
geom_set getStage1LinksFromStage1Fpga(const unsigned) const final
static constexpr uint32_t kHGCalWaferUSignMask
static constexpr uint32_t kHGCalWaferVMask
static constexpr uint32_t kHGCalWaferUSignOffset
edm::FileInPath l1tModulesMapping_
static constexpr uint32_t kHGCalWaferVSignOffset
void initialize(const HGCalGeometry *, const HGCalGeometry *, const HGCalGeometry *) final
#define DEFINE_EDM_PLUGIN(factory, type, name)
const HGCalGeometry * noseGeometry() const
void unpackWaferId(unsigned wafer, int &waferU, int &waferV) const
Log< level::Warning, false > LogWarning
constexpr int32_t waferU() const
constexpr int32_t type() const
get the type
const HGCalGeometry * hsiGeometry() const
geom_set getCellsFromTriggerCell(const unsigned) const final
std::vector< std::pair< int, int > > getTriggerId(int roc, int type) const
const HGCalTopology & hsiTopology() const
geom_ordered_set getOrderedCellsFromModule(const unsigned) const final
geom_set getTriggerCellsFromModule(const unsigned) const final
const HGCalDDDConstants & dddConstants() const
const HGCalGeometry * eeGeometry() const
geom_set getCellsFromModule(const unsigned) const final
unsigned hSc_module_size_
bool disconnectedModule(const unsigned) const final
int zside() const
get the z-side of the cell (1/-1)
static const int kHGCalWaferMask
unsigned getLinksInModule(const unsigned module_id) const final