Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:37:37

0001 /****************************************************************************
0002  *
0003  * This is a part of TOTEM/PPS offline software.
0004  * Author:
0005  *   Laurent Forthomme (laurent.forthomme@cern.ch)
0006  *
0007  ****************************************************************************/
0008 
0009 #include "FWCore/Framework/interface/Frameworkfwd.h"
0010 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0011 #include "FWCore/Framework/interface/Event.h"
0012 #include "FWCore/Framework/interface/EventSetup.h"
0013 #include "FWCore/Framework/interface/ESHandle.h"
0014 #include "FWCore/Framework/interface/MakerMacros.h"
0015 
0016 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0017 #include "FWCore/ServiceRegistry/interface/Service.h"
0018 
0019 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
0020 
0021 #include "CondFormats/PPSObjects/interface/PPSTimingCalibration.h"
0022 #include "CondFormats/DataRecord/interface/PPSTimingCalibrationRcd.h"
0023 
0024 #include <memory>
0025 
0026 class PPSTimingCalibrationWriter : public edm::one::EDAnalyzer<> {
0027 public:
0028   explicit PPSTimingCalibrationWriter(const edm::ParameterSet&)
0029       : tokenCalibration_(esConsumes<PPSTimingCalibration, PPSTimingCalibrationRcd>()) {}
0030 
0031 private:
0032   void beginJob() override {}
0033   void analyze(const edm::Event&, const edm::EventSetup&) override;
0034   void endJob() override {}
0035 
0036   edm::ESGetToken<PPSTimingCalibration, PPSTimingCalibrationRcd> tokenCalibration_;
0037 };
0038 
0039 void PPSTimingCalibrationWriter::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0040   // get timing calibration parameters
0041   const auto& hTimingCalib = iSetup.getData(tokenCalibration_);
0042   // store the calibration into a DB object
0043   edm::Service<cond::service::PoolDBOutputService> poolDbService;
0044   if (poolDbService.isAvailable())
0045     poolDbService->writeOneIOV(hTimingCalib, poolDbService->currentTime(), "PPSTimingCalibrationRcd");
0046   else
0047     throw cms::Exception("PPSTimingCalibrationWriter") << "PoolDBService required.";
0048 }
0049 
0050 DEFINE_FWK_MODULE(PPSTimingCalibrationWriter);