CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
List of all members | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Friends
HGCalMappingModuleIndexer Class Reference

utility class to assign dense readout module indexing the class holds the information on the expected readout sequence (module types) per FED and their offset in the SoAs of data More...

#include <HGCalMappingModuleIndexer.h>

Public Member Functions

void finalize ()
 
uint32_t getIndexForModule (uint32_t fedid, uint32_t nmod) const
 returns the index for the n-th module in the readout sequence of a FED if the index in the readout sequence is unknown alternative methods which take the (capture block, econd idx) are provided which will find first what should be the internal dense index (index in the readout sequence) More...
 
uint32_t getIndexForModule (uint32_t fedid, uint16_t captureblockIdx, uint16_t econdIdx) const
 
uint32_t getIndexForModuleData (uint32_t fedid, uint32_t nmod, uint32_t erxidx, uint32_t chidx) const
 
uint32_t getIndexForModuleData (uint32_t fedid, uint16_t captureblockIdx, uint16_t econdIdx, uint32_t erxidx, uint32_t chidx) const
 
uint32_t getIndexForModuleErx (uint32_t fedid, uint32_t nmod, uint32_t erxidx) const
 
uint32_t getIndexForModuleErx (uint32_t fedid, uint16_t captureblockIdx, uint16_t econdIdx, uint32_t erxidx) const
 
int getTypeForModule (uint32_t fedid, uint32_t nmod) const
 
int getTypeForModule (uint32_t fedid, uint16_t captureblockIdx, uint16_t econdIdx) const
 internal indexer More...
 
 HGCalMappingModuleIndexer ()
 
void processNewModule (uint32_t fedid, uint16_t captureblockIdx, uint16_t econdIdx, uint32_t typecodeIdx, uint32_t nerx, uint32_t nwords)
 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 More...
 
 ~HGCalMappingModuleIndexer ()=default
 

Static Public Member Functions

static std::pair< bool, int > convertTypeCode (std::string_view typecode)
 decodes silicon or sipm type and cell type for the detector id from the typecode string More...
 

Public Attributes

std::vector< uint32_t > dataOffsets_
 global counters (sizes of vectors) More...
 
std::vector< uint32_t > erxOffsets_
 
std::vector< HGCalFEDReadoutSequence_tfedReadoutSequences_
 global counters for types of modules, number of e-Rx and words More...
 
std::vector< uint32_t > globalTypesCounter_
 
std::vector< uint32_t > globalTypesNErx_
 
std::vector< uint32_t > globalTypesNWords_
 base offsets to apply per module type with different granularity : module, e-Rx, channel data More...
 
uint32_t maxDataIdx_
 
uint32_t maxErxIdx_
 
uint32_t maxModulesIdx_
 max number of main buffers/capture blocks per FED More...
 
HGCalDenseIndexerBase modFedIndexer_
 the sequence of FED readout sequence descriptors More...
 
std::vector< uint32_t > moduleOffsets_
 
uint32_t nfeds_
 

Static Public Attributes

static constexpr uint32_t maxCBperFED_ = 10
 max number of ECON-Ds processed by a main buffer/capture block More...
 
static constexpr uint32_t maxECONDperCB_ = 12
 

Private Member Functions

uint32_t denseIndexingFor (uint32_t fedid, uint16_t captureblockIdx, uint16_t econdIdx) const
 given capture block and econd indices returns the dense indexer More...
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Friends

class boost::serialization::access
 
template<typename CondSerializationT , typename Enabled >
struct cond::serialization::access
 

Detailed Description

utility class to assign dense readout module indexing the class holds the information on the expected readout sequence (module types) per FED and their offset in the SoAs of data

Definition at line 34 of file HGCalMappingModuleIndexer.h.

Constructor & Destructor Documentation

◆ HGCalMappingModuleIndexer()

HGCalMappingModuleIndexer::HGCalMappingModuleIndexer ( )
inline

Definition at line 36 of file HGCalMappingModuleIndexer.h.

References maxCBperFED_, and maxECONDperCB_.

static constexpr uint32_t maxCBperFED_
max number of ECON-Ds processed by a main buffer/capture block
static constexpr uint32_t maxECONDperCB_
HGCalDenseIndexerBase modFedIndexer_
the sequence of FED readout sequence descriptors

