CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalElectronicsSim.cc
Go to the documentation of this file.
4 
8 
9 #include <string.h>
10 #include <sstream>
11 #include <iostream>
12 #include <unistd.h>
13 #include <fstream>
14 
16  EcalCoder* coder ,
17  bool applyConstantTerm ,
18  double rmsConstantTerm ) :
19  m_simMap ( parameterMap ) ,
20  m_theCoder ( coder ) ,
21  m_gaussQDistribution ( 0 )
22 {
24 
25  if( applyConstantTerm )
26  {
27  if ( !rng.isAvailable() )
28  {
29  throw cms::Exception("Configuration")
30  << "EcalElectroncSim requires the RandomNumberGeneratorService\n"
31  "which is not present in the configuration file. You must add the service\n"
32  "in the configuration file or remove the modules that require it.";
33  }
34 
35  double thisCT = rmsConstantTerm ;
36  m_gaussQDistribution = new CLHEP::RandGaussQ( rng->getEngine(), 1.0, thisCT ) ;
37  }
38 }
39 
41 {
42  delete m_gaussQDistribution ;
43 }
44 
45 void
47  EcalDataFrame& df ) const
48 {
49  //PG input signal is in pe. Converted in GeV
50  amplify( clf ) ;
51 
52  m_theCoder->analogToDigital( clf, df ) ;
53 }
54 
55 void
57 {
58  const double fac ( m_simMap->simParameters( clf.id() ).photoelectronsToAnalog() ) ;
59  if( 0 != m_gaussQDistribution )
60  {
61  clf *= fac*m_gaussQDistribution->fire() ;
62  }
63  else
64  {
65  clf *= fac ;
66  }
67 }
68 
69 
70 
71 
virtual const CaloSimParameters & simParameters(const DetId &id) const
return the sim parameters relative to the right subdet
void amplify(EcalSamples &clf) const
input signal is in pe. Converted in GeV
CLHEP::RandGaussQ * m_gaussQDistribution
DetId id() const
virtual void analogToDigital(const EcalSamples &clf, EcalDataFrame &df) const
from EcalSamples to EcalDataFrame
Definition: EcalCoder.cc:73
bool isAvailable() const
Definition: Service.h:46
void analogToDigital(EcalSamples &clf, EcalDataFrame &df) const
from EcalSamples to EcalDataFrame
virtual CLHEP::HepRandomEngine & getEngine() const =0
Use this to get the random number engine, this is the only function most users should call...
const EcalSimParameterMap * m_simMap
map of parameters
EcalElectronicsSim(const EcalSimParameterMap *parameterMap, EcalCoder *coder, bool applyConstantTerm, double rmsConstantTerm)