CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
ESElectronicsSim Class Reference

#include <ESElectronicsSim.h>

Public Types

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

Public Member Functions

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

Private Member Functions

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

Private Attributes

bool addNoise_
 
int gain_
 
const ESIntercalibConstantsmips_
 
double MIPToGeV_
 
const ESPedestalspeds_
 

Detailed Description

Definition at line 16 of file ESElectronicsSim.h.

Member Enumeration Documentation

anonymous enum
Enumerator
MAXADC 

Definition at line 20 of file ESElectronicsSim.h.

anonymous enum
Enumerator
MINADC 

Definition at line 21 of file ESElectronicsSim.h.

Constructor & Destructor Documentation

ESElectronicsSim::ESElectronicsSim ( bool  addNoise)

Definition at line 11 of file ESElectronicsSim.cc.

11  :
12  addNoise_(addNoise), peds_(0), mips_(0)
13 {
14  // Preshower Electronics Simulation
15  // gain = 1 : low gain for data taking
16  // gain = 2 : high gain for calibration and low energy runs
17  // For 300(310/320) um Si, the MIP is 78.47(81.08/83.7) keV
18 }
const ESIntercalibConstants * mips_
const ESPedestals * peds_
ESElectronicsSim::~ESElectronicsSim ( )
virtual

Definition at line 20 of file ESElectronicsSim.cc.

21 {}

Member Function Documentation

void ESElectronicsSim::analogToDigital ( CLHEP::HepRandomEngine *  engine,
const CaloSamples cs,
ESDataFrame df 
) const
virtual

Definition at line 23 of file ESElectronicsSim.cc.

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

24 {
25 
26  std::vector<ESSample> essamples = encode(cs, engine);
27 
28  df.setSize(cs.size());
29  for(int i=0; i<df.size(); i++) {
30  df.setSample(i, essamples[i]);
31  }
32 
33 }
int i
Definition: DBlmapReader.cc:9
int size() const
Definition: ESDataFrame.h:23
std::vector< ESSample > encode(const CaloSamples &timeframe, CLHEP::HepRandomEngine *) const
void setSize(int size)
Definition: ESDataFrame.cc:27
void setSample(int i, const ESSample &sam)
Definition: ESDataFrame.h:30
int size() const
get the size
Definition: CaloSamples.h:24
double ESElectronicsSim::decode ( const ESSample sample,
const DetId detId 
) const
private

Definition at line 95 of file ESElectronicsSim.cc.

Referenced by digitalToAnalog().

96 {
97  return 0. ;
98 }
void ESElectronicsSim::digitalToAnalog ( const ESDataFrame df,
CaloSamples cs 
) const
virtual

Definition at line 35 of file ESElectronicsSim.cc.

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

36 {
37 
38  for(int i = 0; i < df.size(); i++) {
39  cs[i] = decode(df[i], df.id());
40  }
41 
42 }
int i
Definition: DBlmapReader.cc:9
const ESDetId & id() const
Definition: ESDataFrame.h:21
int size() const
Definition: ESDataFrame.h:23
double decode(const ESSample &sample, const DetId &detId) const
std::vector< ESSample > ESElectronicsSim::encode ( const CaloSamples timeframe,
CLHEP::HepRandomEngine *  engine 
) const
private

Definition at line 45 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().

46 {
48  if ( ! rng.isAvailable()) {
49  throw cms::Exception("Configuration")
50  << "ESElectroncSim requires the RandomNumberGeneratorService\n"
51  "which is not present in the configuration file. You must add the service\n"
52  "in the configuration file or remove the modules that require it.";
53  }
54 
55 
56  std::vector<ESSample> results;
57  results.reserve(timeframe.size());
58 
59  ESPedestals::const_iterator it_ped = peds_->find(timeframe.id());
61  int baseline_ = (int) it_ped->getMean();
62  double sigma_ = (double) it_ped->getRms();
63  double MIPADC_ = (double) (*it_mip);
64 
65  int adc = 0;
66  double ADCGeV = MIPADC_/MIPToGeV_;
67 
68  for (int i=0; i<timeframe.size(); i++) {
69 
70  double noi = 0;
71  double signal = 0;
72 
73  if (addNoise_) {
74  noi = CLHEP::RandGaussQ::shoot(engine, 0., sigma_);
75  }
76 
77  signal = timeframe[i]*ADCGeV + noi + baseline_;
78 
79  if (signal>0)
80  signal += 0.5;
81  else if (signal<0)
82  signal -= 0.5;
83 
84  adc = int(signal);
85 
86  if (adc>MAXADC) adc = MAXADC;
87  if (adc<MINADC) adc = MINADC;
88 
89  results.emplace_back(adc);
90  }
91 
92  return results;
93 }
int adc(sample_type sample)
get the ADC sample (12 bits)
int i
Definition: DBlmapReader.cc:9
const ESIntercalibConstants * mips_
const self & getMap() const
const_iterator find(uint32_t rawId) const
bool isAvailable() const
Definition: Service.h:46
int size() const
get the size
Definition: CaloSamples.h:24
std::vector< Item >::const_iterator const_iterator
DetId id() const
get the (generic) id
Definition: CaloSamples.h:21
const ESPedestals * peds_
void ESElectronicsSim::newEvent ( CLHEP::HepRandomEngine *  )
inline

anything that needs to be done once per event

Definition at line 35 of file ESElectronicsSim.h.

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

Definition at line 26 of file ESElectronicsSim.h.

References gain_.

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

Definition at line 28 of file ESElectronicsSim.h.

References mips_.

28 { mips_ = mips; }
const ESIntercalibConstants * mips_
void ESElectronicsSim::setMIPToGeV ( const double  MIPToGeV)
inline

Definition at line 29 of file ESElectronicsSim.h.

References MIPToGeV_.

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

Definition at line 27 of file ESElectronicsSim.h.

References peds_.

27 { peds_ = peds; }
const ESPedestals * peds_

Member Data Documentation

bool ESElectronicsSim::addNoise_
private

Definition at line 39 of file ESElectronicsSim.h.

Referenced by encode().

int ESElectronicsSim::gain_
private

Definition at line 40 of file ESElectronicsSim.h.

Referenced by setGain().

const ESIntercalibConstants* ESElectronicsSim::mips_
private

Definition at line 42 of file ESElectronicsSim.h.

Referenced by encode(), and setMIPs().

double ESElectronicsSim::MIPToGeV_
private

Definition at line 43 of file ESElectronicsSim.h.

Referenced by encode(), and setMIPToGeV().

const ESPedestals* ESElectronicsSim::peds_
private

Definition at line 41 of file ESElectronicsSim.h.

Referenced by encode(), and setPedestals().