Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-11-07 23:57:48

0001 #include "FWCore/Framework/interface/Frameworkfwd.h"
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0004 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0005 #include "FWCore/ServiceRegistry/interface/Service.h"
0006 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
0007 #include "CalibTracker/SiStripQuality/interface/SiStripQualityWithFromFedErrorsHelper.h"
0008 #include "DQMServices/Core/interface/DQMEDHarvester.h"
0009 #include "CondFormats/SiStripObjects/interface/SiStripBadStrip.h"
0010 
0011 class SiStripBadStripFromQualityDBWriter : public DQMEDHarvester {
0012 public:
0013   explicit SiStripBadStripFromQualityDBWriter(const edm::ParameterSet&);
0014   ~SiStripBadStripFromQualityDBWriter() override {}
0015 
0016   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0017 
0018   void endRun(edm::Run const&, edm::EventSetup const&) override;
0019   void dqmEndJob(DQMStore::IBooker&, DQMStore::IGetter&) override;
0020 
0021 private:
0022   std::string rcdName_, openIOVAt_;
0023   uint32_t openIOVAtTime_;
0024   SiStripQualityWithFromFedErrorsHelper withFedErrHelper_;
0025 };
0026 
0027 SiStripBadStripFromQualityDBWriter::SiStripBadStripFromQualityDBWriter(const edm::ParameterSet& iConfig)
0028     : rcdName_{iConfig.getParameter<std::string>("record")},
0029       openIOVAt_{iConfig.getUntrackedParameter<std::string>("OpenIovAt", "beginOfTime")},
0030       openIOVAtTime_{iConfig.getUntrackedParameter<uint32_t>("OpenIovAtTime", 1)},
0031       withFedErrHelper_{iConfig, consumesCollector(), true} {}
0032 
0033 void SiStripBadStripFromQualityDBWriter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0034   edm::ParameterSetDescription desc;
0035   desc.add<std::string>("record", "");
0036   desc.addUntracked<std::string>("OpenIovAt", "beginOfTime");
0037   desc.addUntracked<uint32_t>("OpenIovAtTime", 1);
0038   SiStripQualityWithFromFedErrorsHelper::fillDescription(desc);
0039   descriptions.add("siStripBadStripFromQualityDBWriter", desc);
0040 }
0041 
0042 void SiStripBadStripFromQualityDBWriter::endRun(edm::Run const& /*run*/, edm::EventSetup const& iSetup) {
0043   withFedErrHelper_.endRun(iSetup);
0044 }
0045 
0046 void SiStripBadStripFromQualityDBWriter::dqmEndJob(DQMStore::IBooker& /*booker*/, DQMStore::IGetter& getter) {
0047   auto payload = std::make_unique<SiStripBadStrip>(withFedErrHelper_.getMergedQuality(getter));
0048   cond::Time_t time;
0049   edm::Service<cond::service::PoolDBOutputService> dbservice;
0050   if (dbservice.isAvailable()) {
0051     if (openIOVAt_ == "beginOfTime")
0052       time = dbservice->beginOfTime();
0053     else if (openIOVAt_ == "currentTime")
0054       time = dbservice->currentTime();
0055     else
0056       time = openIOVAtTime_;
0057 
0058     dbservice->writeOneIOV(*payload, time, rcdName_);
0059   } else {
0060     edm::LogError("SiStripBadStripFromQualityDBWriter") << "Service is unavailable" << std::endl;
0061   }
0062 }
0063 
0064 #include "FWCore/Framework/interface/MakerMacros.h"
0065 #include "FWCore/Framework/interface/ModuleFactory.h"
0066 DEFINE_FWK_MODULE(SiStripBadStripFromQualityDBWriter);