CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Friends
HGCalMappingCellIndexer Class Reference

utility class to assign dense readout cell indexing More...

#include <HGCalMappingCellIndexer.h>

Public Member Functions

uint32_t denseIndex (std::string typecode, uint32_t chip, uint32_t half, uint32_t seq) const
 builders for the dense index More...
 
uint32_t denseIndex (std::string typecode, uint32_t erx, uint32_t seq) const
 
uint32_t denseIndex (size_t idx, uint32_t chip, uint32_t half, uint32_t seq) const
 
uint32_t denseIndex (size_t idx, uint32_t erx, uint32_t seq) const
 
uint32_t elecIdFromIndex (uint32_t rtn, std::string typecode) const
 decodes the dense index code More...
 
uint32_t elecIdFromIndex (uint32_t rtn, size_t idx) const
 
HGCalDenseIndexerBase getDenseIndexerFor (size_t idx) const
 returns the dense indexer for a given internal index More...
 
HGCalDenseIndexerBase getDenseIndexFor (std::string typecode) const
 returns the dense indexer for a typecode More...
 
size_t getEnumFromTypecode (std::string typecode) const
 gets index given typecode string More...
 
size_t getNErxExpectedFor (std::string typecode) const
 gets the number of e-Rx for a given typecode More...
 
size_t getNErxExpectedFor (size_t typecodeidx) const
 
size_t getNWordsExpectedFor (std::string typecode) const
 gets the number of words for a given typecode More...
 
size_t getNWordsExpectedFor (size_t typecodeidx) const
 
std::string getTypecodeFromEnum (size_t idx) const
 checks if there is a typecode corresponding to an index More...
 
 HGCalMappingCellIndexer ()=default
 
uint32_t maxDenseIndex () const
 returns the max. dense index expected More...
 
void processNewCell (std::string typecode, uint16_t chip, uint16_t half)
 
void update ()
 process the current list of type codes handled and updates the dense indexers More...
 
 ~HGCalMappingCellIndexer ()
 

Public Attributes

std::vector< HGCalDenseIndexerBasedi_
 
std::vector< uint16_t > maxErx_
 
std::vector< uint32_t > offsets_
 
std::map< std::string, size_t > typeCodeIndexer_
 

Static Public Attributes

static constexpr uint16_t maxChPerErx_ = 37
 
static constexpr char maxHalfPerROC_ = 2
 

Private Member Functions

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 cell indexing

Definition at line 15 of file HGCalMappingCellIndexer.h.

Constructor & Destructor Documentation

◆ HGCalMappingCellIndexer()

HGCalMappingCellIndexer::HGCalMappingCellIndexer ( )
default

◆ ~HGCalMappingCellIndexer()

HGCalMappingCellIndexer::~HGCalMappingCellIndexer ( )
inline

Definition at line 159 of file HGCalMappingCellIndexer.h.

159 {}

Member Function Documentation

◆ denseIndex() [1/4]

uint32_t HGCalMappingCellIndexer::denseIndex ( std::string  typecode,
uint32_t  chip,
uint32_t  half,
uint32_t  seq 
) const
inline

builders for the dense index

Definition at line 94 of file HGCalMappingCellIndexer.h.

References getEnumFromTypecode(), and cmsswSequenceInfo::seq.

Referenced by denseIndex(), and ALPAKA_ACCELERATOR_NAMESPACE::hgcal::HGCalMappingCellESProducer::produce().

94  {
95  return denseIndex(getEnumFromTypecode(typecode), chip, half, seq);
96  }
uint32_t denseIndex(std::string typecode, uint32_t chip, uint32_t half, uint32_t seq) const
builders for the dense index
size_t getEnumFromTypecode(std::string typecode) const
gets index given typecode string

◆ denseIndex() [2/4]

uint32_t HGCalMappingCellIndexer::denseIndex ( std::string  typecode,
uint32_t  erx,
uint32_t  seq 
) const
inline

Definition at line 97 of file HGCalMappingCellIndexer.h.

References denseIndex(), getEnumFromTypecode(), and cmsswSequenceInfo::seq.

97  {
98  return denseIndex(getEnumFromTypecode(typecode), erx, seq);
99  }
uint32_t denseIndex(std::string typecode, uint32_t chip, uint32_t half, uint32_t seq) const
builders for the dense index
size_t getEnumFromTypecode(std::string typecode) const
gets index given typecode string

