CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes | Friends
CSCAnalogSignal Class Reference

#include <CSCAnalogSignal.h>

Public Member Functions

 CSCAnalogSignal ()
 
 CSCAnalogSignal (int element, float binSize, std::vector< float > &binValues, float total=0., float timeOffset=0.)
 
float getBinSize () const
 
float getBinValue (int i) const
 
int getElement () const
 constructor from time and amp shape More...
 
int getSize () const
 
float getTimeOffset () const
 
float getTotal () const
 
float getValue (float t) const
 
void operator*= (float scaleFactor)
 
void operator+= (float offset)
 
float & operator[] (int i)
 
const float & operator[] (int i) const
 
float peakTime () const
 the time when the signal peaks More...
 
void setElement (int element)
 
void setTimeOffset (float offset)
 
unsigned size () const
 
void superimpose (const CSCAnalogSignal &signal2)
 

Private Attributes

float invBinSize
 
std::vector< float > theBinValues
 
int theElement
 
float theTimeOffset
 
float theTotal
 

Friends

std::ostream & operator<< (std::ostream &, const CSCAnalogSignal &)
 

Detailed Description

Simple histogram meant to represent the analog signal on a detector element.

Author
Rick Wilkinson

Last mod:
30-Jun-00 ptc Add further traps in getBinValue() and setBinValue().
06-Jul-00 ptc In fact the getBinValue trap was an important bug-fix: it trapped on > size() of stl std::vector but should have trapped >= size(). It occasionally does reach size().

Mods (performace improvements) by Vin 31/07/2000
Critical methods (getBinValue, get Value +=) inlined
bin-size stored and used as his inverse (encapulation helped in not changing interface, named changed to use compiler to catch its occurrencies)
swap input std::vector (be careful if const..)
do proper interpolation (not just /2)

Definition at line 32 of file CSCAnalogSignal.h.

Constructor & Destructor Documentation

◆ CSCAnalogSignal() [1/2]

CSCAnalogSignal::CSCAnalogSignal ( )
inline

Definition at line 34 of file CSCAnalogSignal.h.

◆ CSCAnalogSignal() [2/2]

CSCAnalogSignal::CSCAnalogSignal ( int  element,
float  binSize,
std::vector< float > &  binValues,
float  total = 0.,
float  timeOffset = 0. 
)
inline

Definition at line 36 of file CSCAnalogSignal.h.

38  : theElement(element), invBinSize(1. / binSize), theBinValues(), theTotal(total), theTimeOffset(timeOffset) {
39  theBinValues.swap(binValues);
40  }

References theBinValues.

Member Function Documentation

◆ getBinSize()

float CSCAnalogSignal::getBinSize ( ) const
inline

Definition at line 70 of file CSCAnalogSignal.h.

70 { return 1. / invBinSize; };

References invBinSize.

Referenced by CSCCrosstalkGenerator::getCrosstalk(), and operator<<().

◆ getBinValue()

float CSCAnalogSignal::getBinValue ( int  i) const
inline

Definition at line 48 of file CSCAnalogSignal.h.

48  {
49  return (i >= static_cast<int>(theBinValues.size()) || i < 0) ? 0. : theBinValues[i];
50  }

References mps_fire::i, and theBinValues.

Referenced by CSCWireElectronicsSim::fillDigis(), getValue(), and CSCCrosstalkGenerator::ratio().

◆ getElement()

int CSCAnalogSignal::getElement ( ) const
inline

constructor from time and amp shape

Definition at line 46 of file CSCAnalogSignal.h.

46 { return theElement; };

References theElement.

Referenced by CSCBaseElectronicsSim::add(), and CSCStripConditions::noisify().

◆ getSize()

int CSCAnalogSignal::getSize ( ) const
inline

◆ getTimeOffset()

float CSCAnalogSignal::getTimeOffset ( ) const
inline

Definition at line 72 of file CSCAnalogSignal.h.

72 { return theTimeOffset; };

References theTimeOffset.

Referenced by CSCCrosstalkGenerator::getCrosstalk(), CSCStripConditions::noisify(), and operator<<().

◆ getTotal()

float CSCAnalogSignal::getTotal ( ) const
inline

Definition at line 71 of file CSCAnalogSignal.h.

71 { return theTotal; };

References theTotal.

Referenced by SortSignalsByTotal().

◆ getValue()

float CSCAnalogSignal::getValue ( float  t) const
inline

Definition at line 52 of file CSCAnalogSignal.h.

52  {
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  }

References f, getBinValue(), mps_fire::i, invBinSize, OrderedSet::t, and theTimeOffset.

Referenced by CSCStripElectronicsSim::comparatorReading(), CSCStripElectronicsSim::createDigi(), CSCCrosstalkGenerator::getCrosstalk(), CSCStripElectronicsSim::makeNoiseSignal(), and superimpose().

◆ operator*=()

void CSCAnalogSignal::operator*= ( float  scaleFactor)
inline

Definition at line 90 of file CSCAnalogSignal.h.

90  {
91  for (int i = 0; i < getSize(); ++i) {
93  }
95  }

References getSize(), mps_fire::i, multiplicitycorr_cfi::scaleFactor, theBinValues, and theTotal.

◆ operator+=()

void CSCAnalogSignal::operator+= ( float  offset)
inline

Definition at line 84 of file CSCAnalogSignal.h.

84  {
85  for (int i = 0; i < getSize(); ++i) {
86  theBinValues[i] += offset;
87  }
88  }

References getSize(), mps_fire::i, hltrates_dqm_sourceclient-live_cfg::offset, and theBinValues.

