00001 #include "SimCalorimetry/EcalSimProducers/interface/EcalDigiProducer.h"
00002 #include "SimCalorimetry/EcalSimAlgos/interface/EBHitResponse.h"
00003 #include "SimCalorimetry/EcalSimAlgos/interface/EEHitResponse.h"
00004 #include "SimCalorimetry/EcalSimAlgos/interface/ESHitResponse.h"
00005 #include "SimCalorimetry/CaloSimAlgos/interface/CaloHitResponse.h"
00006 #include "SimCalorimetry/EcalSimAlgos/interface/EcalSimParameterMap.h"
00007 #include "SimCalorimetry/EcalSimAlgos/interface/APDSimParameters.h"
00008 #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
00009 #include "SimCalorimetry/EcalSimAlgos/interface/EcalCoder.h"
00010 #include "SimCalorimetry/EcalSimAlgos/interface/EcalElectronicsSim.h"
00011 #include "SimCalorimetry/EcalSimAlgos/interface/ESElectronicsSimFast.h"
00012 #include "SimCalorimetry/EcalSimAlgos/interface/ESElectronicsSim.h"
00013
00014 #include "SimCalorimetry/EcalSimAlgos/interface/ESDigitizer.h"
00015 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00016 #include "CalibFormats/CaloObjects/interface/CaloSamples.h"
00017 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
00018 #include "FWCore/Framework/interface/ESHandle.h"
00019 #include "DataFormats/Common/interface/Handle.h"
00020 #include "SimDataFormats/CrossingFrame/interface/MixCollection.h"
00021 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00022 #include "SimDataFormats/CaloHit/interface/PCaloHit.h"
00023 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00024 #include "CondFormats/EcalObjects/interface/EcalPedestals.h"
00025 #include "CondFormats/DataRecord/interface/EcalPedestalsRcd.h"
00026 #include "CondFormats/EcalObjects/interface/EcalIntercalibConstantsMC.h"
00027 #include "CondFormats/DataRecord/interface/EcalIntercalibConstantsMCRcd.h"
00028 #include "CondFormats/EcalObjects/interface/EcalADCToGeVConstant.h"
00029 #include "CondFormats/DataRecord/interface/EcalADCToGeVConstantRcd.h"
00030 #include "CondFormats/EcalObjects/interface/EcalGainRatios.h"
00031 #include "CondFormats/DataRecord/interface/EcalGainRatiosRcd.h"
00032
00033 #include "CondFormats/ESObjects/interface/ESIntercalibConstants.h"
00034 #include "CondFormats/DataRecord/interface/ESIntercalibConstantsRcd.h"
00035 #include "CondFormats/ESObjects/interface/ESMIPToGeVConstant.h"
00036 #include "CondFormats/DataRecord/interface/ESMIPToGeVConstantRcd.h"
00037 #include "CondFormats/ESObjects/interface/ESGain.h"
00038 #include "CondFormats/DataRecord/interface/ESGainRcd.h"
00039 #include "CondFormats/ESObjects/interface/ESPedestals.h"
00040 #include "CondFormats/DataRecord/interface/ESPedestalsRcd.h"
00041 #include "Geometry/EcalAlgo/interface/EcalEndcapGeometry.h"
00042
00043 EcalDigiProducer::EcalDigiProducer( const edm::ParameterSet& params ) :
00044 m_APDShape ( params.getParameter<double>( "apdShapeTstart" ) ,
00045 params.getParameter<double>( "apdShapeTau" ) ) ,
00046 m_EBShape ( ) ,
00047 m_EEShape ( ) ,
00048 m_ESShape ( ) ,
00049 m_EBdigiCollection ( params.getParameter<std::string>("EBdigiCollection") ) ,
00050 m_EEdigiCollection ( params.getParameter<std::string>("EEdigiCollection") ) ,
00051 m_ESdigiCollection ( params.getParameter<std::string>("ESdigiCollection") ) ,
00052 m_hitsProducerTag ( params.getParameter<std::string>("hitsProducer" ) ) ,
00053 m_apdSeparateDigi ( params.getParameter<bool> ("apdSeparateDigi") ) ,
00054
00055 m_EBs25notCont ( params.getParameter<double> ("EBs25notContainment") ) ,
00056 m_EEs25notCont ( params.getParameter<double> ("EEs25notContainment") ) ,
00057
00058 m_readoutFrameSize ( params.getParameter<int> ("readoutFrameSize") ) ,
00059 m_ParameterMap ( new EcalSimParameterMap(
00060 params.getParameter<double> ("simHitToPhotoelectronsBarrel") ,
00061 params.getParameter<double> ("simHitToPhotoelectronsEndcap") ,
00062 params.getParameter<double> ("photoelectronsToAnalogBarrel") ,
00063 params.getParameter<double> ("photoelectronsToAnalogEndcap") ,
00064 params.getParameter<double> ("samplingFactor") ,
00065 params.getParameter<double> ("timePhase") ,
00066 m_readoutFrameSize ,
00067 params.getParameter<int> ("binOfMaximum") ,
00068 params.getParameter<bool> ("doPhotostatistics") ,
00069 params.getParameter<bool> ("syncPhase") ) ) ,
00070
00071 m_apdDigiTag ( params.getParameter<std::string> ("apdDigiTag" ) ) ,
00072 m_apdParameters ( new APDSimParameters(
00073 params.getParameter<bool> ("apdAddToBarrel" ) ,
00074 m_apdSeparateDigi ,
00075 params.getParameter<double> ("apdSimToPELow" ) ,
00076 params.getParameter<double> ("apdSimToPEHigh" ) ,
00077 params.getParameter<double> ("apdTimeOffset" ) ,
00078 params.getParameter<double> ("apdTimeOffWidth" ) ,
00079 params.getParameter<bool> ("apdDoPEStats" ) ,
00080 m_apdDigiTag ,
00081 params.getParameter<std::vector<double> > ( "apdNonlParms" ) ) ) ,
00082
00083 m_APDResponse ( !m_apdSeparateDigi ? 0 :
00084 new EBHitResponse( m_ParameterMap ,
00085 &m_EBShape ,
00086 true ,
00087 m_apdParameters ,
00088 &m_APDShape ) ) ,
00089
00090 m_EBResponse ( new EBHitResponse( m_ParameterMap ,
00091 &m_EBShape ,
00092 false ,
00093 m_apdParameters ,
00094 &m_APDShape ) ) ,
00095
00096 m_EEResponse ( new EEHitResponse( m_ParameterMap,
00097 &m_EEShape ) ) ,
00098 m_ESResponse ( new ESHitResponse( m_ParameterMap, &m_ESShape ) ) ,
00099 m_ESOldResponse ( new CaloHitResponse( m_ParameterMap, &m_ESShape ) ) ,
00100
00101 m_addESNoise ( params.getParameter<bool> ("doESNoise") ) ,
00102 m_doFastES ( params.getParameter<bool> ("doFast" ) ) ,
00103
00104 m_ESElectronicsSim ( m_doFastES ? 0 :
00105 new ESElectronicsSim( m_addESNoise ) ) ,
00106
00107 m_ESOldDigitizer ( m_doFastES ? 0 :
00108 new ESOldDigitizer( m_ESOldResponse ,
00109 m_ESElectronicsSim ,
00110 m_addESNoise ) ) ,
00111
00112 m_ESElectronicsSimFast ( !m_doFastES ? 0 :
00113 new ESElectronicsSimFast( m_addESNoise ) ) ,
00114
00115 m_ESDigitizer ( !m_doFastES ? 0 :
00116 new ESDigitizer( m_ESResponse ,
00117 m_ESElectronicsSimFast ,
00118 m_addESNoise ) ) ,
00119
00120 m_APDDigitizer ( 0 ) ,
00121 m_BarrelDigitizer ( 0 ) ,
00122 m_EndcapDigitizer ( 0 ) ,
00123 m_ElectronicsSim ( 0 ) ,
00124 m_Coder ( 0 ) ,
00125 m_APDElectronicsSim ( 0 ) ,
00126 m_APDCoder ( 0 ) ,
00127 m_Geometry ( 0 ) ,
00128 m_EBCorrNoise ( ) ,
00129 m_EECorrNoise ( )
00130 {
00131 const std::vector<double> ebCorMatG12 = params.getParameter< std::vector<double> >("EBCorrNoiseMatrixG12");
00132 const std::vector<double> eeCorMatG12 = params.getParameter< std::vector<double> >("EECorrNoiseMatrixG12");
00133 const std::vector<double> ebCorMatG06 = params.getParameter< std::vector<double> >("EBCorrNoiseMatrixG06");
00134 const std::vector<double> eeCorMatG06 = params.getParameter< std::vector<double> >("EECorrNoiseMatrixG06");
00135 const std::vector<double> ebCorMatG01 = params.getParameter< std::vector<double> >("EBCorrNoiseMatrixG01");
00136 const std::vector<double> eeCorMatG01 = params.getParameter< std::vector<double> >("EECorrNoiseMatrixG01");
00137
00138
00139 const bool applyConstantTerm = params.getParameter<bool> ("applyConstantTerm");
00140 const double rmsConstantTerm = params.getParameter<double> ("ConstantTerm");
00141
00142 const bool addNoise = params.getParameter<bool> ("doNoise");
00143 const bool cosmicsPhase = params.getParameter<bool> ("cosmicsPhase");
00144 const double cosmicsShift = params.getParameter<double> ("cosmicsShift");
00145
00146
00147
00148 if( m_apdSeparateDigi ) produces<EBDigiCollection>( m_apdDigiTag ) ;
00149 produces<EBDigiCollection>( m_EBdigiCollection ) ;
00150 produces<EEDigiCollection>( m_EEdigiCollection ) ;
00151 produces<ESDigiCollection>( m_ESdigiCollection ) ;
00152
00153
00154 if( cosmicsPhase )
00155 {
00156 m_EBResponse->setPhaseShift( 1. + cosmicsShift ) ;
00157 m_EEResponse->setPhaseShift( 1. + cosmicsShift ) ;
00158 }
00159
00160 EcalCorrMatrix ebMatrix[ 3 ] ;
00161 EcalCorrMatrix eeMatrix[ 3 ] ;
00162
00163 assert( ebCorMatG12.size() == m_readoutFrameSize ) ;
00164 assert( eeCorMatG12.size() == m_readoutFrameSize ) ;
00165 assert( ebCorMatG06.size() == m_readoutFrameSize ) ;
00166 assert( eeCorMatG06.size() == m_readoutFrameSize ) ;
00167 assert( ebCorMatG01.size() == m_readoutFrameSize ) ;
00168 assert( eeCorMatG01.size() == m_readoutFrameSize ) ;
00169
00170 assert( 1.e-7 > fabs( ebCorMatG12[0] - 1.0 ) ) ;
00171 assert( 1.e-7 > fabs( ebCorMatG06[0] - 1.0 ) ) ;
00172 assert( 1.e-7 > fabs( ebCorMatG01[0] - 1.0 ) ) ;
00173 assert( 1.e-7 > fabs( eeCorMatG12[0] - 1.0 ) ) ;
00174 assert( 1.e-7 > fabs( eeCorMatG06[0] - 1.0 ) ) ;
00175 assert( 1.e-7 > fabs( eeCorMatG01[0] - 1.0 ) ) ;
00176
00177 for ( unsigned int row ( 0 ) ; row != m_readoutFrameSize ; ++row )
00178 {
00179 assert( 0 == row || 1. >= ebCorMatG12[row] ) ;
00180 assert( 0 == row || 1. >= ebCorMatG06[row] ) ;
00181 assert( 0 == row || 1. >= ebCorMatG01[row] ) ;
00182 assert( 0 == row || 1. >= eeCorMatG12[row] ) ;
00183 assert( 0 == row || 1. >= eeCorMatG06[row] ) ;
00184 assert( 0 == row || 1. >= eeCorMatG01[row] ) ;
00185 for ( unsigned int column ( 0 ) ; column <= row ; ++column )
00186 {
00187 const unsigned int index ( row - column ) ;
00188 ebMatrix[0]( row, column ) = ebCorMatG12[ index ] ;
00189 eeMatrix[0]( row, column ) = eeCorMatG12[ index ] ;
00190 ebMatrix[1]( row, column ) = ebCorMatG06[ index ] ;
00191 eeMatrix[1]( row, column ) = eeCorMatG06[ index ] ;
00192 ebMatrix[2]( row, column ) = ebCorMatG01[ index ] ;
00193 eeMatrix[2]( row, column ) = eeCorMatG01[ index ] ;
00194 }
00195 }
00196
00197 m_EBCorrNoise[0] = new CorrelatedNoisifier<EcalCorrMatrix>( ebMatrix[0] ) ;
00198 m_EECorrNoise[0] = new CorrelatedNoisifier<EcalCorrMatrix>( eeMatrix[0] ) ;
00199 m_EBCorrNoise[1] = new CorrelatedNoisifier<EcalCorrMatrix>( ebMatrix[1] ) ;
00200 m_EECorrNoise[1] = new CorrelatedNoisifier<EcalCorrMatrix>( eeMatrix[1] ) ;
00201 m_EBCorrNoise[2] = new CorrelatedNoisifier<EcalCorrMatrix>( ebMatrix[2] ) ;
00202 m_EECorrNoise[2] = new CorrelatedNoisifier<EcalCorrMatrix>( eeMatrix[2] ) ;
00203
00204 m_Coder = new EcalCoder( addNoise ,
00205 m_EBCorrNoise[0] ,
00206 m_EECorrNoise[0] ,
00207 m_EBCorrNoise[1] ,
00208 m_EECorrNoise[1] ,
00209 m_EBCorrNoise[2] ,
00210 m_EECorrNoise[2] ) ;
00211
00212 m_ElectronicsSim = new EcalElectronicsSim( m_ParameterMap ,
00213 m_Coder ,
00214 applyConstantTerm ,
00215 rmsConstantTerm ) ;
00216
00217 if( m_apdSeparateDigi )
00218 {
00219 m_APDCoder = new EcalCoder( false ,
00220 m_EBCorrNoise[0] ,
00221 m_EECorrNoise[0] ,
00222 m_EBCorrNoise[1] ,
00223 m_EECorrNoise[1] ,
00224 m_EBCorrNoise[2] ,
00225 m_EECorrNoise[2] ) ;
00226
00227 m_APDElectronicsSim = new EcalElectronicsSim( m_ParameterMap ,
00228 m_APDCoder ,
00229 applyConstantTerm ,
00230 rmsConstantTerm ) ;
00231
00232 m_APDDigitizer = new EBDigitizer( m_APDResponse ,
00233 m_APDElectronicsSim ,
00234 false ) ;
00235 }
00236
00237 m_BarrelDigitizer = new EBDigitizer( m_EBResponse ,
00238 m_ElectronicsSim ,
00239 addNoise ) ;
00240
00241 m_EndcapDigitizer = new EEDigitizer( m_EEResponse ,
00242 m_ElectronicsSim ,
00243 addNoise ) ;
00244 }
00245
00246 EcalDigiProducer::~EcalDigiProducer()
00247 {
00248 delete m_EndcapDigitizer ;
00249 delete m_BarrelDigitizer ;
00250 delete m_APDDigitizer ;
00251 delete m_APDElectronicsSim ;
00252 delete m_APDCoder ;
00253 delete m_ElectronicsSim ;
00254 delete m_Coder ;
00255 delete m_EBCorrNoise[0] ;
00256 delete m_EECorrNoise[0] ;
00257 delete m_EBCorrNoise[1] ;
00258 delete m_EECorrNoise[1] ;
00259 delete m_EBCorrNoise[2] ;
00260 delete m_EECorrNoise[2] ;
00261
00262 delete m_ESDigitizer ;
00263 delete m_ESElectronicsSimFast ;
00264 delete m_ESOldDigitizer ;
00265 delete m_ESElectronicsSim ;
00266
00267 delete m_ESOldResponse ;
00268 delete m_ESResponse ;
00269 delete m_EEResponse ;
00270 delete m_EBResponse ;
00271 delete m_APDResponse ;
00272
00273 delete m_apdParameters ;
00274 delete m_ParameterMap ;
00275 }
00276
00277 void
00278 EcalDigiProducer::produce( edm::Event& event ,
00279 const edm::EventSetup& eventSetup )
00280 {
00281
00282
00283 checkGeometry( eventSetup );
00284 checkCalibrations( eventSetup );
00285
00286
00287 edm::Handle<CrossingFrame<PCaloHit> > crossingFrame;
00288
00289
00290 const std::string barrelHitsName ( m_hitsProducerTag + "EcalHitsEB" ) ;
00291 const std::string endcapHitsName ( m_hitsProducerTag + "EcalHitsEE" ) ;
00292 const std::string preshowerHitsName ( m_hitsProducerTag + "EcalHitsES" ) ;
00293
00294 event.getByLabel( "mix",
00295 barrelHitsName ,
00296 crossingFrame ) ;
00297
00298 MixCollection<PCaloHit>* EBHits (
00299 !crossingFrame.isValid() ? 0 :
00300 new MixCollection<PCaloHit>( crossingFrame.product() ) ) ;
00301
00302 const bool isEB ( crossingFrame.isValid() &&
00303 0 != EBHits &&
00304 EBHits->inRegistry() ) ;
00305
00306 if( !crossingFrame.isValid() )
00307 edm::LogError("EcalDigiProducer") << "Error! can't get the product "
00308 << barrelHitsName.c_str() ;
00309
00310 event.getByLabel( "mix",
00311 endcapHitsName ,
00312 crossingFrame ) ;
00313
00314 MixCollection<PCaloHit>* EEHits (
00315 !crossingFrame.isValid() ? 0 :
00316 new MixCollection<PCaloHit>( crossingFrame.product() ) ) ;
00317
00318 const bool isEE ( crossingFrame.isValid() &&
00319 0 != EEHits &&
00320 EEHits->inRegistry() ) ;
00321
00322 if( !crossingFrame.isValid() )
00323 edm::LogError("EcalDigiProducer") << "Error! can't get the product "
00324 << endcapHitsName.c_str() ;
00325
00326 event.getByLabel( "mix",
00327 preshowerHitsName ,
00328 crossingFrame ) ;
00329
00330 MixCollection<PCaloHit>* ESHits (
00331 !crossingFrame.isValid() ? 0 :
00332 new MixCollection<PCaloHit>( crossingFrame.product() ) ) ;
00333
00334 const bool isES ( crossingFrame.isValid() &&
00335 0 != ESHits &&
00336 ESHits->inRegistry() ) ;
00337
00338 if( !crossingFrame.isValid() )
00339 edm::LogError("EcalDigiProducer") << "Error! can't get the product "
00340 << preshowerHitsName.c_str() ;
00341
00342
00343 std::auto_ptr<EBDigiCollection> apdResult ( !m_apdSeparateDigi ? 0 :
00344 new EBDigiCollection() ) ;
00345 std::auto_ptr<EBDigiCollection> barrelResult ( new EBDigiCollection() ) ;
00346 std::auto_ptr<EEDigiCollection> endcapResult ( new EEDigiCollection() ) ;
00347 std::auto_ptr<ESDigiCollection> preshowerResult( new ESDigiCollection() ) ;
00348
00349
00350
00351 if( isEB )
00352 {
00353 std::auto_ptr<MixCollection<PCaloHit> > barrelHits( EBHits ) ;
00354 m_BarrelDigitizer->run( *barrelHits ,
00355 *barrelResult ) ;
00356 cacheEBDigis( &*barrelResult ) ;
00357
00358 edm::LogInfo("DigiInfo") << "EB Digis: " << barrelResult->size() ;
00359
00360 if( m_apdSeparateDigi )
00361 {
00362 m_APDDigitizer->run( *barrelHits ,
00363 *apdResult ) ;
00364
00365 edm::LogInfo("DigiInfo") << "APD Digis: " << apdResult->size() ;
00366 }
00367 }
00368
00369 if( isEE )
00370 {
00371 std::auto_ptr<MixCollection<PCaloHit> > endcapHits( EEHits ) ;
00372 m_EndcapDigitizer->run( *endcapHits ,
00373 *endcapResult ) ;
00374 edm::LogInfo("EcalDigi") << "EE Digis: " << endcapResult->size() ;
00375 cacheEEDigis( &*endcapResult ) ;
00376 }
00377
00378 if( isES )
00379 {
00380 std::auto_ptr<MixCollection<PCaloHit> > preshowerHits( ESHits ) ;
00381 if (!m_doFastES)
00382 {
00383 m_ESOldDigitizer->run( *preshowerHits ,
00384 *preshowerResult ) ;
00385 }
00386 else
00387 {
00388 m_ESDigitizer->run( *preshowerHits,
00389 *preshowerResult ) ;
00390 }
00391 edm::LogInfo("EcalDigi") << "ES Digis: " << preshowerResult->size();
00392 }
00393
00394
00395 if( m_apdSeparateDigi )
00396 event.put( apdResult, m_apdDigiTag ) ;
00397
00398 event.put( barrelResult, m_EBdigiCollection ) ;
00399 event.put( endcapResult, m_EEdigiCollection ) ;
00400 event.put( preshowerResult, m_ESdigiCollection ) ;
00401 }
00402
00403 void
00404 EcalDigiProducer::checkCalibrations( const edm::EventSetup& eventSetup )
00405 {
00406
00407
00408 edm::ESHandle<EcalPedestals> dbPed ;
00409 eventSetup.get<EcalPedestalsRcd>().get( dbPed ) ;
00410 const EcalPedestals* pedestals ( dbPed.product() ) ;
00411
00412 m_Coder->setPedestals( pedestals ) ;
00413 if( 0 != m_APDCoder ) m_APDCoder->setPedestals( pedestals ) ;
00414
00415
00416 edm::ESHandle<EcalIntercalibConstantsMC> pIcal ;
00417 eventSetup.get<EcalIntercalibConstantsMCRcd>().get( pIcal ) ;
00418 const EcalIntercalibConstantsMC* ical ( pIcal.product() ) ;
00419
00420 m_Coder->setIntercalibConstants( ical ) ;
00421 if( 0 != m_APDCoder) m_APDCoder->setIntercalibConstants( ical ) ;
00422
00423 m_EBResponse->setIntercal( ical ) ;
00424 if( 0 != m_APDResponse ) m_APDResponse->setIntercal( ical ) ;
00425
00426
00427 edm::ESHandle<EcalADCToGeVConstant> pAgc;
00428 eventSetup.get<EcalADCToGeVConstantRcd>().get(pAgc);
00429 const EcalADCToGeVConstant* agc = pAgc.product();
00430
00431
00432 edm::ESHandle<EcalGainRatios> pRatio;
00433 eventSetup.get<EcalGainRatiosRcd>().get(pRatio);
00434 const EcalGainRatios* gr = pRatio.product();
00435
00436 m_Coder->setGainRatios( gr );
00437 if( 0 != m_APDCoder) m_APDCoder->setGainRatios( gr );
00438
00439 EcalMGPAGainRatio * defaultRatios = new EcalMGPAGainRatio();
00440
00441 double theGains[m_Coder->NGAINS+1];
00442 theGains[0] = 0.;
00443 theGains[3] = 1.;
00444 theGains[2] = defaultRatios->gain6Over1() ;
00445 theGains[1] = theGains[2]*(defaultRatios->gain12Over6()) ;
00446
00447 LogDebug("EcalDigi") << " Gains: " << "\n" << " g1 = " << theGains[1]
00448 << "\n" << " g2 = " << theGains[2]
00449 << "\n" << " g3 = " << theGains[3] ;
00450
00451 delete defaultRatios;
00452
00453 const double EBscale (
00454 ( agc->getEBValue())*theGains[1]*(m_Coder->MAXADC)*m_EBs25notCont ) ;
00455
00456 LogDebug("EcalDigi") << " GeV/ADC = " << agc->getEBValue()
00457 << "\n" << " notCont = " << m_EBs25notCont
00458 << "\n" << " saturation for EB = " << EBscale
00459 << ", " << m_EBs25notCont ;
00460
00461 const double EEscale (
00462 (agc->getEEValue())*theGains[1]*(m_Coder->MAXADC)*m_EEs25notCont ) ;
00463
00464 LogDebug("EcalDigi") << " GeV/ADC = " << agc->getEEValue()
00465 << "\n" << " notCont = " << m_EEs25notCont
00466 << "\n" << " saturation for EB = " << EEscale
00467 << ", " << m_EEs25notCont ;
00468
00469 m_Coder->setFullScaleEnergy( EBscale ,
00470 EEscale ) ;
00471 if( 0 != m_APDCoder ) m_APDCoder->setFullScaleEnergy( EBscale ,
00472 EEscale ) ;
00473
00474 if( 0 != m_ESOldDigitizer ||
00475 0 != m_ESDigitizer )
00476 {
00477
00478 edm::ESHandle<ESGain> hesgain ;
00479 edm::ESHandle<ESMIPToGeVConstant> hesMIPToGeV ;
00480 edm::ESHandle<ESPedestals> hesPedestals ;
00481 edm::ESHandle<ESIntercalibConstants> hesMIPs ;
00482
00483 eventSetup.get<ESGainRcd>(). get( hesgain ) ;
00484 eventSetup.get<ESMIPToGeVConstantRcd>(). get( hesMIPToGeV ) ;
00485 eventSetup.get<ESPedestalsRcd>(). get( hesPedestals ) ;
00486 eventSetup.get<ESIntercalibConstantsRcd>().get( hesMIPs ) ;
00487
00488 const ESGain* esgain ( hesgain.product() ) ;
00489 const ESPedestals* espeds ( hesPedestals.product() ) ;
00490 const ESIntercalibConstants* esmips ( hesMIPs.product() ) ;
00491 const ESMIPToGeVConstant* esMipToGeV ( hesMIPToGeV.product() ) ;
00492 const int ESGain ( 1.1 > esgain->getESGain() ? 1 : 2 ) ;
00493 const double ESMIPToGeV ( ( 1 == ESGain ) ?
00494 esMipToGeV->getESValueLow() :
00495 esMipToGeV->getESValueHigh() ) ;
00496
00497 m_ESShape.setGain( ESGain );
00498
00499 if( !m_doFastES )
00500 {
00501 m_ESElectronicsSim->setGain( ESGain ) ;
00502 m_ESElectronicsSim->setPedestals( espeds ) ;
00503 m_ESElectronicsSim->setMIPs( esmips ) ;
00504 m_ESElectronicsSim->setMIPToGeV( ESMIPToGeV ) ;
00505 }
00506 else
00507 {
00508 m_ESDigitizer->setGain( ESGain ) ;
00509 m_ESElectronicsSimFast->setPedestals( espeds ) ;
00510 m_ESElectronicsSimFast->setMIPs( esmips ) ;
00511 m_ESElectronicsSimFast->setMIPToGeV( ESMIPToGeV ) ;
00512 }
00513 }
00514 }
00515
00516 void
00517 EcalDigiProducer::checkGeometry( const edm::EventSetup & eventSetup )
00518 {
00519
00520 edm::ESHandle<CaloGeometry> hGeometry ;
00521 eventSetup.get<CaloGeometryRecord>().get( hGeometry ) ;
00522
00523 const CaloGeometry* pGeometry = &*hGeometry;
00524
00525 if( pGeometry != m_Geometry )
00526 {
00527 m_Geometry = pGeometry;
00528 updateGeometry();
00529 }
00530 }
00531
00532 void
00533 EcalDigiProducer::updateGeometry()
00534 {
00535 if( 0 != m_APDResponse ) m_APDResponse->setGeometry(
00536 m_Geometry->getSubdetectorGeometry( DetId::Ecal, EcalBarrel ) ) ;
00537 m_EBResponse->setGeometry(
00538 m_Geometry->getSubdetectorGeometry( DetId::Ecal, EcalBarrel ) ) ;
00539 m_EEResponse->setGeometry(
00540 m_Geometry->getSubdetectorGeometry( DetId::Ecal, EcalEndcap ) ) ;
00541 m_ESResponse->setGeometry(
00542 m_Geometry->getSubdetectorGeometry( DetId::Ecal, EcalPreshower ) ) ;
00543 m_ESOldResponse->setGeometry( m_Geometry ) ;
00544
00545 const std::vector<DetId>* theESDets (
00546 0 != m_Geometry->getSubdetectorGeometry(DetId::Ecal, EcalPreshower) ?
00547 &m_Geometry->getSubdetectorGeometry(DetId::Ecal, EcalPreshower)->getValidDetIds() : 0 ) ;
00548
00549 if( !m_doFastES )
00550 {
00551 if( 0 != m_ESOldDigitizer &&
00552 0 != theESDets )
00553 m_ESOldDigitizer->setDetIds( *theESDets ) ;
00554 }
00555 else
00556 {
00557 if( 0 != m_ESDigitizer &&
00558 0 != theESDets )
00559 m_ESDigitizer->setDetIds( *theESDets ) ;
00560 }
00561 }