◆ denseIndex() [3/4]

uint32_t HGCalMappingCellIndexer::denseIndex ( size_t  idx,
uint32_t  chip,
uint32_t  half,
uint32_t  seq 
) const
inline

Definition at line 100 of file HGCalMappingCellIndexer.h.

References denseIndex(), heavyIonCSV_trainingSettings::idx, maxHalfPerROC_, and cmsswSequenceInfo::seq.

100  {
101  uint16_t erx = chip * maxHalfPerROC_ + half;
102  return denseIndex(idx, erx, seq);
103  }
uint32_t denseIndex(std::string typecode, uint32_t chip, uint32_t half, uint32_t seq) const
builders for the dense index
static constexpr char maxHalfPerROC_

◆ denseIndex() [4/4]

uint32_t HGCalMappingCellIndexer::denseIndex ( size_t  idx,
uint32_t  erx,
uint32_t  seq 
) const
inline

Definition at line 104 of file HGCalMappingCellIndexer.h.

References di_, heavyIonCSV_trainingSettings::idx, offsets_, and cmsswSequenceInfo::seq.

104  {
105  return di_[idx].denseIndex({{erx, seq}}) + offsets_[idx];
106  }
std::vector< uint32_t > offsets_
std::vector< HGCalDenseIndexerBase > di_

◆ elecIdFromIndex() [1/2]

uint32_t HGCalMappingCellIndexer::elecIdFromIndex ( uint32_t  rtn,
std::string  typecode 
) const
inline

decodes the dense index code

Definition at line 111 of file HGCalMappingCellIndexer.h.

References getEnumFromTypecode().

111  {
112  return elecIdFromIndex(rtn, getEnumFromTypecode(typecode));
113  }
size_t getEnumFromTypecode(std::string typecode) const
gets index given typecode string
uint32_t elecIdFromIndex(uint32_t rtn, std::string typecode) const
decodes the dense index code

◆ elecIdFromIndex() [2/2]

uint32_t HGCalMappingCellIndexer::elecIdFromIndex ( uint32_t  rtn,
size_t  idx 
) const
inline

Definition at line 114 of file HGCalMappingCellIndexer.h.

References di_, heavyIonCSV_trainingSettings::idx, offsets_, and HGCalElectronicsId::raw().

114  {
115  if (idx >= di_.size())
116  throw cms::Exception("ValueError") << " index requested for cell dense indexer (i=" << idx
117  << ") is larger than allocated";
118  rtn -= offsets_[idx];
119  auto rtn_codes = di_[idx].unpackDenseIndex(rtn);
120  return HGCalElectronicsId(false, 0, 0, 0, rtn_codes[0], rtn_codes[1]).raw();
121  }
uint32_t raw() const
wrapper for a 32b data word identifying a readout channel in the raw data The format is the following...
std::vector< uint32_t > offsets_
std::vector< HGCalDenseIndexerBase > di_

◆ getDenseIndexerFor()

HGCalDenseIndexerBase HGCalMappingCellIndexer::getDenseIndexerFor ( size_t  idx) const
inline

returns the dense indexer for a given internal index

Definition at line 84 of file HGCalMappingCellIndexer.h.

References di_, and heavyIonCSV_trainingSettings::idx.

Referenced by getDenseIndexFor().

84  {
85  if (idx >= di_.size())
86  throw cms::Exception("ValueError") << " index requested for cell dense indexer (i=" << idx
87  << ") is larger than allocated";
88  return di_[idx];
89  }
std::vector< HGCalDenseIndexerBase > di_

◆ getDenseIndexFor()

HGCalDenseIndexerBase HGCalMappingCellIndexer::getDenseIndexFor ( std::string  typecode) const
inline

returns the dense indexer for a typecode

Definition at line 77 of file HGCalMappingCellIndexer.h.

References getDenseIndexerFor(), and getEnumFromTypecode().

77  {
78  return getDenseIndexerFor(getEnumFromTypecode(typecode));
79  }
size_t getEnumFromTypecode(std::string typecode) const
gets index given typecode string
HGCalDenseIndexerBase getDenseIndexerFor(size_t idx) const
returns the dense indexer for a given internal index