◆ ~HGCalMappingModuleIndexer()

HGCalMappingModuleIndexer::~HGCalMappingModuleIndexer ( )
default

Member Function Documentation

◆ convertTypeCode()

static std::pair<bool, int> HGCalMappingModuleIndexer::convertTypeCode ( std::string_view  typecode)
inlinestatic

decodes silicon or sipm type and cell type for the detector id from the typecode string

Definition at line 151 of file HGCalMappingModuleIndexer.h.

References HcalObjRepresent::isSiPM(), and funct::true.

151  {
152  if (typecode.size() < 5)
153  throw cms::Exception("InvalidHGCALTypeCode") << typecode << " is invalid for decoding readout cell type";
154 
155  bool isSiPM = {typecode.find("TM") != std::string::npos ? true : false};
156  int celltype;
157  if (isSiPM) {
158  celltype = 0; // Assign SiPM type coarse or molded with next version of modulelocator
159  } else {
160  celltype = {typecode[4] == '1' ? 0 : typecode[4] == '2' ? 1 : 2};
161  }
162  return std::pair<bool, bool>(isSiPM, celltype);
163  }
bool isSiPM(int ieta, int iphi, int depth)

◆ denseIndexingFor()

uint32_t HGCalMappingModuleIndexer::denseIndexingFor ( uint32_t  fedid,
uint16_t  captureblockIdx,
uint16_t  econdIdx 
) const
inlineprivate

given capture block and econd indices returns the dense indexer

Definition at line 219 of file HGCalMappingModuleIndexer.h.

References HGCalDenseIndexerBase::denseIndex(), Exception, PixelSLinkDataInputSource_cfi::fedid, fedReadoutSequences_, heavyIonCSV_trainingSettings::idx, modFedIndexer_, and nfeds_.

Referenced by getIndexForModule(), getIndexForModuleData(), getIndexForModuleErx(), and getTypeForModule().

219  {
220  if (fedid > nfeds_)
221  throw cms::Exception("ValueError") << "FED ID=" << fedid << " is unknown to current mapping";
222  uint32_t idx = modFedIndexer_.denseIndex({{captureblockIdx, econdIdx}});
223  auto dense_idx = fedReadoutSequences_[fedid].moduleLUT_[idx];
224  if (dense_idx < 0)
225  throw cms::Exception("ValueError") << "FED ID=" << fedid << " capture block=" << captureblockIdx
226  << " econ=" << econdIdx << "has not been assigned a dense indexing"
227  << std::endl;
228  return uint32_t(dense_idx);
229  }
std::vector< HGCalFEDReadoutSequence_t > fedReadoutSequences_
global counters for types of modules, number of e-Rx and words
HGCalDenseIndexerBase modFedIndexer_
the sequence of FED readout sequence descriptors
uint32_t denseIndex(std::vector< uint32_t > v) const

◆ finalize()

void HGCalMappingModuleIndexer::finalize ( )
inline

Definition at line 81 of file HGCalMappingModuleIndexer.h.

References dataOffsets_, erxOffsets_, fedReadoutSequences_, globalTypesCounter_, globalTypesNErx_, globalTypesNWords_, mps_fire::i, maxDataIdx_, maxErxIdx_, maxModulesIdx_, moduleOffsets_, nfeds_, and heppy_batch::val.

Referenced by HGCalMappingESProducer::prepareModuleMapperIndexer().

