CMS 3D CMS Logo

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

#include <L1MuScale.h>

Inheritance diagram for L1MuBinnedScale:
L1MuScale

Public Member Functions

float getCenter (unsigned packed) const override
 get the center of bin represented by packed More...
 
float getHighEdge (unsigned packed) const override
 get the upper edge of bin represented by packed More...
 
float getLowEdge (unsigned packed) const override
 get the low edge of bin represented by packed More...
 
unsigned getNBins () const override
 get number of bins More...
 
unsigned getPacked (float value) const override
 pack a value More...
 
float getScaleMax () const override
 get the upper edge of the last bin More...
 
float getScaleMin () const override
 get the lower edge of the first bin More...
 
float getValue (unsigned i) const override
 get value of the underlying vector for bin i More...
 
 L1MuBinnedScale ()
 
 L1MuBinnedScale (unsigned int nbits, bool signedPacking, int NBins, const std::vector< double > &Scale, int idx_offset=0)
 
 L1MuBinnedScale (unsigned int nbits, bool signedPacking, int NBins, float xmin, float xmax, int idx_offset=0)
 
std::string print () const override
 
 ~L1MuBinnedScale () override
 destructor More...
 
- Public Member Functions inherited from L1MuScale
 L1MuScale ()
 
virtual ~L1MuScale ()
 

Protected Member Functions

int get_idx (unsigned packed) const
 

Protected Attributes

int m_idxoffset
 
int m_NBins
 
unsigned int m_nbits
 
std::vector< float > m_Scale
 
bool m_signedPacking
 

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

implements a continuous scale of NBins bins.

the index into the binned scale runs from 0 to NBins-1.

It is packed into a data word (unsigned) using a Packing (template parameter)

If the packing accepts negative values, an offset can be specified which will be subtracted from the index before packing. ( The offset is in turn added to the packed value before using it as an index into the scale.)

Definition at line 93 of file L1MuScale.h.

Constructor & Destructor Documentation

◆ L1MuBinnedScale() [1/3]

L1MuBinnedScale::L1MuBinnedScale ( )
inline

constructor

packing is a pointer to a packing object. The L1MuBinnedScale takes ownership of the packing object and deletes it in its destructor

Definition at line 102 of file L1MuScale.h.

102 : m_nbits(0), m_signedPacking(false), m_NBins(0), m_idxoffset(0) {}
unsigned int m_nbits
Definition: L1MuScale.h:216
bool m_signedPacking
Definition: L1MuScale.h:217

◆ L1MuBinnedScale() [2/3]

L1MuBinnedScale::L1MuBinnedScale ( unsigned int  nbits,
bool  signedPacking,
int  NBins,
const std::vector< double > &  Scale,
int  idx_offset = 0 
)
inline

NBins=number of bins, Scale[NBins+1]=bin edges, idx_offset=offeset to index (if stored as signed)

Definition at line 107 of file L1MuScale.h.

References mps_fire::i, m_idxoffset, m_NBins, m_Scale, and SiStripSourceConfigP5_cff::NBins.

109  : m_nbits(nbits), m_signedPacking(signedPacking) {
110  m_NBins = NBins;
111  m_idxoffset = idx_offset;
112 
113  m_Scale.reserve(m_NBins + 1);
114  for (int i = 0; i < m_NBins + 1; i++)
115  //m_Scale[i] = Scale[i];
116  m_Scale.push_back(Scale[i]);
117  };
unsigned int m_nbits
Definition: L1MuScale.h:216
std::vector< float > m_Scale
Definition: L1MuScale.h:220
bool m_signedPacking
Definition: L1MuScale.h:217

◆ L1MuBinnedScale() [3/3]

L1MuBinnedScale::L1MuBinnedScale ( unsigned int  nbits,
bool  signedPacking,
int  NBins,
float  xmin,
float  xmax,
int  idx_offset = 0 
)
inline

constructor

packing is a pointer to a packing object. The L1MuBinnedScale takes ownership of the packing object and deletes it in its destructor

NBins=number of bins, xmin = low edge of first bin, xmax=high edge of last bin, idx_offset=offeset to index (if stored as signed)

Definition at line 129 of file L1MuScale.h.

References mps_fire::i, m_idxoffset, m_NBins, m_Scale, SiStripSourceConfigP5_cff::NBins, TrackerOfflineValidation_Dqm_cff::xmax, and TrackerOfflineValidation_Dqm_cff::xmin.