◆ getEnumFromTypecode()

size_t HGCalMappingCellIndexer::getEnumFromTypecode ( std::string  typecode) const
inline

gets index given typecode string

Definition at line 57 of file HGCalMappingCellIndexer.h.

References ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, and typeCodeIndexer_.

Referenced by denseIndex(), elecIdFromIndex(), getDenseIndexFor(), getNErxExpectedFor(), getNWordsExpectedFor(), HGCalMappingESProducer::prepareModuleMapperIndexer(), and ALPAKA_ACCELERATOR_NAMESPACE::hgcal::HGCalMappingCellESProducer::produce().

57  {
58  auto it = typeCodeIndexer_.find(typecode);
59  if (it == typeCodeIndexer_.end())
60  throw cms::Exception("ValueError") << " unable to find typecode=" << typecode << " in cell indexer";
61  return it->second;
62  }
std::map< std::string, size_t > typeCodeIndexer_

◆ getNErxExpectedFor() [1/2]

size_t HGCalMappingCellIndexer::getNErxExpectedFor ( std::string  typecode) const
inline

gets the number of e-Rx for a given typecode

Definition at line 145 of file HGCalMappingCellIndexer.h.

References getEnumFromTypecode(), and ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it.

Referenced by HGCalMappingESProducer::prepareModuleMapperIndexer().

145  {
146  auto it = getEnumFromTypecode(typecode);
147  return getNErxExpectedFor(it);
148  }
size_t getEnumFromTypecode(std::string typecode) const
gets index given typecode string
size_t getNErxExpectedFor(std::string typecode) const
gets the number of e-Rx for a given typecode

◆ getNErxExpectedFor() [2/2]

size_t HGCalMappingCellIndexer::getNErxExpectedFor ( size_t  typecodeidx) const
inline

Definition at line 149 of file HGCalMappingCellIndexer.h.

References maxErx_.

149 { return maxErx_[typecodeidx]; }
std::vector< uint16_t > maxErx_

◆ getNWordsExpectedFor() [1/2]

size_t HGCalMappingCellIndexer::getNWordsExpectedFor ( std::string  typecode) const
inline

gets the number of words for a given typecode

Definition at line 136 of file HGCalMappingCellIndexer.h.

References getEnumFromTypecode(), and ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it.

Referenced by HGCalMappingESProducer::prepareModuleMapperIndexer().

136  {
137  auto it = getEnumFromTypecode(typecode);
138  return getNWordsExpectedFor(it);
139  }
size_t getEnumFromTypecode(std::string typecode) const
gets index given typecode string
size_t getNWordsExpectedFor(std::string typecode) const
gets the number of words for a given typecode

◆ getNWordsExpectedFor() [2/2]

size_t HGCalMappingCellIndexer::getNWordsExpectedFor ( size_t  typecodeidx) const
inline

Definition at line 140 of file HGCalMappingCellIndexer.h.

References maxChPerErx_, and maxErx_.

140 { return maxErx_[typecodeidx] * maxChPerErx_; }
static constexpr uint16_t maxChPerErx_
std::vector< uint16_t > maxErx_

◆ getTypecodeFromEnum()

std::string HGCalMappingCellIndexer::getTypecodeFromEnum ( size_t  idx) const
inline

checks if there is a typecode corresponding to an index

Definition at line 67 of file HGCalMappingCellIndexer.h.

References Exception, heavyIonCSV_trainingSettings::idx, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, and typeCodeIndexer_.

67  {
68  for (const auto& it : typeCodeIndexer_)
69  if (it.second == idx)
70  return it.first;
71  throw cms::Exception("ValueError") << " unable to find typecode corresponding to idx=" << idx;
72  }
std::map< std::string, size_t > typeCodeIndexer_

◆ maxDenseIndex()

uint32_t HGCalMappingCellIndexer::maxDenseIndex ( ) const
inline

returns the max. dense index expected

Definition at line 126 of file HGCalMappingCellIndexer.h.

References mps_fire::i, maxChPerErx_, maxErx_, and offsets_.

Referenced by ALPAKA_ACCELERATOR_NAMESPACE::hgcal::HGCalMappingCellESProducer::produce().

