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 Member Functions | Protected Attributes
L1MuBinnedScale Class Reference

#include <L1MuScale.h>

Inheritance diagram for L1MuBinnedScale:
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 More...
 
virtual float getScaleMin () const
 get the lower edge of the first bin More...
 
virtual float getValue (unsigned i) const
 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)
 
virtual std::string print () const
 
virtual ~L1MuBinnedScale ()
 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
 

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.

101  :
102  m_nbits( 0 ),
103  m_signedPacking( false ),
104  m_NBins( 0 ),
105  m_idxoffset( 0 )
106  {}
unsigned int m_nbits
Definition: L1MuScale.h:227
bool m_signedPacking
Definition: L1MuScale.h:228
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.

112  : m_nbits( nbits ),
113  m_signedPacking( signedPacking )
114  {
115  m_NBins = NBins;
116  m_idxoffset = idx_offset;
117 
118  m_Scale.reserve(m_NBins + 1);
119  for (int i=0; i<m_NBins + 1; i++)
120  //m_Scale[i] = Scale[i];
121  m_Scale.push_back( Scale[i] ) ;
122  };
int i
Definition: DBlmapReader.cc:9
unsigned int m_nbits
Definition: L1MuScale.h:227
std::vector< float > m_Scale
Definition: L1MuScale.h:231
bool m_signedPacking
Definition: L1MuScale.h:228
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.

135  : m_nbits( nbits ),
136  m_signedPacking( signedPacking )
137  {
138  m_NBins = NBins;
139  m_idxoffset = idx_offset;
140 
141  m_Scale.reserve(m_NBins + 1);
142  for (int i=0; i<m_NBins + 1; i++)
143  // m_Scale[i] = xmin + i * (xmax-xmin) / m_NBins;
144  m_Scale.push_back( xmin + i * (xmax-xmin) / m_NBins ) ;
145  };
int i
Definition: DBlmapReader.cc:9
unsigned int m_nbits
Definition: L1MuScale.h:227
std::vector< float > m_Scale
Definition: L1MuScale.h:231
bool m_signedPacking
Definition: L1MuScale.h:228
virtual L1MuBinnedScale::~L1MuBinnedScale ( )
inlinevirtual

destructor

Definition at line 148 of file L1MuScale.h.

148  {
149 // delete m_packing;
150  };

Member Function Documentation

int L1MuBinnedScale::get_idx ( unsigned  packed) const
inlineprotected

Definition at line 217 of file L1MuScale.h.

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

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

217  {
218  int idxFromPacked = m_signedPacking ?
220  L1MuUnsignedPackingGeneric::idxFromPacked( packed, m_nbits ) ;
221  int idx = idxFromPacked + m_idxoffset;
222  if (idx<0) idx=0;
223  if (idx>=m_NBins) idx=m_NBins-1;
224  return idx;
225  }
unsigned int m_nbits
Definition: L1MuScale.h:227
static int idxFromPacked(unsigned packed, unsigned int nbits)
get the value from the packed notation (+/-)
Definition: L1MuPacking.h:109
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
bool m_signedPacking
Definition: L1MuScale.h:228
virtual float L1MuBinnedScale::getCenter ( unsigned  packed) const
inlinevirtual

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().

154  {
155  int idx = get_idx(packed);
156  return (m_Scale[idx] + m_Scale[idx+1] )/ 2.;
157  };
std::vector< float > m_Scale
Definition: L1MuScale.h:231
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
int get_idx(unsigned packed) const
Definition: L1MuScale.h:217
virtual float L1MuBinnedScale::getHighEdge ( unsigned  packed) const
inlinevirtual

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().

165  {
166  return m_Scale[get_idx(packed)+1];
167  };
std::vector< float > m_Scale
Definition: L1MuScale.h:231
int get_idx(unsigned packed) const
Definition: L1MuScale.h:217
virtual float L1MuBinnedScale::getLowEdge ( unsigned  packed) const
inlinevirtual

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().

160  {
161  return m_Scale[get_idx(packed)];
162  };
std::vector< float > m_Scale
Definition: L1MuScale.h:231
int get_idx(unsigned packed) const
Definition: L1MuScale.h:217
virtual unsigned L1MuBinnedScale::getNBins ( ) const
inlinevirtual

get number of bins

Implements L1MuScale.

Definition at line 194 of file L1MuScale.h.

References m_NBins.

194 { return m_NBins; }
virtual unsigned L1MuBinnedScale::getPacked ( float  value) const
inlinevirtual

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().

171  {
172  if (value < m_Scale[0] || value > m_Scale[m_NBins])
173  edm::LogWarning("ScaleRangeViolation") << "L1MuBinnedScale::getPacked: value out of scale range: " << value << std::endl;
174  int idx = 0;
175  if (value < m_Scale[0]) idx=0;
176  else if (value >= m_Scale[m_NBins]) idx = m_NBins-1;
177  else {
178  for (; idx<m_NBins; idx++)
179  if (value >= m_Scale[idx] && value < m_Scale[idx+1]) break;
180  }
181 
182  return ( m_signedPacking ?
185  };
static unsigned packedFromIdx(int idx, unsigned int nbits)
get the packed notation of a value, check range
Definition: L1MuPacking.h:111
unsigned int m_nbits
Definition: L1MuScale.h:227
std::vector< float > m_Scale
Definition: L1MuScale.h:231
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
bool m_signedPacking
Definition: L1MuScale.h:228
static unsigned packedFromIdx(int idx, unsigned int nbits)
get the packed notation of a value, check the range
Definition: L1MuPacking.h:71
virtual float L1MuBinnedScale::getScaleMax ( ) const
inlinevirtual

get the upper edge of the last bin

Implements L1MuScale.

Definition at line 188 of file L1MuScale.h.

References m_NBins, and m_Scale.

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

get the lower edge of the first bin

Implements L1MuScale.

Definition at line 191 of file L1MuScale.h.

References m_Scale.

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

get value of the underlying vector for bin i

Implements L1MuScale.

Definition at line 197 of file L1MuScale.h.

References i, and m_Scale.

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

Implements L1MuScale.

Definition at line 199 of file L1MuScale.h.

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

199  {
200  std::ostringstream str;
201 
202  str << " ind | low edge | center | high edge" << std::endl;
203  str << "-------------------------------------------" << std::endl;
204  for(int i=0; i<m_NBins; i++){
205  unsigned int ipack = getPacked(m_Scale[i]);
206  str << std::setw(4) << ipack <<
207  " | " << std::setw(10) << getLowEdge(ipack) <<
208  " | " << std::setw(10) << getCenter(ipack) <<
209  " | " << std::setw(10) << getHighEdge(ipack) << std::endl;
210  }
211 
212  return str.str();
213  }
int i
Definition: DBlmapReader.cc:9
virtual float getHighEdge(unsigned packed) const
get the upper edge of bin represented by packed
Definition: L1MuScale.h:165
virtual float getLowEdge(unsigned packed) const
get the low edge of bin represented by packed
Definition: L1MuScale.h:160
std::vector< float > m_Scale
Definition: L1MuScale.h:231
virtual float getCenter(unsigned packed) const
get the center of bin represented by packed
Definition: L1MuScale.h:154
virtual unsigned getPacked(float value) const
pack a value
Definition: L1MuScale.h:171

Member Data Documentation

int L1MuBinnedScale::m_idxoffset
protected

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
bool L1MuBinnedScale::m_signedPacking
protected

Definition at line 228 of file L1MuScale.h.

Referenced by get_idx(), and getPacked().