130  : m_nbits(nbits), m_signedPacking(signedPacking) {
131  m_NBins = NBins;
132  m_idxoffset = idx_offset;
133 
134  m_Scale.reserve(m_NBins + 1);
135  for (int i = 0; i < m_NBins + 1; i++)
136  // m_Scale[i] = xmin + i * (xmax-xmin) / m_NBins;
137  m_Scale.push_back(xmin + i * (xmax - xmin) / m_NBins);
138  };
unsigned int m_nbits
Definition: L1MuScale.h:216
std::vector< float > m_Scale
Definition: L1MuScale.h:220
bool m_signedPacking
Definition: L1MuScale.h:217

◆ ~L1MuBinnedScale()

L1MuBinnedScale::~L1MuBinnedScale ( )
inlineoverride

destructor

Definition at line 141 of file L1MuScale.h.

141  {
142  // delete m_packing;
143  };

Member Function Documentation

◆ get_idx()

int L1MuBinnedScale::get_idx ( unsigned  packed) const
inlineprotected

Definition at line 205 of file L1MuScale.h.

References heavyIonCSV_trainingSettings::idx, L1MuUnsignedPackingGeneric::idxFromPacked(), L1MuSignedPackingGeneric::idxFromPacked(), m_idxoffset, m_NBins, m_nbits, and m_signedPacking.

Referenced by getCenter(), getHighEdge(), and getLowEdge().

205  {
207  : L1MuUnsignedPackingGeneric::idxFromPacked(packed, m_nbits);
208  int idx = idxFromPacked + m_idxoffset;
209  if (idx < 0)
210  idx = 0;
211  if (idx >= m_NBins)
212  idx = m_NBins - 1;
213  return idx;
214  }
unsigned int m_nbits
Definition: L1MuScale.h:216
static int idxFromPacked(unsigned packed, unsigned int nbits)
get the value from the packed notation (+/-)
Definition: L1MuPacking.h:124
bool m_signedPacking
Definition: L1MuScale.h:217

◆ getCenter()

float L1MuBinnedScale::getCenter ( unsigned  packed) const
inlineoverridevirtual

get the center of bin represented by packed

Implements L1MuScale.

Definition at line 146 of file L1MuScale.h.

References get_idx(), heavyIonCSV_trainingSettings::idx, and m_Scale.

Referenced by print().

146  {
147  int idx = get_idx(packed);
148  return (m_Scale[idx] + m_Scale[idx + 1]) / 2.;
149  };
std::vector< float > m_Scale
Definition: L1MuScale.h:220
int get_idx(unsigned packed) const
Definition: L1MuScale.h:205

◆ getHighEdge()

float L1MuBinnedScale::getHighEdge ( unsigned  packed) const
inlineoverridevirtual

get the upper edge of bin represented by packed

Implements L1MuScale.

Definition at line 155 of file L1MuScale.h.

References get_idx(), and m_Scale.

Referenced by print().

155 { return m_Scale[get_idx(packed) + 1]; };
std::vector< float > m_Scale
Definition: L1MuScale.h:220
int get_idx(unsigned packed) const
Definition: L1MuScale.h:205

◆ getLowEdge()

float L1MuBinnedScale::getLowEdge ( unsigned  packed) const
inlineoverridevirtual

get the low edge of bin represented by packed

Implements L1MuScale.

Definition at line 152 of file L1MuScale.h.

References get_idx(), and m_Scale.

Referenced by print().

152 { return m_Scale[get_idx(packed)]; };
std::vector< float > m_Scale
Definition: L1MuScale.h:220
int get_idx(unsigned packed) const
Definition: L1MuScale.h:205

◆ getNBins()

unsigned L1MuBinnedScale::getNBins ( ) const
inlineoverridevirtual

get number of bins

Implements L1MuScale.

Definition at line 185 of file L1MuScale.h.

References m_NBins.

185 { return m_NBins; }

◆ getPacked()

unsigned L1MuBinnedScale::getPacked ( float  value) const
inlineoverridevirtual

pack a value

Implements L1MuScale.

Definition at line 159 of file L1MuScale.h.

References heavyIonCSV_trainingSettings::idx, m_idxoffset, m_NBins, m_nbits, m_Scale, m_signedPacking, L1MuUnsignedPackingGeneric::packedFromIdx(), and L1MuSignedPackingGeneric::packedFromIdx().

Referenced by print().

