CMS 3D CMS Logo

CSCAnalogSignal.h
Go to the documentation of this file.
1 #ifndef MU_END_ANALOG_SIGNAL
2 #define MU_END_ANALOG_SIGNAL
3 
25 #include <cassert>
26 #include <iosfwd>
27 #include <vector>
28 
29 // TODO remove
30 #include <iostream>
31 
33 public:
35 
37  int element, float binSize, std::vector<float> &binValues, float total = 0., float timeOffset = 0.)
38  : theElement(element), invBinSize(1. / binSize), theBinValues(), theTotal(total), theTimeOffset(timeOffset) {
39  theBinValues.swap(binValues);
40  }
41 
43  // CSCAnalogSignal(int element, const CSCAnalogSignal& shape, float time,
44  // float total);
45 
46  inline int getElement() const { return theElement; };
47  inline void setElement(int element) { theElement = element; };
48  inline float getBinValue(int i) const {
49  return (i >= static_cast<int>(theBinValues.size()) || i < 0) ? 0. : theBinValues[i];
50  }
51 
52  inline float getValue(float t) const {
53  // interpolate between bins, if necessary
54  float retval = 0.;
55  float f = (t - theTimeOffset) * invBinSize + 0.000000001;
56  if (f >= 0.) {
57  int i = static_cast<int>(f);
58  f -= static_cast<float>(i);
59  retval = (1. - f) * getBinValue(i) + f * getBinValue(i + 1);
60  }
61  return retval;
62  }
63 
64  // inline void setBinValue(int i, float value) {
65  // if( i >= 0 && i < theBinValues.size() )
66  // theBinValues[i] = value;
67  // }
68 
69  inline int getSize() const { return theBinValues.size(); };
70  inline float getBinSize() const { return 1. / invBinSize; };
71  inline float getTotal() const { return theTotal; };
72  inline float getTimeOffset() const { return theTimeOffset; };
73  inline void setTimeOffset(float offset) { theTimeOffset = offset; };
74 
75  inline void superimpose(const CSCAnalogSignal &signal2) {
76  size_t n = theBinValues.size();
77  for (size_t i = 0; i < n; ++i) {
78  float t = i / invBinSize + theTimeOffset;
79  theBinValues[i] += signal2.getValue(t);
80  }
81  theTotal += signal2.theTotal;
82  }
83 
84  inline void operator+=(float offset) {
85  for (int i = 0; i < getSize(); ++i) {
86  theBinValues[i] += offset;
87  }
88  }
89 
90  inline void operator*=(float scaleFactor) {
91  for (int i = 0; i < getSize(); ++i) {
93  }
95  }
96 
97  friend std::ostream &operator<<(std::ostream &, const CSCAnalogSignal &);
98 
99  float &operator[](int i) {
100  assert(i >= 0 && i < getSize());
101  return theBinValues[i];
102  }
103 
104  const float &operator[](int i) const {
105  assert(i >= 0 && i < getSize());
106  return theBinValues[i];
107  }
108 
110  float peakTime() const;
111  unsigned size() const { return theBinValues.size(); }
112 
113 private:
115  float invBinSize;
116  std::vector<float> theBinValues;
117  float theTotal;
119 };
120 
121 #endif
CSCAnalogSignal::invBinSize
float invBinSize
Definition: CSCAnalogSignal.h:115
CSCAnalogSignal::theTotal
float theTotal
Definition: CSCAnalogSignal.h:117
CSCAnalogSignal::setElement
void setElement(int element)
Definition: CSCAnalogSignal.h:47
mps_fire.i
i
Definition: mps_fire.py:428
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
CSCAnalogSignal::getTotal
float getTotal() const
Definition: CSCAnalogSignal.h:71
CSCAnalogSignal::getBinValue
float getBinValue(int i) const
Definition: CSCAnalogSignal.h:48
cms::cuda::assert
assert(be >=bs)
CSCAnalogSignal::theBinValues
std::vector< float > theBinValues
Definition: CSCAnalogSignal.h:116
CSCAnalogSignal::superimpose
void superimpose(const CSCAnalogSignal &signal2)
Definition: CSCAnalogSignal.h:75
CSCAnalogSignal::operator[]
float & operator[](int i)
Definition: CSCAnalogSignal.h:99
CSCAnalogSignal::CSCAnalogSignal
CSCAnalogSignal(int element, float binSize, std::vector< float > &binValues, float total=0., float timeOffset=0.)
Definition: CSCAnalogSignal.h:36
CSCAnalogSignal::theTimeOffset
float theTimeOffset
Definition: CSCAnalogSignal.h:118
CSCAnalogSignal::operator*=
void operator*=(float scaleFactor)
Definition: CSCAnalogSignal.h:90
CSCAnalogSignal::peakTime
float peakTime() const
the time when the signal peaks
Definition: CSCAnalogSignal.cc:6
CSCAnalogSignal::theElement
int theElement
Definition: CSCAnalogSignal.h:114
CSCAnalogSignal::getValue
float getValue(float t) const
Definition: CSCAnalogSignal.h:52
CSCAnalogSignal::size
unsigned size() const
Definition: CSCAnalogSignal.h:111
CSCAnalogSignal::CSCAnalogSignal
CSCAnalogSignal()
Definition: CSCAnalogSignal.h:34
CSCAnalogSignal::getTimeOffset
float getTimeOffset() const
Definition: CSCAnalogSignal.h:72
CSCAnalogSignal::getSize
int getSize() const
Definition: CSCAnalogSignal.h:69
CSCAnalogSignal::getElement
int getElement() const
constructor from time and amp shape
Definition: CSCAnalogSignal.h:46
CSCAnalogSignal::operator+=
void operator+=(float offset)
Definition: CSCAnalogSignal.h:84
CSCAnalogSignal::operator[]
const float & operator[](int i) const
Definition: CSCAnalogSignal.h:104
CalibratedDigis_cfi.timeOffset
timeOffset
Definition: CalibratedDigis_cfi.py:23
CSCAnalogSignal
Definition: CSCAnalogSignal.h:32
multiplicitycorr_cfi.scaleFactor
scaleFactor
Definition: multiplicitycorr_cfi.py:7
CSCAnalogSignal::operator<<
friend std::ostream & operator<<(std::ostream &, const CSCAnalogSignal &)
Definition: CSCAnalogSignal.cc:11
dqmMemoryStats.total
total
Definition: dqmMemoryStats.py:152
CSCAnalogSignal::getBinSize
float getBinSize() const
Definition: CSCAnalogSignal.h:70
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
CSCAnalogSignal::setTimeOffset
void setTimeOffset(float offset)
Definition: CSCAnalogSignal.h:73