CMS 3D CMS Logo

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

anonymous enum
Enumerator
MAXADC 

Definition at line 18 of file ESElectronicsSim.h.

18 { MAXADC = 4095 };

◆ anonymous enum

anonymous enum
Enumerator
MINADC 

Definition at line 19 of file ESElectronicsSim.h.

19 { MINADC = 0 };

Constructor & Destructor Documentation

◆ ESElectronicsSim()

ESElectronicsSim::ESElectronicsSim ( bool  addNoise)

Definition at line 11 of file ESElectronicsSim.cc.

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

◆ ~ESElectronicsSim()

ESElectronicsSim::~ESElectronicsSim ( )
virtual

Definition at line 18 of file ESElectronicsSim.cc.

18 {}

Member Function Documentation

◆ analogToDigital()

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

Definition at line 20 of file ESElectronicsSim.cc.

20  {
21  std::vector<ESSample> essamples = encode(cs, engine);
22 
23  df.setSize(cs.size());
24  for (int i = 0; i < df.size(); i++) {
25  df.setSample(i, essamples[i]);
26  }
27 }

References fwrapper::cs, hgcalPerformanceValidation::df, encode(), and mps_fire::i.

◆ decode()

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

Definition at line 84 of file ESElectronicsSim.cc.

84 { return 0.; }

Referenced by digitalToAnalog().

◆ digitalToAnalog()

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

Definition at line 29 of file ESElectronicsSim.cc.

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

References fwrapper::cs, decode(), hgcalPerformanceValidation::df, and mps_fire::i.

◆ encode()

std::vector< ESSample > ESElectronicsSim::encode ( const CaloSamples timeframe,
CLHEP::HepRandomEngine *  engine 
) const
private

Definition at line 35 of file ESElectronicsSim.cc.

35  {
37  if (!rng.isAvailable()) {
38  throw cms::Exception("Configuration")
39  << "ESElectroncSim requires the RandomNumberGeneratorService\n"
40  "which is not present in the configuration file. You must add the service\n"
41  "in the configuration file or remove the modules that require it.";
42  }
43 
44  std::vector<ESSample> results;
45  results.reserve(timeframe.size());
46 
47  ESPedestals::const_iterator it_ped = peds_->find(timeframe.id());
49  int baseline_ = (int)it_ped->getMean();
50  double sigma_ = (double)it_ped->getRms();
51  double MIPADC_ = (double)(*it_mip);
52 
53  int adc = 0;
54  double ADCGeV = MIPADC_ / MIPToGeV_;
55 
56  for (int i = 0; i < timeframe.size(); i++) {
57  double noi = 0;
58  double signal = 0;
59 
60  if (addNoise_) {
61  noi = CLHEP::RandGaussQ::shoot(engine, 0., sigma_);
62  }
63 
64  signal = timeframe[i] * ADCGeV + noi + baseline_;
65 
66  if (signal > 0)
67  signal += 0.5;
68  else if (signal < 0)
69  signal -= 0.5;
70 
71  adc = int(signal);
72 
73  if (adc > MAXADC)
74  adc = MAXADC;
75  if (adc < MINADC)
76  adc = MINADC;
77 
78  results.emplace_back(adc);
79  }
80 
81  return results;
82 }

References ecalLiteDTU::adc(), addNoise_, Exception, ESCondObjectContainer< T >::find(), ESCondObjectContainer< T >::getMap(), mps_fire::i, CaloSamples::id(), createfilelist::int, edm::Service< T >::isAvailable(), MAXADC, MINADC, mips_, MIPToGeV_, peds_, bookConverter::results, and CaloSamples::size().

Referenced by analogToDigital().

◆ newEvent()

void ESElectronicsSim::newEvent ( CLHEP::HepRandomEngine *  )
inline

anything that needs to be done once per event

Definition at line 33 of file ESElectronicsSim.h.

33 {}

◆ setGain()

void ESElectronicsSim::setGain ( const int  gain)
inline

Definition at line 24 of file ESElectronicsSim.h.

