CMS 3D CMS Logo

L1MuBinnedScale Class Reference

implements a continuous scale of NBins bins. More...

#include <CondFormats/L1TObjects/interface/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 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
 L1MuBinnedScale (unsigned int nbits, bool signedPacking, int NBins, float xmin, float xmax, int idx_offset=0)
 constructor
 L1MuBinnedScale (unsigned int nbits, bool signedPacking, int NBins, const std::vector< double > Scale, int idx_offset=0)
 NBins=number of bins, Scale[NBins+1]=bin edges, idx_offset=offeset to index (if stored as signed).
 L1MuBinnedScale ()
 constructor
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 85 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 95 of file L1MuScale.h.

00095 {}

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

References i, m_idxoffset, m_NBins, and m_Scale.

00101       : m_nbits( nbits ),
00102         m_signedPacking( signedPacking )
00103   {
00104     m_NBins = NBins;
00105     m_idxoffset = idx_offset;
00106 
00107     m_Scale.reserve(m_NBins + 1);
00108     for (int i=0; i<m_NBins + 1; i++) 
00109         //m_Scale[i] = Scale[i];
00110         m_Scale.push_back( Scale[i] ) ;
00111   };

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

References i, m_idxoffset, m_NBins, and m_Scale.

00124     : m_nbits( nbits ),
00125       m_signedPacking( signedPacking )
00126   {
00127     m_NBins = NBins;
00128     m_idxoffset = idx_offset;
00129 
00130     m_Scale.reserve(m_NBins + 1);
00131     for (int i=0; i<m_NBins + 1; i++) 
00132       //      m_Scale[i] = xmin + i * (xmax-xmin) / m_NBins;
00133       m_Scale.push_back( xmin + i * (xmax-xmin) / m_NBins ) ;
00134   };

virtual L1MuBinnedScale::~L1MuBinnedScale (  )  [inline, virtual]

destructor

Definition at line 137 of file L1MuScale.h.

00137                              {
00138 //    delete m_packing;
00139   };


Member Function Documentation

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

Definition at line 200 of file L1MuScale.h.

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

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

00200                                       {
00201      int idxFromPacked = m_signedPacking ?
00202         L1MuSignedPackingGeneric::idxFromPacked( packed, m_nbits ) :
00203         L1MuUnsignedPackingGeneric::idxFromPacked( packed, m_nbits ) ;
00204     int idx = idxFromPacked + m_idxoffset;
00205     if (idx<0) idx=0;
00206     if (idx>=m_NBins) idx=m_NBins-1;
00207     return idx;
00208   }

virtual float L1MuBinnedScale::getCenter ( unsigned  packed  )  const [inline, virtual]

get the center of bin represented by packed

Implements L1MuScale.

Definition at line 143 of file L1MuScale.h.

References get_idx(), and m_Scale.

Referenced by print().

00143                                                  {
00144     int idx = get_idx(packed);
00145     return (m_Scale[idx] + m_Scale[idx+1] )/ 2.;    
00146   };

virtual float L1MuBinnedScale::getHighEdge ( unsigned  packed  )  const [inline, virtual]

get the upper edge of bin represented by packed

Implements L1MuScale.

Definition at line 154 of file L1MuScale.h.

References get_idx(), and m_Scale.

Referenced by print().

00154                                                   {
00155     return m_Scale[get_idx(packed)+1];
00156   };

virtual float L1MuBinnedScale::getLowEdge ( unsigned  packed  )  const [inline, virtual]

get the low edge of bin represented by packed

Implements L1MuScale.

Definition at line 149 of file L1MuScale.h.

References get_idx(), and m_Scale.

Referenced by print().

00149                                                  {
00150     return m_Scale[get_idx(packed)];
00151   };

virtual unsigned L1MuBinnedScale::getPacked ( float  value  )  const [inline, virtual]

pack a value

Implements L1MuScale.

Definition at line 160 of file L1MuScale.h.

References lat::endl(), m_idxoffset, m_NBins, m_nbits, m_Scale, m_signedPacking, L1MuUnsignedPackingGeneric::packedFromIdx(), and L1MuSignedPackingGeneric::packedFromIdx().

Referenced by print().

00160                                                 {
00161     if (value < m_Scale[0] || value > m_Scale[m_NBins]) 
00162       edm::LogWarning("ScaleRangeViolation") << "L1MuBinnedScale::getPacked: value out of scale range: " << value << std::endl;
00163     int idx = 0;
00164     if (value < m_Scale[0]) idx=0;
00165     else if (value >= m_Scale[m_NBins]) idx = m_NBins-1;
00166     else {
00167       for (; idx<m_NBins; idx++) 
00168         if (value >= m_Scale[idx] && value < m_Scale[idx+1]) break;
00169     }
00170 
00171     return ( m_signedPacking ?
00172              L1MuSignedPackingGeneric::packedFromIdx(idx-m_idxoffset, m_nbits) :
00173              L1MuUnsignedPackingGeneric::packedFromIdx(idx-m_idxoffset, m_nbits) ) ;
00174   };

virtual float L1MuBinnedScale::getScaleMax (  )  const [inline, virtual]

get the upper edge of the last bin

Implements L1MuScale.

Definition at line 177 of file L1MuScale.h.

References m_NBins, and m_Scale.

00177 { 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 180 of file L1MuScale.h.

References m_Scale.

00180 { return m_Scale[0]; }

virtual std::string L1MuBinnedScale::print ( void   )  const [inline, virtual]

Implements L1MuScale.

Definition at line 182 of file L1MuScale.h.

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

00182                                   {
00183     std::ostringstream str;
00184 
00185     str << " ind |   low edge |     center |  high edge" << std::endl;
00186     str << "-------------------------------------------" << std::endl;
00187     for(int i=0; i<m_NBins; i++){
00188       unsigned int ipack = getPacked(m_Scale[i]);
00189       str << std::setw(4) << ipack << 
00190         " | " << std::setw(10) << getLowEdge(ipack) <<
00191         " | " << std::setw(10) << getCenter(ipack) <<
00192         " | " << std::setw(10) << getHighEdge(ipack) << std::endl;
00193     }
00194 
00195     return str.str();
00196   }


Member Data Documentation

int L1MuBinnedScale::m_idxoffset [protected]

Definition at line 213 of file L1MuScale.h.

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

int L1MuBinnedScale::m_NBins [protected]

Definition at line 212 of file L1MuScale.h.

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

unsigned int L1MuBinnedScale::m_nbits [protected]

Definition at line 210 of file L1MuScale.h.

Referenced by get_idx(), and getPacked().

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

Definition at line 214 of file L1MuScale.h.

Referenced by getCenter(), getHighEdge(), getLowEdge(), getPacked(), getScaleMax(), getScaleMin(), L1MuBinnedScale(), and print().

bool L1MuBinnedScale::m_signedPacking [protected]

Definition at line 211 of file L1MuScale.h.

Referenced by get_idx(), and getPacked().


The documentation for this class was generated from the following file:
Generated on Tue Jun 9 18:26:47 2009 for CMSSW by  doxygen 1.5.4