File indexing completed on 2024-04-06 12:02:43
0001 #include <memory>
0002 #include <string>
0003 #include <iostream>
0004 #include <sstream>
0005 #include "FWCore/Framework/interface/Frameworkfwd.h"
0006 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0007 #include "FWCore/Framework/interface/Event.h"
0008 #include "FWCore/Framework/interface/MakerMacros.h"
0009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0010 #include "FWCore/ServiceRegistry/interface/Service.h"
0011 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
0012 #include "CondFormats/BTauObjects/interface/BTagCalibration.h"
0013
0014 class BTagCalibrationDbCreator : public edm::one::EDAnalyzer<> {
0015 public:
0016 BTagCalibrationDbCreator(const edm::ParameterSet&);
0017 void beginJob() override;
0018 void analyze(const edm::Event&, const edm::EventSetup&) override {}
0019 void endJob() override {}
0020 ~BTagCalibrationDbCreator() override {}
0021
0022 private:
0023 std::string csvFile_;
0024 std::string tagger_;
0025 };
0026
0027 BTagCalibrationDbCreator::BTagCalibrationDbCreator(const edm::ParameterSet& p)
0028 : csvFile_(p.getUntrackedParameter<std::string>("csvFile")),
0029 tagger_(p.getUntrackedParameter<std::string>("tagger")) {}
0030
0031 void BTagCalibrationDbCreator::beginJob() {
0032 BTagCalibration calib(tagger_, csvFile_, true);
0033 edm::Service<cond::service::PoolDBOutputService> s;
0034 if (s.isAvailable()) {
0035 s->writeOneIOV(calib, s->beginOfTime(), tagger_);
0036 } else {
0037 std::cout << "ERROR: DB service not available" << std::endl;
0038 }
0039 }
0040
0041 DEFINE_FWK_MODULE(BTagCalibrationDbCreator);