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 95 of file L1MuScale.h.

Constructor & Destructor Documentation

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 105 of file L1MuScale.h.

105  :
106  m_nbits( 0 ),
107  m_signedPacking( false ),
108  m_NBins( 0 ),
109  m_idxoffset( 0 )
110  {}
unsigned int m_nbits
Definition: L1MuScale.h:231
bool m_signedPacking
Definition: L1MuScale.h:232
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 115 of file L1MuScale.h.

References mps_fire::i.

116  : m_nbits( nbits ),
117  m_signedPacking( signedPacking )
118  {
119  m_NBins = NBins;
120  m_idxoffset = idx_offset;
121 
122  m_Scale.reserve(m_NBins + 1);
123  for (int i=0; i<m_NBins + 1; i++)
124  //m_Scale[i] = Scale[i];
125  m_Scale.push_back( Scale[i] ) ;
126  };
unsigned int m_nbits
Definition: L1MuScale.h:231
std::vector< float > m_Scale
Definition: L1MuScale.h:235
bool m_signedPacking
Definition: L1MuScale.h:232
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 138 of file L1MuScale.h.

References mps_fire::i.

139  : m_nbits( nbits ),
140  m_signedPacking( signedPacking )
141  {
142  m_NBins = NBins;
143  m_idxoffset = idx_offset;
144 
145  m_Scale.reserve(m_NBins + 1);
146  for (int i=0; i<m_NBins + 1; i++)
147  // m_Scale[i] = xmin + i * (xmax-xmin) / m_NBins;
148  m_Scale.push_back( xmin + i * (xmax-xmin) / m_NBins ) ;
149  };
unsigned int m_nbits
Definition: L1MuScale.h:231
std::vector< float > m_Scale
Definition: L1MuScale.h:235
bool m_signedPacking
Definition: L1MuScale.h:232
L1MuBinnedScale::~L1MuBinnedScale ( )
inlineoverride

destructor

Definition at line 152 of file L1MuScale.h.

152  {
153 // delete m_packing;
154  };

Member Function Documentation

int L1MuBinnedScale::get_idx ( unsigned  packed) const
inlineprotected

Definition at line 221 of file L1MuScale.h.

References training_settings::idx, L1MuUnsignedPackingGeneric::idxFromPacked(), and L1MuSignedPackingGeneric::idxFromPacked().

221  {
222  int idxFromPacked = m_signedPacking ?
224  L1MuUnsignedPackingGeneric::idxFromPacked( packed, m_nbits ) ;
225  int idx = idxFromPacked + m_idxoffset;
226  if (idx<0) idx=0;
227  if (idx>=m_NBins) idx=m_NBins-1;
228  return idx;
229  }
unsigned int m_nbits
Definition: L1MuScale.h:231
static int idxFromPacked(unsigned packed, unsigned int nbits)
get the value from the packed notation (+/-)
Definition: L1MuPacking.h:118
bool m_signedPacking
Definition: L1MuScale.h:232
float L1MuBinnedScale::getCenter ( unsigned  packed) const
inlineoverridevirtual

get the center of bin represented by packed

Implements L1MuScale.

Definition at line 158 of file L1MuScale.h.

References training_settings::idx.

158  {
159  int idx = get_idx(packed);
160  return (m_Scale[idx] + m_Scale[idx+1] )/ 2.;
161  };
std::vector< float > m_Scale
Definition: L1MuScale.h:235
int get_idx(unsigned packed) const
Definition: L1MuScale.h:221
float L1MuBinnedScale::getHighEdge ( unsigned  packed) const
inlineoverridevirtual

get the upper edge of bin represented by packed

Implements L1MuScale.

Definition at line 169 of file L1MuScale.h.

169  {
170  return m_Scale[get_idx(packed)+1];
171  };
std::vector< float > m_Scale
Definition: L1MuScale.h:235
int get_idx(unsigned packed) const
Definition: L1MuScale.h:221
float L1MuBinnedScale::getLowEdge ( unsigned  packed) const
inlineoverridevirtual

get the low edge of bin represented by packed

Implements L1MuScale.

Definition at line 164 of file L1MuScale.h.

164  {
165  return m_Scale[get_idx(packed)];
166  };
std::vector< float > m_Scale
Definition: L1MuScale.h:235
int get_idx(unsigned packed) const
Definition: L1MuScale.h:221
unsigned L1MuBinnedScale::getNBins ( ) const
inlineoverridevirtual

get number of bins

Implements L1MuScale.

Definition at line 198 of file L1MuScale.h.

