CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Protected Attributes

L1MuBinnedScale Class Reference

#include <L1MuScale.h>

Inheritance diagram for L1MuBinnedScale:
L1MuScale

List of all members.

Public Member Functions

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

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

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

                   :
    m_nbits( 0 ),
    m_signedPacking( false ),
    m_NBins( 0 ),
    m_idxoffset( 0 )
      {}
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 111 of file L1MuScale.h.

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

      : m_nbits( nbits ),
        m_signedPacking( signedPacking )
  {
    m_NBins = NBins;
    m_idxoffset = idx_offset;

    m_Scale.reserve(m_NBins + 1);
    for (int i=0; i<m_NBins + 1; i++) 
        //m_Scale[i] = Scale[i];
        m_Scale.push_back( Scale[i] ) ;
  };
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 134 of file L1MuScale.h.

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

    : m_nbits( nbits ),
      m_signedPacking( signedPacking )
  {
    m_NBins = NBins;
    m_idxoffset = idx_offset;

    m_Scale.reserve(m_NBins + 1);
    for (int i=0; i<m_NBins + 1; i++) 
      //      m_Scale[i] = xmin + i * (xmax-xmin) / m_NBins;
      m_Scale.push_back( xmin + i * (xmax-xmin) / m_NBins ) ;
  };
virtual L1MuBinnedScale::~L1MuBinnedScale ( ) [inline, virtual]

destructor

Definition at line 148 of file L1MuScale.h.

                             {
//    delete m_packing;
  };

Member Function Documentation

int L1MuBinnedScale::get_idx ( unsigned  packed) const [inline, protected]

Definition at line 217 of file L1MuScale.h.

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

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

                                      {
     int idxFromPacked = m_signedPacking ?
        L1MuSignedPackingGeneric::idxFromPacked( packed, m_nbits ) :
        L1MuUnsignedPackingGeneric::idxFromPacked( packed, m_nbits ) ;
    int idx = idxFromPacked + m_idxoffset;
    if (idx<0) idx=0;
    if (idx>=m_NBins) idx=m_NBins-1;
    return idx;
  }
virtual float L1MuBinnedScale::getCenter ( unsigned  packed) const [inline, virtual]

get the center of bin represented by packed

Implements L1MuScale.

Definition at line 154 of file L1MuScale.h.

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

Referenced by print().

                                                 {
    int idx = get_idx(packed);
    return (m_Scale[idx] + m_Scale[idx+1] )/ 2.;    
  };
virtual float L1MuBinnedScale::getHighEdge ( unsigned  packed) const [inline, virtual]

get the upper edge of bin represented by packed

Implements L1MuScale.

Definition at line 165 of file L1MuScale.h.

References get_idx(), and m_Scale.

Referenced by print().

                                                  {
    return m_Scale[get_idx(packed)+1];
  };
virtual float L1MuBinnedScale::getLowEdge ( unsigned  packed) const [inline, virtual]

get the low edge of bin represented by packed

Implements L1MuScale.

Definition at line 160 of file L1MuScale.h.

References get_idx(), and m_Scale.

Referenced by print().

                                                 {
    return m_Scale[get_idx(packed)];
  };
virtual unsigned L1MuBinnedScale::getNBins ( ) const [inline, virtual]

get number of bins

Implements L1MuScale.

Definition at line 194 of file L1MuScale.h.

References m_NBins.

{ return m_NBins; }
virtual unsigned L1MuBinnedScale::getPacked ( float  value) const [inline, virtual]

pack a value

Implements L1MuScale.

Definition at line 171 of file L1MuScale.h.

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

Referenced by print().

                                                {
    if (value < m_Scale[0] || value > m_Scale[m_NBins]) 
      edm::LogWarning("ScaleRangeViolation") << "L1MuBinnedScale::getPacked: value out of scale range: " << value << std::endl;
    int idx = 0;
    if (value < m_Scale[0]) idx=0;
    else if (value >= m_Scale[m_NBins]) idx = m_NBins-1;
    else {
      for (; idx<m_NBins; idx++) 
        if (value >= m_Scale[idx] && value < m_Scale[idx+1]) break;
    }

    return ( m_signedPacking ?
             L1MuSignedPackingGeneric::packedFromIdx(idx-m_idxoffset, m_nbits) :
             L1MuUnsignedPackingGeneric::packedFromIdx(idx-m_idxoffset, m_nbits) ) ;
  };
virtual float L1MuBinnedScale::getScaleMax ( ) const [inline, virtual]

get the upper edge of the last bin

Implements L1MuScale.

Definition at line 188 of file L1MuScale.h.

References m_NBins, and m_Scale.

{ return m_Scale[m_NBins]; }
virtual float L1MuBinnedScale::getScaleMin ( ) const [inline, virtual]

get the lower edge of the first bin

Implements L1MuScale.

Definition at line 191 of file L1MuScale.h.

References m_Scale.

{ return m_Scale[0]; }
virtual float L1MuBinnedScale::getValue ( unsigned  i) const [inline, virtual]

get value of the underlying vector for bin i

Implements L1MuScale.

Definition at line 197 of file L1MuScale.h.

References i, and m_Scale.

{ return m_Scale[i]; }
virtual std::string L1MuBinnedScale::print ( void  ) const [inline, virtual]

Implements L1MuScale.

Definition at line 199 of file L1MuScale.h.

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

                                  {
    std::ostringstream str;

    str << " ind |   low edge |     center |  high edge" << std::endl;
    str << "-------------------------------------------" << std::endl;
    for(int i=0; i<m_NBins; i++){
      unsigned int ipack = getPacked(m_Scale[i]);
      str << std::setw(4) << ipack << 
        " | " << std::setw(10) << getLowEdge(ipack) <<
        " | " << std::setw(10) << getCenter(ipack) <<
        " | " << std::setw(10) << getHighEdge(ipack) << std::endl;
    }

    return str.str();
  }

Member Data Documentation

Definition at line 230 of file L1MuScale.h.

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

int L1MuBinnedScale::m_NBins [protected]

Definition at line 229 of file L1MuScale.h.

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

unsigned int L1MuBinnedScale::m_nbits [protected]

Definition at line 227 of file L1MuScale.h.

Referenced by get_idx(), and getPacked().

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

Definition at line 228 of file L1MuScale.h.

Referenced by get_idx(), and getPacked().