CMS 3D CMS Logo

CSCAnalogSignal Class Reference

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

#include <SimMuon/CSCDigitizer/src/CSCAnalogSignal.h>

List of all members.

Public Member Functions

 CSCAnalogSignal (int element, float binSize, std::vector< float > &binValues, float total=0., float timeOffset=0.)
 CSCAnalogSignal ()
float getBinSize () const
float getBinValue (int i) const
int getElement () const
 constructor from time and amp shape
int getSize () const
float getTimeOffset () const
float getTotal () const
float getValue (float t) const
void operator *= (float scaleFactor)
void operator+= (float offset)
const float & operator[] (int i) const
float & operator[] (int i)
float peakTime () const
 the time when the signal peaks
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 33 of file CSCAnalogSignal.h.


Constructor & Destructor Documentation

CSCAnalogSignal::CSCAnalogSignal (  )  [inline]

Definition at line 37 of file CSCAnalogSignal.h.

00037                            : theElement(0), invBinSize(0.), theBinValues(0), 
00038                                theTotal(0), theTimeOffset(0.) 
00039   {}

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

Definition at line 41 of file CSCAnalogSignal.h.

References theBinValues.

00041                                                                                                                          :
00042     theElement(element), invBinSize(1./binSize), 
00043     theBinValues(), theTotal(total), theTimeOffset(timeOffset) {
00044     theBinValues.swap(binValues);
00045   }


Member Function Documentation

float CSCAnalogSignal::getBinSize (  )  const [inline]

Definition at line 76 of file CSCAnalogSignal.h.

References invBinSize.

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

00076 {return 1./invBinSize;};

float CSCAnalogSignal::getBinValue ( int  i  )  const [inline]

Definition at line 53 of file CSCAnalogSignal.h.

References theBinValues.

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

00053                                          {
00054     return (i >= static_cast<int>(theBinValues.size()) || i < 0 ) ? 0. : theBinValues[i];
00055   }

int CSCAnalogSignal::getElement (  )  const [inline]

constructor from time and amp shape

Definition at line 51 of file CSCAnalogSignal.h.

References theElement.

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

00051 {return theElement;};

int CSCAnalogSignal::getSize (  )  const [inline]

Definition at line 75 of file CSCAnalogSignal.h.

References theBinValues.

Referenced by CSCWireElectronicsSim::fillDigis(), CSCCrosstalkGenerator::getCrosstalk(), operator *=(), operator+=(), operator[](), and CSCCrosstalkGenerator::ratio().

00075 {return theBinValues.size();};

float CSCAnalogSignal::getTimeOffset (  )  const [inline]

Definition at line 78 of file CSCAnalogSignal.h.

References theTimeOffset.

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

00078 {return theTimeOffset;};

float CSCAnalogSignal::getTotal (  )  const [inline]

Definition at line 77 of file CSCAnalogSignal.h.

References theTotal.

Referenced by SortSignalsByTotal().

00077 {return theTotal;};

float CSCAnalogSignal::getValue ( float  t  )  const [inline]

Definition at line 58 of file CSCAnalogSignal.h.

References f, getBinValue(), i, invBinSize, and theTimeOffset.

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

00058                                        {
00059   // interpolate between bins, if necessary
00060     float retval = 0.;
00061     float f = (t-theTimeOffset)*invBinSize + 0.000000001;
00062     if(f>=0.) {
00063       int i = static_cast<int>(f);
00064       f -= static_cast<float>(i);
00065       retval = (1.-f)*getBinValue(i) + f*getBinValue(i + 1);
00066     }
00067     return retval;
00068   }

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

Definition at line 96 of file CSCAnalogSignal.h.

References getSize(), i, theBinValues, and theTotal.

00096                                             {
00097     for(int i = 0; i < getSize(); ++i) {
00098       theBinValues[i] *= scaleFactor;
00099      }
00100     theTotal *= scaleFactor;
00101   }

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

Definition at line 90 of file CSCAnalogSignal.h.

References getSize(), i, and theBinValues.

00090                                        {
00091     for(int i = 0; i < getSize(); ++i) {
00092       theBinValues[i] += offset;
00093     }
00094   }

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

Definition at line 110 of file CSCAnalogSignal.h.

References getSize(), and theBinValues.

00110                                         {
00111     assert(i>=0 && i < getSize());
00112     return theBinValues[i];
00113   }

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

Definition at line 105 of file CSCAnalogSignal.h.

References getSize(), and theBinValues.

00105                             {
00106     assert(i>=0 && i < getSize());
00107     return theBinValues[i];
00108   }

float CSCAnalogSignal::peakTime (  )  const

the time when the signal peaks

Definition at line 6 of file CSCAnalogSignal.cc.

References invBinSize, theBinValues, and theTimeOffset.

00006                                       {
00007   size_t imax = std::max_element(theBinValues.begin(), theBinValues.end()) - theBinValues.begin();
00008   return imax/invBinSize + theTimeOffset;
00009 }

void CSCAnalogSignal::setElement ( int  element  )  [inline]

Definition at line 52 of file CSCAnalogSignal.h.

References theElement.

00052 {theElement = element;};

void CSCAnalogSignal::setTimeOffset ( float  offset  )  [inline]

Definition at line 79 of file CSCAnalogSignal.h.

References theTimeOffset.

00079 {theTimeOffset = offset;};

unsigned CSCAnalogSignal::size ( void   )  const [inline]

Definition at line 117 of file CSCAnalogSignal.h.

References theBinValues.

00117 {return theBinValues.size();}

void CSCAnalogSignal::superimpose ( const CSCAnalogSignal signal2  )  [inline]

Definition at line 81 of file CSCAnalogSignal.h.

References getValue(), i, invBinSize, n, t, theBinValues, theTimeOffset, and theTotal.

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

00081                                                            {
00082     size_t n = theBinValues.size();
00083     for(size_t i = 0; i < n; ++i) {
00084        float t = i/invBinSize + theTimeOffset;
00085        theBinValues[i]+=signal2.getValue(t);
00086     }
00087     theTotal += signal2.theTotal; 
00088   }


Friends And Related Function Documentation

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

Definition at line 12 of file CSCAnalogSignal.cc.

00012                                                                              {
00013   stream << "CSCAnalogSignal: Element " << signal.theElement
00014          << "   Total " << signal.theTotal << std::endl;
00015   for ( int i = 0; i < int( signal.theBinValues.size() ); ++i ) { 
00016 
00017     //@@ ptc 26-Feb-02 Don't both with very small amplitudes
00018 
00019     if ( signal.theBinValues[i] > 1.E-10 ) {
00020        stream << i*signal.getBinSize()+signal.getTimeOffset() << 
00021        "\t" << signal.theBinValues[i] << std::endl;
00022     }
00023   }
00024   return stream;
00025 }


Member Data Documentation

float CSCAnalogSignal::invBinSize [private]

Definition at line 121 of file CSCAnalogSignal.h.

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

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

Definition at line 122 of file CSCAnalogSignal.h.

Referenced by CSCAnalogSignal(), getBinValue(), getSize(), operator *=(), operator+=(), operator<<(), operator[](), peakTime(), size(), and superimpose().

int CSCAnalogSignal::theElement [private]

Definition at line 120 of file CSCAnalogSignal.h.

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

float CSCAnalogSignal::theTimeOffset [private]

Definition at line 124 of file CSCAnalogSignal.h.

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

float CSCAnalogSignal::theTotal [private]

Definition at line 123 of file CSCAnalogSignal.h.

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


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:17:03 2009 for CMSSW by  doxygen 1.5.4