◆ operator[]() [1/2]

float& CSCAnalogSignal::operator[] ( int  i)
inline

Definition at line 99 of file CSCAnalogSignal.h.

99  {
100  assert(i >= 0 && i < getSize());
101  return theBinValues[i];
102  }

References cms::cuda::assert(), getSize(), mps_fire::i, and theBinValues.

◆ operator[]() [2/2]

const float& CSCAnalogSignal::operator[] ( int  i) const
inline

Definition at line 104 of file CSCAnalogSignal.h.

104  {
105  assert(i >= 0 && i < getSize());
106  return theBinValues[i];
107  }

References cms::cuda::assert(), getSize(), mps_fire::i, and theBinValues.

◆ peakTime()

float CSCAnalogSignal::peakTime ( ) const

the time when the signal peaks

Definition at line 6 of file CSCAnalogSignal.cc.

6  {
7  size_t imax = std::max_element(theBinValues.begin(), theBinValues.end()) - theBinValues.begin();
8  return imax / invBinSize + theTimeOffset;
9 }

References invBinSize, theBinValues, and theTimeOffset.

◆ setElement()

void CSCAnalogSignal::setElement ( int  element)
inline

Definition at line 47 of file CSCAnalogSignal.h.

47 { theElement = element; };

References theElement.

◆ setTimeOffset()

void CSCAnalogSignal::setTimeOffset ( float  offset)
inline

Definition at line 73 of file CSCAnalogSignal.h.

73 { theTimeOffset = offset; };

References hltrates_dqm_sourceclient-live_cfg::offset, and theTimeOffset.

◆ size()

unsigned CSCAnalogSignal::size ( void  ) const
inline

Definition at line 111 of file CSCAnalogSignal.h.

111 { return theBinValues.size(); }

References theBinValues.

Referenced by ntupleDataFormat._Collection::__iter__(), and ntupleDataFormat._Collection::__len__().

◆ superimpose()

void CSCAnalogSignal::superimpose ( const CSCAnalogSignal signal2)
inline

Definition at line 75 of file CSCAnalogSignal.h.

75  {
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  }

References getValue(), mps_fire::i, invBinSize, dqmiodumpmetadata::n, OrderedSet::t, theBinValues, theTimeOffset, and theTotal.

Referenced by CSCBaseElectronicsSim::add(), CSCStripElectronicsSim::addCrosstalk(), and CSCStripConditions::noisify().

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  stream,
const CSCAnalogSignal signal 
)
friend

Definition at line 11 of file CSCAnalogSignal.cc.

11  {
12  stream << "CSCAnalogSignal: Element " << signal.theElement << " Total " << signal.theTotal << std::endl;
13  for (int i = 0; i < int(signal.theBinValues.size()); ++i) {
14  //@@ ptc 26-Feb-02 Don't both with very small amplitudes
15 
16  if (signal.theBinValues[i] > 1.E-10) {
17  stream << i * signal.getBinSize() + signal.getTimeOffset() << "\t" << signal.theBinValues[i] << std::endl;
18  }
19  }
20  return stream;
21 }

Member Data Documentation

◆ invBinSize

float CSCAnalogSignal::invBinSize
private

Definition at line 115 of file CSCAnalogSignal.h.

Referenced by getBinSize(), getValue(), peakTime(), and superimpose().

◆ theBinValues

std::vector<float> CSCAnalogSignal::theBinValues
private

◆ theElement

int CSCAnalogSignal::theElement
private

Definition at line 114 of file CSCAnalogSignal.h.

Referenced by getElement(), operator<<(), and setElement().

◆ theTimeOffset

float CSCAnalogSignal::theTimeOffset
private

Definition at line 118 of file CSCAnalogSignal.h.

Referenced by getTimeOffset(), getValue(), peakTime(), setTimeOffset(), and superimpose().

◆ theTotal

float CSCAnalogSignal::theTotal
private

Definition at line 117 of file CSCAnalogSignal.h.

Referenced by getTotal(), operator*=(), operator<<(), and superimpose().

CSCAnalogSignal::invBinSize
float invBinSize
Definition: CSCAnalogSignal.h:115
CSCAnalogSignal::theTotal
float theTotal
Definition: CSCAnalogSignal.h:117
mps_fire.i
i
Definition: mps_fire.py:355
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
CSCAnalogSignal::getBinValue
float getBinValue(int i) const
Definition: CSCAnalogSignal.h:48
cms::cuda::stream
cudaStream_t stream
Definition: HistoContainer.h:57
cms::cuda::assert
assert(be >=bs)
CSCAnalogSignal::theBinValues
std::vector< float > theBinValues
Definition: CSCAnalogSignal.h:116
CSCAnalogSignal::theTimeOffset
float theTimeOffset
Definition: CSCAnalogSignal.h:118
CSCAnalogSignal::theElement
int theElement
Definition: CSCAnalogSignal.h:114
OrderedSet.t
t
Definition: OrderedSet.py:90
CSCAnalogSignal::getValue
float getValue(float t) const
Definition: CSCAnalogSignal.h:52
CSCAnalogSignal::getTimeOffset
float getTimeOffset() const
Definition: CSCAnalogSignal.h:72
createfilelist.int
int
Definition: createfilelist.py:10
CSCAnalogSignal::getSize
int getSize() const
Definition: CSCAnalogSignal.h:69
CalibratedDigis_cfi.timeOffset
timeOffset
Definition: CalibratedDigis_cfi.py:22
multiplicitycorr_cfi.scaleFactor
scaleFactor
Definition: multiplicitycorr_cfi.py:7
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