Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-11-13 03:30:44

0001 // -*- C++ -*-
0002 //
0003 // Description: Fill in time bias record from an old configuration file.
0004 // Original Author:  Dmitrijus Bugelskis
0005 //         Created:  Thu, 14 Nov 2013 17:44:11 GMT
0006 //
0007 
0008 #include <memory>
0009 
0010 #include "FWCore/Framework/interface/Frameworkfwd.h"
0011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0012 
0013 #include "FWCore/Framework/interface/ModuleFactory.h"
0014 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0015 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0016 #include "FWCore/Framework/interface/ESProducts.h"
0017 
0018 #include "CondFormats/EcalObjects/interface/EcalTimeBiasCorrections.h"
0019 
0020 #include "CondCore/CondDB/interface/Serialization.h"
0021 #include "CondFormats/External/interface/EcalDetID.h"
0022 #include "CondFormats/External/interface/SMatrix.h"
0023 #include "CondFormats/External/interface/Timestamp.h"
0024 
0025 #include "CondFormats/DataRecord/interface/EcalTimeBiasCorrectionsRcd.h"
0026 
0027 #include "FWCore/ServiceRegistry/interface/Service.h"
0028 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
0029 
0030 class EcalTimeBiasCorrectionsFillInitial : public edm::one::EDAnalyzer<> {
0031 public:
0032   explicit EcalTimeBiasCorrectionsFillInitial(const edm::ParameterSet &);
0033   ~EcalTimeBiasCorrectionsFillInitial();
0034 
0035   void analyze(const edm::Event &, const edm::EventSetup &);
0036   void endJob();
0037 
0038 private:
0039   std::vector<double> EBtimeCorrAmplitudeBins_;
0040   std::vector<double> EBtimeCorrShiftBins_;
0041   std::vector<double> EEtimeCorrAmplitudeBins_;
0042   std::vector<double> EEtimeCorrShiftBins_;
0043 
0044   EcalTimeBiasCorrections bias_;
0045 };
0046 
0047 EcalTimeBiasCorrectionsFillInitial::EcalTimeBiasCorrectionsFillInitial(const edm::ParameterSet &ps) {
0048   EBtimeCorrAmplitudeBins_ = ps.getParameter<std::vector<double> >("EBtimeCorrAmplitudeBins");
0049   EBtimeCorrShiftBins_ = ps.getParameter<std::vector<double> >("EBtimeCorrShiftBins");
0050   EEtimeCorrAmplitudeBins_ = ps.getParameter<std::vector<double> >("EEtimeCorrAmplitudeBins");
0051   EEtimeCorrShiftBins_ = ps.getParameter<std::vector<double> >("EEtimeCorrShiftBins");
0052 
0053   if (EBtimeCorrAmplitudeBins_.size() != EBtimeCorrShiftBins_.size()) {
0054     edm::LogError("EcalRecHitError") << "Size of EBtimeCorrAmplitudeBins "
0055                                         "different from EBtimeCorrShiftBins.";
0056   }
0057 
0058   if (EEtimeCorrAmplitudeBins_.size() != EEtimeCorrShiftBins_.size()) {
0059     edm::LogError("EcalRecHitError") << "Size of EEtimeCorrAmplitudeBins "
0060                                         "different from EEtimeCorrShiftBins.";
0061   }
0062 
0063   copy(EBtimeCorrAmplitudeBins_.begin(), EBtimeCorrAmplitudeBins_.end(), back_inserter(bias_.EBTimeCorrAmplitudeBins));
0064 
0065   copy(EBtimeCorrShiftBins_.begin(), EBtimeCorrShiftBins_.end(), back_inserter(bias_.EBTimeCorrShiftBins));
0066 
0067   copy(EEtimeCorrAmplitudeBins_.begin(), EEtimeCorrAmplitudeBins_.end(), back_inserter(bias_.EETimeCorrAmplitudeBins));
0068 
0069   copy(EEtimeCorrShiftBins_.begin(), EEtimeCorrShiftBins_.end(), back_inserter(bias_.EETimeCorrShiftBins));
0070 }
0071 
0072 EcalTimeBiasCorrectionsFillInitial::~EcalTimeBiasCorrectionsFillInitial() {}
0073 
0074 void EcalTimeBiasCorrectionsFillInitial::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) {}
0075 void EcalTimeBiasCorrectionsFillInitial::endJob() {
0076   edm::Service<cond::service::PoolDBOutputService> poolDbService;
0077   if (poolDbService.isAvailable()) {
0078     poolDbService->writeOneIOV(bias_, poolDbService->beginOfTime(), "EcalTimeBiasCorrectionsRcd");
0079   }
0080 }
0081 
0082 #include "FWCore/Framework/interface/MakerMacros.h"
0083 DEFINE_FWK_MODULE(EcalTimeBiasCorrectionsFillInitial);