24 { gain_ = gain; }

References PedestalClient_cfi::gain, and gain_.

◆ setMIPs()

void ESElectronicsSim::setMIPs ( const ESIntercalibConstants mips)
inline

Definition at line 26 of file ESElectronicsSim.h.

26 { mips_ = mips; }

References mips_.

◆ setMIPToGeV()

void ESElectronicsSim::setMIPToGeV ( const double  MIPToGeV)
inline

Definition at line 27 of file ESElectronicsSim.h.

27 { MIPToGeV_ = MIPToGeV; }

References MIPToGeV_.

◆ setPedestals()

void ESElectronicsSim::setPedestals ( const ESPedestals peds)
inline

Definition at line 25 of file ESElectronicsSim.h.

25 { peds_ = peds; }

References peds_.

Member Data Documentation

◆ addNoise_

bool ESElectronicsSim::addNoise_
private

Definition at line 36 of file ESElectronicsSim.h.

Referenced by encode().

◆ gain_

int ESElectronicsSim::gain_
private

Definition at line 37 of file ESElectronicsSim.h.

Referenced by setGain().

◆ mips_

const ESIntercalibConstants* ESElectronicsSim::mips_
private

Definition at line 39 of file ESElectronicsSim.h.

Referenced by encode(), and setMIPs().

◆ MIPToGeV_

double ESElectronicsSim::MIPToGeV_
private

Definition at line 40 of file ESElectronicsSim.h.

Referenced by encode(), and setMIPToGeV().

◆ peds_

const ESPedestals* ESElectronicsSim::peds_
private

Definition at line 38 of file ESElectronicsSim.h.

Referenced by encode(), and setPedestals().

mps_fire.i
i
Definition: mps_fire.py:428
ESElectronicsSim::MIPToGeV_
double MIPToGeV_
Definition: ESElectronicsSim.h:40
fwrapper::cs
unique_ptr< ClusterSequence > cs
Definition: fastjetfortran_madfks.cc:47
CaloSamples::size
int size() const
get the size
Definition: CaloSamples.h:24
ESElectronicsSim::encode
std::vector< ESSample > encode(const CaloSamples &timeframe, CLHEP::HepRandomEngine *) const
Definition: ESElectronicsSim.cc:35
ESCondObjectContainer::find
const_iterator find(uint32_t rawId) const
Definition: ESCondObjectContainer.h:33
bookConverter.results
results
Definition: bookConverter.py:144
ESElectronicsSim::peds_
const ESPedestals * peds_
Definition: ESElectronicsSim.h:38
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
ecalLiteDTU::adc
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
Definition: EcalLiteDTUSample.h:12
ESCondObjectContainer< ESPedestal >::const_iterator
std::vector< Item >::const_iterator const_iterator
Definition: ESCondObjectContainer.h:17
ESElectronicsSim::mips_
const ESIntercalibConstants * mips_
Definition: ESElectronicsSim.h:39
ESElectronicsSim::addNoise_
bool addNoise_
Definition: ESElectronicsSim.h:36
CaloSamples::id
DetId id() const
get the (generic) id
Definition: CaloSamples.h:21
edm::Service< edm::RandomNumberGenerator >
createfilelist.int
int
Definition: createfilelist.py:10
ESElectronicsSim::decode
double decode(const ESSample &sample, const DetId &detId) const
Definition: ESElectronicsSim.cc:84
PedestalClient_cfi.gain
gain
Definition: PedestalClient_cfi.py:37
ESCondObjectContainer::getMap
const self & getMap() const
Definition: ESCondObjectContainer.h:41
hgcalPerformanceValidation.df
df
Definition: hgcalPerformanceValidation.py:640
ESElectronicsSim::MAXADC
Definition: ESElectronicsSim.h:18
Exception
Definition: hltDiff.cc:246
ESElectronicsSim::MINADC
Definition: ESElectronicsSim.h:19
ESElectronicsSim::gain_
int gain_
Definition: ESElectronicsSim.h:37