81  {
82  //max indices at different levels
84  maxModulesIdx_ = std::accumulate(globalTypesCounter_.begin(), globalTypesCounter_.end(), 0);
85  maxErxIdx_ =
86  std::inner_product(globalTypesCounter_.begin(), globalTypesCounter_.end(), globalTypesNErx_.begin(), 0);
87  maxDataIdx_ =
88  std::inner_product(globalTypesCounter_.begin(), globalTypesCounter_.end(), globalTypesNWords_.begin(), 0);
89 
90  //compute the global offset to assign per board type, eRx and channel data
91  moduleOffsets_.resize(maxModulesIdx_, 0);
92  erxOffsets_.resize(maxModulesIdx_, 0);
93  dataOffsets_.resize(maxModulesIdx_, 0);
94  for (size_t i = 1; i < globalTypesCounter_.size(); i++) {
98  }
99  std::partial_sum(moduleOffsets_.begin(), moduleOffsets_.end(), moduleOffsets_.begin());
100  std::partial_sum(erxOffsets_.begin(), erxOffsets_.end(), erxOffsets_.begin());
101  std::partial_sum(dataOffsets_.begin(), dataOffsets_.end(), dataOffsets_.begin());
102 
103  //now go through the FEDs and ascribe the offsets per module in the readout sequence
104  std::vector<uint32_t> typeCounters(globalTypesCounter_.size(), 0);
105  for (auto &fedit : fedReadoutSequences_) {
106  //assign the indexing in the look-up table
107  size_t nconn(0);
108  fedit.moduleLUT_.resize(fedit.readoutTypes_.size(), -1);
109  for (size_t i = 0; i < fedit.readoutTypes_.size(); i++) {
110  if (fedit.readoutTypes_[i] == -1)
111  continue; //unexisting
112  fedit.moduleLUT_[i] = nconn;
113  nconn++;
114  }
115 
116  //remove unexisting ECONs building a final compact readout sequence
117  std::remove_if(
118  fedit.readoutTypes_.begin(), fedit.readoutTypes_.end(), [&](int val) -> bool { return val == -1; });
119 
120  //assign the final offsets at the different levels
121  size_t nmods = fedit.readoutTypes_.size();
122  fedit.modOffsets_.resize(nmods, 0);
123  fedit.erxOffsets_.resize(nmods, 0);
124  fedit.chDataOffsets_.resize(nmods, 0);
125  for (size_t i = 0; i < nmods; i++) {
126  uint32_t type_val = fedit.readoutTypes_[i];
127 
128  //module offset : global offset for this type + current index for this type
129  uint32_t baseMod_offset = moduleOffsets_[type_val] + typeCounters[type_val];
130  fedit.modOffsets_[i] = baseMod_offset; // + internalMod_offset;
131 
132  //erx-level offset : global offset of e-Rx of this type + #e-Rrx * current index for this type
133  uint32_t baseErx_offset = erxOffsets_[type_val];
134  uint32_t internalErx_offset = globalTypesNErx_[type_val] * typeCounters[type_val];
135  fedit.erxOffsets_[i] = baseErx_offset + internalErx_offset;
136 
137  //channel data offset: global offset for data of this type + #words * current index for this type
138  uint32_t baseData_offset = dataOffsets_[type_val];
139  uint32_t internalData_offset = globalTypesNWords_[type_val] * typeCounters[type_val];
140  fedit.chDataOffsets_[i] = baseData_offset + internalData_offset;
141 
142  typeCounters[type_val]++;
143  }
144  }
145  }
std::vector< uint32_t > moduleOffsets_
std::vector< uint32_t > erxOffsets_
uint32_t maxModulesIdx_
max number of main buffers/capture blocks per FED
std::vector< HGCalFEDReadoutSequence_t > fedReadoutSequences_
global counters for types of modules, number of e-Rx and words
std::vector< uint32_t > dataOffsets_
global counters (sizes of vectors)
std::vector< uint32_t > globalTypesNWords_
base offsets to apply per module type with different granularity : module, e-Rx, channel data ...
std::vector< uint32_t > globalTypesNErx_
std::vector< uint32_t > globalTypesCounter_

◆ getIndexForModule() [1/2]

uint32_t HGCalMappingModuleIndexer::getIndexForModule ( uint32_t  fedid,
uint32_t  nmod 
) const
inline

returns the index for the n-th module in the readout sequence of a FED if the index in the readout sequence is unknown alternative methods which take the (capture block, econd idx) are provided which will find first what should be the internal dense index (index in the readout sequence)

Definition at line 170 of file HGCalMappingModuleIndexer.h.

References PixelSLinkDataInputSource_cfi::fedid, and fedReadoutSequences_.

Referenced by getIndexForModule().

