Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-22 01:53:18

0001 /****************************************************************************
0002  *
0003  * This is a part of TOTEM/PPS offline software.
0004  * Author:
0005  *   Laurent Forthomme (laurent.forthomme@cern.ch)
0006  *   Christopher Misan
0007  *
0008  ****************************************************************************/
0009 
0010 #include "FWCore/Framework/interface/Frameworkfwd.h"
0011 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0012 #include "FWCore/Framework/interface/Event.h"
0013 #include "FWCore/Framework/interface/EventSetup.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/PPSTimingCalibrationLUT.h"
0022 #include "CondFormats/DataRecord/interface/PPSTimingCalibrationLUTRcd.h"
0023 
0024 #include <memory>
0025 
0026 class PPSTimingCalibrationLUTWriter : public edm::one::EDAnalyzer<> {
0027 public:
0028   explicit PPSTimingCalibrationLUTWriter(const edm::ParameterSet&)
0029       : tokenCalibration_(esConsumes<PPSTimingCalibrationLUT, PPSTimingCalibrationLUTRcd>()) {}
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<PPSTimingCalibrationLUT, PPSTimingCalibrationLUTRcd> tokenCalibration_;
0037 };
0038 
0039 void PPSTimingCalibrationLUTWriter::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(), "PPSTimingCalibrationLUTRcd");
0046   else
0047     throw cms::Exception("PPSTimingCalibrationLUTWriter") << "PoolDBService required.";
0048 }
0049 
0050 DEFINE_FWK_MODULE(PPSTimingCalibrationLUTWriter);