CMS 3D CMS Logo

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

this is a simple class that takes care of building a dense index for a set of categories the maximum number of items expected in each category is encoded in the IndexRanges_t the class is templated for the number of categories to use More...

#include <HGCalDenseIndexerBase.h>

Public Member Functions

uint32_t denseIndex (std::vector< uint32_t > v) const
 
uint32_t getMaxIndex () const
 
 HGCalDenseIndexerBase ()
 
 HGCalDenseIndexerBase (int n)
 
 HGCalDenseIndexerBase (std::vector< uint32_t > const &o)
 
std::vector< uint32_t > unpackDenseIndex (uint32_t rtn) const
 
void updateRanges (std::vector< uint32_t > const &o)
 
 ~HGCalDenseIndexerBase ()=default
 

Private Member Functions

void check (size_t osize) const
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Private Attributes

uint32_t maxIdx_
 
uint32_t n_
 
std::vector< uint32_t > vmax_
 

Friends

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

Detailed Description

this is a simple class that takes care of building a dense index for a set of categories the maximum number of items expected in each category is encoded in the IndexRanges_t the class is templated for the number of categories to use

Definition at line 14 of file HGCalDenseIndexerBase.h.

Constructor & Destructor Documentation

◆ HGCalDenseIndexerBase() [1/3]

HGCalDenseIndexerBase::HGCalDenseIndexerBase ( )
inline

Definition at line 16 of file HGCalDenseIndexerBase.h.

◆ HGCalDenseIndexerBase() [2/3]

HGCalDenseIndexerBase::HGCalDenseIndexerBase ( int  n)
inline

Definition at line 18 of file HGCalDenseIndexerBase.h.

◆ HGCalDenseIndexerBase() [3/3]

HGCalDenseIndexerBase::HGCalDenseIndexerBase ( std::vector< uint32_t > const &  o)
inline

Definition at line 20 of file HGCalDenseIndexerBase.h.

References EcalTangentSkim_cfg::o, and updateRanges().

20 : n_(o.size()) { updateRanges(o); }
void updateRanges(std::vector< uint32_t > const &o)

◆ ~HGCalDenseIndexerBase()

HGCalDenseIndexerBase::~HGCalDenseIndexerBase ( )
default

Member Function Documentation

◆ check()

void HGCalDenseIndexerBase::check ( size_t  osize) const
inlineprivate

Definition at line 53 of file HGCalDenseIndexerBase.h.

References Exception, and n_.

Referenced by updateRanges().

53  {
54  if (osize != n_)
55  throw cms::Exception("ValueError") << " unable to update indexer max values. Expected " << n_ << " received "
56  << osize;
57  }

◆ denseIndex()

uint32_t HGCalDenseIndexerBase::denseIndex ( std::vector< uint32_t >  v) const
inline

Definition at line 28 of file HGCalDenseIndexerBase.h.

References mps_fire::i, n_, findQualityFiles::v, and vmax_.

Referenced by HGCalMappingModuleIndexer::denseIndexingFor(), and HGCalMappingModuleIndexer::processNewModule().

28  {
29  uint32_t rtn = v[0];
30  for (size_t i = 1; i < n_; i++)
31  rtn = rtn * vmax_[i] + v[i];
32  return rtn;
33  }
std::vector< uint32_t > vmax_

◆ getMaxIndex()

uint32_t HGCalDenseIndexerBase::getMaxIndex ( ) const
inline

Definition at line 48 of file HGCalDenseIndexerBase.h.

References maxIdx_.

48 { return maxIdx_; }

◆ serialize()

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

◆ unpackDenseIndex()

std::vector<uint32_t> HGCalDenseIndexerBase::unpackDenseIndex ( uint32_t  rtn) const
inline

Definition at line 35 of file HGCalDenseIndexerBase.h.

References mps_fire::i, n_, and vmax_.

35  {
36  std::vector<uint32_t> codes(n_, 0);
37 
38  const auto rend = vmax_.rend();
39  for (auto rit = vmax_.rbegin(); rit != rend; ++rit) {
40  size_t i = rend - rit - 1;
41  codes[i] = rtn % (*rit);
42  rtn = rtn / (*rit);
43  }
44 
45  return codes;
46  }
std::vector< uint32_t > vmax_

◆ updateRanges()

void HGCalDenseIndexerBase::updateRanges ( std::vector< uint32_t > const &  o)
inline

Definition at line 22 of file HGCalDenseIndexerBase.h.

References check(), maxIdx_, EcalTangentSkim_cfg::o, and vmax_.

Referenced by HGCalDenseIndexerBase().

22  {
23  check(o.size());
24  vmax_ = o;
25  maxIdx_ = std::accumulate(vmax_.begin(), vmax_.end(), 1, std::multiplies<uint32_t>());
26  }
void check(size_t osize) const
std::vector< uint32_t > vmax_

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Definition at line 63 of file HGCalDenseIndexerBase.h.

◆ cond::serialization::access

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

Definition at line 63 of file HGCalDenseIndexerBase.h.

Member Data Documentation

◆ maxIdx_

uint32_t HGCalDenseIndexerBase::maxIdx_
private

Definition at line 60 of file HGCalDenseIndexerBase.h.

Referenced by getMaxIndex(), and updateRanges().

◆ n_

uint32_t HGCalDenseIndexerBase::n_
private

Definition at line 59 of file HGCalDenseIndexerBase.h.

Referenced by check(), denseIndex(), and unpackDenseIndex().

◆ vmax_

std::vector<uint32_t> HGCalDenseIndexerBase::vmax_
private

Definition at line 61 of file HGCalDenseIndexerBase.h.

Referenced by denseIndex(), unpackDenseIndex(), and updateRanges().