CMS 3D CMS Logo

ESElectronicsSimFast.cc
Go to the documentation of this file.
3 
4 #include "CLHEP/Random/RandGaussQ.h"
5 
6 #include <iostream>
7 
8 ESElectronicsSimFast::ESElectronicsSimFast(bool addNoise, bool PreMix1)
9  : m_addNoise(addNoise), m_PreMix1(PreMix1), m_MIPToGeV(0), m_peds(nullptr), m_mips(nullptr) {
10  // Preshower "Fast" Electronics Simulation
11  // gain = 1 : low gain for data taking
12  // gain = 2 : high gain for calibration and low energy runs
13  // For 300(310/320) um Si, the MIP is 78.47(81.08/83.7) keV
14 }
15 
17 
19 
21 
22 void ESElectronicsSimFast::setMIPToGeV(double MIPToGeV) { m_MIPToGeV = MIPToGeV; }
23 
24 void ESElectronicsSimFast::analogToDigital(CLHEP::HepRandomEngine* engine,
25  ESSamples& cs,
26  ESDataFrame& df,
27  bool isNoise) const {
28  assert(nullptr != m_peds && nullptr != m_mips && 0 < m_MIPToGeV); // sanity check
29 
30  df.setSize(cs.size());
31 
32  const DetId id(cs.id());
35 
36  const double baseline((double)it_ped->getMean());
37  const double sigma(isNoise ? 0. : (double)it_ped->getRms());
38  const double MIPADC(isNoise ? 0. : (double)(*it_mip));
39  const double ADCGeV(isNoise ? 1. : MIPADC / m_MIPToGeV);
40 
41  int adc = 0;
42  // std::cout<<" **Id="<<ESDetId(df.id())<<", size="<<df.size();
43  for (unsigned int i(0); i != cs.size(); ++i) {
44  const double noi(isNoise || (!m_addNoise) ? 0 : sigma * CLHEP::RandGaussQ::shoot(engine, 0, 1));
45  double signal;
46 
47  if (!m_PreMix1)
48  signal = cs[i] * ADCGeV + noi + baseline;
49  else
50  signal = cs[i] * ADCGeV;
51 
52  if (0 <= signal) {
53  signal += 0.5;
54  } else {
55  signal -= 0.5;
56  }
57 
58  adc = int(signal);
59 
60  if (!m_PreMix1)
61  assert(0 < adc);
62 
63  if (0.5 < signal - adc)
64  ++adc;
65 
66  if (MAXADC < adc) {
67  adc = MAXADC;
68  } else {
69  if (MINADC > adc)
70  adc = MINADC;
71  }
72 
73  df.setSample(i, ESSample(adc));
74  // std::cout<<", "<<df[i];
75  }
76  // std::cout<<std::endl ;
77 }
ESCondObjectContainer::end
const_iterator end() const
Definition: ESCondObjectContainer.h:37
mps_fire.i
i
Definition: mps_fire.py:428
ESElectronicsSimFast::m_peds
const ESPedestals * m_peds
Definition: ESElectronicsSimFast.h:42
fwrapper::cs
unique_ptr< ClusterSequence > cs
Definition: fastjetfortran_madfks.cc:47
ESElectronicsSimFast::setMIPs
void setMIPs(const ESIntercalibConstants *mips)
Definition: ESElectronicsSimFast.cc:20
ESCondObjectContainer::find
const_iterator find(uint32_t rawId) const
Definition: ESCondObjectContainer.h:33
cms::cuda::assert
assert(be >=bs)
ESElectronicsSimFast::m_mips
const ESIntercalibConstants * m_mips
Definition: ESElectronicsSimFast.h:44
ESDataFrame
Definition: ESDataFrame.h:10
ecalLiteDTU::adc
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
Definition: EcalLiteDTUSample.h:12
DetId
Definition: DetId.h:17
CaloTSamples
Definition: CaloTSamples.h:14
ESElectronicsSimFast::setPedestals
void setPedestals(const ESPedestals *peds)
Definition: ESElectronicsSimFast.cc:18
ESCondObjectContainer< ESPedestal >::const_iterator
std::vector< Item >::const_iterator const_iterator
Definition: ESCondObjectContainer.h:17
ESSample
Definition: ESSample.h:7
createfilelist.int
int
Definition: createfilelist.py:10
ESElectronicsSimFast::MINADC
Definition: ESElectronicsSimFast.h:20
ESCondObjectContainer< ESPedestal >
ESElectronicsSimFast::m_PreMix1
bool m_PreMix1
Definition: ESElectronicsSimFast.h:38
ESCondObjectContainer::getMap
const self & getMap() const
Definition: ESCondObjectContainer.h:41
ESElectronicsSimFast::~ESElectronicsSimFast
~ESElectronicsSimFast()
Definition: ESElectronicsSimFast.cc:16
hgcalPerformanceValidation.df
df
Definition: hgcalPerformanceValidation.py:640
DetId.h
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
ESElectronicsSimFast::analogToDigital
void analogToDigital(CLHEP::HepRandomEngine *, ESSamples &cs, ESDataFrame &df, bool isNoise=false) const
Definition: ESElectronicsSimFast.cc:24
ESElectronicsSimFast::ESElectronicsSimFast
ESElectronicsSimFast(bool addNoise, bool PreMix1)
Definition: ESElectronicsSimFast.cc:8
ESElectronicsSimFast::MAXADC
Definition: ESElectronicsSimFast.h:20
ESElectronicsSimFast.h
ESElectronicsSimFast::setMIPToGeV
void setMIPToGeV(double MIPToGeV)
Definition: ESElectronicsSimFast.cc:22
ESElectronicsSimFast::m_addNoise
bool m_addNoise
Definition: ESElectronicsSimFast.h:36
ESElectronicsSimFast::m_MIPToGeV
double m_MIPToGeV
Definition: ESElectronicsSimFast.h:40