CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

SiTrivialDigitalConverter Class Reference

#include <SiTrivialDigitalConverter.h>

Inheritance diagram for SiTrivialDigitalConverter:
SiDigitalConverter

List of all members.

Public Member Functions

DigitalVecType convert (const std::vector< float > &, edm::ESHandle< SiStripGain > &, unsigned int detid)
DigitalRawVecType convertRaw (const std::vector< float > &, edm::ESHandle< SiStripGain > &, unsigned int detid)
 SiTrivialDigitalConverter (float in)

Private Member Functions

int convert (float in)
int convertRaw (float in)
int truncate (float in_adc) const
int truncateRaw (float in_adc) const

Private Attributes

SiDigitalConverter::DigitalVecType _temp
SiDigitalConverter::DigitalRawVecType _tempRaw
const float electronperADC

Detailed Description

Concrete implementation of SiDigitalConverter.

Definition at line 8 of file SiTrivialDigitalConverter.h.


Constructor & Destructor Documentation

SiTrivialDigitalConverter::SiTrivialDigitalConverter ( float  in)

Definition at line 5 of file SiTrivialDigitalConverter.cc.

References _temp, and _tempRaw.

                                                             :
  electronperADC(in) {
  _temp.reserve(800);
  _tempRaw.reserve(800);
}

Member Function Documentation

SiDigitalConverter::DigitalVecType SiTrivialDigitalConverter::convert ( const std::vector< float > &  analogSignal,
edm::ESHandle< SiStripGain > &  gainHandle,
unsigned int  detid 
) [virtual]

Implements SiDigitalConverter.

Definition at line 12 of file SiTrivialDigitalConverter.cc.

References _temp, ecalMGPA::adc(), i, and edm::ESHandleBase::isValid().

Referenced by DigiSimLinkAlgorithm::run().

                                                                                                                                 {
  
  _temp.clear();
  
  if(gainHandle.isValid()) {
    SiStripApvGain::Range detGainRange = gainHandle->getRange(detid);
    for ( size_t i=0; i<analogSignal.size(); i++) {
      if (analogSignal[i]<=0) continue;
      // convert analog amplitude to digital
      int adc = convert( (gainHandle->getStripGain(i, detGainRange))*(analogSignal[i]) );
      if ( adc > 0) _temp.push_back(SiStripDigi(i, adc));
    }
  } else {
    for ( size_t i=0; i<analogSignal.size(); i++) {
      if (analogSignal[i]<=0) continue;
      // convert analog amplitude to digital
      int adc = convert( analogSignal[i] );
      if ( adc > 0) _temp.push_back(SiStripDigi(i, adc));
    }
  }
  return _temp;
}
int SiTrivialDigitalConverter::convert ( float  in) [inline, private]

Definition at line 18 of file SiTrivialDigitalConverter.h.

References electronperADC, and truncate().

SiDigitalConverter::DigitalRawVecType SiTrivialDigitalConverter::convertRaw ( const std::vector< float > &  analogSignal,
edm::ESHandle< SiStripGain > &  gainHandle,
unsigned int  detid 
) [virtual]

Implements SiDigitalConverter.

Definition at line 36 of file SiTrivialDigitalConverter.cc.

References _tempRaw, ecalMGPA::adc(), i, and edm::ESHandleBase::isValid().

Referenced by DigiSimLinkAlgorithm::run().

                                                                                                                                    {
  
  _tempRaw.clear();

  if(gainHandle.isValid()) {
    SiStripApvGain::Range detGainRange = gainHandle->getRange(detid);
    for ( size_t i=0; i<analogSignal.size(); i++) {
      if (analogSignal[i]<=0) { _tempRaw.push_back(SiStripRawDigi(0)); continue; }
      // convert analog amplitude to digital
      int adc = convertRaw( (gainHandle->getStripGain(i, detGainRange))*(analogSignal[i]));
      _tempRaw.push_back(SiStripRawDigi(adc));
    }
  } else {
    for ( size_t i=0; i<analogSignal.size(); i++) {
      if (analogSignal[i]<=0) { _tempRaw.push_back(SiStripRawDigi(0)); continue; }
      // convert analog amplitude to digital
      int adc = convertRaw( analogSignal[i] );
      _tempRaw.push_back(SiStripRawDigi(adc));
    }
  }
  return _tempRaw;
}
int SiTrivialDigitalConverter::convertRaw ( float  in) [inline, private]

Definition at line 19 of file SiTrivialDigitalConverter.h.

References electronperADC, and truncateRaw().

int SiTrivialDigitalConverter::truncate ( float  in_adc) const [private]

Definition at line 138 of file EnergyLossPlain.cc.

References i, python::multivaluedict::sort(), findQualityFiles::v, makeHLTPrescaleTable::values, and histoStyle::weight.

Referenced by convert().

{
  std::vector<double> values;
  for(std::vector<pair<double,double> >::iterator 
      v = values_.begin(); v!= values_.end(); v++)
    values.push_back((*v).first);

  sort(values.begin(), values.end());

  int num = values.size();
  double sum[2] = {0.,0.};

  for(int i = 0; i < (num+1)/2; i++)
  {
    double weight = 1.;

    if(num%2 == 1 && i == (num-1)/2) weight = 1./2;

    sum[1] += weight * values[i];
    sum[0] += weight;
  }

  return sum[1] / sum[0];
}
int SiTrivialDigitalConverter::truncateRaw ( float  in_adc) const [private]

Definition at line 73 of file SiTrivialDigitalConverter.cc.

References ecalMGPA::adc().

Referenced by convertRaw().

                                                             {
  //Rounding the ADC number
  int adc = int(in_adc+0.5);
  if (adc > 1023 ) return 1023;
  //Protection
  if (adc < 0) return 0;
  return adc;
}

Member Data Documentation

Definition at line 24 of file SiTrivialDigitalConverter.h.

Referenced by convert(), and SiTrivialDigitalConverter().

Definition at line 25 of file SiTrivialDigitalConverter.h.

Referenced by convertRaw(), and SiTrivialDigitalConverter().

Definition at line 23 of file SiTrivialDigitalConverter.h.

Referenced by convert(), and convertRaw().