Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 5 additions & 17 deletions CondFormats/HGCalObjects/interface/HGCalMappingModuleIndexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<bool, int> 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<bool, bool>(isSiPM, celltype);
}
static std::pair<bool, int8_t> getCellType(std::string_view typecode);

/**
* @short returns the index for the n-th module in the readout sequence of a FED
Expand Down Expand Up @@ -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 {
Expand All @@ -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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
56 changes: 53 additions & 3 deletions CondFormats/HGCalObjects/src/HGCalMappingModuleIndexer.cc
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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<bool, int8_t> 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()");
Comment thread
IzaakWN marked this conversation as resolved.
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()");
Comment thread
IzaakWN marked this conversation as resolved.
throw ex;
}
return std::pair<bool, int8_t>(isSiPM, celltype);
Comment thread
IzaakWN marked this conversation as resolved.
}

//
std::pair<uint32_t, uint32_t> HGCalMappingModuleIndexer::getIndexForFedAndModule(std::string const& typecode) const {
auto it = typecodeMap_.find(typecode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion RecoLocalCalo/HGCalRecAlgos/src/HGCalESProducerTools.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Comment thread
IzaakWN marked this conversation as resolved.
} else {
edm::LogInfo("search_fedkey") << "search_fedkey: Matched module='" << fedid << "' to fedkey='" << matchedkey
<< "'";
Expand Down