126  {
127  size_t i = maxErx_.size();
128  if (i == 0)
129  return 0;
130  return offsets_.back() + maxErx_.back() * maxChPerErx_;
131  }
static constexpr uint16_t maxChPerErx_
std::vector< uint32_t > offsets_
std::vector< uint16_t > maxErx_

◆ processNewCell()

void HGCalMappingCellIndexer::processNewCell ( std::string  typecode,
uint16_t  chip,
uint16_t  half 
)
inline

adds to map of type codes (= module types) to handle and updatest the max. number of eRx

Definition at line 24 of file HGCalMappingCellIndexer.h.

References heavyIonCSV_trainingSettings::idx, SiStripPI::max, maxErx_, and typeCodeIndexer_.

Referenced by HGCalMappingESProducer::prepareCellMapperIndexer().

24  {
25  //assign index to this typecode and resize the max e-Rx vector
26  if (typeCodeIndexer_.count(typecode) == 0) {
27  typeCodeIndexer_[typecode] = typeCodeIndexer_.size();
28  maxErx_.resize(typeCodeIndexer_.size(), 0);
29  }
30 
31  size_t idx = typeCodeIndexer_[typecode];
32  uint16_t erx = chip * 2 + half + 1; //use the number not the index here
33  maxErx_[idx] = std::max(maxErx_[idx], erx);
34  }
std::map< std::string, size_t > typeCodeIndexer_
std::vector< uint16_t > maxErx_

◆ serialize()

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

◆ update()

void HGCalMappingCellIndexer::update ( )
inline

process the current list of type codes handled and updates the dense indexers

Definition at line 39 of file HGCalMappingCellIndexer.h.

References di_, heavyIonCSV_trainingSettings::idx, maxChPerErx_, maxErx_, dqmiodumpmetadata::n, offsets_, and typeCodeIndexer_.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), dqm-mbProfile.Profile::finish(), progressbar.ProgressBar::finish(), MatrixUtil.Steps::overwrite(), and HGCalMappingESProducer::prepareCellMapperIndexer().

39  {
40  uint32_t n = typeCodeIndexer_.size();
41  offsets_ = std::vector<uint32_t>(n, 0);
42  di_ = std::vector<HGCalDenseIndexerBase>(n, HGCalDenseIndexerBase(2));
43  for (uint32_t idx = 0; idx < n; idx++) {
44  uint16_t nerx = maxErx_[idx];
45  di_[idx].updateRanges({{nerx, maxChPerErx_}});
46  if (idx < n - 1)
47  offsets_[idx + 1] = di_[idx].getMaxIndex();
48  }
49 
50  //accumulate the offsets in the array
51  std::partial_sum(offsets_.begin(), offsets_.end(), offsets_.begin());
52  }
static constexpr uint16_t maxChPerErx_
this is a simple class that takes care of building a dense index for a set of categories the maximum ...
std::map< std::string, size_t > typeCodeIndexer_
std::vector< uint32_t > offsets_
std::vector< uint16_t > maxErx_
std::vector< HGCalDenseIndexerBase > di_

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Definition at line 161 of file HGCalMappingCellIndexer.h.

◆ cond::serialization::access

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

Definition at line 161 of file HGCalMappingCellIndexer.h.

Member Data Documentation

◆ di_

std::vector<HGCalDenseIndexerBase> HGCalMappingCellIndexer::di_

Definition at line 157 of file HGCalMappingCellIndexer.h.

Referenced by denseIndex(), elecIdFromIndex(), getDenseIndexerFor(), and update().

◆ maxChPerErx_

constexpr uint16_t HGCalMappingCellIndexer::maxChPerErx_ = 37
static

◆ maxErx_

std::vector<uint16_t> HGCalMappingCellIndexer::maxErx_

◆ maxHalfPerROC_

constexpr char HGCalMappingCellIndexer::maxHalfPerROC_ = 2
static

Definition at line 151 of file HGCalMappingCellIndexer.h.

Referenced by denseIndex().

◆ offsets_

std::vector<uint32_t> HGCalMappingCellIndexer::offsets_

Definition at line 156 of file HGCalMappingCellIndexer.h.

Referenced by denseIndex(), elecIdFromIndex(), maxDenseIndex(), and update().

◆ typeCodeIndexer_

std::map<std::string, size_t> HGCalMappingCellIndexer::typeCodeIndexer_