From d142193bc2ce191834fb64419eba2041a18a443a Mon Sep 17 00:00:00 2001 From: Mateusz Date: Tue, 6 Sep 2022 16:35:53 +0200 Subject: [PATCH] Fixed RP ids Now the harvester saves an SQLite file containing long RP ids. --- .../plugins/PPSAlignmentHarvester.cc | 40 +++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/CalibPPS/AlignmentGlobal/plugins/PPSAlignmentHarvester.cc b/CalibPPS/AlignmentGlobal/plugins/PPSAlignmentHarvester.cc index bf5c86809019c..0e694913f6ab5 100644 --- a/CalibPPS/AlignmentGlobal/plugins/PPSAlignmentHarvester.cc +++ b/CalibPPS/AlignmentGlobal/plugins/PPSAlignmentHarvester.cc @@ -16,6 +16,8 @@ #include "CondCore/DBOutputService/interface/PoolDBOutputService.h" +#include "DataFormats/CTPPSDetId/interface/CTPPSDetId.h" + #include "CondFormats/PPSObjects/interface/CTPPSRPAlignmentCorrectionData.h" #include "CondFormats/PPSObjects/interface/CTPPSRPAlignmentCorrectionsData.h" #include "CondFormats/DataRecord/interface/CTPPSRPAlignmentCorrectionsDataRcd.h" @@ -109,6 +111,8 @@ class PPSAlignmentHarvester : public DQMEDHarvester { double binWidth = -1., double min = -1.); + CTPPSRPAlignmentCorrectionsData getLongIdResults(CTPPSRPAlignmentCorrectionsData finalResults); + edm::ESGetToken esTokenTest_; edm::ESGetToken esTokenReference_; @@ -121,6 +125,8 @@ class PPSAlignmentHarvester : public DQMEDHarvester { const bool yAliFinalSlopeFixed_; const std::pair xCorrRange_; const std::pair yCorrRange_; + const unsigned int detectorId_; + const unsigned int subdetectorId_; const bool debug_; // other class variables @@ -154,6 +160,8 @@ PPSAlignmentHarvester::PPSAlignmentHarvester(const edm::ParameterSet& iConfig) iConfig.getParameter("x_corr_max") / 1000.)), // um -> mm yCorrRange_(std::make_pair(iConfig.getParameter("y_corr_min") / 1000., iConfig.getParameter("y_corr_max") / 1000.)), // um -> mm + detectorId_(iConfig.getParameter("detector_id")), + subdetectorId_(iConfig.getParameter("subdetector_id")), debug_(iConfig.getParameter("debug")) { auto textResultsPath = iConfig.getParameter("text_results_path"); if (!textResultsPath.empty()) { @@ -179,8 +187,11 @@ PPSAlignmentHarvester::PPSAlignmentHarvester(const edm::ParameterSet& iConfig) li << "* x_corr_min: " << std::fixed << xCorrRange_.first * 1000. << ", x_corr_max: " << xCorrRange_.second * 1000. << "\n"; // print in um - li << "* y_corr_min: " << std::fixed << yCorrRange_.first * 1000. << ", y_corr_max: " << yCorrRange_.second * 1000.; - li << "* debug: " << std::boolalpha << debug_ << "\n"; + li << "* y_corr_min: " << std::fixed << yCorrRange_.first * 1000. << ", y_corr_max: " << yCorrRange_.second * 1000. + << "\n"; + li << "* detector_id: " << detectorId_ << "\n"; + li << "* subdetector_id: " << subdetectorId_ << "\n"; + li << "* debug: " << std::boolalpha << debug_; }); } @@ -204,6 +215,8 @@ void PPSAlignmentHarvester::fillDescriptions(edm::ConfigurationDescriptions& des desc.add("x_corr_max", 1'000'000.); desc.add("y_corr_min", -1'000'000.); desc.add("y_corr_max", 1'000'000.); + desc.add("detector_id", 7); + desc.add("subdetector_id", 4); desc.add("debug", false); descriptions.addWithDefaultLabel(desc); @@ -322,9 +335,14 @@ void PPSAlignmentHarvester::dqmEndRun(DQMStore::IBooker& iBooker, // if requested, store the results in a DB object if (writeSQLiteResults_) { + CTPPSRPAlignmentCorrectionsData longIdFinalResults = getLongIdResults(finalResults); + edm::LogInfo("PPSAlignmentHarvester") << "trying to store final merged results with long ids:\n" + << longIdFinalResults; + edm::Service poolDbService; if (poolDbService.isAvailable()) { - poolDbService->writeOneIOV(finalResults, poolDbService->currentTime(), "CTPPSRPAlignmentCorrectionsDataRcd"); + poolDbService->writeOneIOV( + longIdFinalResults, poolDbService->currentTime(), "CTPPSRPAlignmentCorrectionsDataRcd"); } else { edm::LogWarning("PPSAlignmentHarvester") << "Could not store the results in a DB object. PoolDBService not available."; @@ -1045,4 +1063,20 @@ std::unique_ptr PPSAlignmentHarvester::getTH1DFromTGraphErrors( return hist; } +// Get Long 32-bit detector ID from short 3-digit ID +CTPPSRPAlignmentCorrectionsData PPSAlignmentHarvester::getLongIdResults(CTPPSRPAlignmentCorrectionsData shortIdResults) { + CTPPSRPAlignmentCorrectionsData longIdResults; + for (const auto& [shortId, correction] : shortIdResults.getRPMap()) { + unsigned int arm = shortId / 100; + unsigned int station = (shortId / 10) % 10; + unsigned int rp = shortId % 10; + + uint32_t longDetId = detectorId_ << 28 | subdetectorId_ << 25 | arm << 24 | station << 22 | rp << 19; + + longIdResults.addRPCorrection(longDetId, correction); + } + + return longIdResults; +} + DEFINE_FWK_MODULE(PPSAlignmentHarvester);