RawDigitAdder_HardSaturate.cxx
Go to the documentation of this file.
1 #ifndef OVERLAY_DATAOVERLAY_RAWDIGITADDER_HARDSATURATE_CXX
2 #define OVERLAY_DATAOVERLAY_RAWDIGITADDER_HARDSATURATE_CXX
3 
5 #include <limits>
6 #include <stdexcept>
7 #include <cmath>
8 
10  RawDigitAdder(t),
11  _max(std::numeric_limits<short>::max()),
12  _scale1(1),
13  _scale2(1)
14 {}
15 
17 {
18  if(x<0){
19  if(_throw)
20  throw std::runtime_error("Error in RawDigitAdder_HardSaturate::SetSaturationPoint : point < 0");
21  return;
22  }
23  _max = x;
24 }
25 
27 {
28  if(f<0){
29  if(_throw)
30  throw std::runtime_error("Error in RawDigitAdder_HardSaturate::SetScaleInput : scale < 0");
31  return;
32  }
33  _scale = f;
34 }
35 
36 void mix::RawDigitAdder_HardSaturate::AddRawDigit(short const& d1, short const& d2, short& d_out)
37 {
38  d_out = (short)(std::round((float)d1 * _scale1)) +
39  (short)(std::round((float)d2 * _scale2));
40  FixOverflow(d_out);
41  if(d_out > _max)
42  d_out=_max;
43 }
44 
45 #endif
void SetScaleInput(float f, float &_scale)
STL namespace.
static int max(int a, int b)
Defintion for a class to add two vectors together, and give an "added" waveform. Takes in a saturatio...
list x
Definition: train.py:276
void FixOverflow(short &)
void AddRawDigit(short const &, short const &, short &)