CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/SimCalorimetry/EcalSimAlgos/src/EcalElectronicsSim.cc

Go to the documentation of this file.
00001 #include "SimCalorimetry/EcalSimAlgos/interface/EcalElectronicsSim.h"
00002 #include "SimCalorimetry/EcalSimAlgos/interface/EcalCoder.h"
00003 #include "SimCalorimetry/EcalSimAlgos/interface/EcalSimParameterMap.h"
00004 
00005 #include "FWCore/ServiceRegistry/interface/Service.h"
00006 #include "FWCore/Utilities/interface/RandomNumberGenerator.h"
00007 #include "CLHEP/Random/RandGaussQ.h"
00008 #include "FWCore/Utilities/interface/Exception.h"
00009 
00010 #include <string.h>
00011 #include <sstream>
00012 #include <iostream>
00013 #include <unistd.h>
00014 #include <fstream>
00015 
00016 EcalElectronicsSim::EcalElectronicsSim(const EcalSimParameterMap * parameterMap, 
00017                                        EcalCoder * coder, 
00018                                        bool applyConstantTerm, 
00019                                        double rmsConstantTerm)
00020 : theParameterMap(parameterMap),
00021   theCoder(coder),
00022   applyConstantTerm_(applyConstantTerm), 
00023   rmsConstantTerm_(rmsConstantTerm)
00024 {
00025 }
00026 
00027 
00028 void EcalElectronicsSim::amplify(CaloSamples & clf) const 
00029 {
00030   clf *= theParameterMap->simParameters(clf.id()).photoelectronsToAnalog();
00031   if (applyConstantTerm_) {
00032     clf *= (1.+constantTerm());
00033   }
00034 }
00035 
00036 double EcalElectronicsSim::constantTerm() const
00037 {
00038   edm::Service<edm::RandomNumberGenerator> rng;
00039   if ( ! rng.isAvailable()) {
00040     throw cms::Exception("Configuration")
00041       << "EcalElectroncSim requires the RandomNumberGeneratorService\n"
00042       "which is not present in the configuration file.  You must add the service\n"
00043       "in the configuration file or remove the modules that require it.";
00044   }
00045 
00046   double thisCT = rmsConstantTerm_;
00047   CLHEP::RandGaussQ gaussQDistribution(rng->getEngine(), 0.0, thisCT);
00048   return gaussQDistribution.fire();
00049 }
00050 
00051 void EcalElectronicsSim::analogToDigital(CaloSamples& clf, EcalDataFrame& df) const 
00052 {
00053   //PG input signal is in pe.  Converted in GeV
00054   amplify(clf);
00055   theCoder->analogToDigital(clf, df);
00056 }
00057 
00058 
00059 
00060