170  {
171  return fedReadoutSequences_[fedid].modOffsets_[nmod];
172  };
std::vector< HGCalFEDReadoutSequence_t > fedReadoutSequences_
global counters for types of modules, number of e-Rx and words

◆ getIndexForModule() [2/2]

uint32_t HGCalMappingModuleIndexer::getIndexForModule ( uint32_t  fedid,
uint16_t  captureblockIdx,
uint16_t  econdIdx 
) const
inline

Definition at line 173 of file HGCalMappingModuleIndexer.h.

References denseIndexingFor(), PixelSLinkDataInputSource_cfi::fedid, and getIndexForModule().

173  {
174  uint32_t nmod = denseIndexingFor(fedid, captureblockIdx, econdIdx);
175  return getIndexForModule(fedid, nmod);
176  };
uint32_t getIndexForModule(uint32_t fedid, uint32_t nmod) const
returns the index for the n-th module in the readout sequence of a FED if the index in the readout se...
uint32_t denseIndexingFor(uint32_t fedid, uint16_t captureblockIdx, uint16_t econdIdx) const
given capture block and econd indices returns the dense indexer

◆ getIndexForModuleData() [1/2]

uint32_t HGCalMappingModuleIndexer::getIndexForModuleData ( uint32_t  fedid,
uint32_t  nmod,
uint32_t  erxidx,
uint32_t  chidx 
) const
inline

Definition at line 184 of file HGCalMappingModuleIndexer.h.

References PixelSLinkDataInputSource_cfi::fedid, fedReadoutSequences_, and HGCalMappingCellIndexer::maxChPerErx_.

Referenced by getIndexForModuleData().

184  {
185  return fedReadoutSequences_[fedid].chDataOffsets_[nmod] + erxidx * HGCalMappingCellIndexer::maxChPerErx_ + chidx;
186  };
static constexpr uint16_t maxChPerErx_
std::vector< HGCalFEDReadoutSequence_t > fedReadoutSequences_
global counters for types of modules, number of e-Rx and words

◆ getIndexForModuleData() [2/2]

uint32_t HGCalMappingModuleIndexer::getIndexForModuleData ( uint32_t  fedid,
uint16_t  captureblockIdx,
uint16_t  econdIdx,
uint32_t  erxidx,
uint32_t  chidx 
) const
inline

Definition at line 187 of file HGCalMappingModuleIndexer.h.

References denseIndexingFor(), PixelSLinkDataInputSource_cfi::fedid, and getIndexForModuleData().

188  {
189  uint32_t nmod = denseIndexingFor(fedid, captureblockIdx, econdIdx);
190  return getIndexForModuleData(fedid, nmod, erxidx, chidx);
191  };
uint32_t getIndexForModuleData(uint32_t fedid, uint32_t nmod, uint32_t erxidx, uint32_t chidx) const
uint32_t denseIndexingFor(uint32_t fedid, uint16_t captureblockIdx, uint16_t econdIdx) const
given capture block and econd indices returns the dense indexer

◆ getIndexForModuleErx() [1/2]

uint32_t HGCalMappingModuleIndexer::getIndexForModuleErx ( uint32_t  fedid,
uint32_t  nmod,
uint32_t  erxidx 
) const
inline

Definition at line 177 of file HGCalMappingModuleIndexer.h.

References PixelSLinkDataInputSource_cfi::fedid, and fedReadoutSequences_.

Referenced by getIndexForModuleErx().

177  {
178  return fedReadoutSequences_[fedid].erxOffsets_[nmod] + erxidx;
179  };
std::vector< HGCalFEDReadoutSequence_t > fedReadoutSequences_
global counters for types of modules, number of e-Rx and words

◆ getIndexForModuleErx() [2/2]

uint32_t HGCalMappingModuleIndexer::getIndexForModuleErx ( uint32_t  fedid,
uint16_t  captureblockIdx,
uint16_t  econdIdx,
uint32_t  erxidx 
) const
inline

Definition at line 180 of file HGCalMappingModuleIndexer.h.

References denseIndexingFor(), PixelSLinkDataInputSource_cfi::fedid, and getIndexForModuleErx().

