Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate HLTPrescaleRecorder and AlignPCLThresholdsWriter to new PoolDBOutputService methods #36142

Merged
merged 1 commit into from Nov 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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();
francescobrivio marked this conversation as resolved.
Show resolved Hide resolved
}
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
francescobrivio marked this conversation as resolved.
Show resolved Hide resolved
<< 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