test
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 | Private Member Functions | Friends
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
 

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

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

105  :
106  m_nbits( 0 ),
107  m_signedPacking( false ),
108  m_NBins( 0 ),
109  m_idxoffset( 0 )
110  {}
unsigned int m_nbits
Definition: L1MuScale.h:231
bool m_signedPacking
Definition: L1MuScale.h:232
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 115 of file L1MuScale.h.

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

116  : m_nbits( nbits ),
117  m_signedPacking( signedPacking )
118  {
119  m_NBins = NBins;
120  m_idxoffset = idx_offset;
121 
122  m_Scale.reserve(m_NBins + 1);
123  for (int i=0; i<m_NBins + 1; i++)
124  //m_Scale[i] = Scale[i];
125  m_Scale.push_back( Scale[i] ) ;
126  };
int i
Definition: DBlmapReader.cc:9
unsigned int m_nbits
Definition: L1MuScale.h:231
std::vector< float > m_Scale
Definition: L1MuScale.h:235
bool m_signedPacking
Definition: L1MuScale.h:232
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 138 of file L1MuScale.h.

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

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

destructor

Definition at line 152 of file L1MuScale.h.

152  {
153 // delete m_packing;
154  };

Member Function Documentation

int L1MuBinnedScale::get_idx ( unsigned  packed) const
inlineprotected

Definition at line 221 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().

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

get the center of bin represented by packed

Implements L1MuScale.

Definition at line 158 of file L1MuScale.h.

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

Referenced by print().

158  {
159  int idx = get_idx(packed);
160  return (m_Scale[idx] + m_Scale[idx+1] )/ 2.;
161  };
std::vector< float > m_Scale
Definition: L1MuScale.h:235
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
int get_idx(unsigned packed) const
Definition: L1MuScale.h:221
virtual float L1MuBinnedScale::getHighEdge ( unsigned  packed) const
inlinevirtual

get the upper edge of bin represented by packed

Implements L1MuScale.

Definition at line 169 of file L1MuScale.h.

References get_idx(), and m_Scale.

Referenced by print().

169  {
170  return m_Scale[get_idx(packed)+1];
171  };
std::vector< float > m_Scale
Definition: L1MuScale.h:235
int get_idx(unsigned packed) const
Definition: L1MuScale.h:221
virtual float L1MuBinnedScale::getLowEdge ( unsigned  packed) const
inlinevirtual

get the low edge of bin represented by packed

Implements L1MuScale.

Definition at line 164 of file L1MuScale.h.

References get_idx(), and m_Scale.

Referenced by print().

164  {
165  return m_Scale[get_idx(packed)];
166  };
std::vector< float > m_Scale
Definition: L1MuScale.h:235
int get_idx(unsigned packed) const
Definition: L1MuScale.h:221
virtual unsigned L1MuBinnedScale::getNBins ( ) const
inlinevirtual

get number of bins

Implements L1MuScale.

Definition at line 198 of file L1MuScale.h.

References m_NBins.

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

pack a value

Implements L1MuScale.

Definition at line 175 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().

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

get the upper edge of the last bin

Implements L1MuScale.

Definition at line 192 of file L1MuScale.h.

References m_NBins, and m_Scale.

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

get the lower edge of the first bin

Implements L1MuScale.

Definition at line 195 of file L1MuScale.h.

References m_Scale.

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

get value of the underlying vector for bin i

Implements L1MuScale.

Definition at line 201 of file L1MuScale.h.

References i, and m_Scale.

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

Implements L1MuScale.

Definition at line 203 of file L1MuScale.h.

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

203  {
204  std::ostringstream str;
205 
206  str << " ind | low edge | center | high edge" << std::endl;
207  str << "-------------------------------------------" << std::endl;
208  for(int i=0; i<m_NBins; i++){
209  unsigned int ipack = getPacked(m_Scale[i]);
210  str << std::setw(4) << ipack <<
211  " | " << std::setw(10) << getLowEdge(ipack) <<
212  " | " << std::setw(10) << getCenter(ipack) <<
213  " | " << std::setw(10) << getHighEdge(ipack) << std::endl;
214  }
215 
216  return str.str();
217  }
int i
Definition: DBlmapReader.cc:9
virtual float getHighEdge(unsigned packed) const
get the upper edge of bin represented by packed
Definition: L1MuScale.h:169
virtual float getLowEdge(unsigned packed) const
get the low edge of bin represented by packed
Definition: L1MuScale.h:164
std::vector< float > m_Scale
Definition: L1MuScale.h:235
virtual float getCenter(unsigned packed) const
get the center of bin represented by packed
Definition: L1MuScale.h:158
virtual unsigned getPacked(float value) const
pack a value
Definition: L1MuScale.h:175
template<class Archive >
void L1MuBinnedScale::serialize ( Archive &  ar,
const unsigned int  version 
)
private

Friends And Related Function Documentation

friend class boost::serialization::access
friend

Definition at line 237 of file L1MuScale.h.

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

Definition at line 237 of file L1MuScale.h.

Member Data Documentation

int L1MuBinnedScale::m_idxoffset
protected

Definition at line 234 of file L1MuScale.h.

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

int L1MuBinnedScale::m_NBins
protected

Definition at line 233 of file L1MuScale.h.

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

unsigned int L1MuBinnedScale::m_nbits
protected

Definition at line 231 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 232 of file L1MuScale.h.

Referenced by get_idx(), and getPacked().