Skip to content

Commit

Permalink
Merge pull request #36142 from francescobrivio/alca-PoolDBOutputMigra…
Browse files Browse the repository at this point in the history
…tion

Migrate HLTPrescaleRecorder and AlignPCLThresholdsWriter to new `PoolDBOutputService` methods
  • Loading branch information
cmsbuild committed Nov 17, 2021
2 parents 9e3204e + e1c8b0a commit 2792782
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 25 deletions.
22 changes: 10 additions & 12 deletions CondFormats/PCLConfig/plugins/AlignPCLThresholdsWriter.cc
Expand Up @@ -54,7 +54,6 @@ class AlignPCLThresholdsWriter : public edm::one::EDAnalyzer<> {
const std::string m_record;
const unsigned int m_minNrecords;
const std::vector<edm::ParameterSet> m_parameters;
AlignPCLThresholds* myThresholds;
};

//
Expand All @@ -63,12 +62,9 @@ class AlignPCLThresholdsWriter : public edm::one::EDAnalyzer<> {
AlignPCLThresholdsWriter::AlignPCLThresholdsWriter(const edm::ParameterSet& iConfig)
: m_record(iConfig.getParameter<std::string>("record")),
m_minNrecords(iConfig.getParameter<unsigned int>("minNRecords")),
m_parameters(iConfig.getParameter<std::vector<edm::ParameterSet> >("thresholds")) {
//now do what ever initialization is needed
myThresholds = new AlignPCLThresholds();
}
m_parameters(iConfig.getParameter<std::vector<edm::ParameterSet> >("thresholds")) {}

AlignPCLThresholdsWriter::~AlignPCLThresholdsWriter() { delete myThresholds; }
AlignPCLThresholdsWriter::~AlignPCLThresholdsWriter() = default;

//
// member functions
Expand All @@ -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
Expand Down Expand Up @@ -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")
Expand All @@ -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<cond::service::PoolDBOutputService> 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);
}
}

Expand Down
18 changes: 5 additions & 13 deletions HLTrigger/HLTcore/plugins/HLTPrescaleRecorder.cc
Expand Up @@ -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<HLTPrescaleTableCond>(product, db_->beginOfTime(), db_->endOfTime(), rcdName);
} else {
::timeval tv;
gettimeofday(&tv, nullptr);
edm::Timestamp tstamp((unsigned long long)tv.tv_sec);
db_->appendSinceTime<HLTPrescaleTableCond>(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!";
}
Expand Down

0 comments on commit 2792782

Please sign in to comment.