180  {
181  uint32_t nmod = denseIndexingFor(fedid, captureblockIdx, econdIdx);
182  return getIndexForModuleErx(fedid, nmod, erxidx);
183  }
uint32_t getIndexForModuleErx(uint32_t fedid, uint32_t nmod, uint32_t erxidx) const
uint32_t denseIndexingFor(uint32_t fedid, uint16_t captureblockIdx, uint16_t econdIdx) const
given capture block and econd indices returns the dense indexer

◆ getTypeForModule() [1/2]

int HGCalMappingModuleIndexer::getTypeForModule ( uint32_t  fedid,
uint32_t  nmod 
) const
inline

Definition at line 193 of file HGCalMappingModuleIndexer.h.

References PixelSLinkDataInputSource_cfi::fedid, and fedReadoutSequences_.

Referenced by getTypeForModule().

193 { return fedReadoutSequences_[fedid].readoutTypes_[nmod]; }
std::vector< HGCalFEDReadoutSequence_t > fedReadoutSequences_
global counters for types of modules, number of e-Rx and words

◆ getTypeForModule() [2/2]

int HGCalMappingModuleIndexer::getTypeForModule ( uint32_t  fedid,
uint16_t  captureblockIdx,
uint16_t  econdIdx 
) const
inline

internal indexer

Definition at line 194 of file HGCalMappingModuleIndexer.h.

References denseIndexingFor(), PixelSLinkDataInputSource_cfi::fedid, and getTypeForModule().

◆ processNewModule()

void HGCalMappingModuleIndexer::processNewModule ( uint32_t  fedid,
uint16_t  captureblockIdx,
uint16_t  econdIdx,
uint32_t  typecodeIdx,
uint32_t  nerx,
uint32_t  nwords 
)
inline

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

Definition at line 46 of file HGCalMappingModuleIndexer.h.

References dataOffsets_, HGCalDenseIndexerBase::denseIndex(), PixelSLinkDataInputSource_cfi::fedid, fedReadoutSequences_, globalTypesCounter_, globalTypesNErx_, globalTypesNWords_, HGCalFEDReadoutSequence_t::id, heavyIonCSV_trainingSettings::idx, modFedIndexer_, and HGCalFEDReadoutSequence_t::readoutTypes_.

Referenced by HGCalMappingESProducer::prepareModuleMapperIndexer().

51  {
52  //add fed if needed
53  if (fedid >= fedReadoutSequences_.size()) {
54  fedReadoutSequences_.resize(fedid + 1);
55  }
57  frs.id = fedid;
58 
59  //assign position, resize if needed, and fill the type code
60  uint32_t idx = modFedIndexer_.denseIndex({{captureblockIdx, econdIdx}});
61  if (idx >= frs.readoutTypes_.size()) {
62  frs.readoutTypes_.resize(idx + 1, -1);
63  }
64  frs.readoutTypes_[idx] = typecodeIdx;
65 
66  //count another typecodein the global list
67  if (typecodeIdx >= globalTypesCounter_.size()) {
68  globalTypesCounter_.resize(typecodeIdx + 1, 0);
69  globalTypesNErx_.resize(typecodeIdx + 1, 0);
70  globalTypesNWords_.resize(typecodeIdx + 1, 0);
71  dataOffsets_.resize(typecodeIdx + 1, 0);
72  }
73  globalTypesCounter_[typecodeIdx]++;
74  globalTypesNErx_[typecodeIdx] = nerx;
75  globalTypesNWords_[typecodeIdx] = nwords;
76  }
std::vector< int > readoutTypes_
>dense sequence of modules in the readout: the type is the one in use in the cell mapping ...
std::vector< HGCalFEDReadoutSequence_t > fedReadoutSequences_
global counters for types of modules, number of e-Rx and words
std::vector< uint32_t > dataOffsets_
global counters (sizes of vectors)
this structure holds the indices and types in the readout sequence as the 12 capture blocks may not a...
std::vector< uint32_t > globalTypesNWords_
base offsets to apply per module type with different granularity : module, e-Rx, channel data ...
std::vector< uint32_t > globalTypesNErx_
HGCalDenseIndexerBase modFedIndexer_
the sequence of FED readout sequence descriptors
uint32_t denseIndex(std::vector< uint32_t > v) const
std::vector< uint32_t > globalTypesCounter_

