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