diff --git a/CondFormats/HGCalObjects/interface/HGCalMappingModuleIndexer.h b/CondFormats/HGCalObjects/interface/HGCalMappingModuleIndexer.h index e1a46439339a5..29fa3d64c0358 100644 --- a/CondFormats/HGCalObjects/interface/HGCalMappingModuleIndexer.h +++ b/CondFormats/HGCalObjects/interface/HGCalMappingModuleIndexer.h @@ -13,7 +13,6 @@ #include "CondFormats/HGCalObjects/interface/HGCalDenseIndexerBase.h" #include "CondFormats/HGCalObjects/interface/HGCalMappingCellIndexer.h" #include "FWCore/Utilities/interface/Exception.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" /** * @short this structure holds the indices and types in the readout sequence @@ -61,21 +60,10 @@ class HGCalMappingModuleIndexer { void finalize(); /** - * @short decodes silicon or sipm type and cell type for the detector id - * from the typecode string + * @short decode silicon or sipm type and cell type for the detector id + * from the typecode string: "M[LH]-X[123]X-*" for Si, "T[LH]-L*S*[PN]" for SiPm */ - static std::pair convertTypeCode(std::string_view typecode) { - if (typecode.size() < 5) - throw cms::Exception("InvalidHGCALTypeCode") << typecode << " is invalid for decoding readout cell type"; - bool isSiPM = {typecode.find("TM") != std::string::npos ? true : false}; - int celltype; - if (isSiPM) { - celltype = 0; // assign SiPM type coarse or molded with next version of modulelocator - } else { - celltype = {typecode[4] == '1' ? 0 : typecode[4] == '2' ? 1 : 2}; - } - return std::pair(isSiPM, celltype); - } + static std::pair getCellType(std::string_view typecode); /** * @short returns the index for the n-th module in the readout sequence of a FED @@ -136,7 +124,7 @@ class HGCalMappingModuleIndexer { uint32_t getMaxModuleSize() const { return maxModulesIdx_; } ///< total number of ECON-Ds (useful for setting ECON-D SoA size) - uint32_t getNModules(uint32_t fedid) const { + uint32_t getNumModules(uint32_t fedid) const { return fedReadoutSequences_[fedid].readoutTypes_.size(); } ///< number of ECON-Ds for given FED id uint32_t getMaxERxSize() const { @@ -162,7 +150,7 @@ class HGCalMappingModuleIndexer { } ///< total number of channels for a given ECON-D typecode /** - @short return type ECON-D Module + * @short return type ECON-D Module */ int getTypeForModule(uint32_t fedid, uint32_t modid) const { return fedReadoutSequences_[fedid].readoutTypes_[modid]; diff --git a/CondFormats/HGCalObjects/interface/HGCalMappingParameterSoA.h b/CondFormats/HGCalObjects/interface/HGCalMappingParameterSoA.h index 81ddcfee498af..0722c1ca868f7 100644 --- a/CondFormats/HGCalObjects/interface/HGCalMappingParameterSoA.h +++ b/CondFormats/HGCalObjects/interface/HGCalMappingParameterSoA.h @@ -19,7 +19,7 @@ namespace hgcal { SOA_COLUMN(int, i1), SOA_COLUMN(int, i2), SOA_COLUMN(uint8_t, irot), - SOA_COLUMN(int, celltype), + SOA_COLUMN(int8_t, celltype), SOA_COLUMN(uint16_t, typeidx), SOA_COLUMN(uint16_t, fedid), SOA_COLUMN(uint16_t, slinkidx), diff --git a/CondFormats/HGCalObjects/src/HGCalMappingModuleIndexer.cc b/CondFormats/HGCalObjects/src/HGCalMappingModuleIndexer.cc index 1bde0af955552..8ced6f1d56144 100644 --- a/CondFormats/HGCalObjects/src/HGCalMappingModuleIndexer.cc +++ b/CondFormats/HGCalObjects/src/HGCalMappingModuleIndexer.cc @@ -1,6 +1,14 @@ +#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "CondFormats/HGCalObjects/interface/HGCalMappingModuleIndexer.h" - -// +#include "DataFormats/ForwardDetId/interface/HGCSiliconDetId.h" // for HGCSiliconDetId::waferType +#include "DataFormats/ForwardDetId/interface/HGCScintillatorDetId.h" // for HGCScintillatorDetId::tileGranularity + +/** + * @short for a new module it adds it's type to the readaout sequence vector + * if the fed id is not yet existing in the mapping it's added + * a dense indexer is used to create the necessary indices for the new module + * unused indices will be set with -1 + */ void HGCalMappingModuleIndexer::processNewModule(uint32_t fedid, uint16_t captureblockIdx, uint16_t econdIdx, @@ -48,7 +56,7 @@ void HGCalMappingModuleIndexer::processNewModule(uint32_t fedid, } } -// +/// @short to be called after all the modules have been processed void HGCalMappingModuleIndexer::finalize() { //max indices at different levels nfeds_ = fedReadoutSequences_.size(); @@ -123,6 +131,48 @@ void HGCalMappingModuleIndexer::finalize() { } } +/** + * @short decode silicon or sipm type and cell type for the detector id + * from the typecode string: "M[LH]-X[123]X-*" for Si, "T[LH]-L*S*[PN]" for SiPm + */ +std::pair HGCalMappingModuleIndexer::getCellType(std::string_view typecode) { + if (typecode.size() < 5) { + cms::Exception ex("InvalidHGCALTypeCode"); + ex << "'" << typecode << "' is invalid for decoding readout cell type"; + ex.addContext("Calling HGCalMappingModuleIndexer::getCellType()"); + throw ex; + } + int8_t celltype = -1; + const bool isSiPM = (typecode[0] == 'T'); + const bool isHD = (typecode[1] == 'H'); + if (isSiPM) { // assign SiPM type coarse or molded with next version of modulelocator + if (isHD) + celltype = HGCScintillatorDetId::tileGranularity::HGCalTileFine; + else + celltype = HGCScintillatorDetId::tileGranularity::HGCalTileNormal; + } else { // assign Si wafer type low/high density and thickness (120, 200, 300 um) + const char thickness = typecode[4]; + if (isHD) { + if (thickness == '1') + celltype = HGCSiliconDetId::waferType::HGCalHD120; + else if (thickness == '2') + celltype = HGCSiliconDetId::waferType::HGCalHD200; + } else { + if (thickness == '2') + celltype = HGCSiliconDetId::waferType::HGCalLD200; + else if (thickness == '3') + celltype = HGCSiliconDetId::waferType::HGCalLD300; + } + } + if (celltype == -1) { + cms::Exception ex("InvalidHGCALTypeCode"); + ex << "Could not parse cell type from typecode='" << typecode << "'"; + ex.addContext("Calling HGCalMappingModuleIndexer::getCellType()"); + throw ex; + } + return std::pair(isSiPM, celltype); +} + // std::pair HGCalMappingModuleIndexer::getIndexForFedAndModule(std::string const& typecode) const { auto it = typecodeMap_.find(typecode); diff --git a/Geometry/HGCalMapping/plugins/alpaka/HGCalMappingModuleESProducer.cc b/Geometry/HGCalMapping/plugins/alpaka/HGCalMappingModuleESProducer.cc index 406e99495f702..e854488099b30 100644 --- a/Geometry/HGCalMapping/plugins/alpaka/HGCalMappingModuleESProducer.cc +++ b/Geometry/HGCalMapping/plugins/alpaka/HGCalMappingModuleESProducer.cc @@ -64,7 +64,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { int typeidx = modIndexer.getTypeForModule(fedid, captureblockidx, econdidx); std::string typecode = pmap.getAttr("typecode", row); - auto celltypes = modIndexer.convertTypeCode(typecode); + auto celltypes = modIndexer.getCellType(typecode); bool isSiPM = celltypes.first; int celltype = celltypes.second; int zside = pmap.getIntAttr("zside", row); diff --git a/RecoLocalCalo/HGCalRecAlgos/src/HGCalESProducerTools.cc b/RecoLocalCalo/HGCalRecAlgos/src/HGCalESProducerTools.cc index c3e7ea9e43b94..ebfb5c106003b 100644 --- a/RecoLocalCalo/HGCalRecAlgos/src/HGCalESProducerTools.cc +++ b/RecoLocalCalo/HGCalRecAlgos/src/HGCalESProducerTools.cc @@ -28,7 +28,6 @@ namespace hgcal { << data.begin().key() << "'..."; ex.addContext("Calling hgcal::search_modkey()"); throw ex; - return data.begin().key(); // no matching key found in whole JSON map } // @short search first match to a given FED index in a JSON (following insertion order) @@ -74,6 +73,7 @@ namespace hgcal { ex << "Could not find matching key for '" << fedid << "' in '" << name << "'! Returning first key '" << matchedkey << "'..."; ex.addContext("Calling hgcal::search_fedkey()"); + throw ex; } else { edm::LogInfo("search_fedkey") << "search_fedkey: Matched module='" << fedid << "' to fedkey='" << matchedkey << "'";