CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Attributes
L1MuSymmetricBinnedScale Class Reference

#include <L1MuScale.h>

Inheritance diagram for L1MuSymmetricBinnedScale:
L1MuScale

Public Member Functions

virtual float getCenter (unsigned packed) const
 get the center of bin represented by packed More...
 
virtual float getHighEdge (unsigned packed) const
 get the upper edge of bin represented by packed More...
 
virtual float getLowEdge (unsigned packed) const
 get the low edge of bin represented by packed More...
 
virtual unsigned getNBins () const
 get number of bins More...
 
virtual unsigned getPacked (float value) const
 pack a value More...
 
virtual float getScaleMax () const
 get the upper edge of the last bin (posivie half) More...
 
virtual float getScaleMin () const
 get the lower edge of the first bin (positive half) More...
 
virtual float getValue (unsigned i) const
 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)
 
virtual std::string print () const
 
virtual ~L1MuSymmetricBinnedScale ()
 destructor More...
 
- Public Member Functions inherited from L1MuScale
 L1MuScale ()
 
virtual ~L1MuScale ()
 

Protected Attributes

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

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

251 {}
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 256 of file L1MuScale.h.

References i, m_NBins, m_Scale, and EnsembleCalibrationLA_cfg::NBins.

258  m_NBins = NBins;
259  m_Scale.reserve(m_NBins + 1);
260  for (int i=0; i<m_NBins + 1; i++)
261  // m_Scale[i] = Scale[i];
262  m_Scale.push_back( Scale[i] ) ;
263  };
int i
Definition: DBlmapReader.cc:9
std::vector< float > m_Scale
Definition: L1MuScale.h:355
L1MuPseudoSignedPacking m_packing
Definition: L1MuScale.h:353
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 275 of file L1MuScale.h.

References i, m_NBins, m_Scale, and EnsembleCalibrationLA_cfg::NBins.

277  m_NBins = NBins;
278  m_Scale.reserve(m_NBins + 1);
279  for (int i=0; i<m_NBins + 1; i++)
280  // m_Scale[i] = xmin + i * (xmax-xmin) / m_NBins;
281  m_Scale.push_back( xmin + i * (xmax-xmin) / m_NBins ) ;
282  };
int i
Definition: DBlmapReader.cc:9
std::vector< float > m_Scale
Definition: L1MuScale.h:355
L1MuPseudoSignedPacking m_packing
Definition: L1MuScale.h:353
virtual L1MuSymmetricBinnedScale::~L1MuSymmetricBinnedScale ( )
inlinevirtual

destructor

Definition at line 285 of file L1MuScale.h.

285  {
286 // delete m_packing;
287  };

Member Function Documentation

virtual float L1MuSymmetricBinnedScale::getCenter ( unsigned  packed) const
inlinevirtual

get the center of bin represented by packed

Implements L1MuScale.

Definition at line 290 of file L1MuScale.h.

References abs, L1MuPseudoSignedPacking::idxFromPacked(), m_NBins, m_packing, m_Scale, and L1MuPseudoSignedPacking::signFromPacked().

Referenced by print().

290  {
291  int absidx = abs ( m_packing.idxFromPacked( packed ) );
292  if (absidx>=m_NBins) absidx=m_NBins-1;
293  float center = (m_Scale[absidx] + m_Scale[absidx+1] )/ 2.;
294  float fsign = m_packing.signFromPacked( packed ) == 0 ? 1. : -1.;
295  return center * fsign;
296  };
std::vector< float > m_Scale
Definition: L1MuScale.h:355
#define abs(x)
Definition: mlp_lapack.h:159
L1MuPseudoSignedPacking m_packing
Definition: L1MuScale.h:353
virtual int idxFromPacked(unsigned packed) const
get the value from the packed notation (+/-)
Definition: L1MuPacking.h:137
virtual int signFromPacked(unsigned packed) const
get the (pseudo-)sign from the packed notation (0=positive, 1=negative)
Definition: L1MuPacking.h:134
virtual float L1MuSymmetricBinnedScale::getHighEdge ( unsigned  packed) const
inlinevirtual

get the upper edge of bin represented by packed

Implements L1MuScale.

Definition at line 308 of file L1MuScale.h.

308  {
309  edm::LogWarning("NotImplemented") << "L1MuSymmetricBinnedScale::getHighEdge not implemented" << std::endl;
310  return 0;
311  };
virtual float L1MuSymmetricBinnedScale::getLowEdge ( unsigned  packed) const
inlinevirtual

get the low edge of bin represented by packed

Implements L1MuScale.

Definition at line 299 of file L1MuScale.h.

References abs, L1MuPseudoSignedPacking::idxFromPacked(), m_NBins, m_packing, m_Scale, and L1MuPseudoSignedPacking::signFromPacked().

Referenced by print().