159  {
160  if (value < m_Scale[0] || value > m_Scale[m_NBins])
161  edm::LogWarning("ScaleRangeViolation")
162  << "L1MuBinnedScale::getPacked: value out of scale range: " << value << std::endl;
163  int idx = 0;
164  if (value < m_Scale[0])
165  idx = 0;
166  else if (value >= m_Scale[m_NBins])
167  idx = m_NBins - 1;
168  else {
169  for (; idx < m_NBins; idx++)
170  if (value >= m_Scale[idx] && value < m_Scale[idx + 1])
171  break;
172  }
173 
176  };
static unsigned packedFromIdx(int idx, unsigned int nbits)
get the packed notation of a value, check range
Definition: L1MuPacking.h:128
unsigned int m_nbits
Definition: L1MuScale.h:216
std::vector< float > m_Scale
Definition: L1MuScale.h:220
Definition: value.py:1
bool m_signedPacking
Definition: L1MuScale.h:217
static unsigned packedFromIdx(int idx, unsigned int nbits)
get the packed notation of a value, check the range
Definition: L1MuPacking.h:79
Log< level::Warning, false > LogWarning

◆ getScaleMax()

float L1MuBinnedScale::getScaleMax ( ) const
inlineoverridevirtual

get the upper edge of the last bin

Implements L1MuScale.

Definition at line 179 of file L1MuScale.h.

References m_NBins, and m_Scale.

179 { return m_Scale[m_NBins]; }
std::vector< float > m_Scale
Definition: L1MuScale.h:220

◆ getScaleMin()

float L1MuBinnedScale::getScaleMin ( ) const
inlineoverridevirtual

get the lower edge of the first bin

Implements L1MuScale.

Definition at line 182 of file L1MuScale.h.

References m_Scale.

182 { return m_Scale[0]; }
std::vector< float > m_Scale
Definition: L1MuScale.h:220

◆ getValue()

float L1MuBinnedScale::getValue ( unsigned  i) const
inlineoverridevirtual

get value of the underlying vector for bin i

Implements L1MuScale.

Definition at line 188 of file L1MuScale.h.

References mps_fire::i, and m_Scale.

188 { return m_Scale[i]; }
std::vector< float > m_Scale
Definition: L1MuScale.h:220

◆ print()

std::string L1MuBinnedScale::print ( void  ) const
inlineoverridevirtual

Implements L1MuScale.

Definition at line 190 of file L1MuScale.h.

References getCenter(), getHighEdge(), getLowEdge(), getPacked(), mps_fire::i, m_NBins, m_Scale, and str.

190  {
191  std::ostringstream str;
192 
193  str << " ind | low edge | center | high edge" << std::endl;
194  str << "-------------------------------------------" << std::endl;
195  for (int i = 0; i < m_NBins; i++) {
196  unsigned int ipack = getPacked(m_Scale[i]);
197  str << std::setw(4) << ipack << " | " << std::setw(10) << getLowEdge(ipack) << " | " << std::setw(10)
198  << getCenter(ipack) << " | " << std::setw(10) << getHighEdge(ipack) << std::endl;
199  }
200 
201  return str.str();
202  }
float getLowEdge(unsigned packed) const override
get the low edge of bin represented by packed
Definition: L1MuScale.h:152
std::vector< float > m_Scale
Definition: L1MuScale.h:220
float getHighEdge(unsigned packed) const override
get the upper edge of bin represented by packed
Definition: L1MuScale.h:155
unsigned getPacked(float value) const override
pack a value
Definition: L1MuScale.h:159
float getCenter(unsigned packed) const override
get the center of bin represented by packed
Definition: L1MuScale.h:146
#define str(s)

◆ serialize()

template<class Archive >
void L1MuBinnedScale::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 222 of file L1MuScale.h.

◆ cond::serialization::access

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

Definition at line 222 of file L1MuScale.h.

Member Data Documentation

◆ m_idxoffset

int L1MuBinnedScale::m_idxoffset
protected

Definition at line 219 of file L1MuScale.h.

Referenced by get_idx(), getPacked(), and L1MuBinnedScale().

◆ m_NBins

int L1MuBinnedScale::m_NBins
protected

Definition at line 218 of file L1MuScale.h.

Referenced by get_idx(), getNBins(), getPacked(), getScaleMax(), L1MuBinnedScale(), and print().

◆ m_nbits

unsigned int L1MuBinnedScale::m_nbits
protected

Definition at line 216 of file L1MuScale.h.

Referenced by get_idx(), and getPacked().

◆ m_Scale

std::vector<float> L1MuBinnedScale::m_Scale
protected

◆ m_signedPacking

bool L1MuBinnedScale::m_signedPacking
protected

Definition at line 217 of file L1MuScale.h.

Referenced by get_idx(), and getPacked().