CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/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 "FWCore/Utilities/interface/Exception.h"
00008 
00009 #include <string.h>
00010 #include <sstream>
00011 #include <iostream>
00012 #include <unistd.h>
00013 #include <fstream>
00014 
00015 EcalElectronicsSim::EcalElectronicsSim( const EcalSimParameterMap* parameterMap      , 
00016                                         EcalCoder*                 coder             , 
00017                                         bool                       applyConstantTerm , 
00018                                         double                     rmsConstantTerm     ) :
00019    m_simMap             ( parameterMap ) ,
00020    m_theCoder           ( coder        ) ,
00021    m_gaussQDistribution ( 0            )
00022 {
00023    edm::Service<edm::RandomNumberGenerator> rng;
00024  
00025    if( applyConstantTerm )
00026    {
00027       if ( !rng.isAvailable() ) 
00028       {
00029          throw cms::Exception("Configuration")
00030             << "EcalElectroncSim requires the RandomNumberGeneratorService\n"
00031             "which is not present in the configuration file.  You must add the service\n"
00032             "in the configuration file or remove the modules that require it.";
00033       }
00034 
00035       double thisCT = rmsConstantTerm ;
00036       m_gaussQDistribution = new CLHEP::RandGaussQ( rng->getEngine(), 1.0, thisCT ) ;
00037    }
00038 }
00039 
00040 EcalElectronicsSim::~EcalElectronicsSim()
00041 {  
00042    delete m_gaussQDistribution ;
00043 }
00044 
00045 void 
00046 EcalElectronicsSim::analogToDigital( EcalElectronicsSim::EcalSamples& clf , 
00047                                      EcalDataFrame&                   df    ) const 
00048 {
00049    //PG input signal is in pe.  Converted in GeV
00050    amplify( clf ) ;
00051 
00052    m_theCoder->analogToDigital( clf, df ) ;
00053 }
00054 
00055 void 
00056 EcalElectronicsSim::amplify( EcalElectronicsSim::EcalSamples& clf ) const 
00057 {
00058    const double fac ( m_simMap->simParameters( clf.id() ).photoelectronsToAnalog() ) ;
00059    if( 0 != m_gaussQDistribution ) 
00060    {
00061       clf *= fac*m_gaussQDistribution->fire() ;
00062    }
00063    else
00064    {
00065       clf *= fac ;
00066    }
00067 }
00068 
00069 
00070 
00071