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 }
void setMIPToGeV(double MIPToGeV)
const ESIntercalibConstants * m_mips
const_iterator end() const
unique_ptr< ClusterSequence > cs
const self & getMap() const
#define nullptr
void analogToDigital(CLHEP::HepRandomEngine *, ESSamples &cs, ESDataFrame &df, bool isNoise=false) const
void setPedestals(const ESPedestals *peds)
void setSize(int size)
Definition: ESDataFrame.cc:27
DetId id() const
const_iterator find(uint32_t rawId) const
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
void setSample(int i, const ESSample &sam)
Definition: ESDataFrame.h:30
Definition: DetId.h:18
ESElectronicsSimFast(bool addNoise, bool PreMix1)
const ESPedestals * m_peds
std::vector< Item >::const_iterator const_iterator
uint32_t size() const
void setMIPs(const ESIntercalibConstants *mips)