CMS 3D CMS Logo

ESElectronicsSimFast Class Reference

#include <SimCalorimetry/EcalSimAlgos/interface/ESElectronicsSimFast.h>

List of all members.

Public Types

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

Public Member Functions

virtual void analogToDigital (const CaloSamples &cs, ESDataFrame &df, bool wasEmpty, CLHEP::RandGeneral *histoDistribution, double hInf, double hSup, double hBin) const
void digitalToAnalog (const ESDataFrame &df, CaloSamples &cs) const
 ESElectronicsSimFast (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< ESSamplefastEncode (const CaloSamples &timeframe, CLHEP::RandGeneral *histoDistribution, double hInf, double hSup, double hBin) const
std::vector< ESSamplestandEncode (const CaloSamples &timeframe) const

Private Attributes

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


Detailed Description

Definition at line 12 of file ESElectronicsSimFast.h.


Member Enumeration Documentation

anonymous enum

Enumerator:
MAXADC 

Definition at line 16 of file ESElectronicsSimFast.h.

00016 {MAXADC = 4095};

anonymous enum

Enumerator:
MINADC 

Definition at line 17 of file ESElectronicsSimFast.h.

00017 {MINADC = 0};


Constructor & Destructor Documentation

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

Definition at line 14 of file ESElectronicsSimFast.cc.

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


Member Function Documentation

void ESElectronicsSimFast::analogToDigital ( const CaloSamples cs,
ESDataFrame df,
bool  wasEmpty,
CLHEP::RandGeneral *  histoDistribution,
double  hInf,
double  hSup,
double  hBin 
) const [virtual]

Definition at line 56 of file ESElectronicsSimFast.cc.

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

Referenced by ESFastTDigitizer::run().

00057 {
00058   std::vector<ESSample> essamples;
00059   if (!wasEmpty) essamples = standEncode(cs);
00060   if ( wasEmpty) essamples = fastEncode(cs, histoDistribution, hInf, hSup, hBin);
00061   
00062   df.setSize(cs.size());
00063   for(int i=0; i<df.size(); i++) {
00064     df.setSample(i, essamples[i]);
00065   }
00066 }

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

Definition at line 167 of file ESElectronicsSimFast.cc.

Referenced by digitalToAnalog().

00168 {
00169   return 0. ;
00170 }

void ESElectronicsSimFast::digitalToAnalog ( const ESDataFrame df,
CaloSamples cs 
) const

Definition at line 68 of file ESElectronicsSimFast.cc.

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

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

std::vector< ESSample > ESElectronicsSimFast::fastEncode ( const CaloSamples timeframe,
CLHEP::RandGeneral *  histoDistribution,
double  hInf,
double  hSup,
double  hBin 
) const [private]

Definition at line 133 of file ESElectronicsSimFast.cc.

References ecalMGPA::adc(), int, MAXADC, MINADC, bookConverter::results, CaloSamples::size(), and width.

Referenced by analogToDigital().

00134 {
00135   std::vector<ESSample> results;
00136   results.reserve(timeframe.size());
00137 
00138   int bin[3]; 
00139   double hBin2 = hBin*hBin;
00140   double hBin3 = hBin*hBin*hBin;
00141   double width = (hSup - hInf)/hBin;  
00142 
00143   double thisRnd  = histoDistribution->fire();  
00144   int thisRndCell = (hBin3)*(thisRnd)/width;  
00145   bin[2] = (thisRndCell/hBin2);                              // sample2 - bin [0,N-1]
00146   bin[1] = ((thisRndCell - hBin2*bin[2])/hBin);              // sample1
00147   bin[0] = (thisRndCell - hBin*(bin[1] + hBin*bin[2]));      // sample0
00148 
00149   int adc[3];
00150   double noi[3];
00151   for(int ii=0; ii<3; ii++){
00152 
00153     noi[ii] = hInf + bin[ii]*width; 
00154     if (noi[ii]>0)      noi[ii] += 0.5;
00155     else if (noi[ii]<0) noi[ii] -= 0.5;
00156     
00157     adc[ii] = int(noi[ii]);      
00158     if (adc[ii]>MAXADC) adc[ii] = MAXADC;
00159     if (adc[ii]<MINADC) adc[ii] = MINADC;
00160     
00161     results.push_back(ESSample(adc[ii]));
00162   }
00163   
00164   return results;
00165 }

void ESElectronicsSimFast::newEvent (  )  [inline]

anything that needs to be done once per event

Definition at line 32 of file ESElectronicsSimFast.h.

Referenced by ESFastTDigitizer::run().

00032 {}

void ESElectronicsSimFast::setBaseline ( const int  baseline  ) 

Definition at line 38 of file ESElectronicsSimFast.cc.

References baseline_.

00039 {
00040   baseline_ = baseline ;
00041   return ;
00042 }

void ESElectronicsSimFast::setGain ( const int  gain  ) 

Definition at line 32 of file ESElectronicsSimFast.cc.

References gain_.

00033 {
00034   gain_ = gain ;
00035   return ;
00036 }

void ESElectronicsSimFast::setMIPADC ( const double  MIPADC  ) 

Definition at line 44 of file ESElectronicsSimFast.cc.

References MIPADC_.

00045 {
00046   MIPADC_ = MIPADC ;
00047   return ;
00048 }

void ESElectronicsSimFast::setMIPkeV ( const double  MIPkeV  ) 

Definition at line 50 of file ESElectronicsSimFast.cc.

References MIPkeV_.

00051 {
00052   MIPkeV_ = MIPkeV ;
00053   return ;
00054 }

void ESElectronicsSimFast::setNoiseSigma ( const double  sigma  ) 

Definition at line 26 of file ESElectronicsSimFast.cc.

References sigma_.

00027 {
00028   sigma_ = sigma ;
00029   return ;
00030 }

std::vector< ESSample > ESElectronicsSimFast::standEncode ( const CaloSamples timeframe  )  const [private]

Definition at line 76 of file ESElectronicsSimFast.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       << "ESElectroncSimFast 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   std::vector<ESSample> results;
00087   results.reserve(timeframe.size());
00088   
00089   int adc = 0; 
00090   double ADCkeV = MIPADC_/MIPkeV_;
00091   for (int i=0; i<timeframe.size(); i++) {
00092     
00093     double noi = 0;
00094     double signal = 0;    
00095     
00096     if (addNoise_) {
00097       CLHEP::RandGaussQ gaussQDistribution(rng->getEngine(), 0, sigma_);
00098       noi = gaussQDistribution.fire();
00099     }
00100     
00101     if (gain_ == 0) { 
00102       signal = timeframe[i]*1000000. + noi + baseline_;     
00103       
00104       if (signal>0) 
00105         signal += 0.5;
00106       else if (signal<0)
00107         signal -= 0.5;
00108       
00109       adc = int(signal);
00110     }
00111     else if (gain_ == 1 || gain_ == 2) {
00112       signal = timeframe[i]*1000000.*ADCkeV + noi + baseline_;
00113       
00114       if (signal>0) 
00115         signal += 0.5;
00116       else if (signal<0)
00117         signal -= 0.5;
00118       
00119       adc = int(signal);
00120     }
00121    
00122     if (adc>MAXADC) adc = MAXADC;
00123     if (adc<MINADC) adc = MINADC;
00124     
00125     results.push_back(ESSample(adc));
00126   }
00127   
00128   return results;
00129 }


Member Data Documentation

bool ESElectronicsSimFast::addNoise_ [private]

Definition at line 36 of file ESElectronicsSimFast.h.

Referenced by standEncode().

int ESElectronicsSimFast::baseline_ [private]

Definition at line 39 of file ESElectronicsSimFast.h.

Referenced by setBaseline(), and standEncode().

int ESElectronicsSimFast::gain_ [private]

Definition at line 38 of file ESElectronicsSimFast.h.

Referenced by setGain(), and standEncode().

double ESElectronicsSimFast::MIPADC_ [private]

Definition at line 40 of file ESElectronicsSimFast.h.

Referenced by setMIPADC(), and standEncode().

double ESElectronicsSimFast::MIPkeV_ [private]

Definition at line 41 of file ESElectronicsSimFast.h.

Referenced by setMIPkeV(), and standEncode().

double ESElectronicsSimFast::sigma_ [private]

Definition at line 37 of file ESElectronicsSimFast.h.

Referenced by setNoiseSigma(), and standEncode().


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