00001 #include "SimCalorimetry/EcalSimProducers/interface/EcalDigiProducer.h"
00002 #include "SimCalorimetry/EcalSimAlgos/interface/EBHitResponse.h"
00003 #include "SimCalorimetry/EcalSimAlgos/interface/EcalSimParameterMap.h"
00004 #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
00005 #include "SimCalorimetry/EcalSimAlgos/interface/APDSimParameters.h"
00006 #include "SimCalorimetry/EcalSimAlgos/interface/EcalCoder.h"
00007 #include "SimCalorimetry/EcalSimAlgos/interface/EcalElectronicsSim.h"
00008 #include "SimCalorimetry/EcalSimAlgos/interface/ESElectronicsSimFast.h"
00009 #include "SimCalorimetry/EcalSimAlgos/interface/ESElectronicsSim.h"
00010 #include "SimCalorimetry/EcalSimAlgos/interface/ESFastTDigitizer.h"
00011 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00012 #include "CalibFormats/CaloObjects/interface/CaloSamples.h"
00013 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
00014 #include "FWCore/Framework/interface/ESHandle.h"
00015 #include "DataFormats/Common/interface/Handle.h"
00016 #include "SimDataFormats/CrossingFrame/interface/MixCollection.h"
00017 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00018 #include "SimDataFormats/CaloHit/interface/PCaloHit.h"
00019 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00020 #include "CondFormats/EcalObjects/interface/EcalPedestals.h"
00021 #include "CondFormats/DataRecord/interface/EcalPedestalsRcd.h"
00022 #include "CondFormats/EcalObjects/interface/EcalIntercalibConstantsMC.h"
00023 #include "CondFormats/DataRecord/interface/EcalIntercalibConstantsMCRcd.h"
00024 #include "CondFormats/EcalObjects/interface/EcalADCToGeVConstant.h"
00025 #include "CondFormats/DataRecord/interface/EcalADCToGeVConstantRcd.h"
00026 #include "CondFormats/EcalObjects/interface/EcalGainRatios.h"
00027 #include "CondFormats/DataRecord/interface/EcalGainRatiosRcd.h"
00028
00029 #include "CondFormats/ESObjects/interface/ESIntercalibConstants.h"
00030 #include "CondFormats/DataRecord/interface/ESIntercalibConstantsRcd.h"
00031 #include "CondFormats/ESObjects/interface/ESMIPToGeVConstant.h"
00032 #include "CondFormats/DataRecord/interface/ESMIPToGeVConstantRcd.h"
00033 #include "CondFormats/ESObjects/interface/ESGain.h"
00034 #include "CondFormats/DataRecord/interface/ESGainRcd.h"
00035 #include "CondFormats/ESObjects/interface/ESPedestals.h"
00036 #include "CondFormats/DataRecord/interface/ESPedestalsRcd.h"
00037
00038
00039 EcalDigiProducer::EcalDigiProducer( const edm::ParameterSet& params ) :
00040 m_APDDigitizer ( 0 ) ,
00041 m_BarrelDigitizer ( 0 ) ,
00042 m_EndcapDigitizer ( 0 ) ,
00043 m_ESDigitizer ( 0 ) ,
00044 m_ESDigitizerFast ( 0 ) ,
00045 m_ParameterMap ( 0 ) ,
00046 m_APDShape ( params.getParameter<double>( "apdShapeTstart" ) ,
00047 params.getParameter<double>( "apdShapeTau" ) ) ,
00048 m_EBShape ( ) ,
00049 m_EEShape ( ) ,
00050 m_ESShape ( new ESShape() ) ,
00051 m_APDResponse ( 0 ) ,
00052 m_EBResponse ( 0 ) ,
00053 m_EEResponse ( 0 ) ,
00054 m_ESResponse ( 0 ) ,
00055 m_ElectronicsSim ( 0 ) ,
00056 m_ESElectronicsSim ( 0 ) ,
00057 m_ESElectronicsSimFast ( 0 ) ,
00058 m_Coder ( 0 ) ,
00059 m_APDElectronicsSim ( 0 ) ,
00060 m_APDCoder ( 0 ) ,
00061 m_Geometry ( 0 ) ,
00062 m_apdParameters ( 0 )
00063 {
00065
00066 m_EBdigiCollection = params.getParameter<std::string>("EBdigiCollection");
00067 m_EEdigiCollection = params.getParameter<std::string>("EEdigiCollection");
00068 m_ESdigiCollection = params.getParameter<std::string>("ESdigiCollection");
00069 const bool addNoise = params.getParameter<bool> ("doNoise");
00070 const double simHitToPhotoelectronsBarrel = params.getParameter<double> ("simHitToPhotoelectronsBarrel");
00071 const double simHitToPhotoelectronsEndcap = params.getParameter<double> ("simHitToPhotoelectronsEndcap");
00072 const double photoelectronsToAnalogBarrel = params.getParameter<double> ("photoelectronsToAnalogBarrel");
00073 const double photoelectronsToAnalogEndcap = params.getParameter<double> ("photoelectronsToAnalogEndcap");
00074 const double samplingFactor = params.getParameter<double> ("samplingFactor");
00075 const double timePhase = params.getParameter<double> ("timePhase");
00076 const unsigned int readoutFrameSize = params.getParameter<int> ("readoutFrameSize");
00077 const int binOfMaximum = params.getParameter<int> ("binOfMaximum");
00078 const bool doPhotostatistics = params.getParameter<bool> ("doPhotostatistics");
00079 const bool syncPhase = params.getParameter<bool> ("syncPhase");
00080 const bool cosmicsPhase = params.getParameter<bool> ("cosmicsPhase");
00081 const double cosmicsShift = params.getParameter<double> ("cosmicsShift");
00082 const std::vector<double> ebCorMatG12 = params.getParameter< std::vector<double> >("EBCorrNoiseMatrixG12");
00083 const std::vector<double> eeCorMatG12 = params.getParameter< std::vector<double> >("EECorrNoiseMatrixG12");
00084 const std::vector<double> ebCorMatG06 = params.getParameter< std::vector<double> >("EBCorrNoiseMatrixG06");
00085 const std::vector<double> eeCorMatG06 = params.getParameter< std::vector<double> >("EECorrNoiseMatrixG06");
00086 const std::vector<double> ebCorMatG01 = params.getParameter< std::vector<double> >("EBCorrNoiseMatrixG01");
00087 const std::vector<double> eeCorMatG01 = params.getParameter< std::vector<double> >("EECorrNoiseMatrixG01");
00088 const bool applyConstantTerm = params.getParameter<bool> ("applyConstantTerm");
00089 const double rmsConstantTerm = params.getParameter<double> ("ConstantTerm");
00090 const bool addESNoise = params.getParameter<bool> ("doESNoise");
00091 const int numESdetId = params.getParameter<int> ("numESdetId");
00092 m_doFast = params.getParameter<bool> ("doFast");
00093 m_EBs25notCont = params.getParameter<double> ("EBs25notContainment");
00094 m_EEs25notCont = params.getParameter<double> ("EEs25notContainment");
00095 m_hitsProducerTag = params.getParameter<std::string>("hitsProducer");
00096
00097 const bool apdAddToBarrel ( params.getParameter<bool> ("apdAddToBarrel") ) ;
00098 const bool apdSeparateDigi ( params.getParameter<bool> ("apdSeparateDigi") ) ;
00099 const double apdSimToPELow ( params.getParameter<double> ("apdSimToPELow" ) ) ;
00100 const double apdSimToPEHigh ( params.getParameter<double> ("apdSimToPEHigh") ) ;
00101 const double apdTimeOffset ( params.getParameter<double> ("apdTimeOffset" ) ) ;
00102 const double apdTimeOffWidth ( params.getParameter<double> ("apdTimeOffWidth" ) ) ;
00103 const bool apdDoPEStats ( params.getParameter<bool> ("apdDoPEStats" ) ) ;
00104 const std::string apdDigiTag ( params.getParameter<std::string>("apdDigiTag") ) ;
00105
00106
00107
00108 if( apdSeparateDigi ) produces<EBDigiCollection>( apdDigiTag ) ;
00109 produces<EBDigiCollection>( m_EBdigiCollection ) ;
00110 produces<EEDigiCollection>( m_EEdigiCollection ) ;
00111 produces<ESDigiCollection>( m_ESdigiCollection ) ;
00112
00113
00114
00115 m_ParameterMap = new EcalSimParameterMap( simHitToPhotoelectronsBarrel ,
00116 simHitToPhotoelectronsEndcap ,
00117 photoelectronsToAnalogBarrel ,
00118 photoelectronsToAnalogEndcap ,
00119 samplingFactor ,
00120 timePhase ,
00121 readoutFrameSize ,
00122 binOfMaximum ,
00123 doPhotostatistics ,
00124 syncPhase ) ;
00125
00126 m_apdParameters = new APDSimParameters( apdAddToBarrel ,
00127 apdSeparateDigi ,
00128 apdSimToPELow ,
00129 apdSimToPEHigh ,
00130 apdTimeOffset ,
00131 apdTimeOffWidth ,
00132 apdDoPEStats ,
00133 apdDigiTag ) ;
00134
00135
00136
00137 if( apdSeparateDigi )
00138 m_APDResponse = new EBHitResponse( m_ParameterMap ,
00139 &m_EBShape ,
00140 true ,
00141 m_apdParameters ,
00142 &m_APDShape ) ;
00143
00144 m_EBResponse = new EBHitResponse( m_ParameterMap ,
00145 &m_EBShape ,
00146 false ,
00147 m_apdParameters ,
00148 &m_APDShape ) ;
00149
00150 m_EEResponse = new CaloHitRespoNew( m_ParameterMap, &m_EEShape ) ;
00151 m_ESResponse = new CaloHitResponse( m_ParameterMap, m_ESShape ) ;
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() == readoutFrameSize ) ;
00164 assert( eeCorMatG12.size() == readoutFrameSize ) ;
00165 assert( ebCorMatG06.size() == readoutFrameSize ) ;
00166 assert( eeCorMatG06.size() == readoutFrameSize ) ;
00167 assert( ebCorMatG01.size() == readoutFrameSize ) ;
00168 assert( eeCorMatG01.size() == 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 != 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
00218 if( apdSeparateDigi )
00219 {
00220 m_APDCoder = new EcalCoder( false ,
00221 m_EBCorrNoise[0] ,
00222 m_EECorrNoise[0] ,
00223 m_EBCorrNoise[1] ,
00224 m_EECorrNoise[1] ,
00225 m_EBCorrNoise[2] ,
00226 m_EECorrNoise[2] ) ;
00227
00228 m_APDElectronicsSim = new EcalElectronicsSim( m_ParameterMap ,
00229 m_APDCoder ,
00230 applyConstantTerm ,
00231 rmsConstantTerm ) ;
00232
00233 m_APDDigitizer = new EBDigitizer( m_APDResponse ,
00234 m_APDElectronicsSim ,
00235 false ) ;
00236 }
00237
00238 m_BarrelDigitizer = new EBDigitizer( m_EBResponse ,
00239 m_ElectronicsSim ,
00240 addNoise ) ;
00241
00242 m_EndcapDigitizer = new EEDigitizer( m_EEResponse ,
00243 m_ElectronicsSim ,
00244 addNoise ) ;
00245
00246 if( !m_doFast )
00247 {
00248 m_ESElectronicsSim = new ESElectronicsSim( addESNoise ) ;
00249
00250 m_ESDigitizer = new ESDigitizer( m_ESResponse ,
00251 m_ESElectronicsSim ,
00252 addESNoise );
00253 }
00254 else
00255 {
00256 m_ESElectronicsSimFast = new ESElectronicsSimFast( addESNoise ) ;
00257
00258 m_ESDigitizerFast = new ESFastTDigitizer( m_ESResponse ,
00259 m_ESElectronicsSimFast ,
00260 addESNoise ,
00261 numESdetId ) ;
00262 }
00263 }
00264
00265 EcalDigiProducer::~EcalDigiProducer()
00266 {
00267 delete m_APDDigitizer ;
00268 delete m_BarrelDigitizer ;
00269 delete m_EndcapDigitizer ;
00270 delete m_ESDigitizer ;
00271 delete m_ESDigitizerFast ;
00272 delete m_ParameterMap ;
00273 delete m_ESShape ;
00274 delete m_APDResponse ;
00275 delete m_EBResponse ;
00276 delete m_EEResponse ;
00277 delete m_ESResponse ;
00278 delete m_EBCorrNoise[0] ;
00279 delete m_EECorrNoise[0] ;
00280 delete m_EBCorrNoise[1] ;
00281 delete m_EECorrNoise[1] ;
00282 delete m_EBCorrNoise[2] ;
00283 delete m_EECorrNoise[2] ;
00284 delete m_ElectronicsSim ;
00285 delete m_ESElectronicsSim ;
00286 delete m_ESElectronicsSimFast ;
00287 delete m_Coder ;
00288 delete m_APDElectronicsSim ;
00289 delete m_APDCoder ;
00290 delete m_apdParameters ;
00291 }
00292
00293 void
00294 EcalDigiProducer::produce( edm::Event& event ,
00295 const edm::EventSetup& eventSetup )
00296 {
00297
00298
00299 checkGeometry( eventSetup );
00300 checkCalibrations( eventSetup );
00301
00302
00303 edm::Handle<CrossingFrame<PCaloHit> > crossingFrame;
00304
00305
00306 const std::string barrelHitsName ( m_hitsProducerTag + "EcalHitsEB" ) ;
00307 const std::string endcapHitsName ( m_hitsProducerTag + "EcalHitsEE" ) ;
00308 const std::string preshowerHitsName ( m_hitsProducerTag + "EcalHitsES" ) ;
00309
00310 event.getByLabel( "mix",
00311 barrelHitsName ,
00312 crossingFrame ) ;
00313
00314 MixCollection<PCaloHit>* EBHits (
00315 !crossingFrame.isValid() ? 0 :
00316 new MixCollection<PCaloHit>( crossingFrame.product() ) ) ;
00317
00318 const bool isEB ( crossingFrame.isValid() &&
00319 0 != EBHits &&
00320 EBHits->inRegistry() ) ;
00321
00322 if( !crossingFrame.isValid() )
00323 edm::LogError("EcalDigiProducer") << "Error! can't get the product "
00324 << barrelHitsName.c_str() ;
00325
00326 event.getByLabel( "mix",
00327 endcapHitsName ,
00328 crossingFrame ) ;
00329
00330 MixCollection<PCaloHit>* EEHits (
00331 !crossingFrame.isValid() ? 0 :
00332 new MixCollection<PCaloHit>( crossingFrame.product() ) ) ;
00333
00334 const bool isEE ( crossingFrame.isValid() &&
00335 0 != EEHits &&
00336 EEHits->inRegistry() ) ;
00337
00338 if( !crossingFrame.isValid() )
00339 edm::LogError("EcalDigiProducer") << "Error! can't get the product "
00340 << endcapHitsName.c_str() ;
00341
00342 event.getByLabel( "mix",
00343 preshowerHitsName ,
00344 crossingFrame ) ;
00345
00346 MixCollection<PCaloHit>* ESHits (
00347 !crossingFrame.isValid() ? 0 :
00348 new MixCollection<PCaloHit>( crossingFrame.product() ) ) ;
00349
00350 const bool isES ( crossingFrame.isValid() &&
00351 0 != ESHits &&
00352 ESHits->inRegistry() ) ;
00353
00354 if( !crossingFrame.isValid() )
00355 edm::LogError("EcalDigiProducer") << "Error! can't get the product "
00356 << preshowerHitsName.c_str() ;
00357
00358 const bool apdSeparateDigi ( 0 != m_APDResponse ) ;
00359
00360
00361 std::auto_ptr<EBDigiCollection> apdResult ( !apdSeparateDigi ? 0 :
00362 new EBDigiCollection() ) ;
00363 std::auto_ptr<EBDigiCollection> barrelResult ( new EBDigiCollection() ) ;
00364 std::auto_ptr<EEDigiCollection> endcapResult ( new EEDigiCollection() ) ;
00365 std::auto_ptr<ESDigiCollection> preshowerResult( new ESDigiCollection() ) ;
00366
00367
00368
00369 if( isEB )
00370 {
00371 std::auto_ptr<MixCollection<PCaloHit> > barrelHits( EBHits ) ;
00372 m_BarrelDigitizer->run( *barrelHits ,
00373 *barrelResult ) ;
00374
00375 edm::LogInfo("DigiInfo") << "EB Digis: " << barrelResult->size() ;
00376
00377 if( apdSeparateDigi )
00378 {
00379 m_APDDigitizer->run( *barrelHits ,
00380 *apdResult ) ;
00381
00382 edm::LogInfo("DigiInfo") << "APD Digis: " << apdResult->size() ;
00383 }
00384 }
00385
00386 if( isEE )
00387 {
00388 std::auto_ptr<MixCollection<PCaloHit> > endcapHits( EEHits ) ;
00389 m_EndcapDigitizer->run( *endcapHits ,
00390 *endcapResult ) ;
00391 edm::LogInfo("EcalDigi") << "EE Digis: " << endcapResult->size() ;
00392 }
00393
00394 if( isES )
00395 {
00396 std::auto_ptr<MixCollection<PCaloHit> > preshowerHits( ESHits ) ;
00397 if (!m_doFast)
00398 {
00399 m_ESDigitizer->run( *preshowerHits ,
00400 *preshowerResult ) ;
00401 }
00402 else
00403 {
00404 m_ESDigitizerFast->run(*preshowerHits, *preshowerResult);
00405 }
00406 edm::LogInfo("EcalDigi") << "ES Digis: " << preshowerResult->size();
00407 }
00408
00409 const std::string& apdDigiTag ( m_apdParameters->digiTag() ) ;
00410
00411
00412 if( apdSeparateDigi )
00413 event.put( apdResult, apdDigiTag ) ;
00414 event.put( barrelResult, m_EBdigiCollection ) ;
00415 event.put( endcapResult, m_EEdigiCollection ) ;
00416 event.put( preshowerResult, m_ESdigiCollection ) ;
00417
00418 }
00419
00420 void
00421 EcalDigiProducer::checkCalibrations( const edm::EventSetup& eventSetup )
00422 {
00423
00424
00425 edm::ESHandle<EcalPedestals> dbPed ;
00426 eventSetup.get<EcalPedestalsRcd>().get( dbPed ) ;
00427 const EcalPedestals* pedestals ( dbPed.product() ) ;
00428
00429 m_Coder->setPedestals( pedestals ) ;
00430 if( 0 != m_APDCoder ) m_APDCoder->setPedestals( pedestals ) ;
00431
00432
00433 edm::ESHandle<EcalIntercalibConstantsMC> pIcal ;
00434 eventSetup.get<EcalIntercalibConstantsMCRcd>().get( pIcal ) ;
00435 const EcalIntercalibConstantsMC* ical ( pIcal.product() ) ;
00436
00437 m_Coder->setIntercalibConstants( ical ) ;
00438 if( 0 != m_APDCoder) m_APDCoder->setIntercalibConstants( ical ) ;
00439
00440 m_EBResponse->setIntercal( ical ) ;
00441 if( 0 != m_APDResponse ) m_APDResponse->setIntercal( ical ) ;
00442
00443
00444 edm::ESHandle<EcalADCToGeVConstant> pAgc;
00445 eventSetup.get<EcalADCToGeVConstantRcd>().get(pAgc);
00446 const EcalADCToGeVConstant* agc = pAgc.product();
00447
00448
00449 edm::ESHandle<EcalGainRatios> pRatio;
00450 eventSetup.get<EcalGainRatiosRcd>().get(pRatio);
00451 const EcalGainRatios* gr = pRatio.product();
00452
00453 m_Coder->setGainRatios( gr );
00454 if( 0 != m_APDCoder) m_APDCoder->setGainRatios( gr );
00455
00456 EcalMGPAGainRatio * defaultRatios = new EcalMGPAGainRatio();
00457
00458 double theGains[m_Coder->NGAINS+1];
00459 theGains[0] = 0.;
00460 theGains[3] = 1.;
00461 theGains[2] = defaultRatios->gain6Over1() ;
00462 theGains[1] = theGains[2]*(defaultRatios->gain12Over6()) ;
00463
00464 LogDebug("EcalDigi") << " Gains: " << "\n" << " g1 = " << theGains[1]
00465 << "\n" << " g2 = " << theGains[2]
00466 << "\n" << " g3 = " << theGains[3] ;
00467
00468 delete defaultRatios;
00469
00470 const double EBscale (
00471 ( agc->getEBValue())*theGains[1]*(m_Coder->MAXADC)*m_EBs25notCont ) ;
00472
00473 LogDebug("EcalDigi") << " GeV/ADC = " << agc->getEBValue()
00474 << "\n" << " notCont = " << m_EBs25notCont
00475 << "\n" << " saturation for EB = " << EBscale
00476 << ", " << m_EBs25notCont ;
00477
00478 const double EEscale (
00479 (agc->getEEValue())*theGains[1]*(m_Coder->MAXADC)*m_EEs25notCont ) ;
00480
00481 LogDebug("EcalDigi") << " GeV/ADC = " << agc->getEEValue()
00482 << "\n" << " notCont = " << m_EEs25notCont
00483 << "\n" << " saturation for EB = " << EEscale
00484 << ", " << m_EEs25notCont ;
00485
00486 m_Coder->setFullScaleEnergy( EBscale ,
00487 EEscale ) ;
00488 if( 0 != m_APDCoder ) m_APDCoder->setFullScaleEnergy( EBscale ,
00489 EEscale ) ;
00490
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_doFast )
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_ESDigitizerFast->setGain( ESGain ) ;
00524 m_ESElectronicsSimFast->setGain( ESGain ) ;
00525 m_ESElectronicsSimFast->setPedestals( espeds ) ;
00526 m_ESElectronicsSimFast->setMIPs( esmips ) ;
00527 m_ESElectronicsSimFast->setMIPToGeV( ESMIPToGeV ) ;
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( m_Geometry ) ;
00557
00558
00559
00560 const std::vector<DetId>& theESDets (
00561 m_Geometry->getSubdetectorGeometry(
00562 DetId::Ecal, EcalPreshower)->getValidDetIds() ) ;
00563
00564 if( !m_doFast )
00565 {
00566 m_ESDigitizer->setDetIds( theESDets ) ;
00567 }
00568 else
00569 {
00570 m_ESDigitizerFast->setDetIds( theESDets ) ;
00571 }
00572 }