◆ serialize()

template<class Archive >
void HGCalMappingModuleIndexer::serialize ( Archive &  ar,
const unsigned int  version 
)
private

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Definition at line 231 of file HGCalMappingModuleIndexer.h.

◆ cond::serialization::access

template<typename CondSerializationT , typename Enabled >
friend struct cond::serialization::access
friend

Definition at line 231 of file HGCalMappingModuleIndexer.h.

Member Data Documentation

◆ dataOffsets_

std::vector<uint32_t> HGCalMappingModuleIndexer::dataOffsets_

global counters (sizes of vectors)

Definition at line 206 of file HGCalMappingModuleIndexer.h.

Referenced by finalize(), and processNewModule().

◆ erxOffsets_

std::vector<uint32_t> HGCalMappingModuleIndexer::erxOffsets_

Definition at line 206 of file HGCalMappingModuleIndexer.h.

Referenced by finalize().

◆ fedReadoutSequences_

std::vector<HGCalFEDReadoutSequence_t> HGCalMappingModuleIndexer::fedReadoutSequences_

global counters for types of modules, number of e-Rx and words

Definition at line 202 of file HGCalMappingModuleIndexer.h.

Referenced by denseIndexingFor(), finalize(), getIndexForModule(), getIndexForModuleData(), getIndexForModuleErx(), getTypeForModule(), and processNewModule().

◆ globalTypesCounter_

std::vector<uint32_t> HGCalMappingModuleIndexer::globalTypesCounter_

Definition at line 204 of file HGCalMappingModuleIndexer.h.

Referenced by finalize(), and processNewModule().

◆ globalTypesNErx_

std::vector<uint32_t> HGCalMappingModuleIndexer::globalTypesNErx_

Definition at line 204 of file HGCalMappingModuleIndexer.h.

Referenced by finalize(), and processNewModule().

◆ globalTypesNWords_

std::vector<uint32_t> HGCalMappingModuleIndexer::globalTypesNWords_

base offsets to apply per module type with different granularity : module, e-Rx, channel data

Definition at line 204 of file HGCalMappingModuleIndexer.h.

Referenced by finalize(), and processNewModule().

◆ maxCBperFED_

constexpr uint32_t HGCalMappingModuleIndexer::maxCBperFED_ = 10
static

max number of ECON-Ds processed by a main buffer/capture block

Definition at line 211 of file HGCalMappingModuleIndexer.h.

Referenced by HGCalMappingModuleIndexer().

◆ maxDataIdx_

uint32_t HGCalMappingModuleIndexer::maxDataIdx_

Definition at line 208 of file HGCalMappingModuleIndexer.h.

Referenced by finalize().

◆ maxECONDperCB_

constexpr uint32_t HGCalMappingModuleIndexer::maxECONDperCB_ = 12
static

Definition at line 213 of file HGCalMappingModuleIndexer.h.

Referenced by HGCalMappingModuleIndexer().

◆ maxErxIdx_

uint32_t HGCalMappingModuleIndexer::maxErxIdx_

Definition at line 208 of file HGCalMappingModuleIndexer.h.

Referenced by finalize().

◆ maxModulesIdx_

uint32_t HGCalMappingModuleIndexer::maxModulesIdx_

max number of main buffers/capture blocks per FED

Definition at line 208 of file HGCalMappingModuleIndexer.h.

Referenced by finalize().

◆ modFedIndexer_

HGCalDenseIndexerBase HGCalMappingModuleIndexer::modFedIndexer_

the sequence of FED readout sequence descriptors

Definition at line 200 of file HGCalMappingModuleIndexer.h.

Referenced by denseIndexingFor(), and processNewModule().

◆ moduleOffsets_

std::vector<uint32_t> HGCalMappingModuleIndexer::moduleOffsets_

Definition at line 206 of file HGCalMappingModuleIndexer.h.

Referenced by finalize().

◆ nfeds_

uint32_t HGCalMappingModuleIndexer::nfeds_

Definition at line 208 of file HGCalMappingModuleIndexer.h.

Referenced by denseIndexingFor(), and finalize().