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 Attributes
ESElectronicsSimFast Class Reference

#include <ESElectronicsSimFast.h>

Public Types

enum  { MAXADC = 4095, MINADC = 0 }
 
typedef CaloTSamples< float, 3 > ESSamples
 

Public Member Functions

void analogToDigital (ESSamples &cs, ESDataFrame &df, bool isNoise=false) const
 
 ESElectronicsSimFast (bool addNoise)
 
void newEvent ()
 
void setMIPs (const ESIntercalibConstants *mips)
 
void setMIPToGeV (double MIPToGeV)
 
void setPedestals (const ESPedestals *peds)
 
 ~ESElectronicsSimFast ()
 

Private Attributes

bool m_addNoise
 
const ESIntercalibConstantsm_mips
 
double m_MIPToGeV
 
const ESPedestalsm_peds
 
CLHEP::RandGaussQ * m_ranGau
 

Detailed Description

Definition at line 15 of file ESElectronicsSimFast.h.

Member Typedef Documentation

Definition at line 19 of file ESElectronicsSimFast.h.

Member Enumeration Documentation

anonymous enum
Enumerator
MAXADC 
MINADC 

Definition at line 21 of file ESElectronicsSimFast.h.

Constructor & Destructor Documentation

ESElectronicsSimFast::ESElectronicsSimFast ( bool  addNoise)

Definition at line 11 of file ESElectronicsSimFast.cc.

References edm::hlt::Exception, edm::RandomNumberGenerator::getEngine(), edm::Service< T >::isAvailable(), m_addNoise, and m_ranGau.

11  :
12  m_addNoise ( addNoise ) ,
13  m_MIPToGeV ( 0 ) ,
14  m_peds ( 0 ) ,
15  m_mips ( 0 ) ,
16  m_ranGau ( 0 )
17 {
18  // Preshower "Fast" Electronics Simulation
19  // gain = 1 : low gain for data taking
20  // gain = 2 : high gain for calibration and low energy runs
21  // For 300(310/320) um Si, the MIP is 78.47(81.08/83.7) keV
22 
23  if( m_addNoise )
24  {
26  if( !rng.isAvailable() )
27  {
28  throw cms::Exception("Configuration")
29  << "ESElectroncSimFast requires the RandomNumberGeneratorService\n"
30  "which is not present in the configuration file. You must add the service\n"
31  "in the configuration file or remove the modules that require it.";
32  }
33  m_ranGau = new CLHEP::RandGaussQ( rng->getEngine(), 0, 1 ) ;
34  }
35 }
const ESIntercalibConstants * m_mips
CLHEP::RandGaussQ * m_ranGau
bool isAvailable() const
Definition: Service.h:46
virtual CLHEP::HepRandomEngine & getEngine() const =0
Use this to get the random number engine, this is the only function most users should call...
const ESPedestals * m_peds
ESElectronicsSimFast::~ESElectronicsSimFast ( )

Definition at line 37 of file ESElectronicsSimFast.cc.

References m_ranGau.

38 {
39  delete m_ranGau ;
40 }
CLHEP::RandGaussQ * m_ranGau

Member Function Documentation

void ESElectronicsSimFast::analogToDigital ( ESSamples cs,
ESDataFrame df,
bool  isNoise = false 
) const

Definition at line 61 of file ESElectronicsSimFast.cc.

References ecalMGPA::adc(), ESCondObjectContainer< T >::end(), ESCondObjectContainer< T >::find(), ESCondObjectContainer< T >::getMap(), i, CaloTSamplesBase< Ttype >::id(), m_addNoise, m_mips, m_MIPToGeV, m_peds, m_ranGau, MAXADC, MINADC, ESDataFrame::setSample(), ESDataFrame::setSize(), and CaloTSamplesBase< Ttype >::size().

