CMS 3D CMS Logo

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

#include <L1MuScale.h>

Inheritance diagram for L1MuSymmetricBinnedScale:
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 (posivie half) More...
 
float getScaleMin () const override
 get the lower edge of the first bin (positive half) More...
 
float getValue (unsigned i) const override
 get value of the underlying vector for bin i More...
 
 L1MuSymmetricBinnedScale ()
 
 L1MuSymmetricBinnedScale (int nbits, int NBins, const std::vector< double > &Scale)
 
 L1MuSymmetricBinnedScale (int nbits, int NBins, float xmin, float xmax)
 
std::string print () const override
 
 ~L1MuSymmetricBinnedScale () override
 destructor More...
 
- Public Member Functions inherited from L1MuScale
 L1MuScale ()
 
virtual ~L1MuScale ()
 

Protected Attributes

int m_NBins
 
L1MuPseudoSignedPacking m_packing
 
std::vector< float > m_Scale
 

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

In the GMT the concept of a symmetric scale exists The internal representation of scale values is "pseudo-signed", i.e. the highest bit stores the sign and the lower bits contain the absolute value

Attention: for reasons of symmetry, the low edge in this scale is the edge closer to zero. the high edge is the edge further away from zero

Definition at line 251 of file L1MuScale.h.

Constructor & Destructor Documentation

L1MuSymmetricBinnedScale::L1MuSymmetricBinnedScale ( )
inline

constructor

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

Definition at line 262 of file L1MuScale.h.

262  :
263  m_NBins( 0 )
264  {}
L1MuSymmetricBinnedScale::L1MuSymmetricBinnedScale ( int  nbits,
int  NBins,
const std::vector< double > &  Scale 
)
inline

NBins=number of bins (in one half of the scale), Scale[NBins+1]=bin edges

Definition at line 269 of file L1MuScale.h.

References mps_fire::i.

271  m_NBins = NBins;
272  m_Scale.reserve(m_NBins + 1);
273  for (int i=0; i<m_NBins + 1; i++)
274  // m_Scale[i] = Scale[i];
275  m_Scale.push_back( Scale[i] ) ;
276  };
std::vector< float > m_Scale
Definition: L1MuScale.h:368
L1MuPseudoSignedPacking m_packing
Definition: L1MuScale.h:366
L1MuSymmetricBinnedScale::L1MuSymmetricBinnedScale ( int  nbits,
int  NBins,
float  xmin,
float  xmax 
)
inline

constructor

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

NBins=number of bins, xmin = low edge of first bin (in positive half) xmax=high edge of last bin (in positive half)

Definition at line 288 of file L1MuScale.h.

References mps_fire::i.

290  m_NBins = NBins;
291  m_Scale.reserve(m_NBins + 1);
292  for (int i=0; i<m_NBins + 1; i++)
293  // m_Scale[i] = xmin + i * (xmax-xmin) / m_NBins;
294  m_Scale.push_back( xmin + i * (xmax-xmin) / m_NBins ) ;
295  };
std::vector< float > m_Scale
Definition: L1MuScale.h:368
L1MuPseudoSignedPacking m_packing
Definition: L1MuScale.h:366
L1MuSymmetricBinnedScale::~L1MuSymmetricBinnedScale ( )
inlineoverride

destructor

Definition at line 298 of file L1MuScale.h.

298  {
299 // delete m_packing;
300  };

Member Function Documentation

float L1MuSymmetricBinnedScale::getCenter ( unsigned  packed) const
inlineoverridevirtual

get the center of bin represented by packed

Implements L1MuScale.

Definition at line 303 of file L1MuScale.h.

References funct::abs().

303  {
304  int absidx = abs ( m_packing.idxFromPacked( packed ) );
305  if (absidx>=m_NBins) absidx=m_NBins-1;
306  float center = (m_Scale[absidx] + m_Scale[absidx+1] )/ 2.;
307  float fsign = m_packing.signFromPacked( packed ) == 0 ? 1. : -1.;
308  return center * fsign;
309  };
std::vector< float > m_Scale
Definition: L1MuScale.h:368
int signFromPacked(unsigned packed) const override
get the (pseudo-)sign from the packed notation (0=positive, 1=negative)
Definition: L1MuPacking.h:143
int idxFromPacked(unsigned packed) const override
get the value from the packed notation (+/-)
Definition: L1MuPacking.h:146
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
L1MuPseudoSignedPacking m_packing
Definition: L1MuScale.h:366
float L1MuSymmetricBinnedScale::getHighEdge ( unsigned  packed) const
inlineoverridevirtual

get the upper edge of bin represented by packed

Implements L1MuScale.

Definition at line 321 of file L1MuScale.h.

321  {
322  edm::LogWarning("NotImplemented") << "L1MuSymmetricBinnedScale::getHighEdge not implemented" << std::endl;
323  return 0;
324  };
float L1MuSymmetricBinnedScale::getLowEdge ( unsigned  packed) const
inlineoverridevirtual