299  { // === edge towards 0
300  int absidx = abs ( m_packing.idxFromPacked( packed ) );
301  if (absidx>=m_NBins) absidx=m_NBins-1;
302  float low = m_Scale[absidx];
303  float fsign = m_packing.signFromPacked( packed ) == 0 ? 1. : -1.;
304  return low * fsign;
305  };
std::vector< float > m_Scale
Definition: L1MuScale.h:355
#define abs(x)
Definition: mlp_lapack.h:159
L1MuPseudoSignedPacking m_packing
Definition: L1MuScale.h:353
virtual int idxFromPacked(unsigned packed) const
get the value from the packed notation (+/-)
Definition: L1MuPacking.h:137
virtual int signFromPacked(unsigned packed) const
get the (pseudo-)sign from the packed notation (0=positive, 1=negative)
Definition: L1MuPacking.h:134
virtual unsigned L1MuSymmetricBinnedScale::getNBins ( ) const
inlinevirtual

get number of bins

Implements L1MuScale.

Definition at line 332 of file L1MuScale.h.

References m_NBins.

332 { return m_NBins; }
virtual unsigned L1MuSymmetricBinnedScale::getPacked ( float  value) const
inlinevirtual

pack a value

Implements L1MuScale.

Definition at line 314 of file L1MuScale.h.

References m_NBins, m_packing, m_Scale, and L1MuPseudoSignedPacking::packedFromIdx().

Referenced by print().

314  {
315  float absval = fabs ( value );
316  if (absval < m_Scale[0] || absval > m_Scale[m_NBins]) edm::LogWarning("ScaleRangeViolation")
317  << "L1MuSymmetricBinnedScale::getPacked: value out of scale range!!! abs(val) = "
318  << absval << " min= " << m_Scale[0] << " max = " << m_Scale[m_NBins] << std::endl;
319  int idx = 0;
320  for (; idx<m_NBins; idx++)
321  if (absval >= m_Scale[idx] && absval < m_Scale[idx+1]) break;
322  if (idx >= m_NBins) idx = m_NBins-1;
323  return m_packing.packedFromIdx(idx, (value>=0) ? 0 : 1);
324  };
std::vector< float > m_Scale
Definition: L1MuScale.h:355
virtual unsigned packedFromIdx(int idx) const
get the packed notation of a value, check range
Definition: L1MuPacking.h:144
L1MuPseudoSignedPacking m_packing
Definition: L1MuScale.h:353
virtual float L1MuSymmetricBinnedScale::getScaleMax ( ) const
inlinevirtual

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

Implements L1MuScale.

Definition at line 326 of file L1MuScale.h.

References m_NBins, and m_Scale.

326 { return m_Scale[m_NBins]; }
std::vector< float > m_Scale
Definition: L1MuScale.h:355
virtual float L1MuSymmetricBinnedScale::getScaleMin ( ) const
inlinevirtual

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

Implements L1MuScale.

Definition at line 329 of file L1MuScale.h.

References m_Scale.

329 { return m_Scale[0]; }
std::vector< float > m_Scale
Definition: L1MuScale.h:355
virtual float L1MuSymmetricBinnedScale::getValue ( unsigned  i) const
inlinevirtual

get value of the underlying vector for bin i

Implements L1MuScale.

Definition at line 335 of file L1MuScale.h.

References i, and m_Scale.

335 { return m_Scale[i]; }
int i
Definition: DBlmapReader.cc:9
std::vector< float > m_Scale
Definition: L1MuScale.h:355
virtual std::string L1MuSymmetricBinnedScale::print ( void  ) const
inlinevirtual

Implements L1MuScale.

Definition at line 337 of file L1MuScale.h.

References getCenter(), getLowEdge(), getPacked(), i, m_NBins, and m_Scale.

337  {
338  std::ostringstream str;
339 
340  str << " ind | low edge | center" << std::endl;
341  str << "-------------------------------------------" << std::endl;
342  for(int i=0; i<m_NBins; i++){
343  unsigned int ipack = getPacked(m_Scale[i]);
344  str << std::setw(4) << ipack <<
345  " | " << std::setw(10) << getLowEdge(ipack) <<
346  " | " << std::setw(10) << getCenter(ipack) << std::endl;
347  }
348 
349  return str.str();
350  }
int i
Definition: DBlmapReader.cc:9
std::vector< float > m_Scale
Definition: L1MuScale.h:355
virtual unsigned getPacked(float value) const
pack a value
Definition: L1MuScale.h:314
virtual float getCenter(unsigned packed) const
get the center of bin represented by packed
Definition: L1MuScale.h:290
virtual float getLowEdge(unsigned packed) const
get the low edge of bin represented by packed
Definition: L1MuScale.h:299

Member Data Documentation

int L1MuSymmetricBinnedScale::m_NBins
protected
L1MuPseudoSignedPacking L1MuSymmetricBinnedScale::m_packing
protected

Definition at line 353 of file L1MuScale.h.

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

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