From e1c8b0adac3351408aea11b28189ad3a9a919758 Mon Sep 17 00:00:00 2001 From: francescobrivio Date: Tue, 16 Nov 2021 22:40:28 +0100 Subject: [PATCH] Migrate HLTPrescaleRecorder and AlignPCLThresholdsWriter to new `PoolDBOutputService` methods --- .../plugins/AlignPCLThresholdsWriter.cc | 22 +++++++++---------- .../HLTcore/plugins/HLTPrescaleRecorder.cc | 18 +++++---------- 2 files changed, 15 insertions(+), 25 deletions(-) diff --git a/CondFormats/PCLConfig/plugins/AlignPCLThresholdsWriter.cc b/CondFormats/PCLConfig/plugins/AlignPCLThresholdsWriter.cc index 62655fad84a9f..8fcd8104f202a 100644 --- a/CondFormats/PCLConfig/plugins/AlignPCLThresholdsWriter.cc +++ b/CondFormats/PCLConfig/plugins/AlignPCLThresholdsWriter.cc @@ -54,7 +54,6 @@ class AlignPCLThresholdsWriter : public edm::one::EDAnalyzer<> { const std::string m_record; const unsigned int m_minNrecords; const std::vector m_parameters; - AlignPCLThresholds* myThresholds; }; // @@ -63,12 +62,9 @@ class AlignPCLThresholdsWriter : public edm::one::EDAnalyzer<> { AlignPCLThresholdsWriter::AlignPCLThresholdsWriter(const edm::ParameterSet& iConfig) : m_record(iConfig.getParameter("record")), m_minNrecords(iConfig.getParameter("minNRecords")), - m_parameters(iConfig.getParameter >("thresholds")) { - //now do what ever initialization is needed - myThresholds = new AlignPCLThresholds(); -} + m_parameters(iConfig.getParameter >("thresholds")) {} -AlignPCLThresholdsWriter::~AlignPCLThresholdsWriter() { delete myThresholds; } +AlignPCLThresholdsWriter::~AlignPCLThresholdsWriter() = default; // // member functions @@ -78,7 +74,9 @@ AlignPCLThresholdsWriter::~AlignPCLThresholdsWriter() { delete myThresholds; } void AlignPCLThresholdsWriter::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { using namespace edm; - edm::LogInfo("AlignPCLThresholdsWriter") << "Size of AlignPCLThresholds object " << myThresholds->size() << std::endl + AlignPCLThresholds myThresholds{}; + + edm::LogInfo("AlignPCLThresholdsWriter") << "Size of AlignPCLThresholds object " << myThresholds.size() << std::endl << std::endl; // loop on the PSet and insert the conditions @@ -149,14 +147,14 @@ void AlignPCLThresholdsWriter::analyze(const edm::Event& iEvent, const edm::Even } AlignPCLThreshold a(my_X, my_tX, my_Y, my_tY, my_Z, my_tZ, extraDOFs); - myThresholds->setAlignPCLThreshold(alignableId, a); + myThresholds.setAlignPCLThreshold(alignableId, a); } // if alignable is found in the PSet } // loop on the PSets // checks if all mandatories are present edm::LogInfo("AlignPCLThresholdsWriter") - << "Size of AlignPCLThresholds object " << myThresholds->size() << std::endl; + << "Size of AlignPCLThresholds object " << myThresholds.size() << std::endl; for (auto& mandatory : mandatories) { if (std::find(presentDOF.begin(), presentDOF.end(), mandatory) == presentDOF.end()) { edm::LogWarning("AlignPCLThresholdsWriter") @@ -168,18 +166,18 @@ void AlignPCLThresholdsWriter::analyze(const edm::Event& iEvent, const edm::Even } // ends loop on the alignable units // set the minimum number of records to be used in pede - myThresholds->setNRecords(m_minNrecords); + myThresholds.setNRecords(m_minNrecords); edm::LogInfo("AlignPCLThresholdsWriter") << "Content of AlignPCLThresholds " << std::endl; // use buil-in method in the CondFormat - myThresholds->printAll(); + myThresholds.printAll(); // Form the data here edm::Service poolDbService; if (poolDbService.isAvailable()) { cond::Time_t valid_time = poolDbService->currentTime(); // this writes the payload to begin in current run defined in cfg - poolDbService->writeOneIOV(*myThresholds, valid_time, m_record); + poolDbService->writeOneIOV(myThresholds, valid_time, m_record); } } diff --git a/HLTrigger/HLTcore/plugins/HLTPrescaleRecorder.cc b/HLTrigger/HLTcore/plugins/HLTPrescaleRecorder.cc index 2a4b51dde3282..013e07d219b53 100644 --- a/HLTrigger/HLTcore/plugins/HLTPrescaleRecorder.cc +++ b/HLTrigger/HLTcore/plugins/HLTPrescaleRecorder.cc @@ -231,19 +231,11 @@ void HLTPrescaleRecorder::endRun(edm::Run const& iRun, const edm::EventSetup& iS if (condDB_) { /// Writing to CondDB (needs PoolDBOutputService) if (db_ != nullptr) { - auto product(new HLTPrescaleTableCond(hlt_)); - const string rcdName("HLTPrescaleTableRcd"); - if (db_->isNewTagRequest(rcdName)) { - db_->createNewIOV(product, db_->beginOfTime(), db_->endOfTime(), rcdName); - } else { - ::timeval tv; - gettimeofday(&tv, nullptr); - edm::Timestamp tstamp((unsigned long long)tv.tv_sec); - db_->appendSinceTime(product, - // db_->currentTime() - tstamp.value(), - rcdName); - } + HLTPrescaleTableCond product(hlt_); + ::timeval tv; + gettimeofday(&tv, nullptr); + edm::Timestamp tstamp((unsigned long long)tv.tv_sec); + db_->writeOneIOV(product, tstamp.value(), "HLTPrescaleTableRcd"); } else { LogError("HLTPrescaleRecorder") << "PoolDBOutputService not available!"; }