get the low edge of bin represented by packed

Implements L1MuScale.

Definition at line 312 of file L1MuScale.h.

References funct::abs().

312  { // === edge towards 0
313  int absidx = abs ( m_packing.idxFromPacked( packed ) );
314  if (absidx>=m_NBins) absidx=m_NBins-1;
315  float low = m_Scale[absidx];
316  float fsign = m_packing.signFromPacked( packed ) == 0 ? 1. : -1.;
317  return low * fsign;
318  };
std::vector< float > m_Scale
Definition: L1MuScale.h:368
int signFromPacked(unsigned packed) const override
get the (pseudo-)sign from the packed notation (0=positive, 1=negative)
Definition: L1MuPacking.h:143
int idxFromPacked(unsigned packed) const override
get the value from the packed notation (+/-)
Definition: L1MuPacking.h:146
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
L1MuPseudoSignedPacking m_packing
Definition: L1MuScale.h:366
unsigned L1MuSymmetricBinnedScale::getNBins ( ) const
inlineoverridevirtual

get number of bins

Implements L1MuScale.

Definition at line 345 of file L1MuScale.h.

345 { return m_NBins; }
unsigned L1MuSymmetricBinnedScale::getPacked ( float  value) const
inlineoverridevirtual

pack a value

Implements L1MuScale.

Definition at line 327 of file L1MuScale.h.

References training_settings::idx.

327  {
328  float absval = fabs ( value );
329  if (absval < m_Scale[0] || absval > m_Scale[m_NBins]) edm::LogWarning("ScaleRangeViolation")
330  << "L1MuSymmetricBinnedScale::getPacked: value out of scale range!!! abs(val) = "
331  << absval << " min= " << m_Scale[0] << " max = " << m_Scale[m_NBins] << std::endl;
332  int idx = 0;
333  for (; idx<m_NBins; idx++)
334  if (absval >= m_Scale[idx] && absval < m_Scale[idx+1]) break;
335  if (idx >= m_NBins) idx = m_NBins-1;
336  return m_packing.packedFromIdx(idx, (value>=0) ? 0 : 1);
337  };
std::vector< float > m_Scale
Definition: L1MuScale.h:368
Definition: value.py:1
L1MuPseudoSignedPacking m_packing
Definition: L1MuScale.h:366
unsigned packedFromIdx(int idx) const override
get the packed notation of a value, check range
Definition: L1MuPacking.h:153
float L1MuSymmetricBinnedScale::getScaleMax ( ) const
inlineoverridevirtual

get the upper edge of the last bin (posivie half)

Implements L1MuScale.

Definition at line 339 of file L1MuScale.h.

339 { return m_Scale[m_NBins]; }
std::vector< float > m_Scale
Definition: L1MuScale.h:368
float L1MuSymmetricBinnedScale::getScaleMin ( ) const
inlineoverridevirtual

get the lower edge of the first bin (positive half)

Implements L1MuScale.

Definition at line 342 of file L1MuScale.h.

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

get value of the underlying vector for bin i

Implements L1MuScale.

Definition at line 348 of file L1MuScale.h.

References mps_fire::i.

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

Implements L1MuScale.

Definition at line 350 of file L1MuScale.h.

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

350  {
351  std::ostringstream str;
352 
353  str << " ind | low edge | center" << std::endl;
354  str << "-------------------------------------------" << std::endl;
355  for(int i=0; i<m_NBins; i++){
356  unsigned int ipack = getPacked(m_Scale[i]);
357  str << std::setw(4) << ipack <<
358  " | " << std::setw(10) << getLowEdge(ipack) <<
359  " | " << std::setw(10) << getCenter(ipack) << std::endl;
360  }
361 
362  return str.str();
363  }
unsigned getPacked(float value) const override
pack a value
Definition: L1MuScale.h:327
std::vector< float > m_Scale
Definition: L1MuScale.h:368
float getCenter(unsigned packed) const override
get the center of bin represented by packed
Definition: L1MuScale.h:303
float getLowEdge(unsigned packed) const override
get the low edge of bin represented by packed
Definition: L1MuScale.h:312
#define str(s)
template<class Archive >
void L1MuSymmetricBinnedScale::serialize ( Archive &  ar,
const unsigned int  version 
)
private

Friends And Related Function Documentation

friend class boost::serialization::access
friend

Definition at line 370 of file L1MuScale.h.

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

Definition at line 370 of file L1MuScale.h.

Member Data Documentation

int L1MuSymmetricBinnedScale::m_NBins
protected

Definition at line 367 of file L1MuScale.h.

L1MuPseudoSignedPacking L1MuSymmetricBinnedScale::m_packing
protected

Definition at line 366 of file L1MuScale.h.

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

Definition at line 368 of file L1MuScale.h.