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