11 #include "oneapi/tbb/concurrent_unordered_set.h"
57 bool validCell(
const unsigned)
const final;
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;
114 hSc_wafers_per_module_ = std::round(hSc_module_size_ * hSc_module_size_ /
float(ntc_per_wafer));
115 if (ntc_per_wafer * hSc_wafers_per_module_ < hSc_module_size_ * hSc_module_size_) {
116 hSc_wafers_per_module_++;
118 std::vector<unsigned> tmp_vector = conf.getParameter<std::vector<unsigned>>(
"DisconnectedModules");
119 std::move(tmp_vector.begin(), tmp_vector.end(), std::inserter(disconnected_modules_, disconnected_modules_.end()));
120 tmp_vector = conf.getParameter<std::vector<unsigned>>(
"DisconnectedLayers");
121 std::move(tmp_vector.begin(), tmp_vector.end(), std::inserter(disconnected_layers_, disconnected_layers_.end()));
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;
242 unsigned module_id = 0;
246 tc_type = trigger_cell_sc_id.
type();
247 layer = trigger_cell_sc_id.
layer();
248 zside = trigger_cell_sc_id.
zside();
259 tc_type = trigger_cell_trig_id.
type();
260 layer = trigger_cell_trig_id.
layer();
261 zside = trigger_cell_trig_id.
zside();
262 int waferu = trigger_cell_trig_id.
waferU();
263 int waferv = trigger_cell_trig_id.
waferV();
271 unsigned subdet = trigger_cell_trig_id.
subdet();
274 layer = trigger_cell_trig_id.
layer();
275 zside = trigger_cell_trig_id.
zside();
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();
312 int ieta = ietaAbs * trigger_cell_sc_id.
zside();
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++) {
332 HFNoseDetId cell_det_id(zside, type, layer, waferu, waferv, cellus[ic], cellvs[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++) {
350 HGCSiliconDetId cell_det_id(cell_det, zside, type, layer, waferu, waferv, cellus[ic], cellvs[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());
369 const unsigned module_id)
const {
372 for (
auto trigger_cell_id : trigger_cells) {
374 cell_det_ids.insert(cells.begin(), cells.end());
380 const unsigned module_id)
const {
381 DetId module_det_id(module_id);
382 unsigned det = module_det_id.
det();
391 for (
int ietaAbs = ieta0; ietaAbs < ieta0 + (int)
hSc_module_size_; ietaAbs++) {
392 int ieta = ietaAbs * module_sc_id.
zside();
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;
446 const unsigned module_id)
const {
447 DetId module_det_id(module_id);
448 unsigned det = module_det_id.
det();
455 for (
int ietaAbs = ieta0; ietaAbs < ieta0 + (int)
hSc_module_size_; ietaAbs++) {
456 int ieta = ietaAbs * module_sc_id.
zside();
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";
513 DetId module_det_id(module_id);
534 DetId module_det_id(module_id);
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;
639 for (; l1tLinksMappingStream >> layer >> module >>
links;) {
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;
872 unsigned stage1_id = 0;
887 unsigned stage1_id = 0;
geom_set getStage2FpgasFromStage1Fpga(const unsigned) const final
unsigned triggerLayer(const unsigned) const final
static const int kHGCalWaferVOffset
unsigned getModuleFromCell(const unsigned) const final
bool validCellId(unsigned det, unsigned cell_id) const
bool validTriggerCell(const unsigned) const final
static const int kHGCalLayerOffset
unsigned packWaferId(int waferU, int waferV) const
geom_ordered_set getOrderedTriggerCellsFromModule(const unsigned) const final
int zside() const
get the z-side of the cell (1/-1)
HGCalTriggerSubdetector subdet() const
get the subdetector
int detIdWaferType(unsigned det, unsigned layer, short waferU, short waferV) const
unsigned hSc_wafers_per_module_
static const int kHGCalLayerMask
void setEEGeometry(const HGCalGeometry *geom)
int type() const
get the type
unsigned lastTriggerLayer() const final
int32_t waferU(const int32_t index)
tbb::concurrent_unordered_set< unsigned > cache_missing_wafers_
std::vector< unsigned > trigger_layers_
const HGCalGeometry * eeGeometry() const
const HGCalTopology & eeTopology() const
static const int kHGCalWaferVSignOffset
geom_set getNeighborsFromTriggerCell(const unsigned) const final
bool valid(const DetId &id) const override
Is this a valid cell id.
unsigned hSc_triggercell_size_
Global3DPoint GlobalPoint
constexpr uint32_t rawId() const
get the raw id
int getTypeHex(int layer, int waferU, int waferV) const
geom_set getModulesFromLpgbt(const unsigned) const final
geom_set getLpgbtsFromModule(const unsigned) const final
std::unordered_map< unsigned, unsigned > links_per_module_
int type() const
get/set the type
std::vector< int > cellV() const
int zside() const
get the z-side of the cell (1/-1)
std::unordered_map< unsigned, unsigned > wafer_to_module_
int zside() const
get the z-side of the cell (1/-1)
static const HFNoseDetId getModule(HFNoseDetId const &id)
static const int kSubdetOffset
const HGCalTopology & hsiTopology() const
void setHSiGeometry(const HGCalGeometry *geom)
std::vector< HFNoseTriggerDetId > getTriggerDetIds(HFNoseDetId const &id) const
int type() const
get the type
void setNoseGeometry(const HGCalGeometry *geom)
constexpr std::array< uint8_t, layerIndexSize > layer
std::vector< std::pair< int, int > > getTriggerId(int roc, int type) const
int layer() const
get the layer #
static const int kHGCalCellMask
const HGCalGeometry * noseGeometry() const
int type() const
get the type
unsigned getStage1FpgaFromLpgbt(const unsigned) const final
unsigned int layers(bool reco) const
int zside() const
get the z-side of the cell (1/-1)
GlobalPoint getModulePosition(const unsigned) const final
static const int kSubdetMask
unsigned getModuleSize(const unsigned module_id) const final
int layer() const
get the layer #
int type() const
get the type
unsigned getModuleFromTriggerCell(const unsigned) const final
int layer() const
get the layer #
void unpackWaferId(unsigned wafer, int &waferU, int &waferV) const
int zside() const
get the z-side of the cell (1/-1)
std::unordered_set< unsigned > disconnected_modules_
unsigned packLayerModuleId(unsigned layer, unsigned wafer) const
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
unsigned getTriggerCellFromCell(const unsigned) const final
Abs< T >::type abs(const T &t)
HGCalTriggerGeometryV9Imp2(const edm::ParameterSet &conf)
std::vector< int > cellV() const
void setHScGeometry(const HGCalGeometry *geom)
int iphi() const
get the phi index
geom_set getStage1LinksFromStage2Fpga(const unsigned) const final
int wafer() const
get the wafer #
edm::FileInPath l1tLinksMapping_
std::pair< int, int > getREtaRange(int lay) const
std::vector< unsigned > trigger_nose_layers_
unsigned hSc_links_per_module_
unsigned getStage2FpgaFromStage1Link(const unsigned) const final
static const int kHGCalLayerMask
geom_set getLpgbtsFromStage1Fpga(const unsigned) const final
const HGCalGeometry * hsiGeometry() const
caConstants::TupleMultiplicity const CAHitNtupletGeneratorKernelsGPU::HitToTuple const cms::cuda::AtomicPairCounter GPUCACell const *__restrict__ cells
std::vector< int > cellU() const
static const int kHGCalWaferVMask
static const int kHGCalWaferUSignMask
static const int kHGCalWaferUMask
bool validCell(const unsigned) const final
unsigned getStage1FpgaFromModule(const unsigned module_id) const final
const HGCalDDDConstants & dddConstants() const
unsigned getStage1FpgaFromStage1Link(const unsigned) const final
const HGCalGeometry * hscGeometry() const
const HGCalTopology & hscTopology() const
static const int kHGCalWaferVSignMask
unsigned last_trigger_layer_
GlobalPoint getTriggerCellPosition(const unsigned) const final
static const int kHGCalWaferOffset
std::set< unsigned > geom_ordered_set
int layer() const
get the layer #
geom_set getStage1FpgasFromStage2Fpga(const unsigned) const final
static const int kHGCalLayerOffset
int layer() const
get the layer #
std::unordered_set< unsigned > disconnected_layers_
std::vector< int > cellU() const
int zside() const
get the z-side of the cell (1/-1)
std::unordered_set< unsigned > geom_set
GlobalPoint getPosition(const DetId &id, bool debug=false) const
std::unordered_multimap< unsigned, unsigned > module_to_wafers_
int32_t waferV(const int32_t index)
geom_set getStage1LinksFromStage1Fpga(const unsigned) const final
const HGCalTopology & noseTopology() const
edm::FileInPath l1tModulesMapping_
std::string fullPath() const
unsigned layerWithOffset(unsigned) const
void initialize(const HGCalGeometry *, const HGCalGeometry *, const HGCalGeometry *) final
#define DEFINE_EDM_PLUGIN(factory, type, name)
unsigned packLayerWaferId(unsigned layer, int waferU, int waferV) const
static const int kHGCalWaferUOffset
Log< level::Warning, false > LogWarning
geom_set getCellsFromTriggerCell(const unsigned) const final
const BasicVectorType & basicVector() const
static const int kHGCalWaferUSignOffset
geom_ordered_set getOrderedCellsFromModule(const unsigned) const final
geom_set getTriggerCellsFromModule(const unsigned) const final
geom_set getCellsFromModule(const unsigned) const final
bool validTriggerCellFromCells(const unsigned) const
int layer() const
get the layer #
unsigned hSc_module_size_
bool disconnectedModule(const unsigned) const final
static const int kHGCalWaferMask
unsigned getLinksInModule(const unsigned module_id) const final
constexpr Detector det() const
get the detector field from this detid