64 {
65  assert( 0 != m_peds &&
66  0 != m_mips &&
67  0 < m_MIPToGeV ) ; // sanity check
68 
69  assert( ( !m_addNoise ) ||
70  0 != m_ranGau ) ; // sanity check
71 
72  df.setSize( cs.size() ) ;
73 
74  const DetId id ( cs.id() ) ;
75  ESPedestals::const_iterator it_ped ( m_peds->find( id ) ) ;
77  isNoise ? m_mips->getMap().end() : m_mips->getMap().find( id ) ) ;
78 
79  const double baseline ( (double) it_ped->getMean() ) ;
80  const double sigma ( isNoise ? 0. : (double) it_ped->getRms() ) ;
81  const double MIPADC ( isNoise ? 0. : (double) (*it_mip) ) ;
82  const double ADCGeV ( isNoise ? 1. : MIPADC/m_MIPToGeV ) ;
83 
84  int adc = 0 ;
85 // std::cout<<" **Id="<<ESDetId(df.id())<<", size="<<df.size();
86  for( unsigned int i ( 0 ) ; i != cs.size(); ++i )
87  {
88  const double noi ( isNoise || (!m_addNoise) ? 0 :
89  sigma*m_ranGau->fire() ) ;
90 
91  double signal = cs[i]*ADCGeV + noi + baseline ;
92 
93  if( 0 <= signal )
94  {
95  signal += 0.5 ;
96  }
97  else
98  {
99  signal -= 0.5 ;
100  }
101 
102  adc = int( signal ) ;
103  assert( 0 < adc ) ;
104 
105  if( 0.5 < signal - adc ) ++adc ;
106 
107  if( MAXADC < adc )
108  {
109  adc = MAXADC ;
110  }
111  else
112  {
113  if( MINADC > adc ) adc = MINADC ;
114  }
115 
116  df.setSample( i, ESSample( adc ) ) ;
117 // std::cout<<", "<<df[i];
118  }
119 // std::cout<<std::endl ;
120 }
int adc(sample_type sample)
get the ADC sample (12 bits)
int i
Definition: DBlmapReader.cc:9
auto_ptr< ClusterSequence > cs
const ESIntercalibConstants * m_mips
const_iterator end() const
const self & getMap() const
CLHEP::RandGaussQ * m_ranGau
void setSize(int size)
Definition: ESDataFrame.cc:27
const_iterator find(uint32_t rawId) const
void setSample(int i, const ESSample &sam)
Definition: ESDataFrame.h:30
Definition: DetId.h:18
const ESPedestals * m_peds
std::vector< Item >::const_iterator const_iterator
void ESElectronicsSimFast::newEvent ( )
inline

Definition at line 37 of file ESElectronicsSimFast.h.

37 {}
void ESElectronicsSimFast::setMIPs ( const ESIntercalibConstants mips)

Definition at line 49 of file ESElectronicsSimFast.cc.

References m_mips.

Referenced by EcalDigiProducer::checkCalibrations().

50 {
51  m_mips = mips ;
52 }
const ESIntercalibConstants * m_mips
void ESElectronicsSimFast::setMIPToGeV ( double  MIPToGeV)

Definition at line 55 of file ESElectronicsSimFast.cc.

References m_MIPToGeV.

Referenced by EcalDigiProducer::checkCalibrations().

56 {
57  m_MIPToGeV = MIPToGeV ;
58 }
void ESElectronicsSimFast::setPedestals ( const ESPedestals peds)

Definition at line 43 of file ESElectronicsSimFast.cc.

References m_peds.

Referenced by EcalDigiProducer::checkCalibrations().

44 {
45  m_peds = peds ;
46 }
const ESPedestals * m_peds

Member Data Documentation

bool ESElectronicsSimFast::m_addNoise
private

Definition at line 41 of file ESElectronicsSimFast.h.

Referenced by analogToDigital(), and ESElectronicsSimFast().

const ESIntercalibConstants* ESElectronicsSimFast::m_mips
private

Definition at line 47 of file ESElectronicsSimFast.h.

Referenced by analogToDigital(), and setMIPs().

double ESElectronicsSimFast::m_MIPToGeV
private

Definition at line 43 of file ESElectronicsSimFast.h.

Referenced by analogToDigital(), and setMIPToGeV().

const ESPedestals* ESElectronicsSimFast::m_peds
private

Definition at line 45 of file ESElectronicsSimFast.h.

Referenced by analogToDigital(), and setPedestals().

CLHEP::RandGaussQ* ESElectronicsSimFast::m_ranGau
private