CMS 3D CMS Logo

Public Types | Public Member Functions | Private Member Functions | Private Attributes

ESElectronicsSim Class Reference

#include <ESElectronicsSim.h>

List of all members.

Public Types

enum  { MAXADC = 4095 }
enum  { MINADC = 0 }

Public Member Functions

virtual void analogToDigital (const CaloSamples &cs, ESDataFrame &df) const
virtual void digitalToAnalog (const ESDataFrame &df, CaloSamples &cs) const
 ESElectronicsSim (bool addNoise)
void newEvent ()
 anything that needs to be done once per event
void setGain (const int gain)
void setMIPs (const ESIntercalibConstants *mips)
void setMIPToGeV (const double MIPToGeV)
void setPedestals (const ESPedestals *peds)

Private Member Functions

double decode (const ESSample &sample, const DetId &detId) const
std::vector< ESSampleencode (const CaloSamples &timeframe) const

Private Attributes

bool addNoise_
int gain_
const ESIntercalibConstantsmips_
double MIPToGeV_
const ESPedestalspeds_

Detailed Description

Definition at line 12 of file ESElectronicsSim.h.


Member Enumeration Documentation

anonymous enum
Enumerator:
MAXADC 

Definition at line 16 of file ESElectronicsSim.h.

{MAXADC = 4095};
anonymous enum
Enumerator:
MINADC 

Definition at line 17 of file ESElectronicsSim.h.

{MINADC = 0};

Constructor & Destructor Documentation

ESElectronicsSim::ESElectronicsSim ( bool  addNoise)

Definition at line 11 of file ESElectronicsSim.cc.

                                                :
  addNoise_(addNoise), peds_(0), mips_(0)
{
  // Preshower Electronics Simulation
  // gain = 1 : low gain for data taking 
  // gain = 2 : high gain for calibration and low energy runs
  // For 300(310/320) um Si, the MIP is 78.47(81.08/83.7) keV
}

Member Function Documentation

void ESElectronicsSim::analogToDigital ( const CaloSamples cs,
ESDataFrame df 
) const [virtual]

Definition at line 20 of file ESElectronicsSim.cc.

References encode(), i, ESDataFrame::setSample(), ESDataFrame::setSize(), ESDataFrame::size(), and CaloSamples::size().

{

  std::vector<ESSample> essamples = encode(cs);

  df.setSize(cs.size());
  for(int i=0; i<df.size(); i++) {
    df.setSample(i, essamples[i]);
  }

}
double ESElectronicsSim::decode ( const ESSample sample,
const DetId detId 
) const [private]

Definition at line 93 of file ESElectronicsSim.cc.

Referenced by digitalToAnalog().

{
  return 0. ;
}
void ESElectronicsSim::digitalToAnalog ( const ESDataFrame df,
CaloSamples cs 
) const [virtual]

Definition at line 32 of file ESElectronicsSim.cc.

References decode(), i, ESDataFrame::id(), and ESDataFrame::size().

{

  for(int i = 0; i < df.size(); i++) {
    cs[i] = decode(df[i], df.id());
  }

}
std::vector< ESSample > ESElectronicsSim::encode ( const CaloSamples timeframe) const [private]

Definition at line 42 of file ESElectronicsSim.cc.

References ecalMGPA::adc(), addNoise_, Exception, ESCondObjectContainer< T >::find(), ESCondObjectContainer< T >::getMap(), i, CaloSamples::id(), edm::Service< T >::isAvailable(), MAXADC, MINADC, mips_, MIPToGeV_, peds_, python::entryComment::results, and CaloSamples::size().

Referenced by analogToDigital().

{
  edm::Service<edm::RandomNumberGenerator> rng;
  if ( ! rng.isAvailable()) {
    throw cms::Exception("Configuration")
      << "ESElectroncSim requires the RandomNumberGeneratorService\n"
      "which is not present in the configuration file.  You must add the service\n"
      "in the configuration file or remove the modules that require it.";
  }


  std::vector<ESSample> results;
  results.reserve(timeframe.size());

  ESPedestals::const_iterator it_ped = peds_->find(timeframe.id());
  ESIntercalibConstantMap::const_iterator it_mip = mips_->getMap().find(timeframe.id());
  int baseline_  = (int) it_ped->getMean();
  double sigma_  = (double) it_ped->getRms();
  double MIPADC_ = (double) (*it_mip);

  int adc = 0; 
  double ADCGeV = MIPADC_/MIPToGeV_;

  for (int i=0; i<timeframe.size(); i++) {

    double noi = 0;
    double signal = 0;    

    if (addNoise_) {
      CLHEP::RandGaussQ gaussQDistribution(rng->getEngine(), 0., sigma_);
      noi = gaussQDistribution.fire();
    }

    signal = timeframe[i]*ADCGeV + noi + baseline_;
    
    if (signal>0) 
      signal += 0.5;
    else if (signal<0)
      signal -= 0.5;
    
    adc = int(signal);

    if (adc>MAXADC) adc = MAXADC;
    if (adc<MINADC) adc = MINADC;

    results.push_back(ESSample(adc));
  }

  return results;
}
void ESElectronicsSim::newEvent ( ) [inline]

anything that needs to be done once per event

Definition at line 30 of file ESElectronicsSim.h.

{}
void ESElectronicsSim::setGain ( const int  gain) [inline]

Definition at line 21 of file ESElectronicsSim.h.

References gain_.

Referenced by EcalDigiProducer::checkCalibrations().

{ gain_ = gain; }
void ESElectronicsSim::setMIPs ( const ESIntercalibConstants mips) [inline]

Definition at line 23 of file ESElectronicsSim.h.

References mips_.

Referenced by EcalDigiProducer::checkCalibrations().

{ mips_ = mips; }
void ESElectronicsSim::setMIPToGeV ( const double  MIPToGeV) [inline]

Definition at line 24 of file ESElectronicsSim.h.

References MIPToGeV_.

Referenced by EcalDigiProducer::checkCalibrations().

{ MIPToGeV_ = MIPToGeV; }
void ESElectronicsSim::setPedestals ( const ESPedestals peds) [inline]

Definition at line 22 of file ESElectronicsSim.h.

References peds_.

Referenced by EcalDigiProducer::checkCalibrations().

{ peds_ = peds; }

Member Data Documentation

Definition at line 34 of file ESElectronicsSim.h.

Referenced by encode().

int ESElectronicsSim::gain_ [private]

Definition at line 35 of file ESElectronicsSim.h.

Referenced by setGain().

Definition at line 37 of file ESElectronicsSim.h.

Referenced by encode(), and setMIPs().

double ESElectronicsSim::MIPToGeV_ [private]

Definition at line 38 of file ESElectronicsSim.h.

Referenced by encode(), and setMIPToGeV().

Definition at line 36 of file ESElectronicsSim.h.

Referenced by encode(), and setPedestals().