198 { return m_NBins; }
unsigned L1MuBinnedScale::getPacked ( float  value) const
inlineoverridevirtual

pack a value

Implements L1MuScale.

Definition at line 175 of file L1MuScale.h.

References training_settings::idx, L1MuUnsignedPackingGeneric::packedFromIdx(), and L1MuSignedPackingGeneric::packedFromIdx().

175  {
176  if (value < m_Scale[0] || value > m_Scale[m_NBins])
177  edm::LogWarning("ScaleRangeViolation") << "L1MuBinnedScale::getPacked: value out of scale range: " << value << std::endl;
178  int idx = 0;
179  if (value < m_Scale[0]) idx=0;
180  else if (value >= m_Scale[m_NBins]) idx = m_NBins-1;
181  else {
182  for (; idx<m_NBins; idx++)
183  if (value >= m_Scale[idx] && value < m_Scale[idx+1]) break;
184  }
185 
186  return ( m_signedPacking ?
189  };
static unsigned packedFromIdx(int idx, unsigned int nbits)
get the packed notation of a value, check range
Definition: L1MuPacking.h:120
unsigned int m_nbits
Definition: L1MuScale.h:231
std::vector< float > m_Scale
Definition: L1MuScale.h:235
Definition: value.py:1
bool m_signedPacking
Definition: L1MuScale.h:232
static unsigned packedFromIdx(int idx, unsigned int nbits)
get the packed notation of a value, check the range
Definition: L1MuPacking.h:80
float L1MuBinnedScale::getScaleMax ( ) const
inlineoverridevirtual

get the upper edge of the last bin

Implements L1MuScale.

Definition at line 192 of file L1MuScale.h.

192 { return m_Scale[m_NBins]; }
std::vector< float > m_Scale
Definition: L1MuScale.h:235
float L1MuBinnedScale::getScaleMin ( ) const
inlineoverridevirtual

get the lower edge of the first bin

Implements L1MuScale.

Definition at line 195 of file L1MuScale.h.

195 { return m_Scale[0]; }
std::vector< float > m_Scale
Definition: L1MuScale.h:235
float L1MuBinnedScale::getValue ( unsigned  i) const
inlineoverridevirtual

get value of the underlying vector for bin i

Implements L1MuScale.

Definition at line 201 of file L1MuScale.h.

References mps_fire::i.

201 { return m_Scale[i]; }
std::vector< float > m_Scale
Definition: L1MuScale.h:235
std::string L1MuBinnedScale::print ( void  ) const
inlineoverridevirtual

Implements L1MuScale.

Definition at line 203 of file L1MuScale.h.

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

203  {
204  std::ostringstream str;
205 
206  str << " ind | low edge | center | high edge" << std::endl;
207  str << "-------------------------------------------" << std::endl;
208  for(int i=0; i<m_NBins; i++){
209  unsigned int ipack = getPacked(m_Scale[i]);
210  str << std::setw(4) << ipack <<
211  " | " << std::setw(10) << getLowEdge(ipack) <<
212  " | " << std::setw(10) << getCenter(ipack) <<
213  " | " << std::setw(10) << getHighEdge(ipack) << std::endl;
214  }
215 
216  return str.str();
217  }
float getHighEdge(unsigned packed) const override
get the upper edge of bin represented by packed
Definition: L1MuScale.h:169
float getCenter(unsigned packed) const override
get the center of bin represented by packed
Definition: L1MuScale.h:158
std::vector< float > m_Scale
Definition: L1MuScale.h:235
unsigned getPacked(float value) const override
pack a value
Definition: L1MuScale.h:175
float getLowEdge(unsigned packed) const override
get the low edge of bin represented by packed
Definition: L1MuScale.h:164
#define str(s)
template<class Archive >
void L1MuBinnedScale::serialize ( Archive &  ar,
const unsigned int  version 
)
private

Friends And Related Function Documentation

friend class boost::serialization::access
friend

Definition at line 237 of file L1MuScale.h.

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

Definition at line 237 of file L1MuScale.h.

Member Data Documentation

int L1MuBinnedScale::m_idxoffset
protected

Definition at line 234 of file L1MuScale.h.

int L1MuBinnedScale::m_NBins
protected

Definition at line 233 of file L1MuScale.h.

unsigned int L1MuBinnedScale::m_nbits
protected

Definition at line 231 of file L1MuScale.h.

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

Definition at line 235 of file L1MuScale.h.

bool L1MuBinnedScale::m_signedPacking
protected

Definition at line 232 of file L1MuScale.h.