CMS 3D CMS Logo

ESElectronicsSim Class Reference

#include <SimCalorimetry/EcalSimAlgos/interface/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, double sigma, int gain, int baseline, double MIPADC, double MIPkeV)
void newEvent ()
 anything that needs to be done once per event
void setBaseline (const int baseline)
void setGain (const int gain)
void setMIPADC (const double MIPADC)
void setMIPkeV (const double MIPkeV)
void setNoiseSigma (const double sigma)

Private Member Functions

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

Private Attributes

bool addNoise_
int baseline_
int gain_
double MIPADC_
double MIPkeV_
double sigma_


Detailed Description

Definition at line 10 of file ESElectronicsSim.h.


Member Enumeration Documentation

anonymous enum

Enumerator:
MAXADC 

Definition at line 14 of file ESElectronicsSim.h.

00014 {MAXADC = 4095};

anonymous enum

Enumerator:
MINADC 

Definition at line 15 of file ESElectronicsSim.h.

00015 {MINADC = 0};


Constructor & Destructor Documentation

ESElectronicsSim::ESElectronicsSim ( bool  addNoise,
double  sigma,
int  gain,
int  baseline,
double  MIPADC,
double  MIPkeV 
)

Definition at line 12 of file ESElectronicsSim.cc.

00012                                                                                                                     :
00013   addNoise_(addNoise), sigma_ (sigma), gain_ (gain), baseline_(baseline), MIPADC_(MIPADC), MIPkeV_(MIPkeV)
00014 {
00015   // Preshower Electronics Simulation
00016   // The default pedestal baseline is 1000
00017   // gain = 0 : old gain used in ORCA (1 ADC count = 1 keV in CMSSW)
00018   //            In ORCA, preshower noise was 15 keV
00019   // gain = 1 : low gain for data taking  (S =  9 ADC counts, N = 3 ADC counts)
00020   // gain = 2 : high gain for calibration (S = 50 ADC counts, N = 7 ADC counts)
00021   // For 300(310/320) um Si, the MIP is 78.47(81.08/83.7) keV
00022 }


Member Function Documentation

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

Definition at line 54 of file ESElectronicsSim.cc.

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

00055 {
00056 
00057   std::vector<ESSample> essamples = encode(cs);
00058 
00059   df.setSize(cs.size());
00060   for(int i=0; i<df.size(); i++) {
00061     df.setSample(i, essamples[i]);
00062   }
00063 
00064 }

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

Definition at line 133 of file ESElectronicsSim.cc.

Referenced by digitalToAnalog().

00134 {
00135   return 0. ;
00136 }

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

Definition at line 66 of file ESElectronicsSim.cc.

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

00067 {
00068 
00069   for(int i = 0; i < df.size(); i++) {
00070     cs[i] = decode(df[i], df.id());
00071   }
00072 
00073 }

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

Definition at line 76 of file ESElectronicsSim.cc.

References ecalMGPA::adc(), addNoise_, baseline_, Exception, gain_, i, int, edm::Service< T >::isAvailable(), MAXADC, MINADC, MIPADC_, MIPkeV_, bookConverter::results, sigma_, signal, and CaloSamples::size().

Referenced by analogToDigital().

00077 {
00078   edm::Service<edm::RandomNumberGenerator> rng;
00079   if ( ! rng.isAvailable()) {
00080     throw cms::Exception("Configuration")
00081       << "ESElectroncSim requires the RandomNumberGeneratorService\n"
00082       "which is not present in the configuration file.  You must add the service\n"
00083       "in the configuration file or remove the modules that require it.";
00084   }
00085 
00086 
00087   std::vector<ESSample> results;
00088   results.reserve(timeframe.size());
00089 
00090   int adc = 0; 
00091   double ADCkeV = MIPADC_/MIPkeV_;
00092 
00093   for (int i=0; i<timeframe.size(); i++) {
00094 
00095     double noi = 0;
00096     double signal = 0;    
00097 
00098     if (addNoise_) {
00099       CLHEP::RandGaussQ gaussQDistribution(rng->getEngine(), 0., sigma_);
00100       noi = gaussQDistribution.fire();
00101     }
00102 
00103     if (gain_ == 0) { 
00104       signal = timeframe[i]*1000000. + noi + baseline_;     
00105 
00106       if (signal>0) 
00107         signal += 0.5;
00108       else if (signal<0)
00109         signal -= 0.5;
00110 
00111       adc = int(signal);
00112     }
00113     else if (gain_ == 1 || gain_ == 2) {
00114       signal = timeframe[i]*1000000.*ADCkeV + noi + baseline_;
00115 
00116       if (signal>0) 
00117         signal += 0.5;
00118       else if (signal<0)
00119         signal -= 0.5;
00120 
00121       adc = int(signal);
00122     }
00123 
00124     if (adc>MAXADC) adc = MAXADC;
00125     if (adc<MINADC) adc = MINADC;
00126 
00127     results.push_back(ESSample(adc));
00128   }
00129 
00130   return results;
00131 }

void ESElectronicsSim::newEvent (  )  [inline]

anything that needs to be done once per event

Definition at line 29 of file ESElectronicsSim.h.

00029 {}

void ESElectronicsSim::setBaseline ( const int  baseline  ) 

Definition at line 36 of file ESElectronicsSim.cc.

References baseline_.

00037 {
00038   baseline_ = baseline ;
00039   return ;
00040 }

void ESElectronicsSim::setGain ( const int  gain  ) 

Definition at line 30 of file ESElectronicsSim.cc.

References gain_.

00031 {
00032   gain_ = gain ;
00033   return ;
00034 }

void ESElectronicsSim::setMIPADC ( const double  MIPADC  ) 

Definition at line 42 of file ESElectronicsSim.cc.

References MIPADC_.

00043 {
00044   MIPADC_ = MIPADC ;
00045   return ;
00046 }

void ESElectronicsSim::setMIPkeV ( const double  MIPkeV  ) 

Definition at line 48 of file ESElectronicsSim.cc.

References MIPkeV_.

00049 {
00050   MIPkeV_ = MIPkeV ;
00051   return ;
00052 }

void ESElectronicsSim::setNoiseSigma ( const double  sigma  ) 

Definition at line 24 of file ESElectronicsSim.cc.

References sigma_.

00025 {
00026   sigma_ = sigma ;
00027   return ;
00028 }


Member Data Documentation

bool ESElectronicsSim::addNoise_ [private]

Definition at line 33 of file ESElectronicsSim.h.

Referenced by encode().

int ESElectronicsSim::baseline_ [private]

Definition at line 36 of file ESElectronicsSim.h.

Referenced by encode(), and setBaseline().

int ESElectronicsSim::gain_ [private]

Definition at line 35 of file ESElectronicsSim.h.

Referenced by encode(), and setGain().

double ESElectronicsSim::MIPADC_ [private]

Definition at line 37 of file ESElectronicsSim.h.

Referenced by encode(), and setMIPADC().

double ESElectronicsSim::MIPkeV_ [private]

Definition at line 38 of file ESElectronicsSim.h.

Referenced by encode(), and setMIPkeV().

double ESElectronicsSim::sigma_ [private]

Definition at line 34 of file ESElectronicsSim.h.

Referenced by encode(), and setNoiseSigma().


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