From abb7c234063012485d498bad62d5c8c47f475f31 Mon Sep 17 00:00:00 2001 From: Wagner Carvalho Date: Fri, 25 Feb 2022 18:17:37 +0100 Subject: [PATCH 01/39] Implement a LHCInfo inspired class with just a few variables needed for PPS HLT workflows --- CondCore/CTPPSPlugins/src/plugin.cc | 3 + .../DataRecord/interface/LHCInfoForPPSRcd.h | 26 +++++ .../DataRecord/src/LHCInfoForPPSRcd.cc | 16 +++ .../PPSObjects/interface/LHCInfoForPPS.h | 63 ++++++++++ CondFormats/PPSObjects/src/LHCInfoForPPS.cc | 109 ++++++++++++++++++ .../src/T_EventSetup_LHCInfoForPPS.cc | 4 + CondFormats/PPSObjects/src/classes_def.xml | 2 + CondFormats/PPSObjects/src/headers.h | 2 + CondFormats/PPSObjects/test/BuildFile.xml | 4 + .../test/testSerializationLHCInfoForPPS.cc | 8 ++ 10 files changed, 237 insertions(+) create mode 100644 CondFormats/DataRecord/interface/LHCInfoForPPSRcd.h create mode 100644 CondFormats/DataRecord/src/LHCInfoForPPSRcd.cc create mode 100644 CondFormats/PPSObjects/interface/LHCInfoForPPS.h create mode 100644 CondFormats/PPSObjects/src/LHCInfoForPPS.cc create mode 100644 CondFormats/PPSObjects/src/T_EventSetup_LHCInfoForPPS.cc create mode 100644 CondFormats/PPSObjects/test/testSerializationLHCInfoForPPS.cc diff --git a/CondCore/CTPPSPlugins/src/plugin.cc b/CondCore/CTPPSPlugins/src/plugin.cc index 2bd2270159d39..4a7f05087250d 100644 --- a/CondCore/CTPPSPlugins/src/plugin.cc +++ b/CondCore/CTPPSPlugins/src/plugin.cc @@ -27,6 +27,8 @@ #include "CondFormats/DataRecord/interface/PPSAlignmentConfigurationRcd.h" #include "CondFormats/PPSObjects/interface/PPSAssociationCuts.h" #include "CondFormats/DataRecord/interface/PPSAssociationCutsRcd.h" +#include "CondFormats/PPSObjects/interface/LHCInfoForPPS.h" +#include "CondFormats/DataRecord/interface/LHCInfoForPPSRcd.h" namespace { struct InitAssociationCuts { @@ -48,5 +50,6 @@ REGISTER_PLUGIN(PPSDirectSimulationDataRcd, PPSDirectSimulationData); REGISTER_PLUGIN(PPSPixelTopologyRcd, PPSPixelTopology); REGISTER_PLUGIN(PPSAlignmentConfigRcd, PPSAlignmentConfig); REGISTER_PLUGIN(PPSAlignmentConfigurationRcd, PPSAlignmentConfiguration); +REGISTER_PLUGIN(LHCInfoForPPSRcd, LHCInfoForPPS); REGISTER_PLUGIN_INIT(PPSAssociationCutsRcd, PPSAssociationCuts, InitAssociationCuts); diff --git a/CondFormats/DataRecord/interface/LHCInfoForPPSRcd.h b/CondFormats/DataRecord/interface/LHCInfoForPPSRcd.h new file mode 100644 index 0000000000000..81b0c14b16f32 --- /dev/null +++ b/CondFormats/DataRecord/interface/LHCInfoForPPSRcd.h @@ -0,0 +1,26 @@ +#ifndef DataRecord_LHCInfoForPPSRcd_h +#define DataRecord_LHCInfoForPPSRcd_h +// -*- C++ -*- +// +// Package: DataRecord +// Class : LHCInfoForPPSRcd +// +/**\class LHCInfoForPPSRcd LHCInfoForPPSRcd.h CondFormats/DataRecord/interface/LHCInfoForPPSRcd.h + + Description: [one line class summary] + + Usage: + + +*/ +// +// Author: +// Created: Tue Feb 15 2022 +// $Id$ +// + +#include "FWCore/Framework/interface/EventSetupRecordImplementation.h" + +class LHCInfoForPPSRcd : public edm::eventsetup::EventSetupRecordImplementation {}; + +#endif diff --git a/CondFormats/DataRecord/src/LHCInfoForPPSRcd.cc b/CondFormats/DataRecord/src/LHCInfoForPPSRcd.cc new file mode 100644 index 0000000000000..0c4c8fc77a1c7 --- /dev/null +++ b/CondFormats/DataRecord/src/LHCInfoForPPSRcd.cc @@ -0,0 +1,16 @@ +// -*- C++ -*- +// +// Package: DataRecord +// Class : LHCInfoForPPSRcd +// +// Implementation: +// [Notes on implementation] +// +// Author: +// Created: Tue Feb 15 2022 +// $Id$ + +#include "CondFormats/DataRecord/interface/LHCInfoForPPSRcd.h" +#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" + +EVENTSETUP_RECORD_REG(LHCInfoForPPSRcd); diff --git a/CondFormats/PPSObjects/interface/LHCInfoForPPS.h b/CondFormats/PPSObjects/interface/LHCInfoForPPS.h new file mode 100644 index 0000000000000..d8f6e8f694bb0 --- /dev/null +++ b/CondFormats/PPSObjects/interface/LHCInfoForPPS.h @@ -0,0 +1,63 @@ +#ifndef CondFormats_PPSObjects_LHCInfoForPPS_H +#define CondFormats_PPSObjects_LHCInfoForPPS_H + +#include "CondFormats/Serialization/interface/Serializable.h" +#include +#include +#include +#include +#include + +class LHCInfoForPPS { +public: + enum IntParamIndex { + LUMI_SECTION = 0, + ISIZE = 1 + }; + enum FloatParamIndex { + CROSSING_ANGLE = 0, + BETA_STAR = 1, + FSIZE = 2 + }; + + LHCInfoForPPS(); + LHCInfoForPPS(const LHCInfoForPPS& rhs); + ~LHCInfoForPPS(); + + //getters + float const crossingAngle() const; + + float const betaStar() const; + + unsigned int const& lumiSection() const; + + //setters + void setCrossingAngle(float const& angle); + + void setBetaStar(float const& betaStar); + + void setLumiSection(unsigned int const& lumiSection); + + //sets all values in one go + void setInfo(float const& angle, + float const& beta, + unsigned int const& lumiSection); + + bool equals(const LHCInfoForPPS& rhs) const; + + bool empty() const; + + //dumping values on output stream + void print(std::stringstream& ss) const; + +private: + bool m_isData = false; + std::vector > m_intParams; + std::vector > m_floatParams; + + COND_SERIALIZABLE; +}; + +std::ostream& operator<<(std::ostream&, LHCInfoForPPS lhcInfo); + +#endif // CondFormats_PPSObjects_LHCInfoForPPS_H diff --git a/CondFormats/PPSObjects/src/LHCInfoForPPS.cc b/CondFormats/PPSObjects/src/LHCInfoForPPS.cc new file mode 100644 index 0000000000000..4ab9478b78e60 --- /dev/null +++ b/CondFormats/PPSObjects/src/LHCInfoForPPS.cc @@ -0,0 +1,109 @@ +#include "CondFormats/PPSObjects/interface/LHCInfoForPPS.h" +//#include "CondFormats/Common/interface/TimeConversions.h" +#include +#include +#include +#include + +LHCInfoForPPS::LHCInfoForPPS() { + m_intParams.resize(ISIZE, std::vector(1, 0)); + m_floatParams.resize(FSIZE, std::vector(1, 0.)); +} + +LHCInfoForPPS::LHCInfoForPPS(const LHCInfoForPPS& rhs) + : m_intParams(rhs.m_intParams), + m_floatParams(rhs.m_floatParams) {} + +LHCInfoForPPS::~LHCInfoForPPS() {} + +namespace LHCInfoForPPSImpl { + template + const T& getParams(const std::vector& params, size_t index) { + if (index >= params.size()) + throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range."); + return params[index]; + } + + template + T& accessParams(std::vector& params, size_t index) { + if (index >= params.size()) + throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range."); + return params[index]; + } + + template + const T& getOneParam(const std::vector >& params, size_t index) { + if (index >= params.size()) + throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range."); + const std::vector& inner = params[index]; + if (inner.empty()) + throw std::out_of_range("Parameter with index " + std::to_string(index) + " type=" + typeid(T).name() + + " has no value stored."); + return inner[0]; + } + + template + void setOneParam(std::vector >& params, size_t index, const T& value) { + if (index >= params.size()) + throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range."); + params[index] = std::vector(1, value); + } + + template + void setParams(std::vector& params, size_t index, const T& value) { + if (index >= params.size()) + throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range."); + params[index] = value; + } + +} // namespace LHCInfoForPPSImpl + +//getters +float const LHCInfoForPPS::crossingAngle() const { return LHCInfoForPPSImpl::getOneParam(m_floatParams, CROSSING_ANGLE); } + +float const LHCInfoForPPS::betaStar() const { return LHCInfoForPPSImpl::getOneParam(m_floatParams, BETA_STAR); } + +unsigned int const& LHCInfoForPPS::lumiSection() const { return LHCInfoForPPSImpl::getOneParam(m_intParams, LUMI_SECTION); } + +//setters +void LHCInfoForPPS::setCrossingAngle(float const& angle) { LHCInfoForPPSImpl::setOneParam(m_floatParams, CROSSING_ANGLE, angle); } + +void LHCInfoForPPS::setBetaStar(float const& betaStar) { LHCInfoForPPSImpl::setOneParam(m_floatParams, BETA_STAR, betaStar); } + +void LHCInfoForPPS::setLumiSection(unsigned int const& lumiSection) { + LHCInfoForPPSImpl::setOneParam(m_intParams, LUMI_SECTION, lumiSection); +} + +//sets all values in one go +void LHCInfoForPPS::setInfo(float const& angle, + float const& beta, + unsigned int const& lumiSection) { + this->setCrossingAngle(angle); + this->setBetaStar(beta); + this->setLumiSection(lumiSection); +} + +void LHCInfoForPPS::print(std::stringstream& ss) const { + ss << "Crossing angle (urad): " << this->crossingAngle() << std::endl + << "Beta star (cm): " << this->betaStar() << std::endl + << "Lumi section: " << this->lumiSection() << std::endl; +} + +std::ostream& operator<<(std::ostream& os, LHCInfoForPPS beamInfo) { + std::stringstream ss; + beamInfo.print(ss); + os << ss.str(); + return os; +} + +bool LHCInfoForPPS::equals(const LHCInfoForPPS& rhs) const { + if (m_isData != rhs.m_isData) + return false; + if (m_intParams != rhs.m_intParams) + return false; + if (m_floatParams != rhs.m_floatParams) + return false; + return true; +} + +bool LHCInfoForPPS::empty() const { return m_intParams[0].empty(); } diff --git a/CondFormats/PPSObjects/src/T_EventSetup_LHCInfoForPPS.cc b/CondFormats/PPSObjects/src/T_EventSetup_LHCInfoForPPS.cc new file mode 100644 index 0000000000000..a79fd64246708 --- /dev/null +++ b/CondFormats/PPSObjects/src/T_EventSetup_LHCInfoForPPS.cc @@ -0,0 +1,4 @@ +#include "CondFormats/PPSObjects/interface/LHCInfoForPPS.h" +#include "FWCore/Utilities/interface/typelookup.h" + +TYPELOOKUP_DATA_REG(LHCInfoForPPS); diff --git a/CondFormats/PPSObjects/src/classes_def.xml b/CondFormats/PPSObjects/src/classes_def.xml index cc77140f70d5f..708ce29dc0db9 100644 --- a/CondFormats/PPSObjects/src/classes_def.xml +++ b/CondFormats/PPSObjects/src/classes_def.xml @@ -104,4 +104,6 @@ + + diff --git a/CondFormats/PPSObjects/src/headers.h b/CondFormats/PPSObjects/src/headers.h index c3351b4c99b2b..738cdf92b7422 100644 --- a/CondFormats/PPSObjects/src/headers.h +++ b/CondFormats/PPSObjects/src/headers.h @@ -18,3 +18,5 @@ #include "CondFormats/PPSObjects/interface/PPSAlignmentConfig.h" #include "CondFormats/PPSObjects/interface/PPSAssociationCuts.h" + +#include "CondFormats/PPSObjects/interface/LHCInfoForPPS.h" diff --git a/CondFormats/PPSObjects/test/BuildFile.xml b/CondFormats/PPSObjects/test/BuildFile.xml index 37fdb1e9d95c1..311eb5f847c4f 100644 --- a/CondFormats/PPSObjects/test/BuildFile.xml +++ b/CondFormats/PPSObjects/test/BuildFile.xml @@ -21,3 +21,7 @@ + + + + diff --git a/CondFormats/PPSObjects/test/testSerializationLHCInfoForPPS.cc b/CondFormats/PPSObjects/test/testSerializationLHCInfoForPPS.cc new file mode 100644 index 0000000000000..9d39badb6a522 --- /dev/null +++ b/CondFormats/PPSObjects/test/testSerializationLHCInfoForPPS.cc @@ -0,0 +1,8 @@ +#include "CondFormats/Serialization/interface/Test.h" +#include "CondFormats/PPSObjects/src/headers.h" + +int main() { + testSerialization(); + + return 0; +} From 0f20d397256bba01ba353c5ff5e30fcd3962292c Mon Sep 17 00:00:00 2001 From: Jan Chyczynski Date: Wed, 13 Jul 2022 14:16:28 +0200 Subject: [PATCH 02/39] renamed LHCInfoForPPS to LHCInfoPerLS --- CondCore/CTPPSPlugins/src/plugin.cc | 6 ++-- .../DataRecord/interface/LHCInfoForPPSRcd.h | 26 -------------- .../DataRecord/interface/LHCInfoPerLSRcd.h | 26 ++++++++++++++ ...LHCInfoForPPSRcd.cc => LHCInfoPerLSRcd.cc} | 6 ++-- .../{LHCInfoForPPS.h => LHCInfoPerLS.h} | 18 +++++----- .../src/{LHCInfoForPPS.cc => LHCInfoPerLS.cc} | 36 +++++++++---------- .../src/T_EventSetup_LHCInfoForPPS.cc | 4 --- .../src/T_EventSetup_LHCInfoPerLS.cc | 4 +++ CondFormats/PPSObjects/src/classes_def.xml | 2 +- CondFormats/PPSObjects/src/headers.h | 2 +- CondFormats/PPSObjects/test/BuildFile.xml | 2 +- ...PS.cc => testSerializationLHCInfoPerLS.cc} | 2 +- 12 files changed, 67 insertions(+), 67 deletions(-) delete mode 100644 CondFormats/DataRecord/interface/LHCInfoForPPSRcd.h create mode 100644 CondFormats/DataRecord/interface/LHCInfoPerLSRcd.h rename CondFormats/DataRecord/src/{LHCInfoForPPSRcd.cc => LHCInfoPerLSRcd.cc} (62%) rename CondFormats/PPSObjects/interface/{LHCInfoForPPS.h => LHCInfoPerLS.h} (74%) rename CondFormats/PPSObjects/src/{LHCInfoForPPS.cc => LHCInfoPerLS.cc} (66%) delete mode 100644 CondFormats/PPSObjects/src/T_EventSetup_LHCInfoForPPS.cc create mode 100644 CondFormats/PPSObjects/src/T_EventSetup_LHCInfoPerLS.cc rename CondFormats/PPSObjects/test/{testSerializationLHCInfoForPPS.cc => testSerializationLHCInfoPerLS.cc} (77%) diff --git a/CondCore/CTPPSPlugins/src/plugin.cc b/CondCore/CTPPSPlugins/src/plugin.cc index 4a7f05087250d..0a4340c98cc31 100644 --- a/CondCore/CTPPSPlugins/src/plugin.cc +++ b/CondCore/CTPPSPlugins/src/plugin.cc @@ -27,8 +27,8 @@ #include "CondFormats/DataRecord/interface/PPSAlignmentConfigurationRcd.h" #include "CondFormats/PPSObjects/interface/PPSAssociationCuts.h" #include "CondFormats/DataRecord/interface/PPSAssociationCutsRcd.h" -#include "CondFormats/PPSObjects/interface/LHCInfoForPPS.h" -#include "CondFormats/DataRecord/interface/LHCInfoForPPSRcd.h" +#include "CondFormats/PPSObjects/interface/LHCInfoPerLS.h" +#include "CondFormats/DataRecord/interface/LHCInfoPerLSRcd.h" namespace { struct InitAssociationCuts { @@ -50,6 +50,6 @@ REGISTER_PLUGIN(PPSDirectSimulationDataRcd, PPSDirectSimulationData); REGISTER_PLUGIN(PPSPixelTopologyRcd, PPSPixelTopology); REGISTER_PLUGIN(PPSAlignmentConfigRcd, PPSAlignmentConfig); REGISTER_PLUGIN(PPSAlignmentConfigurationRcd, PPSAlignmentConfiguration); -REGISTER_PLUGIN(LHCInfoForPPSRcd, LHCInfoForPPS); +REGISTER_PLUGIN(LHCInfoPerLSRcd, LHCInfoPerLS); REGISTER_PLUGIN_INIT(PPSAssociationCutsRcd, PPSAssociationCuts, InitAssociationCuts); diff --git a/CondFormats/DataRecord/interface/LHCInfoForPPSRcd.h b/CondFormats/DataRecord/interface/LHCInfoForPPSRcd.h deleted file mode 100644 index 81b0c14b16f32..0000000000000 --- a/CondFormats/DataRecord/interface/LHCInfoForPPSRcd.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef DataRecord_LHCInfoForPPSRcd_h -#define DataRecord_LHCInfoForPPSRcd_h -// -*- C++ -*- -// -// Package: DataRecord -// Class : LHCInfoForPPSRcd -// -/**\class LHCInfoForPPSRcd LHCInfoForPPSRcd.h CondFormats/DataRecord/interface/LHCInfoForPPSRcd.h - - Description: [one line class summary] - - Usage: - - -*/ -// -// Author: -// Created: Tue Feb 15 2022 -// $Id$ -// - -#include "FWCore/Framework/interface/EventSetupRecordImplementation.h" - -class LHCInfoForPPSRcd : public edm::eventsetup::EventSetupRecordImplementation {}; - -#endif diff --git a/CondFormats/DataRecord/interface/LHCInfoPerLSRcd.h b/CondFormats/DataRecord/interface/LHCInfoPerLSRcd.h new file mode 100644 index 0000000000000..15a6aab20bfeb --- /dev/null +++ b/CondFormats/DataRecord/interface/LHCInfoPerLSRcd.h @@ -0,0 +1,26 @@ +#ifndef DataRecord_LHCInfoPerLSRcd_h +#define DataRecord_LHCInfoPerLSRcd_h +// -*- C++ -*- +// +// Package: DataRecord +// Class : LHCInfoPerLSRcd +// +/**\class LHCInfoPerLSRcd LHCInfoPerLSRcd.h CondFormats/DataRecord/interface/LHCInfoPerLSRcd.h + + Description: [one line class summary] + + Usage: + + +*/ +// +// Author: +// Created: Tue Feb 15 2022 +// $Id$ +// + +#include "FWCore/Framework/interface/EventSetupRecordImplementation.h" + +class LHCInfoPerLSRcd : public edm::eventsetup::EventSetupRecordImplementation {}; + +#endif diff --git a/CondFormats/DataRecord/src/LHCInfoForPPSRcd.cc b/CondFormats/DataRecord/src/LHCInfoPerLSRcd.cc similarity index 62% rename from CondFormats/DataRecord/src/LHCInfoForPPSRcd.cc rename to CondFormats/DataRecord/src/LHCInfoPerLSRcd.cc index 0c4c8fc77a1c7..bda8c25a75bb9 100644 --- a/CondFormats/DataRecord/src/LHCInfoForPPSRcd.cc +++ b/CondFormats/DataRecord/src/LHCInfoPerLSRcd.cc @@ -1,7 +1,7 @@ // -*- C++ -*- // // Package: DataRecord -// Class : LHCInfoForPPSRcd +// Class : LHCInfoPerLSRcd // // Implementation: // [Notes on implementation] @@ -10,7 +10,7 @@ // Created: Tue Feb 15 2022 // $Id$ -#include "CondFormats/DataRecord/interface/LHCInfoForPPSRcd.h" +#include "CondFormats/DataRecord/interface/LHCInfoPerLSRcd.h" #include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" -EVENTSETUP_RECORD_REG(LHCInfoForPPSRcd); +EVENTSETUP_RECORD_REG(LHCInfoPerLSRcd); diff --git a/CondFormats/PPSObjects/interface/LHCInfoForPPS.h b/CondFormats/PPSObjects/interface/LHCInfoPerLS.h similarity index 74% rename from CondFormats/PPSObjects/interface/LHCInfoForPPS.h rename to CondFormats/PPSObjects/interface/LHCInfoPerLS.h index d8f6e8f694bb0..97adba84fa44a 100644 --- a/CondFormats/PPSObjects/interface/LHCInfoForPPS.h +++ b/CondFormats/PPSObjects/interface/LHCInfoPerLS.h @@ -1,5 +1,5 @@ -#ifndef CondFormats_PPSObjects_LHCInfoForPPS_H -#define CondFormats_PPSObjects_LHCInfoForPPS_H +#ifndef CondFormats_PPSObjects_LHCInfoPerLS_H +#define CondFormats_PPSObjects_LHCInfoPerLS_H #include "CondFormats/Serialization/interface/Serializable.h" #include @@ -8,7 +8,7 @@ #include #include -class LHCInfoForPPS { +class LHCInfoPerLS { public: enum IntParamIndex { LUMI_SECTION = 0, @@ -20,9 +20,9 @@ class LHCInfoForPPS { FSIZE = 2 }; - LHCInfoForPPS(); - LHCInfoForPPS(const LHCInfoForPPS& rhs); - ~LHCInfoForPPS(); + LHCInfoPerLS(); + LHCInfoPerLS(const LHCInfoPerLS& rhs); + ~LHCInfoPerLS(); //getters float const crossingAngle() const; @@ -43,7 +43,7 @@ class LHCInfoForPPS { float const& beta, unsigned int const& lumiSection); - bool equals(const LHCInfoForPPS& rhs) const; + bool equals(const LHCInfoPerLS& rhs) const; bool empty() const; @@ -58,6 +58,6 @@ class LHCInfoForPPS { COND_SERIALIZABLE; }; -std::ostream& operator<<(std::ostream&, LHCInfoForPPS lhcInfo); +std::ostream& operator<<(std::ostream&, LHCInfoPerLS lhcInfo); -#endif // CondFormats_PPSObjects_LHCInfoForPPS_H +#endif // CondFormats_PPSObjects_LHCInfoPerLS_H diff --git a/CondFormats/PPSObjects/src/LHCInfoForPPS.cc b/CondFormats/PPSObjects/src/LHCInfoPerLS.cc similarity index 66% rename from CondFormats/PPSObjects/src/LHCInfoForPPS.cc rename to CondFormats/PPSObjects/src/LHCInfoPerLS.cc index 4ab9478b78e60..efee443644f3b 100644 --- a/CondFormats/PPSObjects/src/LHCInfoForPPS.cc +++ b/CondFormats/PPSObjects/src/LHCInfoPerLS.cc @@ -1,22 +1,22 @@ -#include "CondFormats/PPSObjects/interface/LHCInfoForPPS.h" +#include "CondFormats/PPSObjects/interface/LHCInfoPerLS.h" //#include "CondFormats/Common/interface/TimeConversions.h" #include #include #include #include -LHCInfoForPPS::LHCInfoForPPS() { +LHCInfoPerLS::LHCInfoPerLS() { m_intParams.resize(ISIZE, std::vector(1, 0)); m_floatParams.resize(FSIZE, std::vector(1, 0.)); } -LHCInfoForPPS::LHCInfoForPPS(const LHCInfoForPPS& rhs) +LHCInfoPerLS::LHCInfoPerLS(const LHCInfoPerLS& rhs) : m_intParams(rhs.m_intParams), m_floatParams(rhs.m_floatParams) {} -LHCInfoForPPS::~LHCInfoForPPS() {} +LHCInfoPerLS::~LHCInfoPerLS() {} -namespace LHCInfoForPPSImpl { +namespace LHCInfoPerLSImpl { template const T& getParams(const std::vector& params, size_t index) { if (index >= params.size()) @@ -56,26 +56,26 @@ namespace LHCInfoForPPSImpl { params[index] = value; } -} // namespace LHCInfoForPPSImpl +} // namespace LHCInfoPerLSImpl //getters -float const LHCInfoForPPS::crossingAngle() const { return LHCInfoForPPSImpl::getOneParam(m_floatParams, CROSSING_ANGLE); } +float const LHCInfoPerLS::crossingAngle() const { return LHCInfoPerLSImpl::getOneParam(m_floatParams, CROSSING_ANGLE); } -float const LHCInfoForPPS::betaStar() const { return LHCInfoForPPSImpl::getOneParam(m_floatParams, BETA_STAR); } +float const LHCInfoPerLS::betaStar() const { return LHCInfoPerLSImpl::getOneParam(m_floatParams, BETA_STAR); } -unsigned int const& LHCInfoForPPS::lumiSection() const { return LHCInfoForPPSImpl::getOneParam(m_intParams, LUMI_SECTION); } +unsigned int const& LHCInfoPerLS::lumiSection() const { return LHCInfoPerLSImpl::getOneParam(m_intParams, LUMI_SECTION); } //setters -void LHCInfoForPPS::setCrossingAngle(float const& angle) { LHCInfoForPPSImpl::setOneParam(m_floatParams, CROSSING_ANGLE, angle); } +void LHCInfoPerLS::setCrossingAngle(float const& angle) { LHCInfoPerLSImpl::setOneParam(m_floatParams, CROSSING_ANGLE, angle); } -void LHCInfoForPPS::setBetaStar(float const& betaStar) { LHCInfoForPPSImpl::setOneParam(m_floatParams, BETA_STAR, betaStar); } +void LHCInfoPerLS::setBetaStar(float const& betaStar) { LHCInfoPerLSImpl::setOneParam(m_floatParams, BETA_STAR, betaStar); } -void LHCInfoForPPS::setLumiSection(unsigned int const& lumiSection) { - LHCInfoForPPSImpl::setOneParam(m_intParams, LUMI_SECTION, lumiSection); +void LHCInfoPerLS::setLumiSection(unsigned int const& lumiSection) { + LHCInfoPerLSImpl::setOneParam(m_intParams, LUMI_SECTION, lumiSection); } //sets all values in one go -void LHCInfoForPPS::setInfo(float const& angle, +void LHCInfoPerLS::setInfo(float const& angle, float const& beta, unsigned int const& lumiSection) { this->setCrossingAngle(angle); @@ -83,20 +83,20 @@ void LHCInfoForPPS::setInfo(float const& angle, this->setLumiSection(lumiSection); } -void LHCInfoForPPS::print(std::stringstream& ss) const { +void LHCInfoPerLS::print(std::stringstream& ss) const { ss << "Crossing angle (urad): " << this->crossingAngle() << std::endl << "Beta star (cm): " << this->betaStar() << std::endl << "Lumi section: " << this->lumiSection() << std::endl; } -std::ostream& operator<<(std::ostream& os, LHCInfoForPPS beamInfo) { +std::ostream& operator<<(std::ostream& os, LHCInfoPerLS beamInfo) { std::stringstream ss; beamInfo.print(ss); os << ss.str(); return os; } -bool LHCInfoForPPS::equals(const LHCInfoForPPS& rhs) const { +bool LHCInfoPerLS::equals(const LHCInfoPerLS& rhs) const { if (m_isData != rhs.m_isData) return false; if (m_intParams != rhs.m_intParams) @@ -106,4 +106,4 @@ bool LHCInfoForPPS::equals(const LHCInfoForPPS& rhs) const { return true; } -bool LHCInfoForPPS::empty() const { return m_intParams[0].empty(); } +bool LHCInfoPerLS::empty() const { return m_intParams[0].empty(); } diff --git a/CondFormats/PPSObjects/src/T_EventSetup_LHCInfoForPPS.cc b/CondFormats/PPSObjects/src/T_EventSetup_LHCInfoForPPS.cc deleted file mode 100644 index a79fd64246708..0000000000000 --- a/CondFormats/PPSObjects/src/T_EventSetup_LHCInfoForPPS.cc +++ /dev/null @@ -1,4 +0,0 @@ -#include "CondFormats/PPSObjects/interface/LHCInfoForPPS.h" -#include "FWCore/Utilities/interface/typelookup.h" - -TYPELOOKUP_DATA_REG(LHCInfoForPPS); diff --git a/CondFormats/PPSObjects/src/T_EventSetup_LHCInfoPerLS.cc b/CondFormats/PPSObjects/src/T_EventSetup_LHCInfoPerLS.cc new file mode 100644 index 0000000000000..03e7939ff052e --- /dev/null +++ b/CondFormats/PPSObjects/src/T_EventSetup_LHCInfoPerLS.cc @@ -0,0 +1,4 @@ +#include "CondFormats/PPSObjects/interface/LHCInfoPerLS.h" +#include "FWCore/Utilities/interface/typelookup.h" + +TYPELOOKUP_DATA_REG(LHCInfoPerLS); diff --git a/CondFormats/PPSObjects/src/classes_def.xml b/CondFormats/PPSObjects/src/classes_def.xml index 708ce29dc0db9..446a2cf98604c 100644 --- a/CondFormats/PPSObjects/src/classes_def.xml +++ b/CondFormats/PPSObjects/src/classes_def.xml @@ -104,6 +104,6 @@ - + diff --git a/CondFormats/PPSObjects/src/headers.h b/CondFormats/PPSObjects/src/headers.h index 738cdf92b7422..8770937e60566 100644 --- a/CondFormats/PPSObjects/src/headers.h +++ b/CondFormats/PPSObjects/src/headers.h @@ -19,4 +19,4 @@ #include "CondFormats/PPSObjects/interface/PPSAlignmentConfig.h" #include "CondFormats/PPSObjects/interface/PPSAssociationCuts.h" -#include "CondFormats/PPSObjects/interface/LHCInfoForPPS.h" +#include "CondFormats/PPSObjects/interface/LHCInfoPerLS.h" diff --git a/CondFormats/PPSObjects/test/BuildFile.xml b/CondFormats/PPSObjects/test/BuildFile.xml index 311eb5f847c4f..3ed1938fd5eb6 100644 --- a/CondFormats/PPSObjects/test/BuildFile.xml +++ b/CondFormats/PPSObjects/test/BuildFile.xml @@ -22,6 +22,6 @@ - + diff --git a/CondFormats/PPSObjects/test/testSerializationLHCInfoForPPS.cc b/CondFormats/PPSObjects/test/testSerializationLHCInfoPerLS.cc similarity index 77% rename from CondFormats/PPSObjects/test/testSerializationLHCInfoForPPS.cc rename to CondFormats/PPSObjects/test/testSerializationLHCInfoPerLS.cc index 9d39badb6a522..c1ff7668675f7 100644 --- a/CondFormats/PPSObjects/test/testSerializationLHCInfoForPPS.cc +++ b/CondFormats/PPSObjects/test/testSerializationLHCInfoPerLS.cc @@ -2,7 +2,7 @@ #include "CondFormats/PPSObjects/src/headers.h" int main() { - testSerialization(); + testSerialization(); return 0; } From b820dfcb5d6575a6b2823360a5af7db85647394a Mon Sep 17 00:00:00 2001 From: Jan Chyczynski Date: Wed, 13 Jul 2022 15:17:03 +0200 Subject: [PATCH 03/39] moved LHCInfoPerLS from PPS to RunInfo --- CondCore/CTPPSPlugins/src/plugin.cc | 3 --- CondCore/RunInfoPlugins/src/plugin.cc | 3 +++ CondFormats/PPSObjects/src/classes_def.xml | 2 -- CondFormats/PPSObjects/src/headers.h | 2 -- CondFormats/PPSObjects/test/BuildFile.xml | 4 ---- .../PPSObjects/test/testSerializationLHCInfoPerLS.cc | 8 -------- .../{PPSObjects => RunInfo}/interface/LHCInfoPerLS.h | 6 +++--- CondFormats/{PPSObjects => RunInfo}/src/LHCInfoPerLS.cc | 2 +- .../src/T_EventSetup_LHCInfoPerLS.cc | 2 +- CondFormats/RunInfo/src/classes_def.xml | 2 ++ CondFormats/RunInfo/src/headers.h | 1 + CondFormats/RunInfo/test/testSerializationRunInfo.cpp | 1 + 12 files changed, 12 insertions(+), 24 deletions(-) delete mode 100644 CondFormats/PPSObjects/test/testSerializationLHCInfoPerLS.cc rename CondFormats/{PPSObjects => RunInfo}/interface/LHCInfoPerLS.h (89%) rename CondFormats/{PPSObjects => RunInfo}/src/LHCInfoPerLS.cc (98%) rename CondFormats/{PPSObjects => RunInfo}/src/T_EventSetup_LHCInfoPerLS.cc (59%) diff --git a/CondCore/CTPPSPlugins/src/plugin.cc b/CondCore/CTPPSPlugins/src/plugin.cc index 0a4340c98cc31..2bd2270159d39 100644 --- a/CondCore/CTPPSPlugins/src/plugin.cc +++ b/CondCore/CTPPSPlugins/src/plugin.cc @@ -27,8 +27,6 @@ #include "CondFormats/DataRecord/interface/PPSAlignmentConfigurationRcd.h" #include "CondFormats/PPSObjects/interface/PPSAssociationCuts.h" #include "CondFormats/DataRecord/interface/PPSAssociationCutsRcd.h" -#include "CondFormats/PPSObjects/interface/LHCInfoPerLS.h" -#include "CondFormats/DataRecord/interface/LHCInfoPerLSRcd.h" namespace { struct InitAssociationCuts { @@ -50,6 +48,5 @@ REGISTER_PLUGIN(PPSDirectSimulationDataRcd, PPSDirectSimulationData); REGISTER_PLUGIN(PPSPixelTopologyRcd, PPSPixelTopology); REGISTER_PLUGIN(PPSAlignmentConfigRcd, PPSAlignmentConfig); REGISTER_PLUGIN(PPSAlignmentConfigurationRcd, PPSAlignmentConfiguration); -REGISTER_PLUGIN(LHCInfoPerLSRcd, LHCInfoPerLS); REGISTER_PLUGIN_INIT(PPSAssociationCutsRcd, PPSAssociationCuts, InitAssociationCuts); diff --git a/CondCore/RunInfoPlugins/src/plugin.cc b/CondCore/RunInfoPlugins/src/plugin.cc index 519e4fac7eb30..b8447ad0dd00c 100644 --- a/CondCore/RunInfoPlugins/src/plugin.cc +++ b/CondCore/RunInfoPlugins/src/plugin.cc @@ -10,6 +10,8 @@ #include "CondFormats/RunInfo/interface/FillInfo.h" #include "CondFormats/DataRecord/interface/LHCInfoRcd.h" #include "CondFormats/RunInfo/interface/LHCInfo.h" +#include "CondFormats/DataRecord/interface/LHCInfoPerLSRcd.h" +#include "CondFormats/RunInfo/interface/LHCInfoPerLS.h" REGISTER_PLUGIN(RunSummaryRcd, RunSummary); REGISTER_PLUGIN(RunInfoRcd, RunInfo); @@ -17,3 +19,4 @@ REGISTER_PLUGIN(L1TriggerScalerRcd, L1TriggerScaler); REGISTER_PLUGIN(MixingRcd, MixingModuleConfig); REGISTER_PLUGIN(FillInfoRcd, FillInfo); REGISTER_PLUGIN(LHCInfoRcd, LHCInfo); +REGISTER_PLUGIN(LHCInfoPerLSRcd, LHCInfoPerLS); \ No newline at end of file diff --git a/CondFormats/PPSObjects/src/classes_def.xml b/CondFormats/PPSObjects/src/classes_def.xml index 446a2cf98604c..cc77140f70d5f 100644 --- a/CondFormats/PPSObjects/src/classes_def.xml +++ b/CondFormats/PPSObjects/src/classes_def.xml @@ -104,6 +104,4 @@ - - diff --git a/CondFormats/PPSObjects/src/headers.h b/CondFormats/PPSObjects/src/headers.h index 8770937e60566..c3351b4c99b2b 100644 --- a/CondFormats/PPSObjects/src/headers.h +++ b/CondFormats/PPSObjects/src/headers.h @@ -18,5 +18,3 @@ #include "CondFormats/PPSObjects/interface/PPSAlignmentConfig.h" #include "CondFormats/PPSObjects/interface/PPSAssociationCuts.h" - -#include "CondFormats/PPSObjects/interface/LHCInfoPerLS.h" diff --git a/CondFormats/PPSObjects/test/BuildFile.xml b/CondFormats/PPSObjects/test/BuildFile.xml index 3ed1938fd5eb6..37fdb1e9d95c1 100644 --- a/CondFormats/PPSObjects/test/BuildFile.xml +++ b/CondFormats/PPSObjects/test/BuildFile.xml @@ -21,7 +21,3 @@ - - - - diff --git a/CondFormats/PPSObjects/test/testSerializationLHCInfoPerLS.cc b/CondFormats/PPSObjects/test/testSerializationLHCInfoPerLS.cc deleted file mode 100644 index c1ff7668675f7..0000000000000 --- a/CondFormats/PPSObjects/test/testSerializationLHCInfoPerLS.cc +++ /dev/null @@ -1,8 +0,0 @@ -#include "CondFormats/Serialization/interface/Test.h" -#include "CondFormats/PPSObjects/src/headers.h" - -int main() { - testSerialization(); - - return 0; -} diff --git a/CondFormats/PPSObjects/interface/LHCInfoPerLS.h b/CondFormats/RunInfo/interface/LHCInfoPerLS.h similarity index 89% rename from CondFormats/PPSObjects/interface/LHCInfoPerLS.h rename to CondFormats/RunInfo/interface/LHCInfoPerLS.h index 97adba84fa44a..b21a60313fbc9 100644 --- a/CondFormats/PPSObjects/interface/LHCInfoPerLS.h +++ b/CondFormats/RunInfo/interface/LHCInfoPerLS.h @@ -1,5 +1,5 @@ -#ifndef CondFormats_PPSObjects_LHCInfoPerLS_H -#define CondFormats_PPSObjects_LHCInfoPerLS_H +#ifndef CondFormats_RunInfo_LHCInfoPerLS_H +#define CondFormats_RunInfo_LHCInfoPerLS_H #include "CondFormats/Serialization/interface/Serializable.h" #include @@ -60,4 +60,4 @@ class LHCInfoPerLS { std::ostream& operator<<(std::ostream&, LHCInfoPerLS lhcInfo); -#endif // CondFormats_PPSObjects_LHCInfoPerLS_H +#endif // CondFormats_RunInfo_LHCInfoPerLS_H diff --git a/CondFormats/PPSObjects/src/LHCInfoPerLS.cc b/CondFormats/RunInfo/src/LHCInfoPerLS.cc similarity index 98% rename from CondFormats/PPSObjects/src/LHCInfoPerLS.cc rename to CondFormats/RunInfo/src/LHCInfoPerLS.cc index efee443644f3b..7c90b900d2015 100644 --- a/CondFormats/PPSObjects/src/LHCInfoPerLS.cc +++ b/CondFormats/RunInfo/src/LHCInfoPerLS.cc @@ -1,4 +1,4 @@ -#include "CondFormats/PPSObjects/interface/LHCInfoPerLS.h" +#include "CondFormats/RunInfo/interface/LHCInfoPerLS.h" //#include "CondFormats/Common/interface/TimeConversions.h" #include #include diff --git a/CondFormats/PPSObjects/src/T_EventSetup_LHCInfoPerLS.cc b/CondFormats/RunInfo/src/T_EventSetup_LHCInfoPerLS.cc similarity index 59% rename from CondFormats/PPSObjects/src/T_EventSetup_LHCInfoPerLS.cc rename to CondFormats/RunInfo/src/T_EventSetup_LHCInfoPerLS.cc index 03e7939ff052e..e63f84c38bda5 100644 --- a/CondFormats/PPSObjects/src/T_EventSetup_LHCInfoPerLS.cc +++ b/CondFormats/RunInfo/src/T_EventSetup_LHCInfoPerLS.cc @@ -1,4 +1,4 @@ -#include "CondFormats/PPSObjects/interface/LHCInfoPerLS.h" +#include "CondFormats/RunInfo/interface/LHCInfoPerLS.h" #include "FWCore/Utilities/interface/typelookup.h" TYPELOOKUP_DATA_REG(LHCInfoPerLS); diff --git a/CondFormats/RunInfo/src/classes_def.xml b/CondFormats/RunInfo/src/classes_def.xml index 7e9910b7e080b..4bfb6a16a1a54 100644 --- a/CondFormats/RunInfo/src/classes_def.xml +++ b/CondFormats/RunInfo/src/classes_def.xml @@ -22,4 +22,6 @@ + + diff --git a/CondFormats/RunInfo/src/headers.h b/CondFormats/RunInfo/src/headers.h index ed905d61e435a..a1126d2e2aec0 100644 --- a/CondFormats/RunInfo/src/headers.h +++ b/CondFormats/RunInfo/src/headers.h @@ -5,3 +5,4 @@ #include "CondFormats/RunInfo/interface/MixingModuleConfig.h" #include "CondFormats/RunInfo/interface/FillInfo.h" #include "CondFormats/RunInfo/interface/LHCInfo.h" +#include "CondFormats/RunInfo/interface/LHCInfoPerLS.h" \ No newline at end of file diff --git a/CondFormats/RunInfo/test/testSerializationRunInfo.cpp b/CondFormats/RunInfo/test/testSerializationRunInfo.cpp index f12858e8f7720..5aea6c7eecdf4 100644 --- a/CondFormats/RunInfo/test/testSerializationRunInfo.cpp +++ b/CondFormats/RunInfo/test/testSerializationRunInfo.cpp @@ -5,6 +5,7 @@ int main() { testSerialization(); testSerialization(); + testSerialization(); testSerialization(); testSerialization(); testSerialization(); From 3fda01aae897b4c65a5edf9cb809ef7c941aa08a Mon Sep 17 00:00:00 2001 From: Jan Chyczynski Date: Wed, 13 Jul 2022 16:01:38 +0200 Subject: [PATCH 04/39] split betaStar and crossingAngle for x and y --- CondFormats/RunInfo/interface/LHCInfoPerLS.h | 30 +++++++++++------ CondFormats/RunInfo/src/LHCInfoPerLS.cc | 34 ++++++++++++++------ 2 files changed, 45 insertions(+), 19 deletions(-) diff --git a/CondFormats/RunInfo/interface/LHCInfoPerLS.h b/CondFormats/RunInfo/interface/LHCInfoPerLS.h index b21a60313fbc9..5d3296bf47f22 100644 --- a/CondFormats/RunInfo/interface/LHCInfoPerLS.h +++ b/CondFormats/RunInfo/interface/LHCInfoPerLS.h @@ -15,9 +15,11 @@ class LHCInfoPerLS { ISIZE = 1 }; enum FloatParamIndex { - CROSSING_ANGLE = 0, - BETA_STAR = 1, - FSIZE = 2 + CROSSING_ANGLE_X = 0, + CROSSING_ANGLE_Y = 1, + BETA_STAR_X = 2, + BETA_STAR_Y = 3, + FSIZE = 4 }; LHCInfoPerLS(); @@ -25,22 +27,32 @@ class LHCInfoPerLS { ~LHCInfoPerLS(); //getters - float const crossingAngle() const; + float const crossingAngleX() const; - float const betaStar() const; + float const crossingAngleY() const; + + float const betaStarX() const; + + float const betaStarY() const; unsigned int const& lumiSection() const; //setters - void setCrossingAngle(float const& angle); + void setCrossingAngleX(float const& angle); + + void setCrossingAngleY(float const& angle); + + void setBetaStarX(float const& betaStar); - void setBetaStar(float const& betaStar); + void setBetaStarY(float const& betaStar); void setLumiSection(unsigned int const& lumiSection); //sets all values in one go - void setInfo(float const& angle, - float const& beta, + void setInfo(float const& angleX, + float const& angleY, + float const& betaX, + float const& betaY, unsigned int const& lumiSection); bool equals(const LHCInfoPerLS& rhs) const; diff --git a/CondFormats/RunInfo/src/LHCInfoPerLS.cc b/CondFormats/RunInfo/src/LHCInfoPerLS.cc index 7c90b900d2015..9f7d373226980 100644 --- a/CondFormats/RunInfo/src/LHCInfoPerLS.cc +++ b/CondFormats/RunInfo/src/LHCInfoPerLS.cc @@ -59,33 +59,47 @@ namespace LHCInfoPerLSImpl { } // namespace LHCInfoPerLSImpl //getters -float const LHCInfoPerLS::crossingAngle() const { return LHCInfoPerLSImpl::getOneParam(m_floatParams, CROSSING_ANGLE); } +float const LHCInfoPerLS::crossingAngleX() const { return LHCInfoPerLSImpl::getOneParam(m_floatParams, CROSSING_ANGLE_X); } -float const LHCInfoPerLS::betaStar() const { return LHCInfoPerLSImpl::getOneParam(m_floatParams, BETA_STAR); } +float const LHCInfoPerLS::crossingAngleY() const { return LHCInfoPerLSImpl::getOneParam(m_floatParams, CROSSING_ANGLE_Y); } + +float const LHCInfoPerLS::betaStarX() const { return LHCInfoPerLSImpl::getOneParam(m_floatParams, BETA_STAR_X); } + +float const LHCInfoPerLS::betaStarY() const { return LHCInfoPerLSImpl::getOneParam(m_floatParams, BETA_STAR_Y); } unsigned int const& LHCInfoPerLS::lumiSection() const { return LHCInfoPerLSImpl::getOneParam(m_intParams, LUMI_SECTION); } //setters -void LHCInfoPerLS::setCrossingAngle(float const& angle) { LHCInfoPerLSImpl::setOneParam(m_floatParams, CROSSING_ANGLE, angle); } +void LHCInfoPerLS::setCrossingAngleX(float const& angle) { LHCInfoPerLSImpl::setOneParam(m_floatParams, CROSSING_ANGLE_X, angle); } + +void LHCInfoPerLS::setCrossingAngleY(float const& angle) { LHCInfoPerLSImpl::setOneParam(m_floatParams, CROSSING_ANGLE_Y, angle); } + +void LHCInfoPerLS::setBetaStarX(float const& betaStar) { LHCInfoPerLSImpl::setOneParam(m_floatParams, BETA_STAR_X, betaStar); } -void LHCInfoPerLS::setBetaStar(float const& betaStar) { LHCInfoPerLSImpl::setOneParam(m_floatParams, BETA_STAR, betaStar); } +void LHCInfoPerLS::setBetaStarY(float const& betaStar) { LHCInfoPerLSImpl::setOneParam(m_floatParams, BETA_STAR_Y, betaStar); } void LHCInfoPerLS::setLumiSection(unsigned int const& lumiSection) { LHCInfoPerLSImpl::setOneParam(m_intParams, LUMI_SECTION, lumiSection); } //sets all values in one go -void LHCInfoPerLS::setInfo(float const& angle, - float const& beta, +void LHCInfoPerLS::setInfo(float const& angleX, + float const& angleY, + float const& betaX, + float const& betaY, unsigned int const& lumiSection) { - this->setCrossingAngle(angle); - this->setBetaStar(beta); + this->setCrossingAngleX(angleX); + this->setCrossingAngleY(angleY); + this->setBetaStarX(betaX); + this->setBetaStarY(betaY); this->setLumiSection(lumiSection); } void LHCInfoPerLS::print(std::stringstream& ss) const { - ss << "Crossing angle (urad): " << this->crossingAngle() << std::endl - << "Beta star (cm): " << this->betaStar() << std::endl + ss << "Crossing angle x (urad): " << this->crossingAngleX() << std::endl + << "Crossing angle y (urad): " << this->crossingAngleY() << std::endl + << "Beta star x (cm): " << this->betaStarX() << std::endl + << "Beta star y (cm): " << this->betaStarY() << std::endl << "Lumi section: " << this->lumiSection() << std::endl; } From 698c47247be8ff337067d38ab1eec01e0353f0f2 Mon Sep 17 00:00:00 2001 From: Jan Chyczynski Date: Wed, 13 Jul 2022 18:08:00 +0200 Subject: [PATCH 05/39] LHCInfoPerFill class implemented --- .../RunInfo/interface/LHCInfoPerFill.h | 250 +++++++++ CondFormats/RunInfo/src/LHCInfoPerFill.cc | 515 ++++++++++++++++++ 2 files changed, 765 insertions(+) create mode 100644 CondFormats/RunInfo/interface/LHCInfoPerFill.h create mode 100644 CondFormats/RunInfo/src/LHCInfoPerFill.cc diff --git a/CondFormats/RunInfo/interface/LHCInfoPerFill.h b/CondFormats/RunInfo/interface/LHCInfoPerFill.h new file mode 100644 index 0000000000000..16af8dd95d90f --- /dev/null +++ b/CondFormats/RunInfo/interface/LHCInfoPerFill.h @@ -0,0 +1,250 @@ +#ifndef CondFormats_RunInfo_LHCInfoPerFill_H +#define CondFormats_RunInfo_LHCInfoPerFill_H + +#include "CondFormats/Serialization/interface/Serializable.h" +#include "CondFormats/Common/interface/Time.h" +#include +#include +#include +#include +#include + +class LHCInfoPerFill { +public: + enum FillType { UNKNOWN = 0, PROTONS = 1, IONS = 2, COSMICS = 3, GAP = 4 }; + enum ParticleType { NONE = 0, PROTON = 1, PB82 = 2, AR18 = 3, D = 4, XE54 = 5 }; + + enum IntParamIndex { + LHC_FILL = 0, + BUNCHES_1 = 1, + BUNCHES_2 = 2, + COLLIDING_BUNCHES = 3, + TARGET_BUNCHES = 4, + FILL_TYPE = 5, + PARTICLES_1 = 6, + PARTICLES_2 = 7, + ISIZE = 8 + }; + enum FloatParamIndex { + INTENSITY_1 = 0, + INTENSITY_2 = 1, + ENERGY = 2, + DELIV_LUMI = 3, + REC_LUMI = 4, + LUMI_PER_B = 5, + BEAM1_VC = 7, + BEAM2_VC = 8, + BEAM1_RF = 9, + BEAM2_RF = 10, + INST_LUMI = 11, + INST_LUMI_ERR = 12, + FSIZE = 13 + }; + enum TimeParamIndex { CREATE_TIME = 0, BEGIN_TIME = 1, END_TIME = 2, TSIZE = 3 }; + enum StringParamIndex { INJECTION_SCHEME = 0, LHC_STATE = 1, LHC_COMMENT = 2, CTPPS_STATUS = 3, SSIZE = 4 }; + + typedef FillType FillTypeId; + typedef ParticleType ParticleTypeId; + LHCInfoPerFill(); + LHCInfoPerFill(const LHCInfoPerFill& rhs); + ~LHCInfoPerFill(); + + LHCInfoPerFill* cloneFill() const; + + //constant static unsigned integer hosting the maximum number of LHC bunch slots + static size_t const bunchSlots = 3564; + + //constant static unsigned integer hosting the available number of LHC bunch slots + static size_t const availableBunchSlots = 2808; + + void setFillNumber(unsigned short lhcFill); + + //getters + unsigned short const fillNumber() const; + + unsigned short const bunchesInBeam1() const; + + unsigned short const bunchesInBeam2() const; + + unsigned short const collidingBunches() const; + + unsigned short const targetBunches() const; + + FillTypeId const fillType() const; + + ParticleTypeId const particleTypeForBeam1() const; + + ParticleTypeId const particleTypeForBeam2() const; + + float const intensityForBeam1() const; + + float const intensityForBeam2() const; + + float const energy() const; + + float const delivLumi() const; + + float const recLumi() const; + + float const instLumi() const; + + float const instLumiError() const; + + cond::Time_t const createTime() const; + + cond::Time_t const beginTime() const; + + cond::Time_t const endTime() const; + + std::string const& injectionScheme() const; + + std::vector const& lumiPerBX() const; + + std::string const& lhcState() const; + + std::string const& lhcComment() const; + + std::string const& ctppsStatus() const; + + std::vector const& beam1VC() const; + + std::vector const& beam2VC() const; + + std::vector const& beam1RF() const; + + std::vector const& beam2RF() const; + + std::vector& beam1VC(); + + std::vector& beam2VC(); + + std::vector& beam1RF(); + + std::vector& beam2RF(); + + //returns a boolean, true if the injection scheme has a leading 25ns + //TODO: parse the circulating bunch configuration, instead of the string. + bool is25nsBunchSpacing() const; + + //returns a boolean, true if the bunch slot number is in the circulating bunch configuration + bool isBunchInBeam1(size_t const& bunch) const; + + bool isBunchInBeam2(size_t const& bunch) const; + + //member functions returning *by value* a vector with all filled bunch slots + std::vector bunchConfigurationForBeam1() const; + + std::vector bunchConfigurationForBeam2() const; + + //setters + void setBunchesInBeam1(unsigned short const& bunches); + + void setBunchesInBeam2(unsigned short const& bunches); + + void setCollidingBunches(unsigned short const& collidingBunches); + + void setTargetBunches(unsigned short const& targetBunches); + + void setFillType(FillTypeId const& fillType); + + void setParticleTypeForBeam1(ParticleTypeId const& particleType); + + void setParticleTypeForBeam2(ParticleTypeId const& particleType); + + void setIntensityForBeam1(float const& intensity); + + void setIntensityForBeam2(float const& intensity); + + void setEnergy(float const& energy); + + void setDelivLumi(float const& delivLumi); + + void setRecLumi(float const& recLumi); + + void setInstLumi(float const& instLumi); + + void setInstLumiError(float const& instLumiError); + + void setCreationTime(cond::Time_t const& createTime); + + void setBeginTime(cond::Time_t const& beginTime); + + void setEndTime(cond::Time_t const& endTime); + + void setInjectionScheme(std::string const& injectionScheme); + + void setLumiPerBX(std::vector const& lumiPerBX); + + void setLhcState(std::string const& lhcState); + + void setLhcComment(std::string const& lhcComment); + + void setCtppsStatus(std::string const& ctppsStatus); + + void setBeam1VC(std::vector const& beam1VC); + + void setBeam2VC(std::vector const& beam2VC); + + void setBeam1RF(std::vector const& beam1RF); + + void setBeam2RF(std::vector const& beam2RF); + + //sets all values in one go + void setInfo(unsigned short const& bunches1, + unsigned short const& bunches2, + unsigned short const& collidingBunches, + unsigned short const& targetBunches, + FillTypeId const& fillType, + ParticleTypeId const& particleType1, + ParticleTypeId const& particleType2, + float const& intensity1, + float const& intensity2, + float const& energy, + float const& delivLumi, + float const& recLumi, + float const& instLumi, + float const& instLumiError, + cond::Time_t const& createTime, + cond::Time_t const& beginTime, + cond::Time_t const& endTime, + std::string const& scheme, + std::vector const& lumiPerBX, + std::string const& lhcState, + std::string const& lhcComment, + std::string const& ctppsStatus, + std::vector const& beam1VC, + std::vector const& beam2VC, + std::vector const& beam1RF, + std::vector const& beam2RF, + std::bitset const& bunchConf1, + std::bitset const& bunchConf2); + + bool equals(const LHCInfoPerFill& rhs) const; + + bool empty() const; + + //dumping values on output stream + void print(std::stringstream& ss) const; + + std::bitset const& bunchBitsetForBeam1() const; + + std::bitset const& bunchBitsetForBeam2() const; + + void setBunchBitsetForBeam1(std::bitset const& bunchConfiguration); + + void setBunchBitsetForBeam2(std::bitset const& bunchConfiguration); + +private: + bool m_isData = false; + std::vector > m_intParams; + std::vector > m_floatParams; + std::vector > m_timeParams; + std::vector > m_stringParams; + std::bitset m_bunchConfiguration1, m_bunchConfiguration2; + + COND_SERIALIZABLE; +}; + +std::ostream& operator<<(std::ostream&, LHCInfoPerFill lhcInfoPerFill); + +#endif // CondFormats_RunInfo_LHCInfoPerFill_H diff --git a/CondFormats/RunInfo/src/LHCInfoPerFill.cc b/CondFormats/RunInfo/src/LHCInfoPerFill.cc new file mode 100644 index 0000000000000..30796383af04b --- /dev/null +++ b/CondFormats/RunInfo/src/LHCInfoPerFill.cc @@ -0,0 +1,515 @@ +#include "CondFormats/RunInfo/interface/LHCInfoPerFill.h" +#include "CondFormats/Common/interface/TimeConversions.h" +#include +#include +#include +#include + +//helper function: returns the positions of the bits in the bitset that are set (i.e., have a value of 1). +static std::vector bitsetToVector(std::bitset const& bs) { + std::vector vec; + //reserve space only for the bits in the bitset that are set + vec.reserve(bs.count()); + for (size_t i = 0; i < bs.size(); ++i) { + if (bs.test(i)) + vec.push_back((unsigned short)i); + } + return vec; +} + +//helper function: returns the enum for fill types in string type +static std::string fillTypeToString(LHCInfoPerFill::FillTypeId const& fillType) { + std::string s_fillType("UNKNOWN"); + switch (fillType) { + case LHCInfoPerFill::UNKNOWN: + s_fillType = std::string("UNKNOWN"); + break; + case LHCInfoPerFill::PROTONS: + s_fillType = std::string("PROTONS"); + break; + case LHCInfoPerFill::IONS: + s_fillType = std::string("IONS"); + break; + case LHCInfoPerFill::COSMICS: + s_fillType = std::string("COSMICS"); + break; + case LHCInfoPerFill::GAP: + s_fillType = std::string("GAP"); + break; + default: + s_fillType = std::string("UNKNOWN"); + } + return s_fillType; +} + +//helper function: returns the enum for particle types in string type +static std::string particleTypeToString(LHCInfoPerFill::ParticleTypeId const& particleType) { + std::string s_particleType("NONE"); + switch (particleType) { + case LHCInfoPerFill::NONE: + s_particleType = std::string("NONE"); + break; + case LHCInfoPerFill::PROTON: + s_particleType = std::string("PROTON"); + break; + case LHCInfoPerFill::PB82: + s_particleType = std::string("PB82"); + break; + case LHCInfoPerFill::AR18: + s_particleType = std::string("AR18"); + break; + case LHCInfoPerFill::D: + s_particleType = std::string("D"); + break; + case LHCInfoPerFill::XE54: + s_particleType = std::string("XE54"); + break; + default: + s_particleType = std::string("NONE"); + } + return s_particleType; +} + +LHCInfoPerFill::LHCInfoPerFill() { + m_intParams.resize(ISIZE, std::vector(1, 0)); + m_floatParams.resize(FSIZE, std::vector(1, 0.)); + m_floatParams[LUMI_PER_B] = std::vector(); + m_floatParams[BEAM1_VC] = std::vector(); + m_floatParams[BEAM2_VC] = std::vector(); + m_floatParams[BEAM1_RF] = std::vector(); + m_floatParams[BEAM2_RF] = std::vector(); + m_timeParams.resize(TSIZE, std::vector(1, 0ULL)); + m_stringParams.resize(SSIZE, std::vector(1, "")); + m_stringParams[INJECTION_SCHEME].push_back(std::string("None")); +} + +LHCInfoPerFill::LHCInfoPerFill(const LHCInfoPerFill& rhs) + : m_intParams(rhs.m_intParams), + m_floatParams(rhs.m_floatParams), + m_timeParams(rhs.m_timeParams), + m_stringParams(rhs.m_stringParams), + m_bunchConfiguration1(rhs.m_bunchConfiguration1), + m_bunchConfiguration2(rhs.m_bunchConfiguration2) {} + +LHCInfoPerFill::~LHCInfoPerFill() {} + +LHCInfoPerFill* LHCInfoPerFill::cloneFill() const { + LHCInfoPerFill* ret = new LHCInfoPerFill(); + ret->m_isData = m_isData; + if (!m_intParams[0].empty()) { + for (size_t i = 0; i < ISIZE; i++) + ret->m_intParams[i] = m_intParams[i]; + for (size_t i = 0; i < DELIV_LUMI; i++) + ret->m_floatParams[i] = m_floatParams[i]; + ret->m_floatParams[LUMI_PER_B] = m_floatParams[LUMI_PER_B]; + for (size_t i = 0; i < TSIZE; i++) + ret->m_timeParams[i] = m_timeParams[i]; + for (size_t i = 0; i < LHC_STATE; i++) + ret->m_stringParams[i] = m_stringParams[i]; + ret->m_bunchConfiguration1 = m_bunchConfiguration1; + ret->m_bunchConfiguration2 = m_bunchConfiguration2; + } + return ret; +} + +namespace LHCInfoPerFillImpl { + template + const T& getParams(const std::vector& params, size_t index) { + if (index >= params.size()) + throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range."); + return params[index]; + } + + template + T& accessParams(std::vector& params, size_t index) { + if (index >= params.size()) + throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range."); + return params[index]; + } + + template + const T& getOneParam(const std::vector >& params, size_t index) { + if (index >= params.size()) + throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range."); + const std::vector& inner = params[index]; + if (inner.empty()) + throw std::out_of_range("Parameter with index " + std::to_string(index) + " type=" + typeid(T).name() + + " has no value stored."); + return inner[0]; + } + + template + void setOneParam(std::vector >& params, size_t index, const T& value) { + if (index >= params.size()) + throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range."); + params[index] = std::vector(1, value); + } + + template + void setParams(std::vector& params, size_t index, const T& value) { + if (index >= params.size()) + throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range."); + params[index] = value; + } + +} // namespace LHCInfoPerFillImpl + +//getters +unsigned short const LHCInfoPerFill::fillNumber() const { return LHCInfoPerFillImpl::getOneParam(m_intParams, LHC_FILL); } + +unsigned short const LHCInfoPerFill::bunchesInBeam1() const { return LHCInfoPerFillImpl::getOneParam(m_intParams, BUNCHES_1); } + +unsigned short const LHCInfoPerFill::bunchesInBeam2() const { return LHCInfoPerFillImpl::getOneParam(m_intParams, BUNCHES_2); } + +unsigned short const LHCInfoPerFill::collidingBunches() const { + return LHCInfoPerFillImpl::getOneParam(m_intParams, COLLIDING_BUNCHES); +} + +unsigned short const LHCInfoPerFill::targetBunches() const { return LHCInfoPerFillImpl::getOneParam(m_intParams, TARGET_BUNCHES); } + +LHCInfoPerFill::FillTypeId const LHCInfoPerFill::fillType() const { + return static_cast(LHCInfoPerFillImpl::getOneParam(m_intParams, FILL_TYPE)); +} + +LHCInfoPerFill::ParticleTypeId const LHCInfoPerFill::particleTypeForBeam1() const { + return static_cast(LHCInfoPerFillImpl::getOneParam(m_intParams, PARTICLES_1)); +} + +LHCInfoPerFill::ParticleTypeId const LHCInfoPerFill::particleTypeForBeam2() const { + return static_cast(LHCInfoPerFillImpl::getOneParam(m_intParams, PARTICLES_2)); +} + +float const LHCInfoPerFill::intensityForBeam1() const { return LHCInfoPerFillImpl::getOneParam(m_floatParams, INTENSITY_1); } + +float const LHCInfoPerFill::intensityForBeam2() const { return LHCInfoPerFillImpl::getOneParam(m_floatParams, INTENSITY_2); } + +float const LHCInfoPerFill::energy() const { return LHCInfoPerFillImpl::getOneParam(m_floatParams, ENERGY); } + +float const LHCInfoPerFill::delivLumi() const { return LHCInfoPerFillImpl::getOneParam(m_floatParams, DELIV_LUMI); } + +float const LHCInfoPerFill::recLumi() const { return LHCInfoPerFillImpl::getOneParam(m_floatParams, REC_LUMI); } + +float const LHCInfoPerFill::instLumi() const { return LHCInfoPerFillImpl::getOneParam(m_floatParams, INST_LUMI); } + +float const LHCInfoPerFill::instLumiError() const { return LHCInfoPerFillImpl::getOneParam(m_floatParams, INST_LUMI_ERR); } + +cond::Time_t const LHCInfoPerFill::createTime() const { return LHCInfoPerFillImpl::getOneParam(m_timeParams, CREATE_TIME); } + +cond::Time_t const LHCInfoPerFill::beginTime() const { return LHCInfoPerFillImpl::getOneParam(m_timeParams, BEGIN_TIME); } + +cond::Time_t const LHCInfoPerFill::endTime() const { return LHCInfoPerFillImpl::getOneParam(m_timeParams, END_TIME); } + +std::string const& LHCInfoPerFill::injectionScheme() const { + return LHCInfoPerFillImpl::getOneParam(m_stringParams, INJECTION_SCHEME); +} + +std::vector const& LHCInfoPerFill::lumiPerBX() const { return LHCInfoPerFillImpl::getParams(m_floatParams, LUMI_PER_B); } + +std::string const& LHCInfoPerFill::lhcState() const { return LHCInfoPerFillImpl::getOneParam(m_stringParams, LHC_STATE); } + +std::string const& LHCInfoPerFill::lhcComment() const { return LHCInfoPerFillImpl::getOneParam(m_stringParams, LHC_COMMENT); } + +std::string const& LHCInfoPerFill::ctppsStatus() const { return LHCInfoPerFillImpl::getOneParam(m_stringParams, CTPPS_STATUS); } + +std::vector const& LHCInfoPerFill::beam1VC() const { return LHCInfoPerFillImpl::getParams(m_floatParams, BEAM1_VC); } + +std::vector const& LHCInfoPerFill::beam2VC() const { return LHCInfoPerFillImpl::getParams(m_floatParams, BEAM2_VC); } + +std::vector const& LHCInfoPerFill::beam1RF() const { return LHCInfoPerFillImpl::getParams(m_floatParams, BEAM1_RF); } + +std::vector const& LHCInfoPerFill::beam2RF() const { return LHCInfoPerFillImpl::getParams(m_floatParams, BEAM2_RF); } + +std::vector& LHCInfoPerFill::beam1VC() { return LHCInfoPerFillImpl::accessParams(m_floatParams, BEAM1_VC); } + +std::vector& LHCInfoPerFill::beam2VC() { return LHCInfoPerFillImpl::accessParams(m_floatParams, BEAM2_VC); } + +std::vector& LHCInfoPerFill::beam1RF() { return LHCInfoPerFillImpl::accessParams(m_floatParams, BEAM1_RF); } + +std::vector& LHCInfoPerFill::beam2RF() { return LHCInfoPerFillImpl::accessParams(m_floatParams, BEAM2_RF); } + +//returns a boolean, true if the injection scheme has a leading 25ns +//TODO: parse the circulating bunch configuration, instead of the string. +bool LHCInfoPerFill::is25nsBunchSpacing() const { + const std::string prefix("25ns"); + return std::equal(prefix.begin(), prefix.end(), injectionScheme().begin()); +} + +//returns a boolean, true if the bunch slot number is in the circulating bunch configuration +bool LHCInfoPerFill::isBunchInBeam1(size_t const& bunch) const { + if (bunch == 0) + throw std::out_of_range("0 not allowed"); //CMS starts counting bunch crossing from 1! + return m_bunchConfiguration1.test(bunch); +} + +bool LHCInfoPerFill::isBunchInBeam2(size_t const& bunch) const { + if (bunch == 0) + throw std::out_of_range("0 not allowed"); //CMS starts counting bunch crossing from 1! + return m_bunchConfiguration2.test(bunch); +} + +//member functions returning *by value* a vector with all filled bunch slots +std::vector LHCInfoPerFill::bunchConfigurationForBeam1() const { + return bitsetToVector(m_bunchConfiguration1); +} + +std::vector LHCInfoPerFill::bunchConfigurationForBeam2() const { + return bitsetToVector(m_bunchConfiguration2); +} + +void LHCInfoPerFill::setFillNumber(unsigned short lhcFill) { + LHCInfoPerFillImpl::setOneParam(m_intParams, LHC_FILL, static_cast(lhcFill)); +} + +//setters +void LHCInfoPerFill::setBunchesInBeam1(unsigned short const& bunches) { + LHCInfoPerFillImpl::setOneParam(m_intParams, BUNCHES_1, static_cast(bunches)); +} + +void LHCInfoPerFill::setBunchesInBeam2(unsigned short const& bunches) { + LHCInfoPerFillImpl::setOneParam(m_intParams, BUNCHES_2, static_cast(bunches)); +} + +void LHCInfoPerFill::setCollidingBunches(unsigned short const& collidingBunches) { + LHCInfoPerFillImpl::setOneParam(m_intParams, COLLIDING_BUNCHES, static_cast(collidingBunches)); +} + +void LHCInfoPerFill::setTargetBunches(unsigned short const& targetBunches) { + LHCInfoPerFillImpl::setOneParam(m_intParams, TARGET_BUNCHES, static_cast(targetBunches)); +} + +void LHCInfoPerFill::setFillType(LHCInfoPerFill::FillTypeId const& fillType) { + LHCInfoPerFillImpl::setOneParam(m_intParams, FILL_TYPE, static_cast(fillType)); +} + +void LHCInfoPerFill::setParticleTypeForBeam1(LHCInfoPerFill::ParticleTypeId const& particleType) { + LHCInfoPerFillImpl::setOneParam(m_intParams, PARTICLES_1, static_cast(particleType)); +} + +void LHCInfoPerFill::setParticleTypeForBeam2(LHCInfoPerFill::ParticleTypeId const& particleType) { + LHCInfoPerFillImpl::setOneParam(m_intParams, PARTICLES_2, static_cast(particleType)); +} + +void LHCInfoPerFill::setIntensityForBeam1(float const& intensity) { + LHCInfoPerFillImpl::setOneParam(m_floatParams, INTENSITY_1, intensity); +} + +void LHCInfoPerFill::setIntensityForBeam2(float const& intensity) { + LHCInfoPerFillImpl::setOneParam(m_floatParams, INTENSITY_2, intensity); +} + +void LHCInfoPerFill::setEnergy(float const& energy) { LHCInfoPerFillImpl::setOneParam(m_floatParams, ENERGY, energy); } + +void LHCInfoPerFill::setDelivLumi(float const& delivLumi) { LHCInfoPerFillImpl::setOneParam(m_floatParams, DELIV_LUMI, delivLumi); } + +void LHCInfoPerFill::setRecLumi(float const& recLumi) { LHCInfoPerFillImpl::setOneParam(m_floatParams, REC_LUMI, recLumi); } + +void LHCInfoPerFill::setInstLumi(float const& instLumi) { LHCInfoPerFillImpl::setOneParam(m_floatParams, INST_LUMI, instLumi); } + +void LHCInfoPerFill::setInstLumiError(float const& instLumiError) { + LHCInfoPerFillImpl::setOneParam(m_floatParams, INST_LUMI_ERR, instLumiError); +} + +void LHCInfoPerFill::setCreationTime(cond::Time_t const& createTime) { + LHCInfoPerFillImpl::setOneParam(m_timeParams, CREATE_TIME, createTime); +} + +void LHCInfoPerFill::setBeginTime(cond::Time_t const& beginTime) { + LHCInfoPerFillImpl::setOneParam(m_timeParams, BEGIN_TIME, beginTime); +} + +void LHCInfoPerFill::setEndTime(cond::Time_t const& endTime) { LHCInfoPerFillImpl::setOneParam(m_timeParams, END_TIME, endTime); } + +void LHCInfoPerFill::setInjectionScheme(std::string const& injectionScheme) { + LHCInfoPerFillImpl::setOneParam(m_stringParams, INJECTION_SCHEME, injectionScheme); +} + +void LHCInfoPerFill::setLumiPerBX(std::vector const& lumiPerBX) { + LHCInfoPerFillImpl::setParams(m_floatParams, LUMI_PER_B, lumiPerBX); +} + +void LHCInfoPerFill::setLhcState(std::string const& lhcState) { + LHCInfoPerFillImpl::setOneParam(m_stringParams, LHC_STATE, lhcState); +} + +void LHCInfoPerFill::setLhcComment(std::string const& lhcComment) { + LHCInfoPerFillImpl::setOneParam(m_stringParams, LHC_COMMENT, lhcComment); +} + +void LHCInfoPerFill::setCtppsStatus(std::string const& ctppsStatus) { + LHCInfoPerFillImpl::setOneParam(m_stringParams, CTPPS_STATUS, ctppsStatus); +} + +void LHCInfoPerFill::setBeam1VC(std::vector const& beam1VC) { + LHCInfoPerFillImpl::setParams(m_floatParams, BEAM1_VC, beam1VC); +} + +void LHCInfoPerFill::setBeam2VC(std::vector const& beam2VC) { + LHCInfoPerFillImpl::setParams(m_floatParams, BEAM2_VC, beam2VC); +} + +void LHCInfoPerFill::setBeam1RF(std::vector const& beam1RF) { + LHCInfoPerFillImpl::setParams(m_floatParams, BEAM1_RF, beam1RF); +} + +void LHCInfoPerFill::setBeam2RF(std::vector const& beam2RF) { + LHCInfoPerFillImpl::setParams(m_floatParams, BEAM2_RF, beam2RF); +} + +//sets all values in one go +void LHCInfoPerFill::setInfo(unsigned short const& bunches1, + unsigned short const& bunches2, + unsigned short const& collidingBunches, + unsigned short const& targetBunches, + FillTypeId const& fillType, + ParticleTypeId const& particleType1, + ParticleTypeId const& particleType2, + float const& intensity1, + float const& intensity2, + float const& energy, + float const& delivLumi, + float const& recLumi, + float const& instLumi, + float const& instLumiError, + cond::Time_t const& createTime, + cond::Time_t const& beginTime, + cond::Time_t const& endTime, + std::string const& scheme, + std::vector const& lumiPerBX, + std::string const& lhcState, + std::string const& lhcComment, + std::string const& ctppsStatus, + std::vector const& beam1VC, + std::vector const& beam2VC, + std::vector const& beam1RF, + std::vector const& beam2RF, + std::bitset const& bunchConf1, + std::bitset const& bunchConf2) { + this->setBunchesInBeam1(bunches1); + this->setBunchesInBeam2(bunches2); + this->setCollidingBunches(collidingBunches); + this->setTargetBunches(targetBunches); + this->setFillType(fillType); + this->setParticleTypeForBeam1(particleType1); + this->setParticleTypeForBeam2(particleType2); + this->setIntensityForBeam1(intensity1); + this->setIntensityForBeam2(intensity2); + this->setEnergy(energy); + this->setDelivLumi(delivLumi); + this->setRecLumi(recLumi); + this->setInstLumi(instLumi); + this->setInstLumiError(instLumiError); + this->setCreationTime(createTime); + this->setBeginTime(beginTime); + this->setEndTime(endTime); + this->setInjectionScheme(scheme); + this->setLumiPerBX(lumiPerBX); + this->setLhcState(lhcState); + this->setLhcComment(lhcComment); + this->setCtppsStatus(ctppsStatus); + this->setBeam1VC(beam1VC); + this->setBeam2VC(beam2VC); + this->setBeam1RF(beam1RF); + this->setBeam2RF(beam2RF); + this->setBunchBitsetForBeam1(bunchConf1); + this->setBunchBitsetForBeam2(bunchConf2); +} + +void LHCInfoPerFill::print(std::stringstream& ss) const { + ss << "LHC fill: " << this->fillNumber() << std::endl + << "Bunches in Beam 1: " << this->bunchesInBeam1() << std::endl + << "Bunches in Beam 2: " << this->bunchesInBeam2() << std::endl + << "Colliding bunches at IP5: " << this->collidingBunches() << std::endl + << "Target bunches at IP5: " << this->targetBunches() << std::endl + << "Fill type: " << fillTypeToString(static_cast(this->fillType())) << std::endl + << "Particle type for Beam 1: " << particleTypeToString(static_cast(this->particleTypeForBeam1())) + << std::endl + << "Particle type for Beam 2: " << particleTypeToString(static_cast(this->particleTypeForBeam2())) + << std::endl + << "Average Intensity for Beam 1 (number of charges): " << this->intensityForBeam1() << std::endl + << "Average Intensity for Beam 2 (number of charges): " << this->intensityForBeam2() << std::endl + << "Energy (GeV): " << this->energy() << std::endl + << "Delivered Luminosity (max): " << this->delivLumi() << std::endl + << "Recorded Luminosity (max): " << this->recLumi() << std::endl + << "Instantaneous Luminosity: " << this->instLumi() << std::endl + << "Instantaneous Luminosity Error: " << this->instLumiError() << std::endl + << "Creation time of the fill: " + << boost::posix_time::to_iso_extended_string(cond::time::to_boost(this->createTime())) << std::endl + << "Begin time of Stable Beam flag: " + << boost::posix_time::to_iso_extended_string(cond::time::to_boost(this->beginTime())) << std::endl + << "End time of the fill: " << boost::posix_time::to_iso_extended_string(cond::time::to_boost(this->endTime())) + << std::endl + << "Injection scheme as given by LPC: " << this->injectionScheme() << std::endl + << "LHC State: " << this->lhcState() << std::endl + << "LHC Comments: " << this->lhcComment() << std::endl + << "CTPPS Status: " << this->ctppsStatus() << std::endl; + + ss << "Luminosity per bunch (total " << this->lumiPerBX().size() << "): "; + std::copy(this->lumiPerBX().begin(), this->lumiPerBX().end(), std::ostream_iterator(ss, ", ")); + ss << std::endl; + + ss << "Beam 1 VC (total " << this->beam1VC().size() << "): "; + std::copy(this->beam1VC().begin(), this->beam1VC().end(), std::ostream_iterator(ss, "\t")); + ss << std::endl; + + ss << "Beam 2 VC (total " << beam2VC().size() << "): "; + std::copy(beam2VC().begin(), beam2VC().end(), std::ostream_iterator(ss, "\t")); + ss << std::endl; + + ss << "Beam 1 RF (total " << beam1RF().size() << "): "; + std::copy(beam1RF().begin(), beam1RF().end(), std::ostream_iterator(ss, "\t")); + ss << std::endl; + + ss << "Beam 2 RF (total " << beam2RF().size() << "): "; + std::copy(beam2RF().begin(), beam2RF().end(), std::ostream_iterator(ss, "\t")); + ss << std::endl; + + std::vector bunchVector1 = this->bunchConfigurationForBeam1(); + std::vector bunchVector2 = this->bunchConfigurationForBeam2(); + ss << "Bunches filled for Beam 1 (total " << bunchVector1.size() << "): "; + std::copy(bunchVector1.begin(), bunchVector1.end(), std::ostream_iterator(ss, ", ")); + ss << std::endl; + ss << "Bunches filled for Beam 2 (total " << bunchVector2.size() << "): "; + std::copy(bunchVector2.begin(), bunchVector2.end(), std::ostream_iterator(ss, ", ")); + ss << std::endl; +} + +//protected getters +std::bitset const& LHCInfoPerFill::bunchBitsetForBeam1() const { return m_bunchConfiguration1; } + +std::bitset const& LHCInfoPerFill::bunchBitsetForBeam2() const { return m_bunchConfiguration2; } + +//protected setters +void LHCInfoPerFill::setBunchBitsetForBeam1(std::bitset const& bunchConfiguration) { + m_bunchConfiguration1 = bunchConfiguration; +} + +void LHCInfoPerFill::setBunchBitsetForBeam2(std::bitset const& bunchConfiguration) { + m_bunchConfiguration2 = bunchConfiguration; +} + +std::ostream& operator<<(std::ostream& os, LHCInfoPerFill beamInfo) { + std::stringstream ss; + beamInfo.print(ss); + os << ss.str(); + return os; +} + +bool LHCInfoPerFill::equals(const LHCInfoPerFill& rhs) const { + if (m_isData != rhs.m_isData) + return false; + if (m_intParams != rhs.m_intParams) + return false; + if (m_floatParams != rhs.m_floatParams) + return false; + if (m_timeParams != rhs.m_timeParams) + return false; + if (m_stringParams != rhs.m_stringParams) + return false; + if (m_bunchConfiguration1 != rhs.m_bunchConfiguration1) + return false; + if (m_bunchConfiguration2 != rhs.m_bunchConfiguration2) + return false; + return true; +} + +bool LHCInfoPerFill::empty() const { return m_intParams[0].empty(); } From a09b1b66270df6cf713b266a1f1bf9b888990aa5 Mon Sep 17 00:00:00 2001 From: Jan Chyczynski Date: Wed, 13 Jul 2022 18:27:54 +0200 Subject: [PATCH 06/39] other files for LHCInfoPerFill condtions object definition aded/modified --- CondCore/RunInfoPlugins/src/plugin.cc | 5 +++- .../DataRecord/interface/LHCInfoPerFillRcd.h | 25 +++++++++++++++++++ .../DataRecord/src/LHCInfoPerFillRcd.cc | 15 +++++++++++ .../src/T_EventSetup_LHCInfoPerFill.cc | 4 +++ CondFormats/RunInfo/src/classes_def.xml | 2 ++ CondFormats/RunInfo/src/headers.h | 3 ++- .../RunInfo/test/testSerializationRunInfo.cpp | 1 + 7 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 CondFormats/DataRecord/interface/LHCInfoPerFillRcd.h create mode 100644 CondFormats/DataRecord/src/LHCInfoPerFillRcd.cc create mode 100644 CondFormats/RunInfo/src/T_EventSetup_LHCInfoPerFill.cc diff --git a/CondCore/RunInfoPlugins/src/plugin.cc b/CondCore/RunInfoPlugins/src/plugin.cc index b8447ad0dd00c..a7821a6a4dd64 100644 --- a/CondCore/RunInfoPlugins/src/plugin.cc +++ b/CondCore/RunInfoPlugins/src/plugin.cc @@ -12,6 +12,8 @@ #include "CondFormats/RunInfo/interface/LHCInfo.h" #include "CondFormats/DataRecord/interface/LHCInfoPerLSRcd.h" #include "CondFormats/RunInfo/interface/LHCInfoPerLS.h" +#include "CondFormats/DataRecord/interface/LHCInfoPerFillRcd.h" +#include "CondFormats/RunInfo/interface/LHCInfoPerFill.h" REGISTER_PLUGIN(RunSummaryRcd, RunSummary); REGISTER_PLUGIN(RunInfoRcd, RunInfo); @@ -19,4 +21,5 @@ REGISTER_PLUGIN(L1TriggerScalerRcd, L1TriggerScaler); REGISTER_PLUGIN(MixingRcd, MixingModuleConfig); REGISTER_PLUGIN(FillInfoRcd, FillInfo); REGISTER_PLUGIN(LHCInfoRcd, LHCInfo); -REGISTER_PLUGIN(LHCInfoPerLSRcd, LHCInfoPerLS); \ No newline at end of file +REGISTER_PLUGIN(LHCInfoPerLSRcd, LHCInfoPerLS); +REGISTER_PLUGIN(LHCInfoPerFillRcd, LHCInfoPerFill); \ No newline at end of file diff --git a/CondFormats/DataRecord/interface/LHCInfoPerFillRcd.h b/CondFormats/DataRecord/interface/LHCInfoPerFillRcd.h new file mode 100644 index 0000000000000..5a4327a9baaa8 --- /dev/null +++ b/CondFormats/DataRecord/interface/LHCInfoPerFillRcd.h @@ -0,0 +1,25 @@ +#ifndef LHCInfoPerFillRcd_LHCInfoPerFillRcd_h +#define LHCInfoPerFillRcd_LHCInfoPerFillRcd_h +// -*- C++ -*- +// +// Package: CondFormats/DataRecord +// Class : LHCInfoPerFillRcd +// +/**\class LHCInfoPerFillRcd LHCInfoPerFillRcd.h CondFormats/DataRecord/interface/LHCInfoPerFillRcd.h + + Description: [one line class summary] + + Usage: + + +*/ +// +// Author: Jan Krzysztof Chyczynski +// Created: Wed, 13 Jul 2022 16:36:24 GMT +// + +#include "FWCore/Framework/interface/EventSetupRecordImplementation.h" + +class LHCInfoPerFillRcd : public edm::eventsetup::EventSetupRecordImplementation {}; + +#endif diff --git a/CondFormats/DataRecord/src/LHCInfoPerFillRcd.cc b/CondFormats/DataRecord/src/LHCInfoPerFillRcd.cc new file mode 100644 index 0000000000000..9c9f638faa3d9 --- /dev/null +++ b/CondFormats/DataRecord/src/LHCInfoPerFillRcd.cc @@ -0,0 +1,15 @@ +// -*- C++ -*- +// +// Package: CondFormats/DataRecord +// Class : LHCInfoPerFillRcd +// +// Implementation: +// [Notes on implementation] +// +// Author: Jan Krzysztof Chyczynski +// Created: Wed, 13 Jul 2022 16:36:24 GMT + +#include "CondFormats/DataRecord/interface/LHCInfoPerFillRcd.h" +#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" + +EVENTSETUP_RECORD_REG(LHCInfoPerFillRcd); diff --git a/CondFormats/RunInfo/src/T_EventSetup_LHCInfoPerFill.cc b/CondFormats/RunInfo/src/T_EventSetup_LHCInfoPerFill.cc new file mode 100644 index 0000000000000..1dcf64621db96 --- /dev/null +++ b/CondFormats/RunInfo/src/T_EventSetup_LHCInfoPerFill.cc @@ -0,0 +1,4 @@ +#include "CondFormats/RunInfo/interface/LHCInfoPerFill.h" +#include "FWCore/Utilities/interface/typelookup.h" + +TYPELOOKUP_DATA_REG(LHCInfoPerFill); diff --git a/CondFormats/RunInfo/src/classes_def.xml b/CondFormats/RunInfo/src/classes_def.xml index 4bfb6a16a1a54..fffa87301e9bf 100644 --- a/CondFormats/RunInfo/src/classes_def.xml +++ b/CondFormats/RunInfo/src/classes_def.xml @@ -24,4 +24,6 @@ + + diff --git a/CondFormats/RunInfo/src/headers.h b/CondFormats/RunInfo/src/headers.h index a1126d2e2aec0..cc2810e31784e 100644 --- a/CondFormats/RunInfo/src/headers.h +++ b/CondFormats/RunInfo/src/headers.h @@ -5,4 +5,5 @@ #include "CondFormats/RunInfo/interface/MixingModuleConfig.h" #include "CondFormats/RunInfo/interface/FillInfo.h" #include "CondFormats/RunInfo/interface/LHCInfo.h" -#include "CondFormats/RunInfo/interface/LHCInfoPerLS.h" \ No newline at end of file +#include "CondFormats/RunInfo/interface/LHCInfoPerLS.h" +#include "CondFormats/RunInfo/interface/LHCInfoPerFill.h" \ No newline at end of file diff --git a/CondFormats/RunInfo/test/testSerializationRunInfo.cpp b/CondFormats/RunInfo/test/testSerializationRunInfo.cpp index 5aea6c7eecdf4..6236b11e35170 100644 --- a/CondFormats/RunInfo/test/testSerializationRunInfo.cpp +++ b/CondFormats/RunInfo/test/testSerializationRunInfo.cpp @@ -6,6 +6,7 @@ int main() { testSerialization(); testSerialization(); testSerialization(); + testSerialization(); testSerialization(); testSerialization(); testSerialization(); From 3a30c8951d06aa2eabff8d23833f00af7be07ebf Mon Sep 17 00:00:00 2001 From: Jan Chyczynski Date: Mon, 18 Jul 2022 16:25:36 +0200 Subject: [PATCH 07/39] moved vectorized fields handling to a new class LHCInfoVectorizedFields --- .../RunInfo/interface/LHCInfoPerFill.h | 3 +- CondFormats/RunInfo/interface/LHCInfoPerLS.h | 3 +- .../interface/LHCInfoVectorizedFields.h | 27 +++ CondFormats/RunInfo/src/LHCInfoPerFill.cc | 158 +++++++----------- CondFormats/RunInfo/src/LHCInfoPerLS.cc | 62 ++----- .../RunInfo/src/LHCInfoVectorizedFields.cc | 68 ++++++++ CondFormats/RunInfo/src/classes_def.xml | 2 + CondFormats/RunInfo/src/headers.h | 3 +- .../RunInfo/test/testSerializationRunInfo.cpp | 1 + 9 files changed, 172 insertions(+), 155 deletions(-) create mode 100644 CondFormats/RunInfo/interface/LHCInfoVectorizedFields.h create mode 100644 CondFormats/RunInfo/src/LHCInfoVectorizedFields.cc diff --git a/CondFormats/RunInfo/interface/LHCInfoPerFill.h b/CondFormats/RunInfo/interface/LHCInfoPerFill.h index 16af8dd95d90f..9d95739c50b47 100644 --- a/CondFormats/RunInfo/interface/LHCInfoPerFill.h +++ b/CondFormats/RunInfo/interface/LHCInfoPerFill.h @@ -2,6 +2,7 @@ #define CondFormats_RunInfo_LHCInfoPerFill_H #include "CondFormats/Serialization/interface/Serializable.h" +#include "CondFormats/RunInfo/interface/LHCInfoVectorizedFields.h" #include "CondFormats/Common/interface/Time.h" #include #include @@ -9,7 +10,7 @@ #include #include -class LHCInfoPerFill { +class LHCInfoPerFill : public LHCInfoVectorizedFields { public: enum FillType { UNKNOWN = 0, PROTONS = 1, IONS = 2, COSMICS = 3, GAP = 4 }; enum ParticleType { NONE = 0, PROTON = 1, PB82 = 2, AR18 = 3, D = 4, XE54 = 5 }; diff --git a/CondFormats/RunInfo/interface/LHCInfoPerLS.h b/CondFormats/RunInfo/interface/LHCInfoPerLS.h index 5d3296bf47f22..2a113d36e0b58 100644 --- a/CondFormats/RunInfo/interface/LHCInfoPerLS.h +++ b/CondFormats/RunInfo/interface/LHCInfoPerLS.h @@ -2,13 +2,14 @@ #define CondFormats_RunInfo_LHCInfoPerLS_H #include "CondFormats/Serialization/interface/Serializable.h" +#include "CondFormats/RunInfo/interface/LHCInfoVectorizedFields.h" #include #include #include #include #include -class LHCInfoPerLS { +class LHCInfoPerLS : public LHCInfoVectorizedFields { public: enum IntParamIndex { LUMI_SECTION = 0, diff --git a/CondFormats/RunInfo/interface/LHCInfoVectorizedFields.h b/CondFormats/RunInfo/interface/LHCInfoVectorizedFields.h new file mode 100644 index 0000000000000..933bae664708a --- /dev/null +++ b/CondFormats/RunInfo/interface/LHCInfoVectorizedFields.h @@ -0,0 +1,27 @@ +#ifndef CondFormats_RunInfo_LHCInfoVectorizedFields_H +#define CondFormats_RunInfo_LHCInfoVectorizedFields_H + +#include "CondFormats/Serialization/interface/Serializable.h" +#include + +class LHCInfoVectorizedFields { +public: + template + static const T& getParams(const std::vector& params, size_t index); + + template + static T& accessParams(std::vector& params, size_t index); + + template + static const T& getOneParam(const std::vector >& params, size_t index); + + template + static void setOneParam(std::vector >& params, size_t index, const T& value); + + template + static void setParams(std::vector& params, size_t index, const T& value); + + COND_SERIALIZABLE; +}; + +#endif // CondFormats_RunInfo_LHCInfoVectorizedFields_H \ No newline at end of file diff --git a/CondFormats/RunInfo/src/LHCInfoPerFill.cc b/CondFormats/RunInfo/src/LHCInfoPerFill.cc index 30796383af04b..9ac06a32572b2 100644 --- a/CondFormats/RunInfo/src/LHCInfoPerFill.cc +++ b/CondFormats/RunInfo/src/LHCInfoPerFill.cc @@ -112,120 +112,78 @@ LHCInfoPerFill* LHCInfoPerFill::cloneFill() const { return ret; } -namespace LHCInfoPerFillImpl { - template - const T& getParams(const std::vector& params, size_t index) { - if (index >= params.size()) - throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range."); - return params[index]; - } - - template - T& accessParams(std::vector& params, size_t index) { - if (index >= params.size()) - throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range."); - return params[index]; - } - - template - const T& getOneParam(const std::vector >& params, size_t index) { - if (index >= params.size()) - throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range."); - const std::vector& inner = params[index]; - if (inner.empty()) - throw std::out_of_range("Parameter with index " + std::to_string(index) + " type=" + typeid(T).name() + - " has no value stored."); - return inner[0]; - } - - template - void setOneParam(std::vector >& params, size_t index, const T& value) { - if (index >= params.size()) - throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range."); - params[index] = std::vector(1, value); - } - - template - void setParams(std::vector& params, size_t index, const T& value) { - if (index >= params.size()) - throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range."); - params[index] = value; - } - -} // namespace LHCInfoPerFillImpl - //getters -unsigned short const LHCInfoPerFill::fillNumber() const { return LHCInfoPerFillImpl::getOneParam(m_intParams, LHC_FILL); } +unsigned short const LHCInfoPerFill::fillNumber() const { return LHCInfoPerFill::getOneParam(m_intParams, LHC_FILL); } -unsigned short const LHCInfoPerFill::bunchesInBeam1() const { return LHCInfoPerFillImpl::getOneParam(m_intParams, BUNCHES_1); } +unsigned short const LHCInfoPerFill::bunchesInBeam1() const { return LHCInfoPerFill::getOneParam(m_intParams, BUNCHES_1); } -unsigned short const LHCInfoPerFill::bunchesInBeam2() const { return LHCInfoPerFillImpl::getOneParam(m_intParams, BUNCHES_2); } +unsigned short const LHCInfoPerFill::bunchesInBeam2() const { return LHCInfoPerFill::getOneParam(m_intParams, BUNCHES_2); } unsigned short const LHCInfoPerFill::collidingBunches() const { - return LHCInfoPerFillImpl::getOneParam(m_intParams, COLLIDING_BUNCHES); + return LHCInfoPerFill::getOneParam(m_intParams, COLLIDING_BUNCHES); } -unsigned short const LHCInfoPerFill::targetBunches() const { return LHCInfoPerFillImpl::getOneParam(m_intParams, TARGET_BUNCHES); } +unsigned short const LHCInfoPerFill::targetBunches() const { return LHCInfoPerFill::getOneParam(m_intParams, TARGET_BUNCHES); } LHCInfoPerFill::FillTypeId const LHCInfoPerFill::fillType() const { - return static_cast(LHCInfoPerFillImpl::getOneParam(m_intParams, FILL_TYPE)); + return static_cast(LHCInfoPerFill::getOneParam(m_intParams, FILL_TYPE)); } LHCInfoPerFill::ParticleTypeId const LHCInfoPerFill::particleTypeForBeam1() const { - return static_cast(LHCInfoPerFillImpl::getOneParam(m_intParams, PARTICLES_1)); + return static_cast(LHCInfoPerFill::getOneParam(m_intParams, PARTICLES_1)); } LHCInfoPerFill::ParticleTypeId const LHCInfoPerFill::particleTypeForBeam2() const { - return static_cast(LHCInfoPerFillImpl::getOneParam(m_intParams, PARTICLES_2)); + return static_cast(LHCInfoPerFill::getOneParam(m_intParams, PARTICLES_2)); } -float const LHCInfoPerFill::intensityForBeam1() const { return LHCInfoPerFillImpl::getOneParam(m_floatParams, INTENSITY_1); } +float const LHCInfoPerFill::intensityForBeam1() const { return LHCInfoPerFill::getOneParam(m_floatParams, INTENSITY_1); } -float const LHCInfoPerFill::intensityForBeam2() const { return LHCInfoPerFillImpl::getOneParam(m_floatParams, INTENSITY_2); } +float const LHCInfoPerFill::intensityForBeam2() const { return LHCInfoPerFill::getOneParam(m_floatParams, INTENSITY_2); } -float const LHCInfoPerFill::energy() const { return LHCInfoPerFillImpl::getOneParam(m_floatParams, ENERGY); } +float const LHCInfoPerFill::energy() const { return LHCInfoPerFill::getOneParam(m_floatParams, ENERGY); } -float const LHCInfoPerFill::delivLumi() const { return LHCInfoPerFillImpl::getOneParam(m_floatParams, DELIV_LUMI); } +float const LHCInfoPerFill::delivLumi() const { return LHCInfoPerFill::getOneParam(m_floatParams, DELIV_LUMI); } -float const LHCInfoPerFill::recLumi() const { return LHCInfoPerFillImpl::getOneParam(m_floatParams, REC_LUMI); } +float const LHCInfoPerFill::recLumi() const { return LHCInfoPerFill::getOneParam(m_floatParams, REC_LUMI); } -float const LHCInfoPerFill::instLumi() const { return LHCInfoPerFillImpl::getOneParam(m_floatParams, INST_LUMI); } +float const LHCInfoPerFill::instLumi() const { return LHCInfoPerFill::getOneParam(m_floatParams, INST_LUMI); } -float const LHCInfoPerFill::instLumiError() const { return LHCInfoPerFillImpl::getOneParam(m_floatParams, INST_LUMI_ERR); } +float const LHCInfoPerFill::instLumiError() const { return LHCInfoPerFill::getOneParam(m_floatParams, INST_LUMI_ERR); } -cond::Time_t const LHCInfoPerFill::createTime() const { return LHCInfoPerFillImpl::getOneParam(m_timeParams, CREATE_TIME); } +cond::Time_t const LHCInfoPerFill::createTime() const { return LHCInfoPerFill::getOneParam(m_timeParams, CREATE_TIME); } -cond::Time_t const LHCInfoPerFill::beginTime() const { return LHCInfoPerFillImpl::getOneParam(m_timeParams, BEGIN_TIME); } +cond::Time_t const LHCInfoPerFill::beginTime() const { return LHCInfoPerFill::getOneParam(m_timeParams, BEGIN_TIME); } -cond::Time_t const LHCInfoPerFill::endTime() const { return LHCInfoPerFillImpl::getOneParam(m_timeParams, END_TIME); } +cond::Time_t const LHCInfoPerFill::endTime() const { return LHCInfoPerFill::getOneParam(m_timeParams, END_TIME); } std::string const& LHCInfoPerFill::injectionScheme() const { - return LHCInfoPerFillImpl::getOneParam(m_stringParams, INJECTION_SCHEME); + return LHCInfoPerFill::getOneParam(m_stringParams, INJECTION_SCHEME); } -std::vector const& LHCInfoPerFill::lumiPerBX() const { return LHCInfoPerFillImpl::getParams(m_floatParams, LUMI_PER_B); } +std::vector const& LHCInfoPerFill::lumiPerBX() const { return LHCInfoPerFill::getParams(m_floatParams, LUMI_PER_B); } -std::string const& LHCInfoPerFill::lhcState() const { return LHCInfoPerFillImpl::getOneParam(m_stringParams, LHC_STATE); } +std::string const& LHCInfoPerFill::lhcState() const { return LHCInfoPerFill::getOneParam(m_stringParams, LHC_STATE); } -std::string const& LHCInfoPerFill::lhcComment() const { return LHCInfoPerFillImpl::getOneParam(m_stringParams, LHC_COMMENT); } +std::string const& LHCInfoPerFill::lhcComment() const { return LHCInfoPerFill::getOneParam(m_stringParams, LHC_COMMENT); } -std::string const& LHCInfoPerFill::ctppsStatus() const { return LHCInfoPerFillImpl::getOneParam(m_stringParams, CTPPS_STATUS); } +std::string const& LHCInfoPerFill::ctppsStatus() const { return LHCInfoPerFill::getOneParam(m_stringParams, CTPPS_STATUS); } -std::vector const& LHCInfoPerFill::beam1VC() const { return LHCInfoPerFillImpl::getParams(m_floatParams, BEAM1_VC); } +std::vector const& LHCInfoPerFill::beam1VC() const { return LHCInfoPerFill::getParams(m_floatParams, BEAM1_VC); } -std::vector const& LHCInfoPerFill::beam2VC() const { return LHCInfoPerFillImpl::getParams(m_floatParams, BEAM2_VC); } +std::vector const& LHCInfoPerFill::beam2VC() const { return LHCInfoPerFill::getParams(m_floatParams, BEAM2_VC); } -std::vector const& LHCInfoPerFill::beam1RF() const { return LHCInfoPerFillImpl::getParams(m_floatParams, BEAM1_RF); } +std::vector const& LHCInfoPerFill::beam1RF() const { return LHCInfoPerFill::getParams(m_floatParams, BEAM1_RF); } -std::vector const& LHCInfoPerFill::beam2RF() const { return LHCInfoPerFillImpl::getParams(m_floatParams, BEAM2_RF); } +std::vector const& LHCInfoPerFill::beam2RF() const { return LHCInfoPerFill::getParams(m_floatParams, BEAM2_RF); } -std::vector& LHCInfoPerFill::beam1VC() { return LHCInfoPerFillImpl::accessParams(m_floatParams, BEAM1_VC); } +std::vector& LHCInfoPerFill::beam1VC() { return LHCInfoPerFill::accessParams(m_floatParams, BEAM1_VC); } -std::vector& LHCInfoPerFill::beam2VC() { return LHCInfoPerFillImpl::accessParams(m_floatParams, BEAM2_VC); } +std::vector& LHCInfoPerFill::beam2VC() { return LHCInfoPerFill::accessParams(m_floatParams, BEAM2_VC); } -std::vector& LHCInfoPerFill::beam1RF() { return LHCInfoPerFillImpl::accessParams(m_floatParams, BEAM1_RF); } +std::vector& LHCInfoPerFill::beam1RF() { return LHCInfoPerFill::accessParams(m_floatParams, BEAM1_RF); } -std::vector& LHCInfoPerFill::beam2RF() { return LHCInfoPerFillImpl::accessParams(m_floatParams, BEAM2_RF); } +std::vector& LHCInfoPerFill::beam2RF() { return LHCInfoPerFill::accessParams(m_floatParams, BEAM2_RF); } //returns a boolean, true if the injection scheme has a leading 25ns //TODO: parse the circulating bunch configuration, instead of the string. @@ -257,102 +215,102 @@ std::vector LHCInfoPerFill::bunchConfigurationForBeam2() const { } void LHCInfoPerFill::setFillNumber(unsigned short lhcFill) { - LHCInfoPerFillImpl::setOneParam(m_intParams, LHC_FILL, static_cast(lhcFill)); + LHCInfoPerFill::setOneParam(m_intParams, LHC_FILL, static_cast(lhcFill)); } //setters void LHCInfoPerFill::setBunchesInBeam1(unsigned short const& bunches) { - LHCInfoPerFillImpl::setOneParam(m_intParams, BUNCHES_1, static_cast(bunches)); + LHCInfoPerFill::setOneParam(m_intParams, BUNCHES_1, static_cast(bunches)); } void LHCInfoPerFill::setBunchesInBeam2(unsigned short const& bunches) { - LHCInfoPerFillImpl::setOneParam(m_intParams, BUNCHES_2, static_cast(bunches)); + LHCInfoPerFill::setOneParam(m_intParams, BUNCHES_2, static_cast(bunches)); } void LHCInfoPerFill::setCollidingBunches(unsigned short const& collidingBunches) { - LHCInfoPerFillImpl::setOneParam(m_intParams, COLLIDING_BUNCHES, static_cast(collidingBunches)); + LHCInfoPerFill::setOneParam(m_intParams, COLLIDING_BUNCHES, static_cast(collidingBunches)); } void LHCInfoPerFill::setTargetBunches(unsigned short const& targetBunches) { - LHCInfoPerFillImpl::setOneParam(m_intParams, TARGET_BUNCHES, static_cast(targetBunches)); + LHCInfoPerFill::setOneParam(m_intParams, TARGET_BUNCHES, static_cast(targetBunches)); } void LHCInfoPerFill::setFillType(LHCInfoPerFill::FillTypeId const& fillType) { - LHCInfoPerFillImpl::setOneParam(m_intParams, FILL_TYPE, static_cast(fillType)); + LHCInfoPerFill::setOneParam(m_intParams, FILL_TYPE, static_cast(fillType)); } void LHCInfoPerFill::setParticleTypeForBeam1(LHCInfoPerFill::ParticleTypeId const& particleType) { - LHCInfoPerFillImpl::setOneParam(m_intParams, PARTICLES_1, static_cast(particleType)); + LHCInfoPerFill::setOneParam(m_intParams, PARTICLES_1, static_cast(particleType)); } void LHCInfoPerFill::setParticleTypeForBeam2(LHCInfoPerFill::ParticleTypeId const& particleType) { - LHCInfoPerFillImpl::setOneParam(m_intParams, PARTICLES_2, static_cast(particleType)); + LHCInfoPerFill::setOneParam(m_intParams, PARTICLES_2, static_cast(particleType)); } void LHCInfoPerFill::setIntensityForBeam1(float const& intensity) { - LHCInfoPerFillImpl::setOneParam(m_floatParams, INTENSITY_1, intensity); + LHCInfoPerFill::setOneParam(m_floatParams, INTENSITY_1, intensity); } void LHCInfoPerFill::setIntensityForBeam2(float const& intensity) { - LHCInfoPerFillImpl::setOneParam(m_floatParams, INTENSITY_2, intensity); + LHCInfoPerFill::setOneParam(m_floatParams, INTENSITY_2, intensity); } -void LHCInfoPerFill::setEnergy(float const& energy) { LHCInfoPerFillImpl::setOneParam(m_floatParams, ENERGY, energy); } +void LHCInfoPerFill::setEnergy(float const& energy) { LHCInfoPerFill::setOneParam(m_floatParams, ENERGY, energy); } -void LHCInfoPerFill::setDelivLumi(float const& delivLumi) { LHCInfoPerFillImpl::setOneParam(m_floatParams, DELIV_LUMI, delivLumi); } +void LHCInfoPerFill::setDelivLumi(float const& delivLumi) { LHCInfoPerFill::setOneParam(m_floatParams, DELIV_LUMI, delivLumi); } -void LHCInfoPerFill::setRecLumi(float const& recLumi) { LHCInfoPerFillImpl::setOneParam(m_floatParams, REC_LUMI, recLumi); } +void LHCInfoPerFill::setRecLumi(float const& recLumi) { LHCInfoPerFill::setOneParam(m_floatParams, REC_LUMI, recLumi); } -void LHCInfoPerFill::setInstLumi(float const& instLumi) { LHCInfoPerFillImpl::setOneParam(m_floatParams, INST_LUMI, instLumi); } +void LHCInfoPerFill::setInstLumi(float const& instLumi) { LHCInfoPerFill::setOneParam(m_floatParams, INST_LUMI, instLumi); } void LHCInfoPerFill::setInstLumiError(float const& instLumiError) { - LHCInfoPerFillImpl::setOneParam(m_floatParams, INST_LUMI_ERR, instLumiError); + LHCInfoPerFill::setOneParam(m_floatParams, INST_LUMI_ERR, instLumiError); } void LHCInfoPerFill::setCreationTime(cond::Time_t const& createTime) { - LHCInfoPerFillImpl::setOneParam(m_timeParams, CREATE_TIME, createTime); + LHCInfoPerFill::setOneParam(m_timeParams, CREATE_TIME, createTime); } void LHCInfoPerFill::setBeginTime(cond::Time_t const& beginTime) { - LHCInfoPerFillImpl::setOneParam(m_timeParams, BEGIN_TIME, beginTime); + LHCInfoPerFill::setOneParam(m_timeParams, BEGIN_TIME, beginTime); } -void LHCInfoPerFill::setEndTime(cond::Time_t const& endTime) { LHCInfoPerFillImpl::setOneParam(m_timeParams, END_TIME, endTime); } +void LHCInfoPerFill::setEndTime(cond::Time_t const& endTime) { LHCInfoPerFill::setOneParam(m_timeParams, END_TIME, endTime); } void LHCInfoPerFill::setInjectionScheme(std::string const& injectionScheme) { - LHCInfoPerFillImpl::setOneParam(m_stringParams, INJECTION_SCHEME, injectionScheme); + LHCInfoPerFill::setOneParam(m_stringParams, INJECTION_SCHEME, injectionScheme); } void LHCInfoPerFill::setLumiPerBX(std::vector const& lumiPerBX) { - LHCInfoPerFillImpl::setParams(m_floatParams, LUMI_PER_B, lumiPerBX); + LHCInfoPerFill::setParams(m_floatParams, LUMI_PER_B, lumiPerBX); } void LHCInfoPerFill::setLhcState(std::string const& lhcState) { - LHCInfoPerFillImpl::setOneParam(m_stringParams, LHC_STATE, lhcState); + LHCInfoPerFill::setOneParam(m_stringParams, LHC_STATE, lhcState); } void LHCInfoPerFill::setLhcComment(std::string const& lhcComment) { - LHCInfoPerFillImpl::setOneParam(m_stringParams, LHC_COMMENT, lhcComment); + LHCInfoPerFill::setOneParam(m_stringParams, LHC_COMMENT, lhcComment); } void LHCInfoPerFill::setCtppsStatus(std::string const& ctppsStatus) { - LHCInfoPerFillImpl::setOneParam(m_stringParams, CTPPS_STATUS, ctppsStatus); + LHCInfoPerFill::setOneParam(m_stringParams, CTPPS_STATUS, ctppsStatus); } void LHCInfoPerFill::setBeam1VC(std::vector const& beam1VC) { - LHCInfoPerFillImpl::setParams(m_floatParams, BEAM1_VC, beam1VC); + LHCInfoPerFill::setParams(m_floatParams, BEAM1_VC, beam1VC); } void LHCInfoPerFill::setBeam2VC(std::vector const& beam2VC) { - LHCInfoPerFillImpl::setParams(m_floatParams, BEAM2_VC, beam2VC); + LHCInfoPerFill::setParams(m_floatParams, BEAM2_VC, beam2VC); } void LHCInfoPerFill::setBeam1RF(std::vector const& beam1RF) { - LHCInfoPerFillImpl::setParams(m_floatParams, BEAM1_RF, beam1RF); + LHCInfoPerFill::setParams(m_floatParams, BEAM1_RF, beam1RF); } void LHCInfoPerFill::setBeam2RF(std::vector const& beam2RF) { - LHCInfoPerFillImpl::setParams(m_floatParams, BEAM2_RF, beam2RF); + LHCInfoPerFill::setParams(m_floatParams, BEAM2_RF, beam2RF); } //sets all values in one go diff --git a/CondFormats/RunInfo/src/LHCInfoPerLS.cc b/CondFormats/RunInfo/src/LHCInfoPerLS.cc index 9f7d373226980..cf0b79dc63720 100644 --- a/CondFormats/RunInfo/src/LHCInfoPerLS.cc +++ b/CondFormats/RunInfo/src/LHCInfoPerLS.cc @@ -16,70 +16,28 @@ LHCInfoPerLS::LHCInfoPerLS(const LHCInfoPerLS& rhs) LHCInfoPerLS::~LHCInfoPerLS() {} -namespace LHCInfoPerLSImpl { - template - const T& getParams(const std::vector& params, size_t index) { - if (index >= params.size()) - throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range."); - return params[index]; - } - - template - T& accessParams(std::vector& params, size_t index) { - if (index >= params.size()) - throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range."); - return params[index]; - } - - template - const T& getOneParam(const std::vector >& params, size_t index) { - if (index >= params.size()) - throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range."); - const std::vector& inner = params[index]; - if (inner.empty()) - throw std::out_of_range("Parameter with index " + std::to_string(index) + " type=" + typeid(T).name() + - " has no value stored."); - return inner[0]; - } - - template - void setOneParam(std::vector >& params, size_t index, const T& value) { - if (index >= params.size()) - throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range."); - params[index] = std::vector(1, value); - } - - template - void setParams(std::vector& params, size_t index, const T& value) { - if (index >= params.size()) - throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range."); - params[index] = value; - } - -} // namespace LHCInfoPerLSImpl - //getters -float const LHCInfoPerLS::crossingAngleX() const { return LHCInfoPerLSImpl::getOneParam(m_floatParams, CROSSING_ANGLE_X); } +float const LHCInfoPerLS::crossingAngleX() const { return LHCInfoPerLS::getOneParam(m_floatParams, CROSSING_ANGLE_X); } -float const LHCInfoPerLS::crossingAngleY() const { return LHCInfoPerLSImpl::getOneParam(m_floatParams, CROSSING_ANGLE_Y); } +float const LHCInfoPerLS::crossingAngleY() const { return LHCInfoPerLS::getOneParam(m_floatParams, CROSSING_ANGLE_Y); } -float const LHCInfoPerLS::betaStarX() const { return LHCInfoPerLSImpl::getOneParam(m_floatParams, BETA_STAR_X); } +float const LHCInfoPerLS::betaStarX() const { return LHCInfoPerLS::getOneParam(m_floatParams, BETA_STAR_X); } -float const LHCInfoPerLS::betaStarY() const { return LHCInfoPerLSImpl::getOneParam(m_floatParams, BETA_STAR_Y); } +float const LHCInfoPerLS::betaStarY() const { return LHCInfoPerLS::getOneParam(m_floatParams, BETA_STAR_Y); } -unsigned int const& LHCInfoPerLS::lumiSection() const { return LHCInfoPerLSImpl::getOneParam(m_intParams, LUMI_SECTION); } +unsigned int const& LHCInfoPerLS::lumiSection() const { return LHCInfoPerLS::getOneParam(m_intParams, LUMI_SECTION); } //setters -void LHCInfoPerLS::setCrossingAngleX(float const& angle) { LHCInfoPerLSImpl::setOneParam(m_floatParams, CROSSING_ANGLE_X, angle); } +void LHCInfoPerLS::setCrossingAngleX(float const& angle) { LHCInfoPerLS::setOneParam(m_floatParams, CROSSING_ANGLE_X, angle); } -void LHCInfoPerLS::setCrossingAngleY(float const& angle) { LHCInfoPerLSImpl::setOneParam(m_floatParams, CROSSING_ANGLE_Y, angle); } +void LHCInfoPerLS::setCrossingAngleY(float const& angle) { LHCInfoPerLS::setOneParam(m_floatParams, CROSSING_ANGLE_Y, angle); } -void LHCInfoPerLS::setBetaStarX(float const& betaStar) { LHCInfoPerLSImpl::setOneParam(m_floatParams, BETA_STAR_X, betaStar); } +void LHCInfoPerLS::setBetaStarX(float const& betaStar) { LHCInfoPerLS::setOneParam(m_floatParams, BETA_STAR_X, betaStar); } -void LHCInfoPerLS::setBetaStarY(float const& betaStar) { LHCInfoPerLSImpl::setOneParam(m_floatParams, BETA_STAR_Y, betaStar); } +void LHCInfoPerLS::setBetaStarY(float const& betaStar) { LHCInfoPerLS::setOneParam(m_floatParams, BETA_STAR_Y, betaStar); } void LHCInfoPerLS::setLumiSection(unsigned int const& lumiSection) { - LHCInfoPerLSImpl::setOneParam(m_intParams, LUMI_SECTION, lumiSection); + LHCInfoPerLS::setOneParam(m_intParams, LUMI_SECTION, lumiSection); } //sets all values in one go diff --git a/CondFormats/RunInfo/src/LHCInfoVectorizedFields.cc b/CondFormats/RunInfo/src/LHCInfoVectorizedFields.cc new file mode 100644 index 0000000000000..0328400ca1ea9 --- /dev/null +++ b/CondFormats/RunInfo/src/LHCInfoVectorizedFields.cc @@ -0,0 +1,68 @@ +#include "CondFormats/RunInfo/interface/LHCInfoVectorizedFields.h" + +template +const T& LHCInfoVectorizedFields::getParams(const std::vector& params, size_t index) { +if (index >= params.size()) + throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range."); +return params[index]; +} + +template const std::vector& LHCInfoVectorizedFields::getParams(const std::vector>&, size_t); +template const std::vector& LHCInfoVectorizedFields::getParams(const std::vector>&, size_t); +template const std::vector& LHCInfoVectorizedFields::getParams(const std::vector>&, size_t); +template const std::vector& LHCInfoVectorizedFields::getParams(const std::vector>&, size_t); + +template +T& LHCInfoVectorizedFields::accessParams(std::vector& params, size_t index) { +if (index >= params.size()) + throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range."); +return params[index]; +} + +template std::vector& LHCInfoVectorizedFields::accessParams(std::vector>&, size_t); +template std::vector& LHCInfoVectorizedFields::accessParams(std::vector>&, size_t); +template std::vector& LHCInfoVectorizedFields::accessParams(std::vector>&, size_t); +template std::vector& LHCInfoVectorizedFields::accessParams(std::vector>&, size_t); + + + +template +const T& LHCInfoVectorizedFields::getOneParam(const std::vector >& params, size_t index) { +if (index >= params.size()) + throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range."); +const std::vector& inner = params[index]; +if (inner.empty()) + throw std::out_of_range("Parameter with index " + std::to_string(index) + " type=" + typeid(T).name() + + " has no value stored."); +return inner[0]; +} + +template const unsigned int& LHCInfoVectorizedFields::getOneParam(const std::vector >&, size_t); +template const float& LHCInfoVectorizedFields::getOneParam(const std::vector >&, size_t); +template const unsigned long long& LHCInfoVectorizedFields::getOneParam(const std::vector >&, size_t); +template const std::string& LHCInfoVectorizedFields::getOneParam(const std::vector >&, size_t); + +template +void LHCInfoVectorizedFields::setOneParam(std::vector >& params, size_t index, const T& value) { +if (index >= params.size()) + throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range."); +params[index] = std::vector(1, value); +} + +template void LHCInfoVectorizedFields::setOneParam(std::vector >& params, size_t index, const unsigned int& value); +template void LHCInfoVectorizedFields::setOneParam(std::vector >& params, size_t index, const float& value); +template void LHCInfoVectorizedFields::setOneParam(std::vector >& params, size_t index, const unsigned long long& value); +template void LHCInfoVectorizedFields::setOneParam(std::vector >& params, size_t index, const std::string& value); + +template +void LHCInfoVectorizedFields::setParams(std::vector& params, size_t index, const T& value) { +if (index >= params.size()) + throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range."); +params[index] = value; +} + +template void LHCInfoVectorizedFields::setParams(std::vector>& params, size_t index, const std::vector& value); +template void LHCInfoVectorizedFields::setParams(std::vector>& params, size_t index, const std::vector& value); +template void LHCInfoVectorizedFields::setParams(std::vector>& params, size_t index, const std::vector& value); +template void LHCInfoVectorizedFields::setParams(std::vector>& params, size_t index, const std::vector& value); + diff --git a/CondFormats/RunInfo/src/classes_def.xml b/CondFormats/RunInfo/src/classes_def.xml index fffa87301e9bf..4a1a06abca81d 100644 --- a/CondFormats/RunInfo/src/classes_def.xml +++ b/CondFormats/RunInfo/src/classes_def.xml @@ -26,4 +26,6 @@ + + diff --git a/CondFormats/RunInfo/src/headers.h b/CondFormats/RunInfo/src/headers.h index cc2810e31784e..ef15ee4eb69c0 100644 --- a/CondFormats/RunInfo/src/headers.h +++ b/CondFormats/RunInfo/src/headers.h @@ -6,4 +6,5 @@ #include "CondFormats/RunInfo/interface/FillInfo.h" #include "CondFormats/RunInfo/interface/LHCInfo.h" #include "CondFormats/RunInfo/interface/LHCInfoPerLS.h" -#include "CondFormats/RunInfo/interface/LHCInfoPerFill.h" \ No newline at end of file +#include "CondFormats/RunInfo/interface/LHCInfoPerFill.h" +#include "CondFormats/RunInfo/interface/LHCInfoVectorizedFields.h" \ No newline at end of file diff --git a/CondFormats/RunInfo/test/testSerializationRunInfo.cpp b/CondFormats/RunInfo/test/testSerializationRunInfo.cpp index 6236b11e35170..2d2b4763fd637 100644 --- a/CondFormats/RunInfo/test/testSerializationRunInfo.cpp +++ b/CondFormats/RunInfo/test/testSerializationRunInfo.cpp @@ -7,6 +7,7 @@ int main() { testSerialization(); testSerialization(); testSerialization(); + testSerialization(); testSerialization(); testSerialization(); testSerialization(); From f34c528a5f6abb9a9d0dc344e9a3747dcde88796 Mon Sep 17 00:00:00 2001 From: Jan Chyczynski Date: Tue, 19 Jul 2022 12:15:41 +0200 Subject: [PATCH 08/39] exctracted common code to LHCInfoVectorizedFields, added empty m_timeParams and m_stringParams to LHCInfoPerLS --- CondFormats/RunInfo/interface/LHCInfoPerFill.h | 7 ------- CondFormats/RunInfo/interface/LHCInfoPerLS.h | 7 ------- .../RunInfo/interface/LHCInfoVectorizedFields.h | 17 +++++++++++++++++ CondFormats/RunInfo/src/LHCInfoPerFill.cc | 17 ++--------------- CondFormats/RunInfo/src/LHCInfoPerLS.cc | 12 ++---------- .../RunInfo/src/LHCInfoVectorizedFields.cc | 12 ++++++++++-- 6 files changed, 31 insertions(+), 41 deletions(-) diff --git a/CondFormats/RunInfo/interface/LHCInfoPerFill.h b/CondFormats/RunInfo/interface/LHCInfoPerFill.h index 9d95739c50b47..16e4c9bf61985 100644 --- a/CondFormats/RunInfo/interface/LHCInfoPerFill.h +++ b/CondFormats/RunInfo/interface/LHCInfoPerFill.h @@ -47,8 +47,6 @@ class LHCInfoPerFill : public LHCInfoVectorizedFields { typedef FillType FillTypeId; typedef ParticleType ParticleTypeId; LHCInfoPerFill(); - LHCInfoPerFill(const LHCInfoPerFill& rhs); - ~LHCInfoPerFill(); LHCInfoPerFill* cloneFill() const; @@ -236,11 +234,6 @@ class LHCInfoPerFill : public LHCInfoVectorizedFields { void setBunchBitsetForBeam2(std::bitset const& bunchConfiguration); private: - bool m_isData = false; - std::vector > m_intParams; - std::vector > m_floatParams; - std::vector > m_timeParams; - std::vector > m_stringParams; std::bitset m_bunchConfiguration1, m_bunchConfiguration2; COND_SERIALIZABLE; diff --git a/CondFormats/RunInfo/interface/LHCInfoPerLS.h b/CondFormats/RunInfo/interface/LHCInfoPerLS.h index 2a113d36e0b58..7efc1f05ea9a0 100644 --- a/CondFormats/RunInfo/interface/LHCInfoPerLS.h +++ b/CondFormats/RunInfo/interface/LHCInfoPerLS.h @@ -24,8 +24,6 @@ class LHCInfoPerLS : public LHCInfoVectorizedFields { }; LHCInfoPerLS(); - LHCInfoPerLS(const LHCInfoPerLS& rhs); - ~LHCInfoPerLS(); //getters float const crossingAngleX() const; @@ -63,11 +61,6 @@ class LHCInfoPerLS : public LHCInfoVectorizedFields { //dumping values on output stream void print(std::stringstream& ss) const; -private: - bool m_isData = false; - std::vector > m_intParams; - std::vector > m_floatParams; - COND_SERIALIZABLE; }; diff --git a/CondFormats/RunInfo/interface/LHCInfoVectorizedFields.h b/CondFormats/RunInfo/interface/LHCInfoVectorizedFields.h index 933bae664708a..094f08fac0319 100644 --- a/CondFormats/RunInfo/interface/LHCInfoVectorizedFields.h +++ b/CondFormats/RunInfo/interface/LHCInfoVectorizedFields.h @@ -5,6 +5,23 @@ #include class LHCInfoVectorizedFields { +public: + enum IntParamIndex { ISIZE = 0 }; + enum FloatParamIndex { FSIZE = 0 }; + enum TimeParamIndex { TSIZE = 0 }; + enum StringParamIndex { SSIZE = 0 }; + + LHCInfoVectorizedFields(); + +protected: + LHCInfoVectorizedFields(size_t iSize, size_t fSize, size_t tSize, size_t sSize); + + bool m_isData = false; + std::vector > m_intParams; + std::vector > m_floatParams; + std::vector > m_timeParams; + std::vector > m_stringParams; + public: template static const T& getParams(const std::vector& params, size_t index); diff --git a/CondFormats/RunInfo/src/LHCInfoPerFill.cc b/CondFormats/RunInfo/src/LHCInfoPerFill.cc index 9ac06a32572b2..0e84747e8b5e1 100644 --- a/CondFormats/RunInfo/src/LHCInfoPerFill.cc +++ b/CondFormats/RunInfo/src/LHCInfoPerFill.cc @@ -70,29 +70,16 @@ static std::string particleTypeToString(LHCInfoPerFill::ParticleTypeId const& pa return s_particleType; } -LHCInfoPerFill::LHCInfoPerFill() { - m_intParams.resize(ISIZE, std::vector(1, 0)); - m_floatParams.resize(FSIZE, std::vector(1, 0.)); +LHCInfoPerFill::LHCInfoPerFill() + : LHCInfoVectorizedFields (ISIZE, FSIZE, TSIZE, SSIZE) { m_floatParams[LUMI_PER_B] = std::vector(); m_floatParams[BEAM1_VC] = std::vector(); m_floatParams[BEAM2_VC] = std::vector(); m_floatParams[BEAM1_RF] = std::vector(); m_floatParams[BEAM2_RF] = std::vector(); - m_timeParams.resize(TSIZE, std::vector(1, 0ULL)); - m_stringParams.resize(SSIZE, std::vector(1, "")); m_stringParams[INJECTION_SCHEME].push_back(std::string("None")); } -LHCInfoPerFill::LHCInfoPerFill(const LHCInfoPerFill& rhs) - : m_intParams(rhs.m_intParams), - m_floatParams(rhs.m_floatParams), - m_timeParams(rhs.m_timeParams), - m_stringParams(rhs.m_stringParams), - m_bunchConfiguration1(rhs.m_bunchConfiguration1), - m_bunchConfiguration2(rhs.m_bunchConfiguration2) {} - -LHCInfoPerFill::~LHCInfoPerFill() {} - LHCInfoPerFill* LHCInfoPerFill::cloneFill() const { LHCInfoPerFill* ret = new LHCInfoPerFill(); ret->m_isData = m_isData; diff --git a/CondFormats/RunInfo/src/LHCInfoPerLS.cc b/CondFormats/RunInfo/src/LHCInfoPerLS.cc index cf0b79dc63720..4e253e136c5a9 100644 --- a/CondFormats/RunInfo/src/LHCInfoPerLS.cc +++ b/CondFormats/RunInfo/src/LHCInfoPerLS.cc @@ -5,16 +5,8 @@ #include #include -LHCInfoPerLS::LHCInfoPerLS() { - m_intParams.resize(ISIZE, std::vector(1, 0)); - m_floatParams.resize(FSIZE, std::vector(1, 0.)); -} - -LHCInfoPerLS::LHCInfoPerLS(const LHCInfoPerLS& rhs) - : m_intParams(rhs.m_intParams), - m_floatParams(rhs.m_floatParams) {} - -LHCInfoPerLS::~LHCInfoPerLS() {} +LHCInfoPerLS::LHCInfoPerLS() + : LHCInfoVectorizedFields (ISIZE, FSIZE, TSIZE, SSIZE) {} //getters float const LHCInfoPerLS::crossingAngleX() const { return LHCInfoPerLS::getOneParam(m_floatParams, CROSSING_ANGLE_X); } diff --git a/CondFormats/RunInfo/src/LHCInfoVectorizedFields.cc b/CondFormats/RunInfo/src/LHCInfoVectorizedFields.cc index 0328400ca1ea9..dd8d87ffa9cc2 100644 --- a/CondFormats/RunInfo/src/LHCInfoVectorizedFields.cc +++ b/CondFormats/RunInfo/src/LHCInfoVectorizedFields.cc @@ -1,5 +1,15 @@ #include "CondFormats/RunInfo/interface/LHCInfoVectorizedFields.h" +LHCInfoVectorizedFields::LHCInfoVectorizedFields() + : LHCInfoVectorizedFields(ISIZE, FSIZE, TSIZE, SSIZE) {} + +LHCInfoVectorizedFields::LHCInfoVectorizedFields(size_t iSize, size_t fSize, size_t tSize, size_t sSize) { + m_intParams.resize(iSize, std::vector(1, 0)); + m_floatParams.resize(fSize, std::vector(1, 0.)); + m_timeParams.resize(tSize, std::vector(1, 0ULL)); + m_stringParams.resize(sSize, std::vector(1, "")); +} + template const T& LHCInfoVectorizedFields::getParams(const std::vector& params, size_t index) { if (index >= params.size()) @@ -24,8 +34,6 @@ template std::vector& LHCInfoVectorizedFields::accessParams(std::vector& LHCInfoVectorizedFields::accessParams(std::vector>&, size_t); template std::vector& LHCInfoVectorizedFields::accessParams(std::vector>&, size_t); - - template const T& LHCInfoVectorizedFields::getOneParam(const std::vector >& params, size_t index) { if (index >= params.size()) From 7b5b102acd9fe449a8d71cc13e15a307a238518c Mon Sep 17 00:00:00 2001 From: Jan Chyczynski Date: Tue, 19 Jul 2022 12:42:36 +0200 Subject: [PATCH 09/39] removed explicit values in enums --- .../RunInfo/interface/LHCInfoPerFill.h | 59 +++++++++++-------- CondFormats/RunInfo/interface/LHCInfoPerLS.h | 10 ++-- 2 files changed, 40 insertions(+), 29 deletions(-) diff --git a/CondFormats/RunInfo/interface/LHCInfoPerFill.h b/CondFormats/RunInfo/interface/LHCInfoPerFill.h index 16e4c9bf61985..6611402e3ff64 100644 --- a/CondFormats/RunInfo/interface/LHCInfoPerFill.h +++ b/CondFormats/RunInfo/interface/LHCInfoPerFill.h @@ -12,37 +12,48 @@ class LHCInfoPerFill : public LHCInfoVectorizedFields { public: - enum FillType { UNKNOWN = 0, PROTONS = 1, IONS = 2, COSMICS = 3, GAP = 4 }; - enum ParticleType { NONE = 0, PROTON = 1, PB82 = 2, AR18 = 3, D = 4, XE54 = 5 }; + enum FillType { UNKNOWN = 0, PROTONS, IONS, COSMICS, GAP }; + enum ParticleType { NONE = 0, PROTON, PB82, AR18, D, XE54 }; enum IntParamIndex { LHC_FILL = 0, - BUNCHES_1 = 1, - BUNCHES_2 = 2, - COLLIDING_BUNCHES = 3, - TARGET_BUNCHES = 4, - FILL_TYPE = 5, - PARTICLES_1 = 6, - PARTICLES_2 = 7, - ISIZE = 8 + BUNCHES_1, + BUNCHES_2, + COLLIDING_BUNCHES, + TARGET_BUNCHES, + FILL_TYPE, + PARTICLES_1, + PARTICLES_2, + ISIZE }; enum FloatParamIndex { INTENSITY_1 = 0, - INTENSITY_2 = 1, - ENERGY = 2, - DELIV_LUMI = 3, - REC_LUMI = 4, - LUMI_PER_B = 5, - BEAM1_VC = 7, - BEAM2_VC = 8, - BEAM1_RF = 9, - BEAM2_RF = 10, - INST_LUMI = 11, - INST_LUMI_ERR = 12, - FSIZE = 13 + INTENSITY_2, + ENERGY, + DELIV_LUMI, + REC_LUMI, + LUMI_PER_B, + BEAM1_VC, + BEAM2_VC, + BEAM1_RF, + BEAM2_RF, + INST_LUMI, + INST_LUMI_ERR, + FSIZE + }; + enum TimeParamIndex { + CREATE_TIME = 0, + BEGIN_TIME, + END_TIME, + TSIZE + }; + enum StringParamIndex { + INJECTION_SCHEME = 0, + LHC_STATE, + LHC_COMMENT, + CTPPS_STATUS, + SSIZE }; - enum TimeParamIndex { CREATE_TIME = 0, BEGIN_TIME = 1, END_TIME = 2, TSIZE = 3 }; - enum StringParamIndex { INJECTION_SCHEME = 0, LHC_STATE = 1, LHC_COMMENT = 2, CTPPS_STATUS = 3, SSIZE = 4 }; typedef FillType FillTypeId; typedef ParticleType ParticleTypeId; diff --git a/CondFormats/RunInfo/interface/LHCInfoPerLS.h b/CondFormats/RunInfo/interface/LHCInfoPerLS.h index 7efc1f05ea9a0..4056d03699a5b 100644 --- a/CondFormats/RunInfo/interface/LHCInfoPerLS.h +++ b/CondFormats/RunInfo/interface/LHCInfoPerLS.h @@ -13,14 +13,14 @@ class LHCInfoPerLS : public LHCInfoVectorizedFields { public: enum IntParamIndex { LUMI_SECTION = 0, - ISIZE = 1 + ISIZE }; enum FloatParamIndex { CROSSING_ANGLE_X = 0, - CROSSING_ANGLE_Y = 1, - BETA_STAR_X = 2, - BETA_STAR_Y = 3, - FSIZE = 4 + CROSSING_ANGLE_Y, + BETA_STAR_X, + BETA_STAR_Y, + FSIZE }; LHCInfoPerLS(); From 2bfe104df43056e75a7c91a54fa38301aa16b50f Mon Sep 17 00:00:00 2001 From: Jan Chyczynski Date: Tue, 19 Jul 2022 15:00:33 +0200 Subject: [PATCH 10/39] changed throwing std::out_of_range to cond::Exception --- CondFormats/RunInfo/BuildFile.xml | 1 + CondFormats/RunInfo/src/LHCInfoVectorizedFields.cc | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CondFormats/RunInfo/BuildFile.xml b/CondFormats/RunInfo/BuildFile.xml index acc4955cf3993..20474830eeb08 100644 --- a/CondFormats/RunInfo/BuildFile.xml +++ b/CondFormats/RunInfo/BuildFile.xml @@ -1,5 +1,6 @@ + diff --git a/CondFormats/RunInfo/src/LHCInfoVectorizedFields.cc b/CondFormats/RunInfo/src/LHCInfoVectorizedFields.cc index dd8d87ffa9cc2..bb7d14d6463bb 100644 --- a/CondFormats/RunInfo/src/LHCInfoVectorizedFields.cc +++ b/CondFormats/RunInfo/src/LHCInfoVectorizedFields.cc @@ -1,4 +1,5 @@ #include "CondFormats/RunInfo/interface/LHCInfoVectorizedFields.h" +#include "CondCore/CondDB/interface/Exception.h" LHCInfoVectorizedFields::LHCInfoVectorizedFields() : LHCInfoVectorizedFields(ISIZE, FSIZE, TSIZE, SSIZE) {} @@ -13,7 +14,7 @@ LHCInfoVectorizedFields::LHCInfoVectorizedFields(size_t iSize, size_t fSize, siz template const T& LHCInfoVectorizedFields::getParams(const std::vector& params, size_t index) { if (index >= params.size()) - throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range."); + throw cond::Exception("Parameter with index " + std::to_string(index) + " is out of range."); return params[index]; } @@ -25,7 +26,7 @@ template const std::vector& LHCInfoVectorizedFields::getParams(cons template T& LHCInfoVectorizedFields::accessParams(std::vector& params, size_t index) { if (index >= params.size()) - throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range."); + throw cond::Exception("Parameter with index " + std::to_string(index) + " is out of range."); return params[index]; } @@ -37,10 +38,10 @@ template std::vector& LHCInfoVectorizedFields::accessParams(std::ve template const T& LHCInfoVectorizedFields::getOneParam(const std::vector >& params, size_t index) { if (index >= params.size()) - throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range."); + throw cond::Exception("Parameter with index " + std::to_string(index) + " is out of range."); const std::vector& inner = params[index]; if (inner.empty()) - throw std::out_of_range("Parameter with index " + std::to_string(index) + " type=" + typeid(T).name() + + throw cond::Exception("Parameter with index " + std::to_string(index) + " type=" + typeid(T).name() + " has no value stored."); return inner[0]; } @@ -53,7 +54,7 @@ template const std::string& LHCInfoVectorizedFields::getOneParam(const std::vect template void LHCInfoVectorizedFields::setOneParam(std::vector >& params, size_t index, const T& value) { if (index >= params.size()) - throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range."); + throw cond::Exception("Parameter with index " + std::to_string(index) + " is out of range."); params[index] = std::vector(1, value); } @@ -65,7 +66,7 @@ template void LHCInfoVectorizedFields::setOneParam(std::vector void LHCInfoVectorizedFields::setParams(std::vector& params, size_t index, const T& value) { if (index >= params.size()) - throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range."); + throw cond::Exception("Parameter with index " + std::to_string(index) + " is out of range."); params[index] = value; } From 11b7d3da939e1a6106632c046d47c09fd5aa3112 Mon Sep 17 00:00:00 2001 From: Jan Chyczynski Date: Tue, 19 Jul 2022 18:36:25 +0200 Subject: [PATCH 11/39] added setup READMY.md --- CondFormats/RunInfo/test/README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 CondFormats/RunInfo/test/README.md diff --git a/CondFormats/RunInfo/test/README.md b/CondFormats/RunInfo/test/README.md new file mode 100644 index 0000000000000..a86a4ba9fcf95 --- /dev/null +++ b/CondFormats/RunInfo/test/README.md @@ -0,0 +1,13 @@ +#jc_lhcInfo_split + +##Set CMSSW workspace and compile + +```bash +source /cvmfs/cms.cern.ch/cmsset_default.sh +scram project CMSSW CMSSW_12_5_0_pre3 +cd CMSSW_12_5_0_pre3/src/ +cmsenv +git cms-init +git cms-checkout-topic CTPPS:jc_lhcInfo_split +scram b -j 8 +``` \ No newline at end of file From d59bfd63d3fb3fa7be98e2327b49db5d9d89dd8c Mon Sep 17 00:00:00 2001 From: Jan Chyczynski Date: Thu, 21 Jul 2022 09:57:37 +0200 Subject: [PATCH 12/39] added fields definitions to classes_def.xml --- CondFormats/RunInfo/src/classes_def.xml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/CondFormats/RunInfo/src/classes_def.xml b/CondFormats/RunInfo/src/classes_def.xml index 4a1a06abca81d..e5e867d6c3e5c 100644 --- a/CondFormats/RunInfo/src/classes_def.xml +++ b/CondFormats/RunInfo/src/classes_def.xml @@ -25,7 +25,19 @@ - + + + + - + + + + + + + + + + From 552bea10b0b3939c83b13862185029bf91735323 Mon Sep 17 00:00:00 2001 From: Jan Chyczynski Date: Fri, 22 Jul 2022 16:42:45 +0200 Subject: [PATCH 13/39] simple tests: writing and retrieving objects of new classes in sqlite DB --- CondFormats/RunInfo/test/README.md | 11 +++ CondTools/RunInfo/plugins/BuildFile.xml | 18 +++++ .../RunInfo/plugins/LHCInfoPerFillAnalyzer.cc | 42 ++++++++++++ .../RunInfo/plugins/LHCInfoPerFillWriter.cc | 67 +++++++++++++++++++ .../RunInfo/plugins/LHCInfoPerLSAnalyzer.cc | 42 ++++++++++++ .../RunInfo/plugins/LHCInfoPerLSWriter.cc | 45 +++++++++++++ .../test/LHCInfoPerFillAnalyzer_cfg.py | 42 ++++++++++++ .../RunInfo/test/LHCInfoPerFillWriter_cfg.py | 38 +++++++++++ .../RunInfo/test/LHCInfoPerLSAnalyzer_cfg.py | 42 ++++++++++++ .../RunInfo/test/LHCInfoPerLSWriter_cfg.py | 38 +++++++++++ 10 files changed, 385 insertions(+) create mode 100644 CondTools/RunInfo/plugins/LHCInfoPerFillAnalyzer.cc create mode 100644 CondTools/RunInfo/plugins/LHCInfoPerFillWriter.cc create mode 100644 CondTools/RunInfo/plugins/LHCInfoPerLSAnalyzer.cc create mode 100644 CondTools/RunInfo/plugins/LHCInfoPerLSWriter.cc create mode 100644 CondTools/RunInfo/test/LHCInfoPerFillAnalyzer_cfg.py create mode 100644 CondTools/RunInfo/test/LHCInfoPerFillWriter_cfg.py create mode 100644 CondTools/RunInfo/test/LHCInfoPerLSAnalyzer_cfg.py create mode 100644 CondTools/RunInfo/test/LHCInfoPerLSWriter_cfg.py diff --git a/CondFormats/RunInfo/test/README.md b/CondFormats/RunInfo/test/README.md index a86a4ba9fcf95..9ee631507486e 100644 --- a/CondFormats/RunInfo/test/README.md +++ b/CondFormats/RunInfo/test/README.md @@ -10,4 +10,15 @@ cmsenv git cms-init git cms-checkout-topic CTPPS:jc_lhcInfo_split scram b -j 8 +``` + +##Running tests +assuming being in the CMSSW_12_5_0_pre3/src directory and having run cmsenv + +```bash +cd CondTools/RunInfo/test +cmsRun LHCInfoPerLSWriter_cfg.py +cmsRun LHCInfoPerFillWriter_cfg.py +cmsRun LHCInfoPerLSAnalyzer_cfg.py +cmsRun LHCInfoPerFillAnalyzer_cfg.py ``` \ No newline at end of file diff --git a/CondTools/RunInfo/plugins/BuildFile.xml b/CondTools/RunInfo/plugins/BuildFile.xml index f1ed6cfc4fc16..4adf874fba8b1 100644 --- a/CondTools/RunInfo/plugins/BuildFile.xml +++ b/CondTools/RunInfo/plugins/BuildFile.xml @@ -46,3 +46,21 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CondTools/RunInfo/plugins/LHCInfoPerFillAnalyzer.cc b/CondTools/RunInfo/plugins/LHCInfoPerFillAnalyzer.cc new file mode 100644 index 0000000000000..d69d070d1d335 --- /dev/null +++ b/CondTools/RunInfo/plugins/LHCInfoPerFillAnalyzer.cc @@ -0,0 +1,42 @@ +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/ESWatcher.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ServiceRegistry/interface/Service.h" + +#include "CondCore/DBOutputService/interface/PoolDBOutputService.h" + +#include "CondFormats/RunInfo/interface/LHCInfoPerFill.h" +#include "CondFormats/DataRecord/interface/LHCInfoPerFillRcd.h" + +#include +#include + +class LHCInfoPerFillAnalyzer : public edm::one::EDAnalyzer<> { +public: + explicit LHCInfoPerFillAnalyzer(const edm::ParameterSet&) + : tokenInfoPerFill_(esConsumes()) {} + +private: + void beginJob() override {} + void analyze(const edm::Event&, const edm::EventSetup&) override; + void endJob() override {} + + edm::ESWatcher infoPerFillWatcher_; + + edm::ESGetToken tokenInfoPerFill_; +}; + +void LHCInfoPerFillAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { + // get InfoPerFill + if (infoPerFillWatcher_.check(iSetup)) { + edm::LogInfo("LHCInfoPerFillAnalyzer") << "LHCInfoPerFill retrieved:\n" << iSetup.getData(tokenInfoPerFill_); + } +} + +DEFINE_FWK_MODULE(LHCInfoPerFillAnalyzer); \ No newline at end of file diff --git a/CondTools/RunInfo/plugins/LHCInfoPerFillWriter.cc b/CondTools/RunInfo/plugins/LHCInfoPerFillWriter.cc new file mode 100644 index 0000000000000..a231f83a48567 --- /dev/null +++ b/CondTools/RunInfo/plugins/LHCInfoPerFillWriter.cc @@ -0,0 +1,67 @@ +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ServiceRegistry/interface/Service.h" + +#include "CondCore/DBOutputService/interface/PoolDBOutputService.h" + +#include "CondFormats/RunInfo/interface/LHCInfoPerFill.h" +#include "CondFormats/DataRecord/interface/LHCInfoPerFillRcd.h" + +#include +#include + +class LHCInfoPerFillWriter : public edm::one::EDAnalyzer<> { +public: + explicit LHCInfoPerFillWriter(const edm::ParameterSet&) {} + +private: + void beginJob() override {} + void analyze(const edm::Event&, const edm::EventSetup&) override; + void endJob() override {} +}; + +void LHCInfoPerFillWriter::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { + LHCInfoPerFill lhcInfoPerFill; + lhcInfoPerFill.setFillNumber(3); + lhcInfoPerFill.setBunchesInBeam1(10); + lhcInfoPerFill.setBunchesInBeam2(8); + lhcInfoPerFill.setCollidingBunches(5); + lhcInfoPerFill.setTargetBunches(4); + lhcInfoPerFill.setFillType(lhcInfoPerFill.PROTONS); + lhcInfoPerFill.setParticleTypeForBeam1(lhcInfoPerFill.PROTON); + lhcInfoPerFill.setParticleTypeForBeam2(lhcInfoPerFill.PROTON); + lhcInfoPerFill.setIntensityForBeam1(21.37); + lhcInfoPerFill.setIntensityForBeam2(12.23); + lhcInfoPerFill.setEnergy(1.12); + lhcInfoPerFill.setDelivLumi(2.34); + lhcInfoPerFill.setRecLumi(3.43); + lhcInfoPerFill.setInstLumi(4.345); + lhcInfoPerFill.setInstLumiError(5.567); + lhcInfoPerFill.setCreationTime(65766); + lhcInfoPerFill.setBeginTime(76788); + lhcInfoPerFill.setEndTime(89090); + lhcInfoPerFill.setInjectionScheme("None"); + lhcInfoPerFill.setLumiPerBX({3.4, 45.3}); + lhcInfoPerFill.setLhcState("some lhcState"); + lhcInfoPerFill.setLhcComment("some lhcComment"); + lhcInfoPerFill.setCtppsStatus("some ctppsStatus"); + lhcInfoPerFill.setBeam1VC({45.6, 67.4}); + lhcInfoPerFill.setBeam2VC({245.56, 56.45}); + lhcInfoPerFill.setBeam1RF({56.78, 34.3}); + lhcInfoPerFill.setBeam2RF({123.566, 5767}); + + // store the info into a DB object + edm::Service poolDbService; + if (poolDbService.isAvailable()) + poolDbService->writeOneIOV(lhcInfoPerFill, poolDbService->currentTime(), "LHCInfoPerFillRcd"); + else + throw cms::Exception("LHCInfoPerFillWriter") << "PoolDBService required."; +} + +DEFINE_FWK_MODULE(LHCInfoPerFillWriter); \ No newline at end of file diff --git a/CondTools/RunInfo/plugins/LHCInfoPerLSAnalyzer.cc b/CondTools/RunInfo/plugins/LHCInfoPerLSAnalyzer.cc new file mode 100644 index 0000000000000..4c8fe35bda554 --- /dev/null +++ b/CondTools/RunInfo/plugins/LHCInfoPerLSAnalyzer.cc @@ -0,0 +1,42 @@ +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/ESWatcher.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ServiceRegistry/interface/Service.h" + +#include "CondCore/DBOutputService/interface/PoolDBOutputService.h" + +#include "CondFormats/RunInfo/interface/LHCInfoPerLS.h" +#include "CondFormats/DataRecord/interface/LHCInfoPerLSRcd.h" + +#include +#include + +class LHCInfoPerLSAnalyzer : public edm::one::EDAnalyzer<> { +public: + explicit LHCInfoPerLSAnalyzer(const edm::ParameterSet&) + : tokenInfoPerLS_(esConsumes()) {} + +private: + void beginJob() override {} + void analyze(const edm::Event&, const edm::EventSetup&) override; + void endJob() override {} + + edm::ESWatcher infoPerLSWatcher_; + + edm::ESGetToken tokenInfoPerLS_; +}; + +void LHCInfoPerLSAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { + // get InfoPerLS + if (infoPerLSWatcher_.check(iSetup)) { + edm::LogInfo("LHCInfoPerLSAnalyzer") << "LHCInfoPerLS retrieved:\n" << iSetup.getData(tokenInfoPerLS_); + } +} + +DEFINE_FWK_MODULE(LHCInfoPerLSAnalyzer); \ No newline at end of file diff --git a/CondTools/RunInfo/plugins/LHCInfoPerLSWriter.cc b/CondTools/RunInfo/plugins/LHCInfoPerLSWriter.cc new file mode 100644 index 0000000000000..7f2cb3d338202 --- /dev/null +++ b/CondTools/RunInfo/plugins/LHCInfoPerLSWriter.cc @@ -0,0 +1,45 @@ +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ServiceRegistry/interface/Service.h" + +#include "CondCore/DBOutputService/interface/PoolDBOutputService.h" + +#include "CondFormats/RunInfo/interface/LHCInfoPerLS.h" +#include "CondFormats/DataRecord/interface/LHCInfoPerLSRcd.h" + +#include +#include + +class LHCInfoPerLSWriter : public edm::one::EDAnalyzer<> { +public: + explicit LHCInfoPerLSWriter(const edm::ParameterSet&) {} + +private: + void beginJob() override {} + void analyze(const edm::Event&, const edm::EventSetup&) override; + void endJob() override {} +}; + +void LHCInfoPerLSWriter::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { + LHCInfoPerLS lhcInfoPerLS; + lhcInfoPerLS.setCrossingAngleX(5.5); + lhcInfoPerLS.setCrossingAngleY(6.6); + lhcInfoPerLS.setBetaStarX(8.8); + lhcInfoPerLS.setBetaStarY(10); + lhcInfoPerLS.setLumiSection(3); + + // store the info into a DB object + edm::Service poolDbService; + if (poolDbService.isAvailable()) + poolDbService->writeOneIOV(lhcInfoPerLS, poolDbService->currentTime(), "LHCInfoPerLSRcd"); + else + throw cms::Exception("LHCInfoPerLSWriter") << "PoolDBService required."; +} + +DEFINE_FWK_MODULE(LHCInfoPerLSWriter); \ No newline at end of file diff --git a/CondTools/RunInfo/test/LHCInfoPerFillAnalyzer_cfg.py b/CondTools/RunInfo/test/LHCInfoPerFillAnalyzer_cfg.py new file mode 100644 index 0000000000000..ddc2ce84bfc99 --- /dev/null +++ b/CondTools/RunInfo/test/LHCInfoPerFillAnalyzer_cfg.py @@ -0,0 +1,42 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process('test') + +# minimum logging +process.MessageLogger = cms.Service("MessageLogger", + cerr = cms.untracked.PSet( + enable = cms.untracked.bool(False) + ), + cout = cms.untracked.PSet( + enable = cms.untracked.bool(True), + threshold = cms.untracked.string('INFO') + ) +) + +process.source = cms.Source('EmptyIOVSource', + timetype = cms.string('runnumber'), + firstValue = cms.uint64(1), + lastValue = cms.uint64(1), + interval = cms.uint64(1) +) + +# load calibrations from database +process.load('CondCore.CondDB.CondDB_cfi') +process.CondDB.connect = 'sqlite_file:LHCInfoPerFill.sqlite' # SQLite input + +process.PoolDBESSource = cms.ESSource('PoolDBESSource', + process.CondDB, + DumpStats = cms.untracked.bool(True), + toGet = cms.VPSet( + cms.PSet( + record = cms.string('LHCInfoPerFillRcd'), + tag = cms.string('LHCInfoPerFillFake') + ) + ) +) + +process.LHCInfoPerFillAnalyzer = cms.EDAnalyzer('LHCInfoPerFillAnalyzer') + +process.path = cms.Path( + process.LHCInfoPerFillAnalyzer +) \ No newline at end of file diff --git a/CondTools/RunInfo/test/LHCInfoPerFillWriter_cfg.py b/CondTools/RunInfo/test/LHCInfoPerFillWriter_cfg.py new file mode 100644 index 0000000000000..4a9e7e2c80a15 --- /dev/null +++ b/CondTools/RunInfo/test/LHCInfoPerFillWriter_cfg.py @@ -0,0 +1,38 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process('test') + +process.source = cms.Source('EmptyIOVSource', + timetype = cms.string('runnumber'), + firstValue = cms.uint64(1), + lastValue = cms.uint64(1), + interval = cms.uint64(1) +) + +# from CondFormats.PPSObjects.PPSTimingDetEnum_cff import PPSTimingDetEnum + +# # load calibrations from JSON file +# process.load('CalibPPS.ESProducers.ppsTimingCalibrationESSource_cfi') +# process.ppsTimingCalibrationESSource.calibrationFile = cms.FileInPath('RecoPPS/Local/data/timing_calibration_diamond_2018_mar19.ex.json') +# process.ppsTimingCalibrationESSource.subDetector = PPSTimingDetEnum.PPS_DIAMOND + +# output service for database +process.load('CondCore.CondDB.CondDB_cfi') +process.CondDB.connect = 'sqlite_file:LHCInfoPerFill.sqlite' # SQLite output + +process.PoolDBOutputService = cms.Service('PoolDBOutputService', + process.CondDB, + timetype = cms.untracked.string('runnumber'), + toPut = cms.VPSet( + cms.PSet( + record = cms.string('LHCInfoPerFillRcd'), + tag = cms.string('LHCInfoPerFillFake'), + ) + ) +) + +process.LHCInfoPerFillWriter = cms.EDAnalyzer('LHCInfoPerFillWriter') + +process.path = cms.Path( + process.LHCInfoPerFillWriter +) diff --git a/CondTools/RunInfo/test/LHCInfoPerLSAnalyzer_cfg.py b/CondTools/RunInfo/test/LHCInfoPerLSAnalyzer_cfg.py new file mode 100644 index 0000000000000..ad521ec4e1861 --- /dev/null +++ b/CondTools/RunInfo/test/LHCInfoPerLSAnalyzer_cfg.py @@ -0,0 +1,42 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process('test') + +# minimum logging +process.MessageLogger = cms.Service("MessageLogger", + cerr = cms.untracked.PSet( + enable = cms.untracked.bool(False) + ), + cout = cms.untracked.PSet( + enable = cms.untracked.bool(True), + threshold = cms.untracked.string('INFO') + ) +) + +process.source = cms.Source('EmptyIOVSource', + timetype = cms.string('runnumber'), + firstValue = cms.uint64(1), + lastValue = cms.uint64(1), + interval = cms.uint64(1) +) + +# load calibrations from database +process.load('CondCore.CondDB.CondDB_cfi') +process.CondDB.connect = 'sqlite_file:LHCInfoPerLS.sqlite' # SQLite input + +process.PoolDBESSource = cms.ESSource('PoolDBESSource', + process.CondDB, + DumpStats = cms.untracked.bool(True), + toGet = cms.VPSet( + cms.PSet( + record = cms.string('LHCInfoPerLSRcd'), + tag = cms.string('LHCInfoPerLSFake') + ) + ) +) + +process.LHCInfoPerLSAnalyzer = cms.EDAnalyzer('LHCInfoPerLSAnalyzer') + +process.path = cms.Path( + process.LHCInfoPerLSAnalyzer +) \ No newline at end of file diff --git a/CondTools/RunInfo/test/LHCInfoPerLSWriter_cfg.py b/CondTools/RunInfo/test/LHCInfoPerLSWriter_cfg.py new file mode 100644 index 0000000000000..f8cedeaa535d5 --- /dev/null +++ b/CondTools/RunInfo/test/LHCInfoPerLSWriter_cfg.py @@ -0,0 +1,38 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process('test') + +process.source = cms.Source('EmptyIOVSource', + timetype = cms.string('runnumber'), + firstValue = cms.uint64(1), + lastValue = cms.uint64(1), + interval = cms.uint64(1) +) + +# from CondFormats.PPSObjects.PPSTimingDetEnum_cff import PPSTimingDetEnum + +# # load calibrations from JSON file +# process.load('CalibPPS.ESProducers.ppsTimingCalibrationESSource_cfi') +# process.ppsTimingCalibrationESSource.calibrationFile = cms.FileInPath('RecoPPS/Local/data/timing_calibration_diamond_2018_mar19.ex.json') +# process.ppsTimingCalibrationESSource.subDetector = PPSTimingDetEnum.PPS_DIAMOND + +# output service for database +process.load('CondCore.CondDB.CondDB_cfi') +process.CondDB.connect = 'sqlite_file:LHCInfoPerLS.sqlite' # SQLite output + +process.PoolDBOutputService = cms.Service('PoolDBOutputService', + process.CondDB, + timetype = cms.untracked.string('runnumber'), + toPut = cms.VPSet( + cms.PSet( + record = cms.string('LHCInfoPerLSRcd'), + tag = cms.string('LHCInfoPerLSFake'), + ) + ) +) + +process.LHCInfoPerLSWriter = cms.EDAnalyzer('LHCInfoPerLSWriter') + +process.path = cms.Path( + process.LHCInfoPerLSWriter +) From 7e0768304710649b4fbbff24898e46ad37a29da3 Mon Sep 17 00:00:00 2001 From: Jan Chyczynski Date: Tue, 26 Jul 2022 15:51:50 +0200 Subject: [PATCH 14/39] improved tests data and removed old commented code --- .../RunInfo/plugins/LHCInfoPerFillWriter.cc | 26 ++++++++----------- .../RunInfo/plugins/LHCInfoPerLSWriter.cc | 10 +++---- .../test/LHCInfoPerFillAnalyzer_cfg.py | 2 +- .../RunInfo/test/LHCInfoPerFillWriter_cfg.py | 7 ----- .../RunInfo/test/LHCInfoPerLSAnalyzer_cfg.py | 2 +- .../RunInfo/test/LHCInfoPerLSWriter_cfg.py | 7 ----- 6 files changed, 18 insertions(+), 36 deletions(-) diff --git a/CondTools/RunInfo/plugins/LHCInfoPerFillWriter.cc b/CondTools/RunInfo/plugins/LHCInfoPerFillWriter.cc index a231f83a48567..915b6b685d4b9 100644 --- a/CondTools/RunInfo/plugins/LHCInfoPerFillWriter.cc +++ b/CondTools/RunInfo/plugins/LHCInfoPerFillWriter.cc @@ -36,25 +36,21 @@ void LHCInfoPerFillWriter::analyze(const edm::Event& iEvent, const edm::EventSet lhcInfoPerFill.setFillType(lhcInfoPerFill.PROTONS); lhcInfoPerFill.setParticleTypeForBeam1(lhcInfoPerFill.PROTON); lhcInfoPerFill.setParticleTypeForBeam2(lhcInfoPerFill.PROTON); - lhcInfoPerFill.setIntensityForBeam1(21.37); - lhcInfoPerFill.setIntensityForBeam2(12.23); - lhcInfoPerFill.setEnergy(1.12); - lhcInfoPerFill.setDelivLumi(2.34); - lhcInfoPerFill.setRecLumi(3.43); - lhcInfoPerFill.setInstLumi(4.345); - lhcInfoPerFill.setInstLumiError(5.567); - lhcInfoPerFill.setCreationTime(65766); - lhcInfoPerFill.setBeginTime(76788); - lhcInfoPerFill.setEndTime(89090); + lhcInfoPerFill.setIntensityForBeam1(1016.5); + lhcInfoPerFill.setIntensityForBeam2(1096.66); + lhcInfoPerFill.setEnergy(7000); + lhcInfoPerFill.setDelivLumi(2E-07); + lhcInfoPerFill.setRecLumi(2E-07); + lhcInfoPerFill.setInstLumi(0); + lhcInfoPerFill.setInstLumiError(0); + lhcInfoPerFill.setCreationTime(6561530930997627120); + lhcInfoPerFill.setBeginTime(6561530930997627120); + lhcInfoPerFill.setEndTime(6561530930997627120); lhcInfoPerFill.setInjectionScheme("None"); - lhcInfoPerFill.setLumiPerBX({3.4, 45.3}); + lhcInfoPerFill.setLumiPerBX({0.000114139, 0.000114139}); lhcInfoPerFill.setLhcState("some lhcState"); lhcInfoPerFill.setLhcComment("some lhcComment"); lhcInfoPerFill.setCtppsStatus("some ctppsStatus"); - lhcInfoPerFill.setBeam1VC({45.6, 67.4}); - lhcInfoPerFill.setBeam2VC({245.56, 56.45}); - lhcInfoPerFill.setBeam1RF({56.78, 34.3}); - lhcInfoPerFill.setBeam2RF({123.566, 5767}); // store the info into a DB object edm::Service poolDbService; diff --git a/CondTools/RunInfo/plugins/LHCInfoPerLSWriter.cc b/CondTools/RunInfo/plugins/LHCInfoPerLSWriter.cc index 7f2cb3d338202..735cc8a960883 100644 --- a/CondTools/RunInfo/plugins/LHCInfoPerLSWriter.cc +++ b/CondTools/RunInfo/plugins/LHCInfoPerLSWriter.cc @@ -28,11 +28,11 @@ class LHCInfoPerLSWriter : public edm::one::EDAnalyzer<> { void LHCInfoPerLSWriter::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { LHCInfoPerLS lhcInfoPerLS; - lhcInfoPerLS.setCrossingAngleX(5.5); - lhcInfoPerLS.setCrossingAngleY(6.6); - lhcInfoPerLS.setBetaStarX(8.8); - lhcInfoPerLS.setBetaStarY(10); - lhcInfoPerLS.setLumiSection(3); + lhcInfoPerLS.setLumiSection(1); + lhcInfoPerLS.setCrossingAngleX(170); + lhcInfoPerLS.setCrossingAngleY(170); + lhcInfoPerLS.setBetaStarX(11); + lhcInfoPerLS.setBetaStarY(11); // store the info into a DB object edm::Service poolDbService; diff --git a/CondTools/RunInfo/test/LHCInfoPerFillAnalyzer_cfg.py b/CondTools/RunInfo/test/LHCInfoPerFillAnalyzer_cfg.py index ddc2ce84bfc99..a3a0ab0f19f0b 100644 --- a/CondTools/RunInfo/test/LHCInfoPerFillAnalyzer_cfg.py +++ b/CondTools/RunInfo/test/LHCInfoPerFillAnalyzer_cfg.py @@ -20,7 +20,7 @@ interval = cms.uint64(1) ) -# load calibrations from database +# load info from database process.load('CondCore.CondDB.CondDB_cfi') process.CondDB.connect = 'sqlite_file:LHCInfoPerFill.sqlite' # SQLite input diff --git a/CondTools/RunInfo/test/LHCInfoPerFillWriter_cfg.py b/CondTools/RunInfo/test/LHCInfoPerFillWriter_cfg.py index 4a9e7e2c80a15..9ee905d9ff524 100644 --- a/CondTools/RunInfo/test/LHCInfoPerFillWriter_cfg.py +++ b/CondTools/RunInfo/test/LHCInfoPerFillWriter_cfg.py @@ -9,13 +9,6 @@ interval = cms.uint64(1) ) -# from CondFormats.PPSObjects.PPSTimingDetEnum_cff import PPSTimingDetEnum - -# # load calibrations from JSON file -# process.load('CalibPPS.ESProducers.ppsTimingCalibrationESSource_cfi') -# process.ppsTimingCalibrationESSource.calibrationFile = cms.FileInPath('RecoPPS/Local/data/timing_calibration_diamond_2018_mar19.ex.json') -# process.ppsTimingCalibrationESSource.subDetector = PPSTimingDetEnum.PPS_DIAMOND - # output service for database process.load('CondCore.CondDB.CondDB_cfi') process.CondDB.connect = 'sqlite_file:LHCInfoPerFill.sqlite' # SQLite output diff --git a/CondTools/RunInfo/test/LHCInfoPerLSAnalyzer_cfg.py b/CondTools/RunInfo/test/LHCInfoPerLSAnalyzer_cfg.py index ad521ec4e1861..ca23551c9ca66 100644 --- a/CondTools/RunInfo/test/LHCInfoPerLSAnalyzer_cfg.py +++ b/CondTools/RunInfo/test/LHCInfoPerLSAnalyzer_cfg.py @@ -20,7 +20,7 @@ interval = cms.uint64(1) ) -# load calibrations from database +# load info from database process.load('CondCore.CondDB.CondDB_cfi') process.CondDB.connect = 'sqlite_file:LHCInfoPerLS.sqlite' # SQLite input diff --git a/CondTools/RunInfo/test/LHCInfoPerLSWriter_cfg.py b/CondTools/RunInfo/test/LHCInfoPerLSWriter_cfg.py index f8cedeaa535d5..d617d8f322700 100644 --- a/CondTools/RunInfo/test/LHCInfoPerLSWriter_cfg.py +++ b/CondTools/RunInfo/test/LHCInfoPerLSWriter_cfg.py @@ -9,13 +9,6 @@ interval = cms.uint64(1) ) -# from CondFormats.PPSObjects.PPSTimingDetEnum_cff import PPSTimingDetEnum - -# # load calibrations from JSON file -# process.load('CalibPPS.ESProducers.ppsTimingCalibrationESSource_cfi') -# process.ppsTimingCalibrationESSource.calibrationFile = cms.FileInPath('RecoPPS/Local/data/timing_calibration_diamond_2018_mar19.ex.json') -# process.ppsTimingCalibrationESSource.subDetector = PPSTimingDetEnum.PPS_DIAMOND - # output service for database process.load('CondCore.CondDB.CondDB_cfi') process.CondDB.connect = 'sqlite_file:LHCInfoPerLS.sqlite' # SQLite output From 6f9f14181c5e7a4edf6375ec4286c52dff9742b3 Mon Sep 17 00:00:00 2001 From: Jan Chyczynski Date: Mon, 1 Aug 2022 10:25:25 +0200 Subject: [PATCH 15/39] Added new CondFormats to Module_2XML.cc and CondFormats.h --- CondCore/Utilities/plugins/Module_2XML.cc | 2 ++ CondCore/Utilities/src/CondFormats.h | 3 +++ 2 files changed, 5 insertions(+) diff --git a/CondCore/Utilities/plugins/Module_2XML.cc b/CondCore/Utilities/plugins/Module_2XML.cc index 0e99a897e891b..545686d069e15 100644 --- a/CondCore/Utilities/plugins/Module_2XML.cc +++ b/CondCore/Utilities/plugins/Module_2XML.cc @@ -211,6 +211,8 @@ PAYLOAD_2XML_MODULE(pluginUtilities_payload2xml) { PAYLOAD_2XML_CLASS(L1TriggerKeyExt); PAYLOAD_2XML_CLASS(L1TriggerKeyListExt); PAYLOAD_2XML_CLASS(LHCInfo); + PAYLOAD_2XML_CLASS(LHCInfoPerFill); + PAYLOAD_2XML_CLASS(LHCInfoPerLS); PAYLOAD_2XML_CLASS(METCorrectorParametersCollection); PAYLOAD_2XML_CLASS(MEtXYcorrectParametersCollection); PAYLOAD_2XML_CLASS(MagFieldConfig); diff --git a/CondCore/Utilities/src/CondFormats.h b/CondCore/Utilities/src/CondFormats.h index 38e8e8273909f..bc70211ada4f7 100644 --- a/CondCore/Utilities/src/CondFormats.h +++ b/CondCore/Utilities/src/CondFormats.h @@ -139,6 +139,9 @@ #include "CondFormats/RecoMuonObjects/interface/DYTParamObject.h" #include "CondFormats/RunInfo/interface/RunInfo.h" #include "CondFormats/RunInfo/interface/LHCInfo.h" +#include "CondFormats/RunInfo/interface/LHCInfoVectorizedFields.h" +#include "CondFormats/RunInfo/interface/LHCInfoPerFill.h" +#include "CondFormats/RunInfo/interface/LHCInfoPerLS.h" #include "CondFormats/RunInfo/interface/MixingModuleConfig.h" #include "CondFormats/SiPixelObjects/interface/SiPixelCalibConfiguration.h" #include "CondFormats/SiPixelObjects/interface/SiPixelCPEGenericErrorParm.h" From 6a2e73eff9233f9d6507aae5ecce58a9f0b050db Mon Sep 17 00:00:00 2001 From: Jan Chyczynski Date: Wed, 10 Aug 2022 12:11:39 +0200 Subject: [PATCH 16/39] fixed PopCon lumisection query limit --- .../RunInfo/interface/LHCInfoPopConSourceHandler.h | 2 ++ CondTools/RunInfo/interface/OMSAccess.h | 7 +++++++ .../RunInfo/src/LHCInfoPopConSourceHandler.cc | 8 +++++++- CondTools/RunInfo/src/OMSAccess.cc | 14 +++++++++++++- 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/CondTools/RunInfo/interface/LHCInfoPopConSourceHandler.h b/CondTools/RunInfo/interface/LHCInfoPopConSourceHandler.h index 9c49bce6f6774..7d7fa1dba7842 100644 --- a/CondTools/RunInfo/interface/LHCInfoPopConSourceHandler.h +++ b/CondTools/RunInfo/interface/LHCInfoPopConSourceHandler.h @@ -18,6 +18,8 @@ class LHCInfoPopConSourceHandler : public popcon::PopConSourceHandler { void getNewObjects() override; std::string id() const override; + static constexpr unsigned int kLumisectionsQueryLimit = 4000; + private: void addEmptyPayload(cond::Time_t iov); diff --git a/CondTools/RunInfo/interface/OMSAccess.h b/CondTools/RunInfo/interface/OMSAccess.h index 5bf98e89ae8da..625bb2dfbcb3f 100644 --- a/CondTools/RunInfo/interface/OMSAccess.h +++ b/CondTools/RunInfo/interface/OMSAccess.h @@ -185,6 +185,9 @@ namespace cond { std::stringstream filter; if (m_filter.empty()) { filter << "?"; + if(!m_limit.empty()){ + m_limit.front() = '&'; + } } else { filter << m_filter << "&"; } @@ -212,6 +215,9 @@ namespace cond { // not null filter inline OMSServiceQuery& filterNotNull(const std::string& varName) { return filterNEQ(varName, SNULL); } + // limit for the page size, when unspecified OMS's default limit is 100 + OMSServiceQuery& limit(int value); + // triggers the execution of the query ( calling curl functions ) bool execute(); @@ -230,6 +236,7 @@ namespace cond { private: std::string m_url; std::string m_filter; + std::string m_limit; std::string m_varList; std::unique_ptr m_result; unsigned long m_status = 0; diff --git a/CondTools/RunInfo/src/LHCInfoPopConSourceHandler.cc b/CondTools/RunInfo/src/LHCInfoPopConSourceHandler.cc index 99b4ea5215b80..42ed95690c662 100644 --- a/CondTools/RunInfo/src/LHCInfoPopConSourceHandler.cc +++ b/CondTools/RunInfo/src/LHCInfoPopConSourceHandler.cc @@ -156,7 +156,9 @@ size_t LHCInfoPopConSourceHandler::getLumiData(const cond::OMSService& oms, const boost::posix_time::ptime& endFillTime) { auto query = oms.query("lumisections"); query->addOutputVars({"start_time", "delivered_lumi", "recorded_lumi"}); - query->filterEQ("fill_number", fillId).filterGT("start_time", beginFillTime).filterLT("start_time", endFillTime); + query->filterEQ("fill_number", fillId); + query->filterGT("start_time", beginFillTime).filterLT("start_time", endFillTime); + query->limit(kLumisectionsQueryLimit); size_t nlumi = 0; if (query->execute()) { auto res = query->result(); @@ -239,6 +241,8 @@ void LHCInfoPopConSourceHandler::getDipData(const cond::OMSService& oms, // the old implementation is not helping: apparently it is checking only the bunchconfiguration for the first diptime set of values... auto query1 = oms.query("diplogger/dip/acc/LHC/RunControl/CirculatingBunchConfig/Beam1"); query1->filterGT("dip_time", beginFillTime).filterLT("dip_time", endFillTime); + //This query is limited to 100 rows, but currently only one is used + //If all this data is needed and saved properly the limit has to be set: query1->limit(...) if (query1->execute()) { auto res = query1->result(); if (!res.empty()) { @@ -256,6 +260,7 @@ void LHCInfoPopConSourceHandler::getDipData(const cond::OMSService& oms, } auto query2 = oms.query("diplogger/dip/acc/LHC/RunControl/CirculatingBunchConfig/Beam2"); query2->filterGT("dip_time", beginFillTime).filterLT("dip_time", endFillTime); + //This query is limited to 100 rows, but currently only one is used if (query2->execute()) { auto res = query2->result(); if (!res.empty()) { @@ -274,6 +279,7 @@ void LHCInfoPopConSourceHandler::getDipData(const cond::OMSService& oms, auto query3 = oms.query("diplogger/dip/CMS/LHC/LumiPerBunch"); query3->filterGT("dip_time", beginFillTime).filterLT("dip_time", endFillTime); + //This query is limited to 100 rows, but currently only one is used if (query3->execute()) { auto res = query3->result(); if (!res.empty()) { diff --git a/CondTools/RunInfo/src/OMSAccess.cc b/CondTools/RunInfo/src/OMSAccess.cc index 951fac68c5d17..fed5b88c74d25 100644 --- a/CondTools/RunInfo/src/OMSAccess.cc +++ b/CondTools/RunInfo/src/OMSAccess.cc @@ -83,6 +83,18 @@ namespace cond { return *this; } + OMSServiceQuery& OMSServiceQuery::limit(int value) { + std::stringstream pageLimit; + if (m_filter.empty()) { + pageLimit << "?"; + } else { + pageLimit << "&"; + } + pageLimit << "page[limit]=" << value; + m_limit = pageLimit.str(); + return *this; + } + bool OMSServiceQuery::execute() { bool ret = false; std::string out; @@ -99,7 +111,7 @@ namespace cond { OMSServiceResult& OMSServiceQuery::result() { return *m_result; } - std::string OMSServiceQuery::url() { return m_url + m_filter + m_varList; } + std::string OMSServiceQuery::url() { return m_url + m_filter + m_limit + m_varList; } OMSService::OMSService() : m_baseUrl() {} From 6b3501c41abb63bdf96ee5cd28cd3597e3c5a1f4 Mon Sep 17 00:00:00 2001 From: Jan Chyczynski Date: Fri, 12 Aug 2022 15:23:23 +0200 Subject: [PATCH 17/39] added fill number field to LHCInfoPerLS --- CondFormats/RunInfo/interface/LHCInfoPerLS.h | 14 ++++++++++---- CondFormats/RunInfo/src/LHCInfoPerLS.cc | 17 ++++++++++++----- CondTools/RunInfo/plugins/LHCInfoPerLSWriter.cc | 1 + 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/CondFormats/RunInfo/interface/LHCInfoPerLS.h b/CondFormats/RunInfo/interface/LHCInfoPerLS.h index 4056d03699a5b..58b150811662a 100644 --- a/CondFormats/RunInfo/interface/LHCInfoPerLS.h +++ b/CondFormats/RunInfo/interface/LHCInfoPerLS.h @@ -12,7 +12,8 @@ class LHCInfoPerLS : public LHCInfoVectorizedFields { public: enum IntParamIndex { - LUMI_SECTION = 0, + LHC_FILL = 0, + LUMI_SECTION, ISIZE }; enum FloatParamIndex { @@ -26,6 +27,8 @@ class LHCInfoPerLS : public LHCInfoVectorizedFields { LHCInfoPerLS(); //getters + unsigned short const fillNumber() const; + float const crossingAngleX() const; float const crossingAngleY() const; @@ -37,6 +40,8 @@ class LHCInfoPerLS : public LHCInfoVectorizedFields { unsigned int const& lumiSection() const; //setters + void setFillNumber(unsigned short lhcFill); + void setCrossingAngleX(float const& angle); void setCrossingAngleY(float const& angle); @@ -48,11 +53,12 @@ class LHCInfoPerLS : public LHCInfoVectorizedFields { void setLumiSection(unsigned int const& lumiSection); //sets all values in one go - void setInfo(float const& angleX, + void setInfo(unsigned short lhcFill, + unsigned int const& lumiSection, + float const& angleX, float const& angleY, float const& betaX, - float const& betaY, - unsigned int const& lumiSection); + float const& betaY); bool equals(const LHCInfoPerLS& rhs) const; diff --git a/CondFormats/RunInfo/src/LHCInfoPerLS.cc b/CondFormats/RunInfo/src/LHCInfoPerLS.cc index 4e253e136c5a9..d07916c92be29 100644 --- a/CondFormats/RunInfo/src/LHCInfoPerLS.cc +++ b/CondFormats/RunInfo/src/LHCInfoPerLS.cc @@ -9,6 +9,8 @@ LHCInfoPerLS::LHCInfoPerLS() : LHCInfoVectorizedFields (ISIZE, FSIZE, TSIZE, SSIZE) {} //getters +unsigned short const LHCInfoPerLS::fillNumber() const { return LHCInfoPerLS::getOneParam(m_intParams, LHC_FILL); } + float const LHCInfoPerLS::crossingAngleX() const { return LHCInfoPerLS::getOneParam(m_floatParams, CROSSING_ANGLE_X); } float const LHCInfoPerLS::crossingAngleY() const { return LHCInfoPerLS::getOneParam(m_floatParams, CROSSING_ANGLE_Y); } @@ -20,6 +22,8 @@ float const LHCInfoPerLS::betaStarY() const { return LHCInfoPerLS::getOneParam(m unsigned int const& LHCInfoPerLS::lumiSection() const { return LHCInfoPerLS::getOneParam(m_intParams, LUMI_SECTION); } //setters +void LHCInfoPerLS::setFillNumber(unsigned short lhcFill) { LHCInfoPerLS::setOneParam(m_intParams, LHC_FILL, static_cast(lhcFill)); } + void LHCInfoPerLS::setCrossingAngleX(float const& angle) { LHCInfoPerLS::setOneParam(m_floatParams, CROSSING_ANGLE_X, angle); } void LHCInfoPerLS::setCrossingAngleY(float const& angle) { LHCInfoPerLS::setOneParam(m_floatParams, CROSSING_ANGLE_Y, angle); } @@ -33,20 +37,23 @@ void LHCInfoPerLS::setLumiSection(unsigned int const& lumiSection) { } //sets all values in one go -void LHCInfoPerLS::setInfo(float const& angleX, +void LHCInfoPerLS::setInfo(unsigned short lhcFill, + unsigned int const& lumiSection, + float const& angleX, float const& angleY, float const& betaX, - float const& betaY, - unsigned int const& lumiSection) { + float const& betaY) { + this->setFillNumber(lhcFill); + this->setLumiSection(lumiSection); this->setCrossingAngleX(angleX); this->setCrossingAngleY(angleY); this->setBetaStarX(betaX); this->setBetaStarY(betaY); - this->setLumiSection(lumiSection); } void LHCInfoPerLS::print(std::stringstream& ss) const { - ss << "Crossing angle x (urad): " << this->crossingAngleX() << std::endl + ss << "LHC fill: " << this->fillNumber() << std::endl + << "Crossing angle x (urad): " << this->crossingAngleX() << std::endl << "Crossing angle y (urad): " << this->crossingAngleY() << std::endl << "Beta star x (cm): " << this->betaStarX() << std::endl << "Beta star y (cm): " << this->betaStarY() << std::endl diff --git a/CondTools/RunInfo/plugins/LHCInfoPerLSWriter.cc b/CondTools/RunInfo/plugins/LHCInfoPerLSWriter.cc index 735cc8a960883..9b1d0c9365d62 100644 --- a/CondTools/RunInfo/plugins/LHCInfoPerLSWriter.cc +++ b/CondTools/RunInfo/plugins/LHCInfoPerLSWriter.cc @@ -28,6 +28,7 @@ class LHCInfoPerLSWriter : public edm::one::EDAnalyzer<> { void LHCInfoPerLSWriter::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { LHCInfoPerLS lhcInfoPerLS; + lhcInfoPerLS.setFillNumber(7066); lhcInfoPerLS.setLumiSection(1); lhcInfoPerLS.setCrossingAngleX(170); lhcInfoPerLS.setCrossingAngleY(170); From 190a47574dc898536d012d1afa946107592b6af1 Mon Sep 17 00:00:00 2001 From: Jan Chyczynski Date: Tue, 16 Aug 2022 11:44:36 +0200 Subject: [PATCH 18/39] added run number field to LHCInfoPerLS --- CondFormats/RunInfo/interface/LHCInfoPerLS.h | 25 ++++++++++++----- CondFormats/RunInfo/src/LHCInfoPerLS.cc | 27 ++++++++++++------- .../RunInfo/plugins/LHCInfoPerLSWriter.cc | 1 + 3 files changed, 38 insertions(+), 15 deletions(-) diff --git a/CondFormats/RunInfo/interface/LHCInfoPerLS.h b/CondFormats/RunInfo/interface/LHCInfoPerLS.h index 58b150811662a..5fa3c5be3d251 100644 --- a/CondFormats/RunInfo/interface/LHCInfoPerLS.h +++ b/CondFormats/RunInfo/interface/LHCInfoPerLS.h @@ -3,6 +3,9 @@ #include "CondFormats/Serialization/interface/Serializable.h" #include "CondFormats/RunInfo/interface/LHCInfoVectorizedFields.h" + +#include "CondCore/CondDB/interface/Types.h" + #include #include #include @@ -23,12 +26,18 @@ class LHCInfoPerLS : public LHCInfoVectorizedFields { BETA_STAR_Y, FSIZE }; + enum TimeParamIndex { + RUN_NUMBER = 0, + TSIZE + }; LHCInfoPerLS(); //getters unsigned short const fillNumber() const; - + + unsigned int const& lumiSection() const; + float const crossingAngleX() const; float const crossingAngleY() const; @@ -37,10 +46,13 @@ class LHCInfoPerLS : public LHCInfoVectorizedFields { float const betaStarY() const; - unsigned int const& lumiSection() const; + cond::Time_t runNumber() const; + //setters - void setFillNumber(unsigned short lhcFill); + void setFillNumber(unsigned short const& lhcFill); + + void setLumiSection(unsigned int const& lumiSection); void setCrossingAngleX(float const& angle); @@ -50,15 +62,16 @@ class LHCInfoPerLS : public LHCInfoVectorizedFields { void setBetaStarY(float const& betaStar); - void setLumiSection(unsigned int const& lumiSection); + void setRunNumber(cond::Time_t const& runNumber); //sets all values in one go - void setInfo(unsigned short lhcFill, + void setInfo(unsigned short const& lhcFill, unsigned int const& lumiSection, float const& angleX, float const& angleY, float const& betaX, - float const& betaY); + float const& betaY, + cond::Time_t const& runNumber); bool equals(const LHCInfoPerLS& rhs) const; diff --git a/CondFormats/RunInfo/src/LHCInfoPerLS.cc b/CondFormats/RunInfo/src/LHCInfoPerLS.cc index d07916c92be29..545304fc55c81 100644 --- a/CondFormats/RunInfo/src/LHCInfoPerLS.cc +++ b/CondFormats/RunInfo/src/LHCInfoPerLS.cc @@ -11,6 +11,8 @@ LHCInfoPerLS::LHCInfoPerLS() //getters unsigned short const LHCInfoPerLS::fillNumber() const { return LHCInfoPerLS::getOneParam(m_intParams, LHC_FILL); } +unsigned int const& LHCInfoPerLS::lumiSection() const { return LHCInfoPerLS::getOneParam(m_intParams, LUMI_SECTION); } + float const LHCInfoPerLS::crossingAngleX() const { return LHCInfoPerLS::getOneParam(m_floatParams, CROSSING_ANGLE_X); } float const LHCInfoPerLS::crossingAngleY() const { return LHCInfoPerLS::getOneParam(m_floatParams, CROSSING_ANGLE_Y); } @@ -19,10 +21,14 @@ float const LHCInfoPerLS::betaStarX() const { return LHCInfoPerLS::getOneParam(m float const LHCInfoPerLS::betaStarY() const { return LHCInfoPerLS::getOneParam(m_floatParams, BETA_STAR_Y); } -unsigned int const& LHCInfoPerLS::lumiSection() const { return LHCInfoPerLS::getOneParam(m_intParams, LUMI_SECTION); } +cond::Time_t LHCInfoPerLS::runNumber() const { return LHCInfoPerLS::getOneParam(m_timeParams, RUN_NUMBER); } //setters -void LHCInfoPerLS::setFillNumber(unsigned short lhcFill) { LHCInfoPerLS::setOneParam(m_intParams, LHC_FILL, static_cast(lhcFill)); } +void LHCInfoPerLS::setFillNumber(unsigned short const& lhcFill) { LHCInfoPerLS::setOneParam(m_intParams, LHC_FILL, static_cast(lhcFill)); } + +void LHCInfoPerLS::setLumiSection(unsigned int const& lumiSection) { + LHCInfoPerLS::setOneParam(m_intParams, LUMI_SECTION, lumiSection); +} void LHCInfoPerLS::setCrossingAngleX(float const& angle) { LHCInfoPerLS::setOneParam(m_floatParams, CROSSING_ANGLE_X, angle); } @@ -32,32 +38,33 @@ void LHCInfoPerLS::setBetaStarX(float const& betaStar) { LHCInfoPerLS::setOnePar void LHCInfoPerLS::setBetaStarY(float const& betaStar) { LHCInfoPerLS::setOneParam(m_floatParams, BETA_STAR_Y, betaStar); } -void LHCInfoPerLS::setLumiSection(unsigned int const& lumiSection) { - LHCInfoPerLS::setOneParam(m_intParams, LUMI_SECTION, lumiSection); -} +void LHCInfoPerLS::setRunNumber(cond::Time_t const& runNumber) { LHCInfoPerLS::setOneParam(m_timeParams, RUN_NUMBER, runNumber); }; //sets all values in one go -void LHCInfoPerLS::setInfo(unsigned short lhcFill, +void LHCInfoPerLS::setInfo(unsigned short const& lhcFill, unsigned int const& lumiSection, float const& angleX, float const& angleY, float const& betaX, - float const& betaY) { + float const& betaY, + cond::Time_t const& runNumber) { this->setFillNumber(lhcFill); this->setLumiSection(lumiSection); this->setCrossingAngleX(angleX); this->setCrossingAngleY(angleY); this->setBetaStarX(betaX); this->setBetaStarY(betaY); + this->setRunNumber(runNumber); } void LHCInfoPerLS::print(std::stringstream& ss) const { ss << "LHC fill: " << this->fillNumber() << std::endl + << "Lumi section: " << this->lumiSection() << std::endl + << "Run number: " << this->runNumber() << std::endl << "Crossing angle x (urad): " << this->crossingAngleX() << std::endl << "Crossing angle y (urad): " << this->crossingAngleY() << std::endl << "Beta star x (cm): " << this->betaStarX() << std::endl - << "Beta star y (cm): " << this->betaStarY() << std::endl - << "Lumi section: " << this->lumiSection() << std::endl; + << "Beta star y (cm): " << this->betaStarY() << std::endl; } std::ostream& operator<<(std::ostream& os, LHCInfoPerLS beamInfo) { @@ -74,6 +81,8 @@ bool LHCInfoPerLS::equals(const LHCInfoPerLS& rhs) const { return false; if (m_floatParams != rhs.m_floatParams) return false; + if (m_timeParams != rhs.m_timeParams) + return false; return true; } diff --git a/CondTools/RunInfo/plugins/LHCInfoPerLSWriter.cc b/CondTools/RunInfo/plugins/LHCInfoPerLSWriter.cc index 9b1d0c9365d62..68f5aa0c519b4 100644 --- a/CondTools/RunInfo/plugins/LHCInfoPerLSWriter.cc +++ b/CondTools/RunInfo/plugins/LHCInfoPerLSWriter.cc @@ -34,6 +34,7 @@ void LHCInfoPerLSWriter::analyze(const edm::Event& iEvent, const edm::EventSetup lhcInfoPerLS.setCrossingAngleY(170); lhcInfoPerLS.setBetaStarX(11); lhcInfoPerLS.setBetaStarY(11); + lhcInfoPerLS.setRunNumber(301765); // store the info into a DB object edm::Service poolDbService; From 10cbd4a71c3d5094c6e6c4caff36f68a09b235d3 Mon Sep 17 00:00:00 2001 From: Jan Chyczynski Date: Thu, 18 Aug 2022 11:41:22 +0200 Subject: [PATCH 19/39] created perLS PopCon: cloned old one, removed irrelevant code and adjusted the rest --- .../LHCInfoPerLSPopConSourceHandler.h | 63 +++ CondTools/RunInfo/plugins/BuildFile.xml | 6 +- .../plugins/LHCInfoPerLSPopConAnalyzer.cc | 7 + .../LHCInfoPerLSPopConAnalyzerEndFill.py | 88 ++++ .../LHCInfoPerLSPopConAnalyzerStartFill.py | 88 ++++ .../src/LHCInfoPerLSPopConSourceHandler.cc | 477 ++++++++++++++++++ 6 files changed, 728 insertions(+), 1 deletion(-) create mode 100644 CondTools/RunInfo/interface/LHCInfoPerLSPopConSourceHandler.h create mode 100644 CondTools/RunInfo/plugins/LHCInfoPerLSPopConAnalyzer.cc create mode 100644 CondTools/RunInfo/python/LHCInfoPerLSPopConAnalyzerEndFill.py create mode 100644 CondTools/RunInfo/python/LHCInfoPerLSPopConAnalyzerStartFill.py create mode 100644 CondTools/RunInfo/src/LHCInfoPerLSPopConSourceHandler.cc diff --git a/CondTools/RunInfo/interface/LHCInfoPerLSPopConSourceHandler.h b/CondTools/RunInfo/interface/LHCInfoPerLSPopConSourceHandler.h new file mode 100644 index 0000000000000..de5c54b8e8521 --- /dev/null +++ b/CondTools/RunInfo/interface/LHCInfoPerLSPopConSourceHandler.h @@ -0,0 +1,63 @@ +#ifndef LHCINFOPOPCONSOURCEHANDLER_H +#define LHCINFOPOPCONSOURCEHANDLER_H + +#include + +#include "CondCore/PopCon/interface/PopConSourceHandler.h" +#include "CondFormats/RunInfo/interface/LHCInfoPerLS.h" +#include "FWCore/ParameterSet/interface/ParameterSetfwd.h" +#include "CondCore/CondDB/interface/Types.h" +#include "CondTools/RunInfo/interface/OMSAccess.h" + + +namespace cond { + class OMSService; +} + +class LHCInfoPerLSPopConSourceHandler : public popcon::PopConSourceHandler { +public: + LHCInfoPerLSPopConSourceHandler(const edm::ParameterSet& pset); + ~LHCInfoPerLSPopConSourceHandler() override; + void getNewObjects() override; + std::string id() const override; + + static constexpr unsigned int kLumisectionsQueryLimit = 4000; + +private: + void addEmptyPayload(cond::Time_t iov); + + bool makeFillPayload(std::unique_ptr& targetPayload, + const cond::OMSServiceResult& queryResult); + + + size_t getLumiData(const cond::OMSService& service, + unsigned short fillId, + const boost::posix_time::ptime& beginFillTime, + const boost::posix_time::ptime& endFillTime); + bool getCTTPSData(cond::persistency::Session& session, + const boost::posix_time::ptime& beginFillTime, + const boost::posix_time::ptime& endFillTime); + +private: + bool m_debug; + // starting date for sampling + boost::posix_time::ptime m_startTime; + boost::posix_time::ptime m_endTime; + // sampling interval in seconds + unsigned int m_samplingInterval; + bool m_endFill = true; + std::string m_name; + //for reading from relational database source + std::string m_connectionString, m_ecalConnectionString; + std::string m_dipSchema, m_authpath; + std::string m_omsBaseUrl; + std::unique_ptr m_fillPayload; + std::shared_ptr m_prevPayload; + cond::Time_t m_startFillTime; + cond::Time_t m_endFillTime; + cond::Time_t m_prevEndFillTime; + std::vector > > m_tmpBuffer; + bool m_lastPayloadEmpty = false; +}; + +#endif diff --git a/CondTools/RunInfo/plugins/BuildFile.xml b/CondTools/RunInfo/plugins/BuildFile.xml index 4adf874fba8b1..592b9909bfc42 100644 --- a/CondTools/RunInfo/plugins/BuildFile.xml +++ b/CondTools/RunInfo/plugins/BuildFile.xml @@ -63,4 +63,8 @@ - \ No newline at end of file + + + + + diff --git a/CondTools/RunInfo/plugins/LHCInfoPerLSPopConAnalyzer.cc b/CondTools/RunInfo/plugins/LHCInfoPerLSPopConAnalyzer.cc new file mode 100644 index 0000000000000..a33a817d25498 --- /dev/null +++ b/CondTools/RunInfo/plugins/LHCInfoPerLSPopConAnalyzer.cc @@ -0,0 +1,7 @@ +#include "CondCore/PopCon/interface/PopConAnalyzer.h" +#include "CondTools/RunInfo/interface/LHCInfoPerLSPopConSourceHandler.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +typedef popcon::PopConAnalyzer LHCInfoPerLSPopConAnalyzer; +//define this as a plug-in +DEFINE_FWK_MODULE(LHCInfoPerLSPopConAnalyzer); diff --git a/CondTools/RunInfo/python/LHCInfoPerLSPopConAnalyzerEndFill.py b/CondTools/RunInfo/python/LHCInfoPerLSPopConAnalyzerEndFill.py new file mode 100644 index 0000000000000..3b7ff8f41cd98 --- /dev/null +++ b/CondTools/RunInfo/python/LHCInfoPerLSPopConAnalyzerEndFill.py @@ -0,0 +1,88 @@ +import socket +import FWCore.ParameterSet.Config as cms +import FWCore.ParameterSet.VarParsing as VarParsing +process = cms.Process("LHCInfoPerLSPopulator") +from CondCore.CondDB.CondDB_cfi import * +#process.load("CondCore.DBCommon.CondDBCommon_cfi") +#process.CondDBCommon.connect = 'sqlite_file:lhcinfoperls_pop_test.db' +#process.CondDBCommon.DBParameters.authenticationPath = '.' +#process.CondDBCommon.DBParameters.messageLevel=cms.untracked.int32(1) + +sourceConnection = 'oracle://cms_omds_adg/CMS_RUNINFO_R' +if socket.getfqdn().find('.cms') != -1: + sourceConnection = 'oracle://cms_omds_lb/CMS_RUNINFO_R' + +options = VarParsing.VarParsing() +options.register( 'destinationConnection' + , 'sqlite_file:lhcinfo_pop_test.db' #default value + , VarParsing.VarParsing.multiplicity.singleton + , VarParsing.VarParsing.varType.string + , "Connection string to the DB where payloads will be possibly written." + ) +options.register( 'targetConnection' + , '' #default value + , VarParsing.VarParsing.multiplicity.singleton + , VarParsing.VarParsing.varType.string + , """Connection string to the target DB: + if not empty (default), this provides the latest IOV and payloads to compare; + it is the DB where payloads should be finally uploaded.""" + ) +options.register( 'tag' + , 'LHCInfoPerLS_PopCon_start_test' + , VarParsing.VarParsing.multiplicity.singleton + , VarParsing.VarParsing.varType.string + , "Tag written in destinationConnection and finally appended in targetConnection." + ) +options.register( 'messageLevel' + , 0 #default value + , VarParsing.VarParsing.multiplicity.singleton + , VarParsing.VarParsing.varType.int + , "Message level; default to 0" + ) +options.parseArguments() + +CondDBConnection = CondDB.clone( connect = cms.string( options.destinationConnection ) ) +CondDBConnection.DBParameters.messageLevel = cms.untracked.int32( options.messageLevel ) + +process.MessageLogger = cms.Service("MessageLogger", + cout = cms.untracked.PSet(threshold = cms.untracked.string('INFO')), + destinations = cms.untracked.vstring('cout') + ) + +process.source = cms.Source("EmptyIOVSource", + lastValue = cms.uint64(1), + timetype = cms.string('runnumber'), + firstValue = cms.uint64(1), + interval = cms.uint64(1) + ) + +process.PoolDBOutputService = cms.Service("PoolDBOutputService", + CondDBConnection, + timetype = cms.untracked.string('timestamp'), + toPut = cms.VPSet(cms.PSet(record = cms.string('LHCInfoPerLSRcd'), + tag = cms.string( options.tag ) + ) + ) + ) + +process.Test1 = cms.EDAnalyzer("LHCInfoPerLSPopConAnalyzer", + SinceAppendMode = cms.bool(True), + record = cms.string('LHCInfoPerLSRcd'), + name = cms.untracked.string('LHCInfo'), + Source = cms.PSet(fill = cms.untracked.uint32(6417), + startTime = cms.untracked.string('2021-09-10 03:10:18.000'), + # endTime = cms.untracked.string('2018-04-06 05:00:00.000'), + samplingInterval = cms.untracked.uint32( 600 ), + endFill = cms.untracked.bool(True), + connectionString = cms.untracked.string("oracle://cms_orcon_adg/CMS_RUNTIME_LOGGER"), + ecalConnectionString = cms.untracked.string("oracle://cms_orcon_adg/CMS_DCS_ENV_PVSS_COND"), + DIPSchema = cms.untracked.string("CMS_BEAM_COND"), + omsBaseUrl = cms.untracked.string("http://vocms0184.cern.ch/agg/api/v1"), + #authenticationPath = cms.untracked.string("."), + debug=cms.untracked.bool(False) + ), + loggingOn = cms.untracked.bool(True), + IsDestDbCheckedInQueryLog = cms.untracked.bool(False) + ) + +process.p = cms.Path(process.Test1) diff --git a/CondTools/RunInfo/python/LHCInfoPerLSPopConAnalyzerStartFill.py b/CondTools/RunInfo/python/LHCInfoPerLSPopConAnalyzerStartFill.py new file mode 100644 index 0000000000000..ac1461f80c1b4 --- /dev/null +++ b/CondTools/RunInfo/python/LHCInfoPerLSPopConAnalyzerStartFill.py @@ -0,0 +1,88 @@ +import socket +import FWCore.ParameterSet.Config as cms +import FWCore.ParameterSet.VarParsing as VarParsing +process = cms.Process("LHCInfoPerLSPopulator") +from CondCore.CondDB.CondDB_cfi import * +#process.load("CondCore.DBCommon.CondDBCommon_cfi") +#process.CondDBCommon.connect = 'sqlite_file:lhcinfoperls_pop_test.db' +#process.CondDBCommon.DBParameters.authenticationPath = '.' +#process.CondDBCommon.DBParameters.messageLevel=cms.untracked.int32(1) + +sourceConnection = 'oracle://cms_omds_adg/CMS_RUNINFO_R' +if socket.getfqdn().find('.cms') != -1: + sourceConnection = 'oracle://cms_omds_lb/CMS_RUNINFO_R' + +options = VarParsing.VarParsing() +options.register( 'destinationConnection' + , 'sqlite_file:lhcinfo_pop_test.db' #default value + , VarParsing.VarParsing.multiplicity.singleton + , VarParsing.VarParsing.varType.string + , "Connection string to the DB where payloads will be possibly written." + ) +options.register( 'targetConnection' + , '' #default value + , VarParsing.VarParsing.multiplicity.singleton + , VarParsing.VarParsing.varType.string + , """Connection string to the target DB: + if not empty (default), this provides the latest IOV and payloads to compare; + it is the DB where payloads should be finally uploaded.""" + ) +options.register( 'tag' + , 'LHCInfoPerLS_PopCon_start_test' + , VarParsing.VarParsing.multiplicity.singleton + , VarParsing.VarParsing.varType.string + , "Tag written in destinationConnection and finally appended in targetConnection." + ) +options.register( 'messageLevel' + , 0 #default value + , VarParsing.VarParsing.multiplicity.singleton + , VarParsing.VarParsing.varType.int + , "Message level; default to 0" + ) +options.parseArguments() + +CondDBConnection = CondDB.clone( connect = cms.string( options.destinationConnection ) ) +CondDBConnection.DBParameters.messageLevel = cms.untracked.int32( options.messageLevel ) + +process.MessageLogger = cms.Service("MessageLogger", + cout = cms.untracked.PSet(threshold = cms.untracked.string('INFO')), + destinations = cms.untracked.vstring('cout') + ) + +process.source = cms.Source("EmptyIOVSource", + lastValue = cms.uint64(1), + timetype = cms.string('runnumber'), + firstValue = cms.uint64(1), + interval = cms.uint64(1) + ) + +process.PoolDBOutputService = cms.Service("PoolDBOutputService", + CondDBConnection, + timetype = cms.untracked.string('timestamp'), + toPut = cms.VPSet(cms.PSet(record = cms.string('LHCInfoPerLSRcd'), + tag = cms.string( options.tag ) + ) + ) + ) + +process.Test1 = cms.EDAnalyzer("LHCInfoPerLSPopConAnalyzer", + SinceAppendMode = cms.bool(True), + record = cms.string('LHCInfoPerLSRcd'), + name = cms.untracked.string('LHCInfo'), + Source = cms.PSet(fill = cms.untracked.uint32(6417), + startTime = cms.untracked.string('2021-09-10 03:10:18.000'), + # endTime = cms.untracked.string('2018-04-06 05:00:00.000'), + samplingInterval = cms.untracked.uint32( 600 ), + endFill = cms.untracked.bool(False), + connectionString = cms.untracked.string("oracle://cms_orcon_adg/CMS_RUNTIME_LOGGER"), + ecalConnectionString = cms.untracked.string("oracle://cms_orcon_adg/CMS_DCS_ENV_PVSS_COND"), + DIPSchema = cms.untracked.string("CMS_BEAM_COND"), + omsBaseUrl = cms.untracked.string("http://vocms0184.cern.ch/agg/api/v1"), + #authenticationPath = cms.untracked.string("."), + debug=cms.untracked.bool(False) + ), + loggingOn = cms.untracked.bool(True), + IsDestDbCheckedInQueryLog = cms.untracked.bool(False) + ) + +process.p = cms.Path(process.Test1) diff --git a/CondTools/RunInfo/src/LHCInfoPerLSPopConSourceHandler.cc b/CondTools/RunInfo/src/LHCInfoPerLSPopConSourceHandler.cc new file mode 100644 index 0000000000000..d47e3f51d054b --- /dev/null +++ b/CondTools/RunInfo/src/LHCInfoPerLSPopConSourceHandler.cc @@ -0,0 +1,477 @@ +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "CondCore/CondDB/interface/ConnectionPool.h" +#include "CondFormats/Common/interface/TimeConversions.h" +#include "CondTools/RunInfo/interface/LHCInfoPerLSPopConSourceHandler.h" +#include "CondTools/RunInfo/interface/OMSAccess.h" +#include "RelationalAccess/ISessionProxy.h" +#include "RelationalAccess/ISchema.h" +#include "RelationalAccess/IQuery.h" +#include "RelationalAccess/ICursor.h" +#include "CoralBase/AttributeList.h" +#include "CoralBase/Attribute.h" +#include "CoralBase/AttributeSpecification.h" +#include "CoralBase/TimeStamp.h" +#include +#include +#include +#include +#include +#include +#include + +LHCInfoPerLSPopConSourceHandler::LHCInfoPerLSPopConSourceHandler(edm::ParameterSet const& pset) + : m_debug(pset.getUntrackedParameter("debug", false)), + m_startTime(), + m_endTime(), + m_samplingInterval((unsigned int)pset.getUntrackedParameter("samplingInterval", 300)), + m_endFill(pset.getUntrackedParameter("endFill", true)), + m_name(pset.getUntrackedParameter("name", "LHCInfoPerLSPopConSourceHandler")), + m_connectionString(pset.getUntrackedParameter("connectionString", "")), + m_dipSchema(pset.getUntrackedParameter("DIPSchema", "")), + m_authpath(pset.getUntrackedParameter("authenticationPath", "")), + m_omsBaseUrl(pset.getUntrackedParameter("omsBaseUrl", "")), + m_fillPayload(), + m_prevPayload(), + m_tmpBuffer() { + if (pset.exists("startTime")) { + m_startTime = boost::posix_time::time_from_string(pset.getUntrackedParameter("startTime")); + } + boost::posix_time::ptime now = boost::posix_time::second_clock::local_time(); + m_endTime = now; + if (pset.exists("endTime")) { + m_endTime = boost::posix_time::time_from_string(pset.getUntrackedParameter("endTime")); + if (m_endTime > now) + m_endTime = now; + } +} +//L1: try with different m_dipSchema +//L2: try with different m_name +LHCInfoPerLSPopConSourceHandler::~LHCInfoPerLSPopConSourceHandler() {} + +namespace LHCInfoPerLSImpl { + + struct IOVComp { + bool operator()(const cond::Time_t& x, const std::pair>& y) { + return (x < y.first); + } + }; + + // function to search in the vector the target time + std::vector>>::const_iterator search( + const cond::Time_t& val, const std::vector>>& container) { + if (container.empty()) + return container.end(); + auto p = std::upper_bound(container.begin(), container.end(), val, IOVComp()); + return (p != container.begin()) ? p - 1 : container.end(); + } + +} // namespace LHCInfoPerLSImpl + +bool LHCInfoPerLSPopConSourceHandler::makeFillPayload (std::unique_ptr& targetPayload, + const cond::OMSServiceResult& queryResult) { + bool ret = false; + if (!queryResult.empty()) { + auto row = *queryResult.begin(); + auto currentFill = row.get("fill_number"); + m_startFillTime = cond::time::from_boost(row.get("start_time")); + m_endFillTime = cond::time::from_boost(row.get("end_time")); + targetPayload = std::make_unique(); + targetPayload->setFillNumber(currentFill); + ret = true; + } + return ret; +} + +size_t LHCInfoPerLSPopConSourceHandler::getLumiData(const cond::OMSService& oms, + unsigned short fillId, + const boost::posix_time::ptime& beginFillTime, + const boost::posix_time::ptime& endFillTime) { + auto query = oms.query("lumisections"); + query->addOutputVars({"start_time", "delivered_lumi", "recorded_lumi"}); + query->filterEQ("fill_number", fillId); + query->filterGT("start_time", beginFillTime).filterLT("start_time", endFillTime); + query->limit(kLumisectionsQueryLimit); + size_t nlumi = 0; + if (query->execute()) { + auto res = query->result(); + std::stringstream condIovs; + std::stringstream posixIovs; + for (auto r : res) { + nlumi++; + auto lumiTime = r.get("start_time"); + LHCInfoPerLS* thisLumiSectionInfo = new LHCInfoPerLS(*m_fillPayload); + m_tmpBuffer.emplace_back(std::make_pair(cond::time::from_boost(lumiTime), thisLumiSectionInfo)); + LHCInfoPerLS& payload = *thisLumiSectionInfo; + + condIovs << cond::time::from_boost(lumiTime) << " "; + posixIovs << lumiTime << " "; + } + + } + return nlumi; +} + +namespace LHCInfoPerLSImpl { + struct LumiSectionFilter { + LumiSectionFilter(const std::vector>>& samples) + : currLow(samples.begin()), currUp(samples.begin()), end(samples.end()) { + currUp++; + } + + void reset(const std::vector>>& samples) { + currLow = samples.begin(); + currUp = samples.begin(); + currUp++; + end = samples.end(); + currentDipTime = 0; + } + + bool process(cond::Time_t dipTime) { + if (currLow == end) + return false; + bool search = false; + if (currentDipTime == 0) { + search = true; + } else { + if (dipTime == currentDipTime) + return true; + else { + cond::Time_t upper = cond::time::MAX_VAL; + if (currUp != end) + upper = currUp->first; + if (dipTime < upper) + return false; + else { + search = true; + } + } + } + if (search) { + while (currUp != end and currUp->first < dipTime) { + currLow++; + currUp++; + } + currentDipTime = dipTime; + return currLow != end; + } + return false; + } + + cond::Time_t currentSince() { return currLow->first; } + LHCInfoPerLS& currentPayload() { return *currLow->second; } + + std::vector>>::const_iterator current() { return currLow; } + std::vector>>::const_iterator currLow; + std::vector>>::const_iterator currUp; + std::vector>>::const_iterator end; + cond::Time_t currentDipTime = 0; + }; +} // namespace LHCInfoPerLSImpl + + +bool LHCInfoPerLSPopConSourceHandler::getCTTPSData(cond::persistency::Session& session, + const boost::posix_time::ptime& beginFillTime, + const boost::posix_time::ptime& endFillTime) { + //run the fifth query against the CTPPS schema + //Initializing the CMS_CTP_CTPPS_COND schema. + coral::ISchema& CTPPS = session.coralSession().schema("CMS_PPS_SPECT_COND"); + //execute query for CTPPS Data + std::unique_ptr CTPPSDataQuery(CTPPS.newQuery()); + //FROM clause + CTPPSDataQuery->addToTableList(std::string("PPS_LHC_MACHINE_PARAMS")); + //SELECT clause + CTPPSDataQuery->addToOutputList(std::string("DIP_UPDATE_TIME")); + CTPPSDataQuery->addToOutputList(std::string("LUMI_SECTION")); + CTPPSDataQuery->addToOutputList(std::string("XING_ANGLE_P5_X_URAD")); + CTPPSDataQuery->addToOutputList(std::string("BETA_STAR_P5_X_M")); + //WHERE CLAUSE + coral::AttributeList CTPPSDataBindVariables; + CTPPSDataBindVariables.extend(std::string("beginFillTime")); + CTPPSDataBindVariables.extend(std::string("endFillTime")); + CTPPSDataBindVariables[std::string("beginFillTime")].data() = coral::TimeStamp(beginFillTime); + CTPPSDataBindVariables[std::string("endFillTime")].data() = coral::TimeStamp(endFillTime); + std::string conditionStr = std::string("DIP_UPDATE_TIME>= :beginFillTime and DIP_UPDATE_TIME< :endFillTime"); + CTPPSDataQuery->setCondition(conditionStr, CTPPSDataBindVariables); + //ORDER BY clause + CTPPSDataQuery->addToOrderList(std::string("DIP_UPDATE_TIME")); + //define query output + coral::AttributeList CTPPSDataOutput; + CTPPSDataOutput.extend(std::string("DIP_UPDATE_TIME")); + CTPPSDataOutput.extend(std::string("LUMI_SECTION")); + CTPPSDataOutput.extend(std::string("XING_ANGLE_P5_X_URAD")); + CTPPSDataOutput.extend(std::string("BETA_STAR_P5_X_M")); + CTPPSDataQuery->defineOutput(CTPPSDataOutput); + //execute the query + coral::ICursor& CTPPSDataCursor = CTPPSDataQuery->execute(); + cond::Time_t dipTime = 0; + unsigned int lumiSection = 0; + float crossingAngle = 0., betastar = 0.; + + bool ret = false; + LHCInfoPerLSImpl::LumiSectionFilter filter(m_tmpBuffer); + while (CTPPSDataCursor.next()) { + if (m_debug) { + std::ostringstream CTPPS; + CTPPSDataCursor.currentRow().toOutputStream(CTPPS); + } + coral::Attribute const& dipTimeAttribute = CTPPSDataCursor.currentRow()[std::string("DIP_UPDATE_TIME")]; + if (!dipTimeAttribute.isNull()) { + dipTime = cond::time::from_boost(dipTimeAttribute.data().time()); + if (filter.process(dipTime)) { + ret = true; + coral::Attribute const& lumiSectionAttribute = CTPPSDataCursor.currentRow()[std::string("LUMI_SECTION")]; + if (!lumiSectionAttribute.isNull()) { + lumiSection = lumiSectionAttribute.data(); + } + coral::Attribute const& crossingAngleXAttribute = + CTPPSDataCursor.currentRow()[std::string("XING_ANGLE_P5_X_URAD")]; + if (!crossingAngleXAttribute.isNull()) { + crossingAngle = crossingAngleXAttribute.data(); + } + coral::Attribute const& betaStarXAttribute = CTPPSDataCursor.currentRow()[std::string("BETA_STAR_P5_X_M")]; + if (!betaStarXAttribute.isNull()) { + betastar = betaStarXAttribute.data(); + } + for (auto it = filter.current(); it != m_tmpBuffer.end(); it++) { + // set the current values to all of the payloads of the lumi section samples after the current since + LHCInfoPerLS& payload = *(it->second); + payload.setCrossingAngleX(crossingAngle); + payload.setBetaStarX(betastar); + payload.setLumiSection(lumiSection); + } + } + } + } + return ret; +} + +void LHCInfoPerLSPopConSourceHandler::addEmptyPayload(cond::Time_t iov) { + bool add = false; + if (m_iovs.empty()) { + if (!m_lastPayloadEmpty) + add = true; + } else { + auto lastAdded = m_iovs.rbegin()->second; + if (lastAdded->fillNumber() != 0) { + add = true; + } + } + if (add) { + auto newPayload = std::make_shared(); + m_iovs.insert(std::make_pair(iov, newPayload)); + m_prevPayload = newPayload; + m_prevEndFillTime = 0; + } +} + +namespace LHCInfoPerLSImpl { + bool comparePayloads(const LHCInfoPerLS& rhs, const LHCInfoPerLS& lhs) { + if (rhs.fillNumber() != lhs.fillNumber()) + return false; + if (rhs.runNumber() != lhs.runNumber()) + return false; + if (rhs.crossingAngleX() != lhs.crossingAngleX()) + return false; + if (rhs.crossingAngleY() != lhs.crossingAngleY()) + return false; + if (rhs.betaStarX() != lhs.betaStarX()) + return false; + if (rhs.betaStarY() != lhs.betaStarY()) + return false; + return true; + } + + size_t transferPayloads(const std::vector>>& buffer, + std::map>& iovsToTransfer, + std::shared_ptr& prevPayload) { + size_t niovs = 0; + std::stringstream condIovs; + for (auto& iov : buffer) { + bool add = false; + auto payload = iov.second; + cond::Time_t since = iov.first; + if (iovsToTransfer.empty()) { + add = true; + } else { + LHCInfoPerLS& lastAdded = *iovsToTransfer.rbegin()->second; + if (!comparePayloads(lastAdded, *payload)) { + add = true; + } + } + if (add) { + niovs++; + condIovs << since << " "; + iovsToTransfer.insert(std::make_pair(since, payload)); + prevPayload = iov.second; + } + } + edm::LogInfo("transferPayloads") << "TRANSFERED COND IOVS: " << condIovs.str(); + return niovs; + } + +} // namespace LHCInfoPerLSImpl + +void LHCInfoPerLSPopConSourceHandler::getNewObjects() { + //if a new tag is created, transfer fake fill from 1 to the first fill for the first time + if (tagInfo().size == 0) { + edm::LogInfo(m_name) << "New tag " << tagInfo().name << "; from " << m_name << "::getNewObjects"; + } else { + //check what is already inside the database + edm::LogInfo(m_name) << "got info for tag " << tagInfo().name << ": size " << tagInfo().size + << ", last object valid since " << tagInfo().lastInterval.since << " ( " + << boost::posix_time::to_iso_extended_string( + cond::time::to_boost(tagInfo().lastInterval.since)) + << " ); from " << m_name << "::getNewObjects"; + } + + cond::Time_t lastSince = tagInfo().lastInterval.since; + if (tagInfo().isEmpty()) { + // for a new or empty tag, an empty payload should be added on top with since=1 + addEmptyPayload(1); + lastSince = 1; + } else { + edm::LogInfo(m_name) << "The last Iov in tag " << tagInfo().name << " valid since " << lastSince << "from " + << m_name << "::getNewObjects"; + } + + boost::posix_time::ptime executionTime = boost::posix_time::second_clock::local_time(); + cond::Time_t targetSince = 0; + cond::Time_t endIov = cond::time::from_boost(executionTime); + if (!m_startTime.is_not_a_date_time()) { + targetSince = cond::time::from_boost(m_startTime); + } + if (lastSince > targetSince) + targetSince = lastSince; + + edm::LogInfo(m_name) << "Starting sampling at " + << boost::posix_time::to_simple_string(cond::time::to_boost(targetSince)); + + //retrieve the data from the relational database source + cond::persistency::ConnectionPool connection; + //configure the connection + if (m_debug) { + connection.setMessageVerbosity(coral::Debug); + } else { + connection.setMessageVerbosity(coral::Error); + } + connection.setAuthenticationPath(m_authpath); + connection.configure(); + //create the sessions + cond::persistency::Session session = connection.createSession(m_connectionString, false); + // fetch last payload when available + if (!tagInfo().lastInterval.payloadId.empty()) { + cond::persistency::Session session3 = dbSession(); + session3.transaction().start(true); + m_prevPayload = session3.fetchPayload(tagInfo().lastInterval.payloadId); + session3.transaction().commit(); + if(m_prevPayload->fillNumber() != 0) + { + cond::OMSService oms; + oms.connect(m_omsBaseUrl); + auto query = oms.query("fills"); + query->addOutputVar("end_time"); + query->filterEQ("fill_number", m_prevPayload->fillNumber()); + bool foundFill = query->execute(); + if (foundFill) { + auto result = query->result(); + + if (!result.empty()) { + auto endFillTime = (*result.begin()).get("end_time"); + m_prevEndFillTime = cond::time::from_boost(endFillTime); + } + else { + foundFill = false; + } + } + if (!foundFill) { + edm::LogError(m_name) << "Could not find end time of fill #" << m_prevPayload->fillNumber(); + } + } + else + { + m_prevEndFillTime = 0; + } + } + + bool iovAdded = false; + while (true) { + if (targetSince >= endIov) { + edm::LogInfo(m_name) << "Sampling ended at the time " + << boost::posix_time::to_simple_string(cond::time::to_boost(endIov)); + break; + } + boost::posix_time::ptime targetTime = cond::time::to_boost(targetSince); + boost::posix_time::ptime startSampleTime; + boost::posix_time::ptime endSampleTime; + + cond::OMSService oms; + oms.connect(m_omsBaseUrl); + auto query = oms.query("fills"); + + if (!m_endFill and m_prevPayload->fillNumber() and m_prevEndFillTime == 0ULL) { + // execute the query for the current fill + edm::LogInfo(m_name) << "Searching started fill #" << m_prevPayload->fillNumber(); + query->filterEQ("fill_number", m_prevPayload->fillNumber()); + bool foundFill = query->execute(); + if (foundFill) + foundFill = makeFillPayload(m_fillPayload, query->result()); + if (!foundFill) { + edm::LogError(m_name) << "Could not find fill #" << m_prevPayload->fillNumber(); + break; + } + startSampleTime = cond::time::to_boost(lastSince); + } else { + edm::LogInfo(m_name) << "Searching new fill after " << boost::posix_time::to_simple_string(targetTime); + boost::posix_time::ptime startTime = targetTime + boost::posix_time::seconds(1); + query->filterNotNull("start_stable_beam").filterGT("start_time", startTime).filterNotNull("fill_number"); + if (m_endFill) + query->filterNotNull("end_time"); + bool foundFill = query->execute(); + if (foundFill) + foundFill = makeFillPayload(m_fillPayload, query->result()); + if (!foundFill) { + edm::LogInfo(m_name) << "No fill found - END of job."; + if (iovAdded) + addEmptyPayload(targetSince); + break; + } + startSampleTime = cond::time::to_boost(m_startFillTime); + } + + unsigned short lhcFill = m_fillPayload->fillNumber(); + if (m_endFillTime == 0ULL) { + edm::LogInfo(m_name) << "Found ongoing fill " << lhcFill << " created at " << cond::time::to_boost(m_startFillTime); + endSampleTime = executionTime; + targetSince = endIov; + } else { + edm::LogInfo(m_name) << "Found fill " << lhcFill << " created at " << cond::time::to_boost(m_startFillTime) + << " ending at " << cond::time::to_boost(m_endFillTime); + endSampleTime = cond::time::to_boost(m_endFillTime); + targetSince = m_endFillTime; + } + + + size_t nlumi = getLumiData(oms, lhcFill, startSampleTime, endSampleTime); + edm::LogInfo(m_name) << "Found " << nlumi << " lumisections during the fill " << lhcFill; + boost::posix_time::ptime flumiStart = cond::time::to_boost(m_tmpBuffer.front().first); + boost::posix_time::ptime flumiStop = cond::time::to_boost(m_tmpBuffer.back().first); + edm::LogInfo(m_name) << "First lumi starts at " << flumiStart << " last lumi starts at " << flumiStop; + session.transaction().start(true); + getCTTPSData(session, startSampleTime, endSampleTime); + session.transaction().commit(); + + // + size_t niovs = LHCInfoPerLSImpl::transferPayloads(m_tmpBuffer, m_iovs, m_prevPayload); + edm::LogInfo(m_name) << "Added " << niovs << " iovs within the Fill time"; + if(niovs){ + m_prevEndFillTime = m_endFillTime; + } + m_tmpBuffer.clear(); + iovAdded = true; + if (m_prevPayload->fillNumber() and m_endFillTime != 0ULL) + addEmptyPayload(m_endFillTime); + } +} + +std::string LHCInfoPerLSPopConSourceHandler::id() const { return m_name; } From 821d7738883a3739186f4fb188b9f481c018414e Mon Sep 17 00:00:00 2001 From: Jan Chyczynski Date: Thu, 18 Aug 2022 12:36:28 +0200 Subject: [PATCH 20/39] populating crossing angle Y and beta* Y --- .../src/LHCInfoPerLSPopConSourceHandler.cc | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/CondTools/RunInfo/src/LHCInfoPerLSPopConSourceHandler.cc b/CondTools/RunInfo/src/LHCInfoPerLSPopConSourceHandler.cc index d47e3f51d054b..212fc5dfcf2ba 100644 --- a/CondTools/RunInfo/src/LHCInfoPerLSPopConSourceHandler.cc +++ b/CondTools/RunInfo/src/LHCInfoPerLSPopConSourceHandler.cc @@ -184,7 +184,9 @@ bool LHCInfoPerLSPopConSourceHandler::getCTTPSData(cond::persistency::Session& s CTPPSDataQuery->addToOutputList(std::string("DIP_UPDATE_TIME")); CTPPSDataQuery->addToOutputList(std::string("LUMI_SECTION")); CTPPSDataQuery->addToOutputList(std::string("XING_ANGLE_P5_X_URAD")); + CTPPSDataQuery->addToOutputList(std::string("XING_ANGLE_P5_Y_URAD")); CTPPSDataQuery->addToOutputList(std::string("BETA_STAR_P5_X_M")); + CTPPSDataQuery->addToOutputList(std::string("BETA_STAR_P5_Y_M")); //WHERE CLAUSE coral::AttributeList CTPPSDataBindVariables; CTPPSDataBindVariables.extend(std::string("beginFillTime")); @@ -200,13 +202,16 @@ bool LHCInfoPerLSPopConSourceHandler::getCTTPSData(cond::persistency::Session& s CTPPSDataOutput.extend(std::string("DIP_UPDATE_TIME")); CTPPSDataOutput.extend(std::string("LUMI_SECTION")); CTPPSDataOutput.extend(std::string("XING_ANGLE_P5_X_URAD")); + CTPPSDataOutput.extend(std::string("XING_ANGLE_P5_Y_URAD")); CTPPSDataOutput.extend(std::string("BETA_STAR_P5_X_M")); + CTPPSDataOutput.extend(std::string("BETA_STAR_P5_Y_M")); CTPPSDataQuery->defineOutput(CTPPSDataOutput); //execute the query coral::ICursor& CTPPSDataCursor = CTPPSDataQuery->execute(); cond::Time_t dipTime = 0; unsigned int lumiSection = 0; - float crossingAngle = 0., betastar = 0.; + float crossingAngleX = 0., betaStarX = 0.; + float crossingAngleY = 0., betaStarY = 0.; bool ret = false; LHCInfoPerLSImpl::LumiSectionFilter filter(m_tmpBuffer); @@ -227,17 +232,28 @@ bool LHCInfoPerLSPopConSourceHandler::getCTTPSData(cond::persistency::Session& s coral::Attribute const& crossingAngleXAttribute = CTPPSDataCursor.currentRow()[std::string("XING_ANGLE_P5_X_URAD")]; if (!crossingAngleXAttribute.isNull()) { - crossingAngle = crossingAngleXAttribute.data(); + crossingAngleX = crossingAngleXAttribute.data(); + } + coral::Attribute const& crossingAngleYAttribute = + CTPPSDataCursor.currentRow()[std::string("XING_ANGLE_P5_Y_URAD")]; + if (!crossingAngleYAttribute.isNull()) { + crossingAngleY = crossingAngleYAttribute.data(); } coral::Attribute const& betaStarXAttribute = CTPPSDataCursor.currentRow()[std::string("BETA_STAR_P5_X_M")]; if (!betaStarXAttribute.isNull()) { - betastar = betaStarXAttribute.data(); + betaStarX = betaStarXAttribute.data(); + } + coral::Attribute const& betaStarYAttribute = CTPPSDataCursor.currentRow()[std::string("BETA_STAR_P5_Y_M")]; + if (!betaStarYAttribute.isNull()) { + betaStarY = betaStarYAttribute.data(); } for (auto it = filter.current(); it != m_tmpBuffer.end(); it++) { // set the current values to all of the payloads of the lumi section samples after the current since LHCInfoPerLS& payload = *(it->second); - payload.setCrossingAngleX(crossingAngle); - payload.setBetaStarX(betastar); + payload.setCrossingAngleX(crossingAngleX); + payload.setCrossingAngleY(crossingAngleY); + payload.setBetaStarX(betaStarX); + payload.setBetaStarY(betaStarY); payload.setLumiSection(lumiSection); } } From dc39517ff7afba6ba7696fca988144d4f9013a0a Mon Sep 17 00:00:00 2001 From: Jan Chyczynski Date: Fri, 19 Aug 2022 13:35:26 +0200 Subject: [PATCH 21/39] populating run number --- CondTools/RunInfo/interface/OMSAccess.h | 6 ++++++ CondTools/RunInfo/src/LHCInfoPerLSPopConSourceHandler.cc | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CondTools/RunInfo/interface/OMSAccess.h b/CondTools/RunInfo/interface/OMSAccess.h index 625bb2dfbcb3f..4e096b3cc79b3 100644 --- a/CondTools/RunInfo/interface/OMSAccess.h +++ b/CondTools/RunInfo/interface/OMSAccess.h @@ -52,6 +52,12 @@ namespace cond { unsigned long int_val = from_string_impl(attributeValue, 0); return (unsigned short)int_val; } + inline unsigned long long s_to_ull(const std::string& val) { return std::stoull(val); } + template <> + inline unsigned long long from_string(const std::string& attributeValue) { + unsigned long long int_val = from_string_impl(attributeValue, 0); + return int_val; + } inline boost::posix_time::ptime s_to_time(const std::string& val) { boost::posix_time::time_input_facet* facet = new boost::posix_time::time_input_facet(OMS_TIME_FMT); diff --git a/CondTools/RunInfo/src/LHCInfoPerLSPopConSourceHandler.cc b/CondTools/RunInfo/src/LHCInfoPerLSPopConSourceHandler.cc index 212fc5dfcf2ba..b8017fd7edfd0 100644 --- a/CondTools/RunInfo/src/LHCInfoPerLSPopConSourceHandler.cc +++ b/CondTools/RunInfo/src/LHCInfoPerLSPopConSourceHandler.cc @@ -88,7 +88,7 @@ size_t LHCInfoPerLSPopConSourceHandler::getLumiData(const cond::OMSService& oms, const boost::posix_time::ptime& beginFillTime, const boost::posix_time::ptime& endFillTime) { auto query = oms.query("lumisections"); - query->addOutputVars({"start_time", "delivered_lumi", "recorded_lumi"}); + query->addOutputVars({"start_time", "run_number"}); query->filterEQ("fill_number", fillId); query->filterGT("start_time", beginFillTime).filterLT("start_time", endFillTime); query->limit(kLumisectionsQueryLimit); @@ -103,6 +103,7 @@ size_t LHCInfoPerLSPopConSourceHandler::getLumiData(const cond::OMSService& oms, LHCInfoPerLS* thisLumiSectionInfo = new LHCInfoPerLS(*m_fillPayload); m_tmpBuffer.emplace_back(std::make_pair(cond::time::from_boost(lumiTime), thisLumiSectionInfo)); LHCInfoPerLS& payload = *thisLumiSectionInfo; + payload.setRunNumber(r.get("run_number")); condIovs << cond::time::from_boost(lumiTime) << " "; posixIovs << lumiTime << " "; From 89aa6902c93a41fe31b0b5ea37d8fc1d30ef91ed Mon Sep 17 00:00:00 2001 From: Jan Chyczynski Date: Mon, 29 Aug 2022 18:50:01 +0200 Subject: [PATCH 22/39] implemented startFill mode of perLS PopCon --- .../LHCInfoPerLSPopConSourceHandler.h | 3 + .../src/LHCInfoPerLSPopConSourceHandler.cc | 78 +++++++++++++------ 2 files changed, 59 insertions(+), 22 deletions(-) diff --git a/CondTools/RunInfo/interface/LHCInfoPerLSPopConSourceHandler.h b/CondTools/RunInfo/interface/LHCInfoPerLSPopConSourceHandler.h index de5c54b8e8521..2dd29493763f7 100644 --- a/CondTools/RunInfo/interface/LHCInfoPerLSPopConSourceHandler.h +++ b/CondTools/RunInfo/interface/LHCInfoPerLSPopConSourceHandler.h @@ -29,6 +29,9 @@ class LHCInfoPerLSPopConSourceHandler : public popcon::PopConSourceHandler& targetPayload, const cond::OMSServiceResult& queryResult); + void addPayloadToBuffer(cond::OMSServiceResultRef& row); + size_t bufferAllLS(const cond::OMSServiceResult& queryResult); + size_t bufferFirstStableBeamLS(const cond::OMSServiceResult& queryResult); size_t getLumiData(const cond::OMSService& service, unsigned short fillId, diff --git a/CondTools/RunInfo/src/LHCInfoPerLSPopConSourceHandler.cc b/CondTools/RunInfo/src/LHCInfoPerLSPopConSourceHandler.cc index b8017fd7edfd0..4c9b36b8646e4 100644 --- a/CondTools/RunInfo/src/LHCInfoPerLSPopConSourceHandler.cc +++ b/CondTools/RunInfo/src/LHCInfoPerLSPopConSourceHandler.cc @@ -83,32 +83,66 @@ bool LHCInfoPerLSPopConSourceHandler::makeFillPayload (std::unique_ptr("start_time"); + LHCInfoPerLS* thisLumiSectionInfo = new LHCInfoPerLS(*m_fillPayload); + m_tmpBuffer.emplace_back(std::make_pair(cond::time::from_boost(lumiTime), thisLumiSectionInfo)); + + thisLumiSectionInfo->setRunNumber(row.get("run_number")); +} + +size_t LHCInfoPerLSPopConSourceHandler::bufferAllLS(const cond::OMSServiceResult& queryResult) +{ + for (auto r : queryResult) { + addPayloadToBuffer(r); + } + return queryResult.size(); +} + +size_t LHCInfoPerLSPopConSourceHandler::bufferFirstStableBeamLS(const cond::OMSServiceResult& queryResult) +{ + for (auto r : queryResult) { + if(r.get("beams_stable") == "true") { + addPayloadToBuffer(r); + edm::LogInfo(m_name) << "Buffered first lumisection of stable beam: LS: " + << r.get("lumisection_number") + << " run: " << r.get("run_number"); + + return 1; + } + } + return 0; +} + size_t LHCInfoPerLSPopConSourceHandler::getLumiData(const cond::OMSService& oms, - unsigned short fillId, - const boost::posix_time::ptime& beginFillTime, - const boost::posix_time::ptime& endFillTime) { + unsigned short fillId, + const boost::posix_time::ptime& beginFillTime, + const boost::posix_time::ptime& endFillTime) { auto query = oms.query("lumisections"); - query->addOutputVars({"start_time", "run_number"}); - query->filterEQ("fill_number", fillId); + query->addOutputVars({"start_time", "run_number", "beams_stable", "lumisection_number"}); + query->filterEQ("fill_number", fillId); query->filterGT("start_time", beginFillTime).filterLT("start_time", endFillTime); query->limit(kLumisectionsQueryLimit); size_t nlumi = 0; if (query->execute()) { - auto res = query->result(); - std::stringstream condIovs; - std::stringstream posixIovs; - for (auto r : res) { - nlumi++; - auto lumiTime = r.get("start_time"); - LHCInfoPerLS* thisLumiSectionInfo = new LHCInfoPerLS(*m_fillPayload); - m_tmpBuffer.emplace_back(std::make_pair(cond::time::from_boost(lumiTime), thisLumiSectionInfo)); - LHCInfoPerLS& payload = *thisLumiSectionInfo; - payload.setRunNumber(r.get("run_number")); - - condIovs << cond::time::from_boost(lumiTime) << " "; - posixIovs << lumiTime << " "; + auto queryResult = query->result(); + if(m_endFill){ + nlumi = bufferAllLS(queryResult); } - + else { + nlumi = bufferFirstStableBeamLS(queryResult); + if(!nlumi && !queryResult.empty()) + { + auto firstRow = *queryResult.begin(); + addPayloadToBuffer(firstRow); + nlumi++; + } + } + edm::LogInfo(m_name) << "Found " << queryResult.size() << " lumisections during the fill " << fillId; + } + else { + edm::LogInfo(m_name) << "OMS query for lumisections of fill " << fillId << "failed, status:" << query->status(); } return nlumi; } @@ -141,7 +175,7 @@ namespace LHCInfoPerLSImpl { cond::Time_t upper = cond::time::MAX_VAL; if (currUp != end) upper = currUp->first; - if (dipTime < upper) + if (dipTime < upper && currentDipTime >= currLow->first) return false; else { search = true; @@ -442,6 +476,7 @@ void LHCInfoPerLSPopConSourceHandler::getNewObjects() { edm::LogInfo(m_name) << "Searching new fill after " << boost::posix_time::to_simple_string(targetTime); boost::posix_time::ptime startTime = targetTime + boost::posix_time::seconds(1); query->filterNotNull("start_stable_beam").filterGT("start_time", startTime).filterNotNull("fill_number"); + query->filterLT("start_time", m_endTime); if (m_endFill) query->filterNotNull("end_time"); bool foundFill = query->execute(); @@ -469,8 +504,7 @@ void LHCInfoPerLSPopConSourceHandler::getNewObjects() { } - size_t nlumi = getLumiData(oms, lhcFill, startSampleTime, endSampleTime); - edm::LogInfo(m_name) << "Found " << nlumi << " lumisections during the fill " << lhcFill; + getLumiData(oms, lhcFill, startSampleTime, endSampleTime); boost::posix_time::ptime flumiStart = cond::time::to_boost(m_tmpBuffer.front().first); boost::posix_time::ptime flumiStop = cond::time::to_boost(m_tmpBuffer.back().first); edm::LogInfo(m_name) << "First lumi starts at " << flumiStart << " last lumi starts at " << flumiStop; From b7820e8534d72c5d86d178d7400244ae98387316 Mon Sep 17 00:00:00 2001 From: Jan Chyczynski Date: Thu, 1 Sep 2022 11:49:03 +0200 Subject: [PATCH 23/39] implemented perFill PopCon --- .../LHCInfoPerFillPopConSourceHandler.h | 64 ++ CondTools/RunInfo/interface/OMSAccess.h | 3 + CondTools/RunInfo/plugins/BuildFile.xml | 6 +- .../plugins/LHCInfoPerFillPopConAnalyzer.cc | 7 + .../LHCInfoPerFillPopConAnalyzerEndFill.py | 88 ++ .../LHCInfoPerFillPopConAnalyzerStartFill.py | 88 ++ .../src/LHCInfoPerFillPopConSourceHandler.cc | 789 ++++++++++++++++++ CondTools/RunInfo/src/OMSAccess.cc | 10 + 8 files changed, 1054 insertions(+), 1 deletion(-) create mode 100644 CondTools/RunInfo/interface/LHCInfoPerFillPopConSourceHandler.h create mode 100644 CondTools/RunInfo/plugins/LHCInfoPerFillPopConAnalyzer.cc create mode 100644 CondTools/RunInfo/python/LHCInfoPerFillPopConAnalyzerEndFill.py create mode 100644 CondTools/RunInfo/python/LHCInfoPerFillPopConAnalyzerStartFill.py create mode 100644 CondTools/RunInfo/src/LHCInfoPerFillPopConSourceHandler.cc diff --git a/CondTools/RunInfo/interface/LHCInfoPerFillPopConSourceHandler.h b/CondTools/RunInfo/interface/LHCInfoPerFillPopConSourceHandler.h new file mode 100644 index 0000000000000..c49aed244a8e4 --- /dev/null +++ b/CondTools/RunInfo/interface/LHCInfoPerFillPopConSourceHandler.h @@ -0,0 +1,64 @@ +#ifndef LHCInfoPerFillPOPCONSOURCEHANDLER_H +#define LHCInfoPerFillPOPCONSOURCEHANDLER_H + +#include + +#include "CondCore/PopCon/interface/PopConSourceHandler.h" +#include "CondFormats/RunInfo/interface/LHCInfoPerFill.h" +#include "FWCore/ParameterSet/interface/ParameterSetfwd.h" +#include "CondTools/RunInfo/interface/OMSAccess.h" + +namespace cond { + class OMSService; +} + +class LHCInfoPerFillPopConSourceHandler : public popcon::PopConSourceHandler { +public: + LHCInfoPerFillPopConSourceHandler(const edm::ParameterSet& pset); + ~LHCInfoPerFillPopConSourceHandler() override; + void getNewObjects() override; + std::string id() const override; + + static constexpr unsigned int kLumisectionsQueryLimit = 4000; + +private: + void addEmptyPayload(cond::Time_t iov); + void addPayloadToBuffer(cond::OMSServiceResultRef& row); + + size_t getLumiData(const cond::OMSService& service, + unsigned short fillId, + const boost::posix_time::ptime& beginFillTime, + const boost::posix_time::ptime& endFillTime); + void getDipData(const cond::OMSService& service, + const boost::posix_time::ptime& beginFillTime, + const boost::posix_time::ptime& endFillTime); + bool getCTTPSData(cond::persistency::Session& session, + const boost::posix_time::ptime& beginFillTime, + const boost::posix_time::ptime& endFillTime); + bool getEcalData(cond::persistency::Session& session, + const boost::posix_time::ptime& lowerTime, + const boost::posix_time::ptime& upperTime, + bool update); + + void duplicateToBuffer(const LHCInfoPerFill& targetPayload, const cond::OMSServiceResult& queryResult); + +private: + bool m_debug; + // starting date for sampling + boost::posix_time::ptime m_startTime; + boost::posix_time::ptime m_endTime; + // sampling interval in seconds + unsigned int m_samplingInterval; + bool m_endFill = true; + std::string m_name; + //for reading from relational database source + std::string m_connectionString, m_ecalConnectionString; + std::string m_dipSchema, m_authpath; + std::string m_omsBaseUrl; + std::unique_ptr m_fillPayload; + std::shared_ptr m_prevPayload; + std::vector > > m_tmpBuffer; + bool m_lastPayloadEmpty = false; +}; + +#endif diff --git a/CondTools/RunInfo/interface/OMSAccess.h b/CondTools/RunInfo/interface/OMSAccess.h index 4e096b3cc79b3..d73c77b810e19 100644 --- a/CondTools/RunInfo/interface/OMSAccess.h +++ b/CondTools/RunInfo/interface/OMSAccess.h @@ -153,6 +153,9 @@ namespace cond { OMSServiceResultIterator begin() const; OMSServiceResultIterator end() const; + OMSServiceResultRef front() const; + OMSServiceResultRef back() const; + // parse json returned from curl, filling the property tree size_t parseData(const std::string& data); diff --git a/CondTools/RunInfo/plugins/BuildFile.xml b/CondTools/RunInfo/plugins/BuildFile.xml index 592b9909bfc42..f19a7958ab441 100644 --- a/CondTools/RunInfo/plugins/BuildFile.xml +++ b/CondTools/RunInfo/plugins/BuildFile.xml @@ -49,7 +49,7 @@ - + @@ -68,3 +68,7 @@ + + + + diff --git a/CondTools/RunInfo/plugins/LHCInfoPerFillPopConAnalyzer.cc b/CondTools/RunInfo/plugins/LHCInfoPerFillPopConAnalyzer.cc new file mode 100644 index 0000000000000..673ea289e788f --- /dev/null +++ b/CondTools/RunInfo/plugins/LHCInfoPerFillPopConAnalyzer.cc @@ -0,0 +1,7 @@ +#include "CondCore/PopCon/interface/PopConAnalyzer.h" +#include "CondTools/RunInfo/interface/LHCInfoPerFillPopConSourceHandler.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +typedef popcon::PopConAnalyzer LHCInfoPerFillPopConAnalyzer; +//define this as a plug-in +DEFINE_FWK_MODULE(LHCInfoPerFillPopConAnalyzer); diff --git a/CondTools/RunInfo/python/LHCInfoPerFillPopConAnalyzerEndFill.py b/CondTools/RunInfo/python/LHCInfoPerFillPopConAnalyzerEndFill.py new file mode 100644 index 0000000000000..75985e4b20b5b --- /dev/null +++ b/CondTools/RunInfo/python/LHCInfoPerFillPopConAnalyzerEndFill.py @@ -0,0 +1,88 @@ +import socket +import FWCore.ParameterSet.Config as cms +import FWCore.ParameterSet.VarParsing as VarParsing +process = cms.Process("LHCInfoPerFillPopulator") +from CondCore.CondDB.CondDB_cfi import * +#process.load("CondCore.DBCommon.CondDBCommon_cfi") +#process.CondDBCommon.connect = 'sqlite_file:lhcinfoperls_pop_test.db' +#process.CondDBCommon.DBParameters.authenticationPath = '.' +#process.CondDBCommon.DBParameters.messageLevel=cms.untracked.int32(1) + +sourceConnection = 'oracle://cms_omds_adg/CMS_RUNINFO_R' +if socket.getfqdn().find('.cms') != -1: + sourceConnection = 'oracle://cms_omds_lb/CMS_RUNINFO_R' + +options = VarParsing.VarParsing() +options.register( 'destinationConnection' + , 'sqlite_file:lhcinfo_pop_test.db' #default value + , VarParsing.VarParsing.multiplicity.singleton + , VarParsing.VarParsing.varType.string + , "Connection string to the DB where payloads will be possibly written." + ) +options.register( 'targetConnection' + , '' #default value + , VarParsing.VarParsing.multiplicity.singleton + , VarParsing.VarParsing.varType.string + , """Connection string to the target DB: + if not empty (default), this provides the latest IOV and payloads to compare; + it is the DB where payloads should be finally uploaded.""" + ) +options.register( 'tag' + , 'LHCInfoPerFill_PopCon_start_test' + , VarParsing.VarParsing.multiplicity.singleton + , VarParsing.VarParsing.varType.string + , "Tag written in destinationConnection and finally appended in targetConnection." + ) +options.register( 'messageLevel' + , 0 #default value + , VarParsing.VarParsing.multiplicity.singleton + , VarParsing.VarParsing.varType.int + , "Message level; default to 0" + ) +options.parseArguments() + +CondDBConnection = CondDB.clone( connect = cms.string( options.destinationConnection ) ) +CondDBConnection.DBParameters.messageLevel = cms.untracked.int32( options.messageLevel ) + +process.MessageLogger = cms.Service("MessageLogger", + cout = cms.untracked.PSet(threshold = cms.untracked.string('INFO')), + destinations = cms.untracked.vstring('cout') + ) + +process.source = cms.Source("EmptyIOVSource", + lastValue = cms.uint64(1), + timetype = cms.string('runnumber'), + firstValue = cms.uint64(1), + interval = cms.uint64(1) + ) + +process.PoolDBOutputService = cms.Service("PoolDBOutputService", + CondDBConnection, + timetype = cms.untracked.string('timestamp'), + toPut = cms.VPSet(cms.PSet(record = cms.string('LHCInfoPerFillRcd'), + tag = cms.string( options.tag ) + ) + ) + ) + +process.Test1 = cms.EDAnalyzer("LHCInfoPerFillPopConAnalyzer", + SinceAppendMode = cms.bool(True), + record = cms.string('LHCInfoPerFillRcd'), + name = cms.untracked.string('LHCInfo'), + Source = cms.PSet(fill = cms.untracked.uint32(6417), + startTime = cms.untracked.string('2021-09-10 03:10:18.000'), + # endTime = cms.untracked.string('2022-08-19 00:00:00.000'), + samplingInterval = cms.untracked.uint32( 600 ), + endFill = cms.untracked.bool(True), + connectionString = cms.untracked.string("oracle://cms_orcon_adg/CMS_RUNTIME_LOGGER"), + ecalConnectionString = cms.untracked.string("oracle://cms_orcon_adg/CMS_DCS_ENV_PVSS_COND"), + DIPSchema = cms.untracked.string("CMS_BEAM_COND"), + omsBaseUrl = cms.untracked.string("http://vocms0184.cern.ch/agg/api/v1"), + #authenticationPath = cms.untracked.string("."), + debug=cms.untracked.bool(False) + ), + loggingOn = cms.untracked.bool(True), + IsDestDbCheckedInQueryLog = cms.untracked.bool(False) + ) + +process.p = cms.Path(process.Test1) diff --git a/CondTools/RunInfo/python/LHCInfoPerFillPopConAnalyzerStartFill.py b/CondTools/RunInfo/python/LHCInfoPerFillPopConAnalyzerStartFill.py new file mode 100644 index 0000000000000..a2f6df179ff06 --- /dev/null +++ b/CondTools/RunInfo/python/LHCInfoPerFillPopConAnalyzerStartFill.py @@ -0,0 +1,88 @@ +import socket +import FWCore.ParameterSet.Config as cms +import FWCore.ParameterSet.VarParsing as VarParsing +process = cms.Process("LHCInfoPerFillPopulator") +from CondCore.CondDB.CondDB_cfi import * +#process.load("CondCore.DBCommon.CondDBCommon_cfi") +#process.CondDBCommon.connect = 'sqlite_file:lhcinfoperls_pop_test.db' +#process.CondDBCommon.DBParameters.authenticationPath = '.' +#process.CondDBCommon.DBParameters.messageLevel=cms.untracked.int32(1) + +sourceConnection = 'oracle://cms_omds_adg/CMS_RUNINFO_R' +if socket.getfqdn().find('.cms') != -1: + sourceConnection = 'oracle://cms_omds_lb/CMS_RUNINFO_R' + +options = VarParsing.VarParsing() +options.register( 'destinationConnection' + , 'sqlite_file:lhcinfo_pop_test.db' #default value + , VarParsing.VarParsing.multiplicity.singleton + , VarParsing.VarParsing.varType.string + , "Connection string to the DB where payloads will be possibly written." + ) +options.register( 'targetConnection' + , '' #default value + , VarParsing.VarParsing.multiplicity.singleton + , VarParsing.VarParsing.varType.string + , """Connection string to the target DB: + if not empty (default), this provides the latest IOV and payloads to compare; + it is the DB where payloads should be finally uploaded.""" + ) +options.register( 'tag' + , 'LHCInfoPerFill_PopCon_start_test' + , VarParsing.VarParsing.multiplicity.singleton + , VarParsing.VarParsing.varType.string + , "Tag written in destinationConnection and finally appended in targetConnection." + ) +options.register( 'messageLevel' + , 0 #default value + , VarParsing.VarParsing.multiplicity.singleton + , VarParsing.VarParsing.varType.int + , "Message level; default to 0" + ) +options.parseArguments() + +CondDBConnection = CondDB.clone( connect = cms.string( options.destinationConnection ) ) +CondDBConnection.DBParameters.messageLevel = cms.untracked.int32( options.messageLevel ) + +process.MessageLogger = cms.Service("MessageLogger", + cout = cms.untracked.PSet(threshold = cms.untracked.string('INFO')), + destinations = cms.untracked.vstring('cout') + ) + +process.source = cms.Source("EmptyIOVSource", + lastValue = cms.uint64(1), + timetype = cms.string('runnumber'), + firstValue = cms.uint64(1), + interval = cms.uint64(1) + ) + +process.PoolDBOutputService = cms.Service("PoolDBOutputService", + CondDBConnection, + timetype = cms.untracked.string('timestamp'), + toPut = cms.VPSet(cms.PSet(record = cms.string('LHCInfoPerFillRcd'), + tag = cms.string( options.tag ) + ) + ) + ) + +process.Test1 = cms.EDAnalyzer("LHCInfoPerFillPopConAnalyzer", + SinceAppendMode = cms.bool(True), + record = cms.string('LHCInfoPerFillRcd'), + name = cms.untracked.string('LHCInfo'), + Source = cms.PSet(fill = cms.untracked.uint32(6417), + startTime = cms.untracked.string('2021-09-10 03:10:18.000'), + # endTime = cms.untracked.string('2022-08-19 00:00:00.000'), + samplingInterval = cms.untracked.uint32( 600 ), + endFill = cms.untracked.bool(False), + connectionString = cms.untracked.string("oracle://cms_orcon_adg/CMS_RUNTIME_LOGGER"), + ecalConnectionString = cms.untracked.string("oracle://cms_orcon_adg/CMS_DCS_ENV_PVSS_COND"), + DIPSchema = cms.untracked.string("CMS_BEAM_COND"), + omsBaseUrl = cms.untracked.string("http://vocms0184.cern.ch/agg/api/v1"), + #authenticationPath = cms.untracked.string("."), + debug=cms.untracked.bool(False) + ), + loggingOn = cms.untracked.bool(True), + IsDestDbCheckedInQueryLog = cms.untracked.bool(False) + ) + +process.p = cms.Path(process.Test1) diff --git a/CondTools/RunInfo/src/LHCInfoPerFillPopConSourceHandler.cc b/CondTools/RunInfo/src/LHCInfoPerFillPopConSourceHandler.cc new file mode 100644 index 0000000000000..3ed9872542083 --- /dev/null +++ b/CondTools/RunInfo/src/LHCInfoPerFillPopConSourceHandler.cc @@ -0,0 +1,789 @@ +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "CondCore/CondDB/interface/ConnectionPool.h" +#include "CondFormats/Common/interface/TimeConversions.h" +#include "CondTools/RunInfo/interface/LHCInfoPerFillPopConSourceHandler.h" +#include "CondTools/RunInfo/interface/OMSAccess.h" +#include "RelationalAccess/ISessionProxy.h" +#include "RelationalAccess/ISchema.h" +#include "RelationalAccess/IQuery.h" +#include "RelationalAccess/ICursor.h" +#include "CoralBase/AttributeList.h" +#include "CoralBase/Attribute.h" +#include "CoralBase/AttributeSpecification.h" +#include "CoralBase/TimeStamp.h" +#include +#include +#include +#include +#include +#include + +namespace cond { + namespace LHCInfoPerFillPopConImpl { + + static const std::pair s_fillTypeMap[] = { + std::make_pair("PROTONS", LHCInfoPerFill::PROTONS), + std::make_pair("IONS", LHCInfoPerFill::IONS), + std::make_pair("COSMICS", LHCInfoPerFill::COSMICS), + std::make_pair("GAP", LHCInfoPerFill::GAP)}; + + static const std::pair s_particleTypeMap[] = { + std::make_pair("PROTON", LHCInfoPerFill::PROTON), + std::make_pair("PB82", LHCInfoPerFill::PB82), + std::make_pair("AR18", LHCInfoPerFill::AR18), + std::make_pair("D", LHCInfoPerFill::D), + std::make_pair("XE54", LHCInfoPerFill::XE54)}; + + LHCInfoPerFill::FillType fillTypeFromString(const std::string& s_fill_type) { + for (auto const& i : s_fillTypeMap) + if (s_fill_type == i.first) + return i.second; + return LHCInfoPerFill::UNKNOWN; + } + + LHCInfoPerFill::ParticleType particleTypeFromString(const std::string& s_particle_type) { + for (auto const& i : s_particleTypeMap) + if (s_particle_type == i.first) + return i.second; + return LHCInfoPerFill::NONE; + } + } + + namespace impl { + + template <> + LHCInfoPerFill::FillType from_string(const std::string& attributeValue) { + return from_string_impl(attributeValue, LHCInfoPerFill::UNKNOWN); + } + + template <> + LHCInfoPerFill::ParticleType from_string(const std::string& attributeValue) { + return from_string_impl(attributeValue, LHCInfoPerFill::NONE); + } + + } // namespace impl +} // namespace cond + +LHCInfoPerFillPopConSourceHandler::LHCInfoPerFillPopConSourceHandler(edm::ParameterSet const& pset) + : m_debug(pset.getUntrackedParameter("debug", false)), + m_startTime(), + m_endTime(), + m_samplingInterval((unsigned int)pset.getUntrackedParameter("samplingInterval", 300)), + m_endFill(pset.getUntrackedParameter("endFill", true)), + m_name(pset.getUntrackedParameter("name", "LHCInfoPerFillPopConSourceHandler")), + m_connectionString(pset.getUntrackedParameter("connectionString", "")), + m_ecalConnectionString(pset.getUntrackedParameter("ecalConnectionString", "")), + m_dipSchema(pset.getUntrackedParameter("DIPSchema", "")), + m_authpath(pset.getUntrackedParameter("authenticationPath", "")), + m_omsBaseUrl(pset.getUntrackedParameter("omsBaseUrl", "")), + m_fillPayload(), + m_prevPayload(), + m_tmpBuffer() { + if (pset.exists("startTime")) { + m_startTime = boost::posix_time::time_from_string(pset.getUntrackedParameter("startTime")); + } + boost::posix_time::ptime now = boost::posix_time::second_clock::local_time(); + m_endTime = now; + if (pset.exists("endTime")) { + m_endTime = boost::posix_time::time_from_string(pset.getUntrackedParameter("endTime")); + if (m_endTime > now) + m_endTime = now; + } +} +//L1: try with different m_dipSchema +//L2: try with different m_name +LHCInfoPerFillPopConSourceHandler::~LHCInfoPerFillPopConSourceHandler() {} + +namespace LHCInfoPerFillImpl { + + struct IOVComp { + bool operator()(const cond::Time_t& x, const std::pair>& y) { + return (x < y.first); + } + }; + + // function to search in the vector the target time + std::vector>>::const_iterator search( + const cond::Time_t& val, const std::vector>>& container) { + if (container.empty()) + return container.end(); + auto p = std::upper_bound(container.begin(), container.end(), val, IOVComp()); + return (p != container.begin()) ? p - 1 : container.end(); + } + + bool makeFillPayload(std::unique_ptr& targetPayload, const cond::OMSServiceResult& queryResult) { + bool ret = false; + if (!queryResult.empty()) { + auto row = *queryResult.begin(); + auto currentFill = row.get("fill_number"); + auto bunches1 = row.get("bunches_beam1"); + auto bunches2 = row.get("bunches_beam2"); + auto collidingBunches = row.get("bunches_colliding"); + auto targetBunches = row.get("bunches_target"); + auto fillType = row.get("fill_type_runtime"); + auto particleType1 = row.get("fill_type_party1"); + auto particleType2 = row.get("fill_type_party2"); + auto intensityBeam1 = row.get("intensity_beam1"); + auto intensityBeam2 = row.get("intensity_beam2"); + auto energy = row.get("energy"); + auto creationTime = row.get("start_time"); + auto stableBeamStartTime = row.get("start_stable_beam"); + auto beamDumpTime = row.get("end_time"); + auto injectionScheme = row.get("injection_scheme"); + targetPayload = std::make_unique(); + targetPayload->setFillNumber(currentFill); + targetPayload->setBunchesInBeam1(bunches1); + targetPayload->setBunchesInBeam2(bunches2); + targetPayload->setCollidingBunches(collidingBunches); + targetPayload->setTargetBunches(targetBunches); + targetPayload->setFillType(fillType); + targetPayload->setParticleTypeForBeam1(particleType1); + targetPayload->setParticleTypeForBeam2(particleType2); + targetPayload->setIntensityForBeam1(intensityBeam1); + targetPayload->setIntensityForBeam2(intensityBeam2); + targetPayload->setEnergy(energy); + targetPayload->setCreationTime(cond::time::from_boost(creationTime)); + targetPayload->setBeginTime(cond::time::from_boost(stableBeamStartTime)); + targetPayload->setEndTime(cond::time::from_boost(beamDumpTime)); + targetPayload->setInjectionScheme(injectionScheme); + ret = true; + } + return ret; + } + +} // namespace LHCInfoPerFillImpl + +void LHCInfoPerFillPopConSourceHandler::addPayloadToBuffer(cond::OMSServiceResultRef& row) +{ + auto lumiTime = row.get("start_time"); + auto delivLumi = row.get("delivered_lumi"); + auto recLumi = row.get("recorded_lumi"); + LHCInfoPerFill* thisLumiSectionInfo = m_fillPayload->cloneFill(); + m_tmpBuffer.emplace_back(std::make_pair(cond::time::from_boost(lumiTime), thisLumiSectionInfo)); + LHCInfoPerFill& payload = *thisLumiSectionInfo; + payload.setDelivLumi(delivLumi); + payload.setRecLumi(recLumi); + edm::LogInfo(m_name) << "set on IOV " << cond::time::from_boost(lumiTime) << " " << + boost::posix_time::to_iso_extended_string(lumiTime) << ": " << + "delivLumi= " << delivLumi << "in pld: " << payload.delivLumi()<< + " recLumi= " << recLumi << "in pld: " << payload.recLumi(); +} + +size_t LHCInfoPerFillPopConSourceHandler::getLumiData(const cond::OMSService& oms, + unsigned short fillId, + const boost::posix_time::ptime& beginFillTime, + const boost::posix_time::ptime& endFillTime) { + auto query = oms.query("lumisections"); + query->addOutputVars({"start_time", "delivered_lumi", "recorded_lumi", "beams_stable"}); + query->filterEQ("fill_number", fillId); + query->filterGT("start_time", beginFillTime).filterLT("start_time", endFillTime); + query->filterEQ("beams_stable", "true"); + query->limit(kLumisectionsQueryLimit); + if (query->execute()) { + auto queryResult = query->result(); + if(m_endFill) { + auto lastRow = queryResult.back(); + addPayloadToBuffer(lastRow); + return 1; + } else { + auto firstRow = queryResult.front(); + addPayloadToBuffer(firstRow); + return 1; + } + } + return 0; +} + +namespace LHCInfoPerFillImpl { + struct LumiSectionFilter { + LumiSectionFilter(const std::vector>>& samples) + : currLow(samples.begin()), currUp(samples.begin()), end(samples.end()) { + currUp++; + } + + void reset(const std::vector>>& samples) { + currLow = samples.begin(); + currUp = samples.begin(); + currUp++; + end = samples.end(); + currentDipTime = 0; + } + + bool process(cond::Time_t dipTime) { + if (currLow == end) + return false; + bool search = false; + if (currentDipTime == 0) { + search = true; + } else { + if (dipTime == currentDipTime) + return true; + else { + cond::Time_t upper = cond::time::MAX_VAL; + if (currUp != end) + upper = currUp->first; + if (dipTime < upper && currentDipTime >= currLow->first) + return false; + else { + search = true; + } + } + } + if (search) { + while (currUp != end and currUp->first < dipTime) { + currLow++; + currUp++; + } + currentDipTime = dipTime; + return currLow != end; + } + return false; + } + + cond::Time_t currentSince() { return currLow->first; } + LHCInfoPerFill& currentPayload() { return *currLow->second; } + + std::vector>>::const_iterator current() { return currLow; } + std::vector>>::const_iterator currLow; + std::vector>>::const_iterator currUp; + std::vector>>::const_iterator end; + cond::Time_t currentDipTime = 0; + }; +} // namespace LHCInfoPerFillImpl + +void LHCInfoPerFillPopConSourceHandler::getDipData(const cond::OMSService& oms, + const boost::posix_time::ptime& beginFillTime, + const boost::posix_time::ptime& endFillTime) { + // unsure how to handle this. + // the old implementation is not helping: apparently it is checking only the bunchconfiguration for the first diptime set of values... + auto query1 = oms.query("diplogger/dip/acc/LHC/RunControl/CirculatingBunchConfig/Beam1"); + query1->filterGT("dip_time", beginFillTime).filterLT("dip_time", endFillTime); + //This query is limited to 100 rows, but currently only one is used + //If all this data is needed and saved properly the limit has to be set: query1->limit(...) + if (query1->execute()) { + auto res = query1->result(); + if (!res.empty()) { + std::bitset bunchConfiguration1(0ULL); + auto row = *res.begin(); + auto vbunchConf1 = row.getArray("value"); + for (auto vb : vbunchConf1) { + if (vb != 0) { + unsigned short slot = (vb - 1) / 10 + 1; + bunchConfiguration1[slot] = true; + } + } + m_fillPayload->setBunchBitsetForBeam1(bunchConfiguration1); + } + } + auto query2 = oms.query("diplogger/dip/acc/LHC/RunControl/CirculatingBunchConfig/Beam2"); + query2->filterGT("dip_time", beginFillTime).filterLT("dip_time", endFillTime); + //This query is limited to 100 rows, but currently only one is used + if (query2->execute()) { + auto res = query2->result(); + if (!res.empty()) { + std::bitset bunchConfiguration2(0ULL); + auto row = *res.begin(); + auto vbunchConf2 = row.getArray("value"); + for (auto vb : vbunchConf2) { + if (vb != 0) { + unsigned short slot = (vb - 1) / 10 + 1; + bunchConfiguration2[slot] = true; + } + } + m_fillPayload->setBunchBitsetForBeam2(bunchConfiguration2); + } + } + + auto query3 = oms.query("diplogger/dip/CMS/LHC/LumiPerBunch"); + query3->filterGT("dip_time", beginFillTime).filterLT("dip_time", endFillTime); + //This query is limited to 100 rows, but currently only one is used + if (query3->execute()) { + auto res = query3->result(); + if (!res.empty()) { + std::vector lumiPerBX; + auto row = *res.begin(); + auto lumiBunchInst = row.getArray("lumi_bunch_inst"); + for (auto lb : lumiBunchInst) { + if (lb != 0.) { + lumiPerBX.push_back(lb); + } + } + m_fillPayload->setLumiPerBX(lumiPerBX); + } + } +} + +bool LHCInfoPerFillPopConSourceHandler::getCTTPSData(cond::persistency::Session& session, + const boost::posix_time::ptime& beginFillTime, + const boost::posix_time::ptime& endFillTime) { + //run the fifth query against the CTPPS schema + //Initializing the CMS_CTP_CTPPS_COND schema. + coral::ISchema& CTPPS = session.coralSession().schema("CMS_PPS_SPECT_COND"); + //execute query for CTPPS Data + std::unique_ptr CTPPSDataQuery(CTPPS.newQuery()); + //FROM clause + CTPPSDataQuery->addToTableList(std::string("PPS_LHC_MACHINE_PARAMS")); + //SELECT clause + CTPPSDataQuery->addToOutputList(std::string("DIP_UPDATE_TIME")); + CTPPSDataQuery->addToOutputList(std::string("LHC_STATE")); + CTPPSDataQuery->addToOutputList(std::string("LHC_COMMENT")); + //dbg + CTPPSDataQuery->addToOutputList(std::string("RUN_NUMBER")); + CTPPSDataQuery->addToOutputList(std::string("LUMI_SECTION")); + //dbge + //WHERE CLAUSE + coral::AttributeList CTPPSDataBindVariables; + CTPPSDataBindVariables.extend(std::string("beginFillTime")); + CTPPSDataBindVariables.extend(std::string("endFillTime")); + CTPPSDataBindVariables[std::string("beginFillTime")].data() = coral::TimeStamp(beginFillTime); + CTPPSDataBindVariables[std::string("endFillTime")].data() = coral::TimeStamp(endFillTime); + std::string conditionStr = std::string("DIP_UPDATE_TIME>= :beginFillTime and DIP_UPDATE_TIME< :endFillTime"); + CTPPSDataQuery->setCondition(conditionStr, CTPPSDataBindVariables); + //ORDER BY clause + CTPPSDataQuery->addToOrderList(std::string("DIP_UPDATE_TIME")); + //define query output + coral::AttributeList CTPPSDataOutput; + CTPPSDataOutput.extend(std::string("DIP_UPDATE_TIME")); + CTPPSDataOutput.extend(std::string("LHC_STATE")); + CTPPSDataOutput.extend(std::string("LHC_COMMENT")); + //dbg + CTPPSDataOutput.extend(std::string("RUN_NUMBER")); + CTPPSDataOutput.extend(std::string("LUMI_SECTION")); + //dbge + CTPPSDataQuery->defineOutput(CTPPSDataOutput); + //execute the query + coral::ICursor& CTPPSDataCursor = CTPPSDataQuery->execute(); + cond::Time_t dipTime = 0; + std::string lhcState = "", lhcComment = "", ctppsStatus = ""; + //dbg + unsigned int lumiSection = 0; + cond::Time_t runNumber = 0; + + cond::Time_t savedDipTime = 0; + unsigned int savedLumiSection = 0; + cond::Time_t savedRunNumber = 0; + //dbge + + + bool ret = false; + LHCInfoPerFillImpl::LumiSectionFilter filter(m_tmpBuffer); + while (CTPPSDataCursor.next()) { + if (m_debug) { + std::ostringstream CTPPS; + CTPPSDataCursor.currentRow().toOutputStream(CTPPS); + } + coral::Attribute const& dipTimeAttribute = CTPPSDataCursor.currentRow()[std::string("DIP_UPDATE_TIME")]; + if (!dipTimeAttribute.isNull()) { + dipTime = cond::time::from_boost(dipTimeAttribute.data().time()); + if (filter.process(dipTime)) { + ret = true; + coral::Attribute const& lhcStateAttribute = CTPPSDataCursor.currentRow()[std::string("LHC_STATE")]; + if (!lhcStateAttribute.isNull()) { + lhcState = lhcStateAttribute.data(); + } + coral::Attribute const& lhcCommentAttribute = CTPPSDataCursor.currentRow()[std::string("LHC_COMMENT")]; + if (!lhcCommentAttribute.isNull()) { + lhcComment = lhcCommentAttribute.data(); + } + + //dbg + coral::Attribute const& runNumberAttribute = CTPPSDataCursor.currentRow()[std::string("RUN_NUMBER")]; + if (!runNumberAttribute.isNull()) { + runNumber = runNumberAttribute.data(); + } + coral::Attribute const& lumiSectionAttribute = CTPPSDataCursor.currentRow()[std::string("LUMI_SECTION")]; + if (!lumiSectionAttribute.isNull()) { + lumiSection = lumiSectionAttribute.data(); + } + + for (auto it = filter.current(); it != m_tmpBuffer.end(); it++) { + // set the current values to all of the payloads of the lumi section samples after the current since + LHCInfoPerFill& payload = *(it->second); + payload.setLhcState(lhcState); + payload.setLhcComment(lhcComment); + payload.setCtppsStatus(ctppsStatus); + + //dbg + savedDipTime = dipTime; + savedLumiSection = lumiSection; + savedRunNumber = runNumber; + //dbge + } + } + } + } + //dbg + edm::LogInfo(m_name) << "Last assigned: " << "DipTime: " << savedDipTime << " " + << "LumiSection: " << savedLumiSection << " " + << "RunNumber: " << savedRunNumber; + return ret; + //dbge +} + +namespace LHCInfoPerFillImpl { + static const std::map vecMap = { + {"Beam1/beamPhaseMean", 1}, {"Beam2/beamPhaseMean", 2}, {"Beam1/cavPhaseMean", 3}, {"Beam2/cavPhaseMean", 4}}; + void setElementData(cond::Time_t since, + const std::string& dipVal, + unsigned int elementNr, + float value, + LHCInfoPerFill& payload, + std::set& initList) { + if (initList.find(since) == initList.end()) { + payload.beam1VC().resize(LHCInfoPerFill::bunchSlots, 0.); + payload.beam2VC().resize(LHCInfoPerFill::bunchSlots, 0.); + payload.beam1RF().resize(LHCInfoPerFill::bunchSlots, 0.); + payload.beam2RF().resize(LHCInfoPerFill::bunchSlots, 0.); + initList.insert(since); + } + // set the current values to all of the payloads of the lumi section samples after the current since + if (elementNr < LHCInfoPerFill::bunchSlots) { + switch (vecMap.at(dipVal)) { + case 1: + payload.beam1VC()[elementNr] = value; + break; + case 2: + payload.beam2VC()[elementNr] = value; + break; + case 3: + payload.beam1RF()[elementNr] = value; + break; + case 4: + payload.beam2RF()[elementNr] = value; + break; + default: + break; + } + } + } +} // namespace LHCInfoPerFillImpl + +bool LHCInfoPerFillPopConSourceHandler::getEcalData(cond::persistency::Session& session, + const boost::posix_time::ptime& lowerTime, + const boost::posix_time::ptime& upperTime, + bool update) { + //run the sixth query against the CMS_DCS_ENV_PVSS_COND schema + //Initializing the CMS_DCS_ENV_PVSS_COND schema. + coral::ISchema& ECAL = session.nominalSchema(); + //start the transaction against the fill logging schema + //execute query for ECAL Data + std::unique_ptr ECALDataQuery(ECAL.newQuery()); + //FROM clause + ECALDataQuery->addToTableList(std::string("BEAM_PHASE")); + //SELECT clause + ECALDataQuery->addToOutputList(std::string("CHANGE_DATE")); + ECALDataQuery->addToOutputList(std::string("DIP_value")); + ECALDataQuery->addToOutputList(std::string("element_nr")); + ECALDataQuery->addToOutputList(std::string("VALUE_NUMBER")); + //WHERE CLAUSE + coral::AttributeList ECALDataBindVariables; + ECALDataBindVariables.extend(std::string("lowerTime")); + ECALDataBindVariables.extend(std::string("upperTime")); + ECALDataBindVariables[std::string("lowerTime")].data() = coral::TimeStamp(lowerTime); + ECALDataBindVariables[std::string("upperTime")].data() = coral::TimeStamp(upperTime); + std::string conditionStr = std::string( + "(DIP_value LIKE '%beamPhaseMean%' OR DIP_value LIKE '%cavPhaseMean%') AND CHANGE_DATE >= :lowerTime AND " + "CHANGE_DATE < :upperTime"); + + ECALDataQuery->setCondition(conditionStr, ECALDataBindVariables); + //ORDER BY clause + ECALDataQuery->addToOrderList(std::string("CHANGE_DATE")); + ECALDataQuery->addToOrderList(std::string("DIP_value")); + ECALDataQuery->addToOrderList(std::string("element_nr")); + //define query output + coral::AttributeList ECALDataOutput; + ECALDataOutput.extend(std::string("CHANGE_DATE")); + ECALDataOutput.extend(std::string("DIP_value")); + ECALDataOutput.extend(std::string("element_nr")); + ECALDataOutput.extend(std::string("VALUE_NUMBER")); + //ECALDataQuery->limitReturnedRows( 14256 ); //3564 entries per vector. + ECALDataQuery->defineOutput(ECALDataOutput); + //execute the query + coral::ICursor& ECALDataCursor = ECALDataQuery->execute(); + cond::Time_t changeTime = 0; + cond::Time_t firstTime = 0; + std::string dipVal = ""; + unsigned int elementNr = 0; + float value = 0.; + std::set initializedVectors; + LHCInfoPerFillImpl::LumiSectionFilter filter(m_tmpBuffer); + bool ret = false; + if (m_prevPayload.get()) { + for (auto& lumiSlot : m_tmpBuffer) { + lumiSlot.second->setBeam1VC(m_prevPayload->beam1VC()); + lumiSlot.second->setBeam2VC(m_prevPayload->beam2VC()); + lumiSlot.second->setBeam1RF(m_prevPayload->beam1RF()); + lumiSlot.second->setBeam2RF(m_prevPayload->beam2RF()); + } + } + std::map iovMap; + cond::Time_t lowerLumi = m_tmpBuffer.front().first; + while (ECALDataCursor.next()) { + if (m_debug) { + std::ostringstream ECAL; + ECALDataCursor.currentRow().toOutputStream(ECAL); + } + coral::Attribute const& changeDateAttribute = ECALDataCursor.currentRow()[std::string("CHANGE_DATE")]; + if (!changeDateAttribute.isNull()) { + ret = true; + boost::posix_time::ptime chTime = changeDateAttribute.data().time(); + // move the first IOV found to the start of the fill interval selected + if (changeTime == 0) { + firstTime = cond::time::from_boost(chTime); + } + changeTime = cond::time::from_boost(chTime); + cond::Time_t iovTime = changeTime; + if (!update and changeTime == firstTime) + iovTime = lowerLumi; + coral::Attribute const& dipValAttribute = ECALDataCursor.currentRow()[std::string("DIP_value")]; + coral::Attribute const& valueNumberAttribute = ECALDataCursor.currentRow()[std::string("VALUE_NUMBER")]; + coral::Attribute const& elementNrAttribute = ECALDataCursor.currentRow()[std::string("element_nr")]; + if (!dipValAttribute.isNull() and !valueNumberAttribute.isNull()) { + dipVal = dipValAttribute.data(); + elementNr = elementNrAttribute.data(); + value = valueNumberAttribute.data(); + if (std::isnan(value)) + value = 0.; + if (filter.process(iovTime)) { + iovMap.insert(std::make_pair(changeTime, filter.current()->first)); + for (auto it = filter.current(); it != m_tmpBuffer.end(); it++) { + LHCInfoPerFill& payload = *(it->second); + LHCInfoPerFillImpl::setElementData(it->first, dipVal, elementNr, value, payload, initializedVectors); + } + } + //} + } + } + } + if (m_debug) { + for (auto& im : iovMap) { + edm::LogInfo(m_name) << "Found iov=" << im.first << " (" << cond::time::to_boost(im.first) << " ) moved to " + << im.second << " ( " << cond::time::to_boost(im.second) << " )"; + } + } + return ret; +} + +void LHCInfoPerFillPopConSourceHandler::addEmptyPayload(cond::Time_t iov) { + bool add = false; + if (m_iovs.empty()) { + if (!m_lastPayloadEmpty) + add = true; + } else { + auto lastAdded = m_iovs.rbegin()->second; + if (lastAdded->fillNumber() != 0) { + add = true; + } + } + if (add) { + auto newPayload = std::make_shared(); + m_iovs.insert(std::make_pair(iov, newPayload)); + m_prevPayload = newPayload; + } +} + +namespace LHCInfoPerFillImpl { + bool comparePayloads(const LHCInfoPerFill& rhs, const LHCInfoPerFill& lhs) { + if (rhs.fillNumber() != lhs.fillNumber() || + rhs.delivLumi() != lhs.delivLumi() || + rhs.recLumi() != lhs.recLumi() || + rhs.instLumi() != lhs.instLumi() || + rhs.instLumiError() != lhs.instLumiError() || + rhs.lhcState() != rhs.lhcState() || + rhs.lhcComment() != rhs.lhcComment() || + rhs.ctppsStatus() != rhs.ctppsStatus()) { + return false; + } + return true; + } + + size_t transferPayloads(const std::vector>>& buffer, + std::map>& iovsToTransfer, + std::shared_ptr& prevPayload) { + size_t niovs = 0; + std::stringstream condIovs; + std::stringstream formattedIovs; + for (auto& iov : buffer) { + bool add = false; + auto payload = iov.second; + cond::Time_t since = iov.first; + if (iovsToTransfer.empty()) { + add = true; + } else { + LHCInfoPerFill& lastAdded = *iovsToTransfer.rbegin()->second; + if (!comparePayloads(lastAdded, *payload)) { + add = true; + } + } + if (add) { + niovs++; + condIovs << since << " "; + formattedIovs << boost::posix_time::to_iso_extended_string(cond::time::to_boost(since)) << " "; + iovsToTransfer.insert(std::make_pair(since, payload)); + prevPayload = iov.second; + } + } + edm::LogInfo("transferPayloads") << "TRANSFERED COND IOVS: " << condIovs.str(); + edm::LogInfo("transferPayloads") << "FORMATTED COND IOVS: " << formattedIovs.str(); + return niovs; + } + +} // namespace LHCInfoPerFillImpl + +void LHCInfoPerFillPopConSourceHandler::duplicateToBuffer(const LHCInfoPerFill& targetPayload, + const cond::OMSServiceResult& queryResult) { + auto row = *queryResult.begin(); + cond::Time_t stableBeamStart = cond::time::from_boost(row.get("start_stable_beam")); + cond::Time_t stableBeamEnd = cond::time::from_boost(row.get("end_stable_beam")); + if(m_endFill) { + m_tmpBuffer.emplace_back(std::make_pair(stableBeamEnd, targetPayload.cloneFill())); + } else { + m_tmpBuffer.emplace_back(std::make_pair(stableBeamStart, targetPayload.cloneFill())); + } +} + +void LHCInfoPerFillPopConSourceHandler::getNewObjects() { + //reference to the last payload in the tag + Ref previousFill; + + //if a new tag is created, transfer fake fill from 1 to the first fill for the first time + if (tagInfo().size == 0) { + edm::LogInfo(m_name) << "New tag " << tagInfo().name << "; from " << m_name << "::getNewObjects"; + } else { + //check what is already inside the database + edm::LogInfo(m_name) << "got info for tag " << tagInfo().name << ": size " << tagInfo().size + << ", last object valid since " << tagInfo().lastInterval.since << " ( " + << boost::posix_time::to_iso_extended_string( + cond::time::to_boost(tagInfo().lastInterval.since)) + << " ); from " << m_name << "::getNewObjects"; + } + + cond::Time_t lastSince = tagInfo().lastInterval.since; + if (tagInfo().isEmpty()) { + // for a new or empty tag, an empty payload should be added on top with since=1 + addEmptyPayload(1); + lastSince = 1; + } else { + edm::LogInfo(m_name) << "The last Iov in tag " << tagInfo().name << " valid since " << lastSince << "from " + << m_name << "::getNewObjects"; + } + + boost::posix_time::ptime executionTime = boost::posix_time::second_clock::local_time(); + cond::Time_t targetSince = 0; + cond::Time_t endIov = cond::time::from_boost(executionTime); + if (!m_startTime.is_not_a_date_time()) { + targetSince = cond::time::from_boost(m_startTime); + } + if (lastSince > targetSince) + targetSince = lastSince; + + edm::LogInfo(m_name) << "Starting sampling at " + << boost::posix_time::to_simple_string(cond::time::to_boost(targetSince)); + + //retrieve the data from the relational database source + cond::persistency::ConnectionPool connection; + //configure the connection + if (m_debug) { + connection.setMessageVerbosity(coral::Debug); + } else { + connection.setMessageVerbosity(coral::Error); + } + connection.setAuthenticationPath(m_authpath); + connection.configure(); + //create the sessions + cond::persistency::Session session = connection.createSession(m_connectionString, false); + cond::persistency::Session session2 = connection.createSession(m_ecalConnectionString, false); + // fetch last payload when available + if (!tagInfo().lastInterval.payloadId.empty()) { + cond::persistency::Session session3 = dbSession(); + session3.transaction().start(true); + m_prevPayload = session3.fetchPayload(tagInfo().lastInterval.payloadId); + session3.transaction().commit(); + } + + bool iovAdded = false; + while (true) { + if (targetSince >= endIov) { + edm::LogInfo(m_name) << "Sampling ended at the time " + << boost::posix_time::to_simple_string(cond::time::to_boost(endIov)); + break; + } + bool updateEcal = false; + boost::posix_time::ptime targetTime = cond::time::to_boost(targetSince); + boost::posix_time::ptime startSampleTime; + boost::posix_time::ptime endSampleTime; + + cond::OMSService oms; + oms.connect(m_omsBaseUrl); + auto query = oms.query("fills"); + + // if (!m_endFill and m_prevPayload->fillNumber() and m_prevPayload->endTime() == 0ULL) { + // // execute the query for the current fill + // edm::LogInfo(m_name) << "Searching started fill #" << m_prevPayload->fillNumber(); + // query->filterEQ("fill_number", m_prevPayload->fillNumber()); + // bool foundFill = query->execute(); + // if (foundFill) + // foundFill = LHCInfoPerFillImpl::makeFillPayload(m_fillPayload, query->result()); + // if (!foundFill) { + // edm::LogError(m_name) << "Could not find fill #" << m_prevPayload->fillNumber(); + // break; + // } + // updateEcal = true; + // startSampleTime = cond::time::to_boost(lastSince); + // } else { + edm::LogInfo(m_name) << "Searching new fill after " << boost::posix_time::to_simple_string(targetTime); + boost::posix_time::ptime startTime = targetTime + boost::posix_time::seconds(1); + query->filterNotNull("start_stable_beam").filterGT("start_time", startTime).filterNotNull("fill_number"); + query->filterLT("start_time", m_endTime); + if (m_endFill) + query->filterNotNull("end_time"); + bool foundFill = query->execute(); + if (foundFill) + foundFill = LHCInfoPerFillImpl::makeFillPayload(m_fillPayload, query->result()); + if (!foundFill) { + edm::LogInfo(m_name) << "No fill found - END of job."; + if (iovAdded) + addEmptyPayload(targetSince); + break; + } + startSampleTime = cond::time::to_boost(m_fillPayload->createTime()); + // } + cond::Time_t startFillTime = m_fillPayload->createTime(); + cond::Time_t endFillTime = m_fillPayload->endTime(); + unsigned short lhcFill = m_fillPayload->fillNumber(); + if (endFillTime == 0ULL) { + edm::LogInfo(m_name) << "Found ongoing fill " << lhcFill << " created at " << cond::time::to_boost(startFillTime); + endSampleTime = executionTime; + targetSince = endIov; + } else { + edm::LogInfo(m_name) << "Found fill " << lhcFill << " created at " << cond::time::to_boost(startFillTime) + << " ending at " << cond::time::to_boost(endFillTime); + endSampleTime = cond::time::to_boost(endFillTime); + targetSince = endFillTime; + } + // duplicateToBuffer(*m_fillPayload, query->result()); + + getDipData(oms, startSampleTime, endSampleTime); + getLumiData(oms, lhcFill, startSampleTime, endSampleTime); + // edm::LogInfo(m_name) << "Found " << nlumi << " lumisections during the fill " << lhcFill; + boost::posix_time::ptime flumiStart = cond::time::to_boost(m_tmpBuffer.front().first); + boost::posix_time::ptime flumiStop = cond::time::to_boost(m_tmpBuffer.back().first); + edm::LogInfo(m_name) << "First lumi starts at " << flumiStart << " last lumi starts at " << flumiStop; + session.transaction().start(true); + getCTTPSData(session, startSampleTime, endSampleTime); + session.transaction().commit(); + session2.transaction().start(true); + getEcalData(session2, startSampleTime, endSampleTime, updateEcal); + session2.transaction().commit(); + // + size_t niovs = LHCInfoPerFillImpl::transferPayloads(m_tmpBuffer, m_iovs, m_prevPayload); + edm::LogInfo(m_name) << "Added " << niovs << " iovs within the Fill time"; + m_tmpBuffer.clear(); + iovAdded = true; + if (m_prevPayload->fillNumber() and m_fillPayload->endTime() != 0ULL) + addEmptyPayload(m_fillPayload->endTime()); + } +} + +std::string LHCInfoPerFillPopConSourceHandler::id() const { return m_name; } diff --git a/CondTools/RunInfo/src/OMSAccess.cc b/CondTools/RunInfo/src/OMSAccess.cc index fed5b88c74d25..21d9941986e28 100644 --- a/CondTools/RunInfo/src/OMSAccess.cc +++ b/CondTools/RunInfo/src/OMSAccess.cc @@ -33,6 +33,16 @@ namespace cond { OMSServiceResultIterator OMSServiceResult::end() const { return OMSServiceResultIterator(m_data->end()); } + OMSServiceResultRef OMSServiceResult::front() const { + auto& attributeList = m_data->front().second.get_child("attributes"); + return OMSServiceResultRef(&attributeList); + } + + OMSServiceResultRef OMSServiceResult::back() const{ + auto& attributeList = m_data->back().second.get_child("attributes"); + return OMSServiceResultRef(&attributeList); + } + size_t OMSServiceResult::parseData(const std::string& data) { m_data = nullptr; std::stringstream sout; From 0df218969367d1fe9dbe9f64999108eee019140d Mon Sep 17 00:00:00 2001 From: Jan Chyczynski Date: Fri, 2 Sep 2022 15:49:31 +0200 Subject: [PATCH 24/39] removed unused code, made some debug info be printed only in debug mode --- .../LHCInfoPerFillPopConSourceHandler.h | 2 - .../src/LHCInfoPerFillPopConSourceHandler.cc | 96 +++++++------------ 2 files changed, 32 insertions(+), 66 deletions(-) diff --git a/CondTools/RunInfo/interface/LHCInfoPerFillPopConSourceHandler.h b/CondTools/RunInfo/interface/LHCInfoPerFillPopConSourceHandler.h index c49aed244a8e4..40c1fe9db332a 100644 --- a/CondTools/RunInfo/interface/LHCInfoPerFillPopConSourceHandler.h +++ b/CondTools/RunInfo/interface/LHCInfoPerFillPopConSourceHandler.h @@ -40,8 +40,6 @@ class LHCInfoPerFillPopConSourceHandler : public popcon::PopConSourceHandlerlimit(kLumisectionsQueryLimit); if (query->execute()) { auto queryResult = query->result(); + edm::LogInfo(m_name) << "Found " << queryResult.size() << " lumisections with STABLE BEAM during the fill " << fillId; if(m_endFill) { auto lastRow = queryResult.back(); addPayloadToBuffer(lastRow); @@ -328,10 +325,10 @@ bool LHCInfoPerFillPopConSourceHandler::getCTTPSData(cond::persistency::Session& CTPPSDataQuery->addToOutputList(std::string("DIP_UPDATE_TIME")); CTPPSDataQuery->addToOutputList(std::string("LHC_STATE")); CTPPSDataQuery->addToOutputList(std::string("LHC_COMMENT")); - //dbg + if (m_debug) { CTPPSDataQuery->addToOutputList(std::string("RUN_NUMBER")); CTPPSDataQuery->addToOutputList(std::string("LUMI_SECTION")); - //dbge + } //WHERE CLAUSE coral::AttributeList CTPPSDataBindVariables; CTPPSDataBindVariables.extend(std::string("beginFillTime")); @@ -347,24 +344,22 @@ bool LHCInfoPerFillPopConSourceHandler::getCTTPSData(cond::persistency::Session& CTPPSDataOutput.extend(std::string("DIP_UPDATE_TIME")); CTPPSDataOutput.extend(std::string("LHC_STATE")); CTPPSDataOutput.extend(std::string("LHC_COMMENT")); - //dbg - CTPPSDataOutput.extend(std::string("RUN_NUMBER")); - CTPPSDataOutput.extend(std::string("LUMI_SECTION")); - //dbge + if (m_debug) { + CTPPSDataOutput.extend(std::string("RUN_NUMBER")); + CTPPSDataOutput.extend(std::string("LUMI_SECTION")); + } CTPPSDataQuery->defineOutput(CTPPSDataOutput); //execute the query coral::ICursor& CTPPSDataCursor = CTPPSDataQuery->execute(); cond::Time_t dipTime = 0; std::string lhcState = "", lhcComment = "", ctppsStatus = ""; - //dbg + + //debug informations unsigned int lumiSection = 0; cond::Time_t runNumber = 0; - cond::Time_t savedDipTime = 0; unsigned int savedLumiSection = 0; cond::Time_t savedRunNumber = 0; - //dbge - bool ret = false; LHCInfoPerFillImpl::LumiSectionFilter filter(m_tmpBuffer); @@ -387,16 +382,17 @@ bool LHCInfoPerFillPopConSourceHandler::getCTTPSData(cond::persistency::Session& lhcComment = lhcCommentAttribute.data(); } - //dbg - coral::Attribute const& runNumberAttribute = CTPPSDataCursor.currentRow()[std::string("RUN_NUMBER")]; - if (!runNumberAttribute.isNull()) { - runNumber = runNumberAttribute.data(); - } - coral::Attribute const& lumiSectionAttribute = CTPPSDataCursor.currentRow()[std::string("LUMI_SECTION")]; - if (!lumiSectionAttribute.isNull()) { - lumiSection = lumiSectionAttribute.data(); + if (m_debug) { + coral::Attribute const& runNumberAttribute = CTPPSDataCursor.currentRow()[std::string("RUN_NUMBER")]; + if (!runNumberAttribute.isNull()) { + runNumber = runNumberAttribute.data(); + } + coral::Attribute const& lumiSectionAttribute = CTPPSDataCursor.currentRow()[std::string("LUMI_SECTION")]; + if (!lumiSectionAttribute.isNull()) { + lumiSection = lumiSectionAttribute.data(); + } } - + for (auto it = filter.current(); it != m_tmpBuffer.end(); it++) { // set the current values to all of the payloads of the lumi section samples after the current since LHCInfoPerFill& payload = *(it->second); @@ -404,21 +400,21 @@ bool LHCInfoPerFillPopConSourceHandler::getCTTPSData(cond::persistency::Session& payload.setLhcComment(lhcComment); payload.setCtppsStatus(ctppsStatus); - //dbg - savedDipTime = dipTime; - savedLumiSection = lumiSection; - savedRunNumber = runNumber; - //dbge + if (m_debug) { + savedDipTime = dipTime; + savedLumiSection = lumiSection; + savedRunNumber = runNumber; + } } } } } - //dbg - edm::LogInfo(m_name) << "Last assigned: " << "DipTime: " << savedDipTime << " " - << "LumiSection: " << savedLumiSection << " " - << "RunNumber: " << savedRunNumber; + if (m_debug) { + edm::LogInfo(m_name) << "Last assigned: " << "DipTime: " << savedDipTime << " " + << "LumiSection: " << savedLumiSection << " " + << "RunNumber: " << savedRunNumber; + } return ret; - //dbge } namespace LHCInfoPerFillImpl { @@ -624,25 +620,13 @@ namespace LHCInfoPerFillImpl { prevPayload = iov.second; } } - edm::LogInfo("transferPayloads") << "TRANSFERED COND IOVS: " << condIovs.str(); - edm::LogInfo("transferPayloads") << "FORMATTED COND IOVS: " << formattedIovs.str(); + edm::LogInfo("transferPayloads") << "TRANSFERED IOVS: " << condIovs.str(); + edm::LogInfo("transferPayloads") << "FORMATTED TRANSFERED IOVS: " << formattedIovs.str(); return niovs; } } // namespace LHCInfoPerFillImpl -void LHCInfoPerFillPopConSourceHandler::duplicateToBuffer(const LHCInfoPerFill& targetPayload, - const cond::OMSServiceResult& queryResult) { - auto row = *queryResult.begin(); - cond::Time_t stableBeamStart = cond::time::from_boost(row.get("start_stable_beam")); - cond::Time_t stableBeamEnd = cond::time::from_boost(row.get("end_stable_beam")); - if(m_endFill) { - m_tmpBuffer.emplace_back(std::make_pair(stableBeamEnd, targetPayload.cloneFill())); - } else { - m_tmpBuffer.emplace_back(std::make_pair(stableBeamStart, targetPayload.cloneFill())); - } -} - void LHCInfoPerFillPopConSourceHandler::getNewObjects() { //reference to the last payload in the tag Ref previousFill; @@ -718,20 +702,6 @@ void LHCInfoPerFillPopConSourceHandler::getNewObjects() { oms.connect(m_omsBaseUrl); auto query = oms.query("fills"); - // if (!m_endFill and m_prevPayload->fillNumber() and m_prevPayload->endTime() == 0ULL) { - // // execute the query for the current fill - // edm::LogInfo(m_name) << "Searching started fill #" << m_prevPayload->fillNumber(); - // query->filterEQ("fill_number", m_prevPayload->fillNumber()); - // bool foundFill = query->execute(); - // if (foundFill) - // foundFill = LHCInfoPerFillImpl::makeFillPayload(m_fillPayload, query->result()); - // if (!foundFill) { - // edm::LogError(m_name) << "Could not find fill #" << m_prevPayload->fillNumber(); - // break; - // } - // updateEcal = true; - // startSampleTime = cond::time::to_boost(lastSince); - // } else { edm::LogInfo(m_name) << "Searching new fill after " << boost::posix_time::to_simple_string(targetTime); boost::posix_time::ptime startTime = targetTime + boost::posix_time::seconds(1); query->filterNotNull("start_stable_beam").filterGT("start_time", startTime).filterNotNull("fill_number"); @@ -747,8 +717,8 @@ void LHCInfoPerFillPopConSourceHandler::getNewObjects() { addEmptyPayload(targetSince); break; } + startSampleTime = cond::time::to_boost(m_fillPayload->createTime()); - // } cond::Time_t startFillTime = m_fillPayload->createTime(); cond::Time_t endFillTime = m_fillPayload->endTime(); unsigned short lhcFill = m_fillPayload->fillNumber(); @@ -762,11 +732,9 @@ void LHCInfoPerFillPopConSourceHandler::getNewObjects() { endSampleTime = cond::time::to_boost(endFillTime); targetSince = endFillTime; } - // duplicateToBuffer(*m_fillPayload, query->result()); getDipData(oms, startSampleTime, endSampleTime); getLumiData(oms, lhcFill, startSampleTime, endSampleTime); - // edm::LogInfo(m_name) << "Found " << nlumi << " lumisections during the fill " << lhcFill; boost::posix_time::ptime flumiStart = cond::time::to_boost(m_tmpBuffer.front().first); boost::posix_time::ptime flumiStop = cond::time::to_boost(m_tmpBuffer.back().first); edm::LogInfo(m_name) << "First lumi starts at " << flumiStart << " last lumi starts at " << flumiStop; From acc22e450aee486bf7699dc7370abe822d0c7f91 Mon Sep 17 00:00:00 2001 From: Jan Chyczynski Date: Mon, 5 Sep 2022 11:25:47 +0200 Subject: [PATCH 25/39] moved populating run number from getLumiData to getCTPSData --- .../RunInfo/src/LHCInfoPerLSPopConSourceHandler.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/CondTools/RunInfo/src/LHCInfoPerLSPopConSourceHandler.cc b/CondTools/RunInfo/src/LHCInfoPerLSPopConSourceHandler.cc index 4c9b36b8646e4..e0b7baf292859 100644 --- a/CondTools/RunInfo/src/LHCInfoPerLSPopConSourceHandler.cc +++ b/CondTools/RunInfo/src/LHCInfoPerLSPopConSourceHandler.cc @@ -88,8 +88,6 @@ void LHCInfoPerLSPopConSourceHandler::addPayloadToBuffer(cond::OMSServiceResultR auto lumiTime = row.get("start_time"); LHCInfoPerLS* thisLumiSectionInfo = new LHCInfoPerLS(*m_fillPayload); m_tmpBuffer.emplace_back(std::make_pair(cond::time::from_boost(lumiTime), thisLumiSectionInfo)); - - thisLumiSectionInfo->setRunNumber(row.get("run_number")); } size_t LHCInfoPerLSPopConSourceHandler::bufferAllLS(const cond::OMSServiceResult& queryResult) @@ -218,6 +216,7 @@ bool LHCInfoPerLSPopConSourceHandler::getCTTPSData(cond::persistency::Session& s //SELECT clause CTPPSDataQuery->addToOutputList(std::string("DIP_UPDATE_TIME")); CTPPSDataQuery->addToOutputList(std::string("LUMI_SECTION")); + CTPPSDataQuery->addToOutputList(std::string("RUN_NUMBER")); CTPPSDataQuery->addToOutputList(std::string("XING_ANGLE_P5_X_URAD")); CTPPSDataQuery->addToOutputList(std::string("XING_ANGLE_P5_Y_URAD")); CTPPSDataQuery->addToOutputList(std::string("BETA_STAR_P5_X_M")); @@ -236,6 +235,7 @@ bool LHCInfoPerLSPopConSourceHandler::getCTTPSData(cond::persistency::Session& s coral::AttributeList CTPPSDataOutput; CTPPSDataOutput.extend(std::string("DIP_UPDATE_TIME")); CTPPSDataOutput.extend(std::string("LUMI_SECTION")); + CTPPSDataOutput.extend(std::string("RUN_NUMBER")); CTPPSDataOutput.extend(std::string("XING_ANGLE_P5_X_URAD")); CTPPSDataOutput.extend(std::string("XING_ANGLE_P5_Y_URAD")); CTPPSDataOutput.extend(std::string("BETA_STAR_P5_X_M")); @@ -245,6 +245,7 @@ bool LHCInfoPerLSPopConSourceHandler::getCTTPSData(cond::persistency::Session& s coral::ICursor& CTPPSDataCursor = CTPPSDataQuery->execute(); cond::Time_t dipTime = 0; unsigned int lumiSection = 0; + cond::Time_t runNumber = 0; float crossingAngleX = 0., betaStarX = 0.; float crossingAngleY = 0., betaStarY = 0.; @@ -264,6 +265,10 @@ bool LHCInfoPerLSPopConSourceHandler::getCTTPSData(cond::persistency::Session& s if (!lumiSectionAttribute.isNull()) { lumiSection = lumiSectionAttribute.data(); } + coral::Attribute const& runNumberAttribute = CTPPSDataCursor.currentRow()[std::string("RUN_NUMBER")]; + if (!runNumberAttribute.isNull()) { + runNumber = runNumberAttribute.data(); + } coral::Attribute const& crossingAngleXAttribute = CTPPSDataCursor.currentRow()[std::string("XING_ANGLE_P5_X_URAD")]; if (!crossingAngleXAttribute.isNull()) { @@ -290,6 +295,7 @@ bool LHCInfoPerLSPopConSourceHandler::getCTTPSData(cond::persistency::Session& s payload.setBetaStarX(betaStarX); payload.setBetaStarY(betaStarY); payload.setLumiSection(lumiSection); + payload.setRunNumber(runNumber); } } } From d0019509bc71dc63a19361ff110bbfa31e635c28 Mon Sep 17 00:00:00 2001 From: Jan Chyczynski Date: Mon, 5 Sep 2022 13:36:56 +0200 Subject: [PATCH 26/39] added payload at start of SB in perFill endfill PopCon, removed 1 case of adding empty payloads --- .../src/LHCInfoPerFillPopConSourceHandler.cc | 20 ++++++++++--------- .../src/LHCInfoPerLSPopConSourceHandler.cc | 8 ++++---- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/CondTools/RunInfo/src/LHCInfoPerFillPopConSourceHandler.cc b/CondTools/RunInfo/src/LHCInfoPerFillPopConSourceHandler.cc index 3245c2323baa5..33a4161f2a10c 100644 --- a/CondTools/RunInfo/src/LHCInfoPerFillPopConSourceHandler.cc +++ b/CondTools/RunInfo/src/LHCInfoPerFillPopConSourceHandler.cc @@ -177,17 +177,19 @@ size_t LHCInfoPerFillPopConSourceHandler::getLumiData(const cond::OMSService& om query->filterEQ("beams_stable", "true"); query->limit(kLumisectionsQueryLimit); if (query->execute()) { + int nLumi = 0; auto queryResult = query->result(); edm::LogInfo(m_name) << "Found " << queryResult.size() << " lumisections with STABLE BEAM during the fill " << fillId; + if(m_endFill) { - auto lastRow = queryResult.back(); - addPayloadToBuffer(lastRow); - return 1; - } else { auto firstRow = queryResult.front(); addPayloadToBuffer(firstRow); - return 1; + nLumi++; } + + auto lastRow = queryResult.back(); + addPayloadToBuffer(lastRow); + nLumi++; } return 0; } @@ -686,7 +688,7 @@ void LHCInfoPerFillPopConSourceHandler::getNewObjects() { session3.transaction().commit(); } - bool iovAdded = false; + // bool iovAdded = false; while (true) { if (targetSince >= endIov) { edm::LogInfo(m_name) << "Sampling ended at the time " @@ -713,8 +715,8 @@ void LHCInfoPerFillPopConSourceHandler::getNewObjects() { foundFill = LHCInfoPerFillImpl::makeFillPayload(m_fillPayload, query->result()); if (!foundFill) { edm::LogInfo(m_name) << "No fill found - END of job."; - if (iovAdded) - addEmptyPayload(targetSince); + // if (iovAdded) + // addEmptyPayload(targetSince); break; } @@ -748,7 +750,7 @@ void LHCInfoPerFillPopConSourceHandler::getNewObjects() { size_t niovs = LHCInfoPerFillImpl::transferPayloads(m_tmpBuffer, m_iovs, m_prevPayload); edm::LogInfo(m_name) << "Added " << niovs << " iovs within the Fill time"; m_tmpBuffer.clear(); - iovAdded = true; + // iovAdded = true; if (m_prevPayload->fillNumber() and m_fillPayload->endTime() != 0ULL) addEmptyPayload(m_fillPayload->endTime()); } diff --git a/CondTools/RunInfo/src/LHCInfoPerLSPopConSourceHandler.cc b/CondTools/RunInfo/src/LHCInfoPerLSPopConSourceHandler.cc index e0b7baf292859..16173022beb75 100644 --- a/CondTools/RunInfo/src/LHCInfoPerLSPopConSourceHandler.cc +++ b/CondTools/RunInfo/src/LHCInfoPerLSPopConSourceHandler.cc @@ -451,7 +451,7 @@ void LHCInfoPerLSPopConSourceHandler::getNewObjects() { } } - bool iovAdded = false; + // bool iovAdded = false; while (true) { if (targetSince >= endIov) { edm::LogInfo(m_name) << "Sampling ended at the time " @@ -490,8 +490,8 @@ void LHCInfoPerLSPopConSourceHandler::getNewObjects() { foundFill = makeFillPayload(m_fillPayload, query->result()); if (!foundFill) { edm::LogInfo(m_name) << "No fill found - END of job."; - if (iovAdded) - addEmptyPayload(targetSince); + // if (iovAdded) + // addEmptyPayload(targetSince); break; } startSampleTime = cond::time::to_boost(m_startFillTime); @@ -525,7 +525,7 @@ void LHCInfoPerLSPopConSourceHandler::getNewObjects() { m_prevEndFillTime = m_endFillTime; } m_tmpBuffer.clear(); - iovAdded = true; + // iovAdded = true; if (m_prevPayload->fillNumber() and m_endFillTime != 0ULL) addEmptyPayload(m_endFillTime); } From d2d4366308966d867f86dc941a32f87309db3720 Mon Sep 17 00:00:00 2001 From: Jan Chyczynski Date: Mon, 5 Sep 2022 14:01:48 +0200 Subject: [PATCH 27/39] added greater or equal and less or equal filters to OMSServiceQuery --- CondTools/RunInfo/interface/OMSAccess.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CondTools/RunInfo/interface/OMSAccess.h b/CondTools/RunInfo/interface/OMSAccess.h index d73c77b810e19..3ed48c956709e 100644 --- a/CondTools/RunInfo/interface/OMSAccess.h +++ b/CondTools/RunInfo/interface/OMSAccess.h @@ -177,7 +177,9 @@ namespace cond { static constexpr const char* const NEQ = "NEQ"; static constexpr const char* const EQ = "EQ"; static constexpr const char* const LT = "LT"; + static constexpr const char* const LE = "LE"; static constexpr const char* const GT = "GT"; + static constexpr const char* const GE = "GE"; static constexpr const char* const SNULL = "null"; public: @@ -218,9 +220,17 @@ namespace cond { return filter(GT, varName, value); } template + inline OMSServiceQuery& filterGE(const std::string& varName, const T& value) { + return filter(GE, varName, value); + } + template inline OMSServiceQuery& filterLT(const std::string& varName, const T& value) { return filter(LT, varName, value); } + template + inline OMSServiceQuery& filterLE(const std::string& varName, const T& value) { + return filter(LE, varName, value); + } // not null filter inline OMSServiceQuery& filterNotNull(const std::string& varName) { return filterNEQ(varName, SNULL); } From 7cf8bac240b1fc9e29fc6c3900433c18f1284f99 Mon Sep 17 00:00:00 2001 From: Jan Chyczynski Date: Mon, 5 Sep 2022 14:02:30 +0200 Subject: [PATCH 28/39] fixed perFill and perLS PopCons skipping fills --- .../interface/LHCInfoPerLSPopConSourceHandler.h | 1 + .../src/LHCInfoPerFillPopConSourceHandler.cc | 9 +++++++-- .../RunInfo/src/LHCInfoPerLSPopConSourceHandler.cc | 14 ++++++++++++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/CondTools/RunInfo/interface/LHCInfoPerLSPopConSourceHandler.h b/CondTools/RunInfo/interface/LHCInfoPerLSPopConSourceHandler.h index 2dd29493763f7..f69e57f5311bf 100644 --- a/CondTools/RunInfo/interface/LHCInfoPerLSPopConSourceHandler.h +++ b/CondTools/RunInfo/interface/LHCInfoPerLSPopConSourceHandler.h @@ -59,6 +59,7 @@ class LHCInfoPerLSPopConSourceHandler : public popcon::PopConSourceHandler > > m_tmpBuffer; bool m_lastPayloadEmpty = false; }; diff --git a/CondTools/RunInfo/src/LHCInfoPerFillPopConSourceHandler.cc b/CondTools/RunInfo/src/LHCInfoPerFillPopConSourceHandler.cc index 33a4161f2a10c..c1601b43a7542 100644 --- a/CondTools/RunInfo/src/LHCInfoPerFillPopConSourceHandler.cc +++ b/CondTools/RunInfo/src/LHCInfoPerFillPopConSourceHandler.cc @@ -705,8 +705,13 @@ void LHCInfoPerFillPopConSourceHandler::getNewObjects() { auto query = oms.query("fills"); edm::LogInfo(m_name) << "Searching new fill after " << boost::posix_time::to_simple_string(targetTime); - boost::posix_time::ptime startTime = targetTime + boost::posix_time::seconds(1); - query->filterNotNull("start_stable_beam").filterGT("start_time", startTime).filterNotNull("fill_number"); + query->filterNotNull("start_stable_beam").filterNotNull("fill_number"); + if (targetTime > cond::time::to_boost(m_prevPayload->createTime())) { + query->filterGE("start_time", targetTime); + } else { + query->filterGT("start_time", targetTime); + } + query->filterLT("start_time", m_endTime); if (m_endFill) query->filterNotNull("end_time"); diff --git a/CondTools/RunInfo/src/LHCInfoPerLSPopConSourceHandler.cc b/CondTools/RunInfo/src/LHCInfoPerLSPopConSourceHandler.cc index 16173022beb75..64d742d598f5a 100644 --- a/CondTools/RunInfo/src/LHCInfoPerLSPopConSourceHandler.cc +++ b/CondTools/RunInfo/src/LHCInfoPerLSPopConSourceHandler.cc @@ -319,6 +319,7 @@ void LHCInfoPerLSPopConSourceHandler::addEmptyPayload(cond::Time_t iov) { m_iovs.insert(std::make_pair(iov, newPayload)); m_prevPayload = newPayload; m_prevEndFillTime = 0; + m_prevStartFillTime = 0; } } @@ -436,6 +437,8 @@ void LHCInfoPerLSPopConSourceHandler::getNewObjects() { if (!result.empty()) { auto endFillTime = (*result.begin()).get("end_time"); m_prevEndFillTime = cond::time::from_boost(endFillTime); + auto startFillTime = (*result.begin()).get("start_time"); + m_prevStartFillTime = cond::time::from_boost(startFillTime); } else { foundFill = false; @@ -448,6 +451,7 @@ void LHCInfoPerLSPopConSourceHandler::getNewObjects() { else { m_prevEndFillTime = 0; + m_prevStartFillTime = 0; } } @@ -480,8 +484,13 @@ void LHCInfoPerLSPopConSourceHandler::getNewObjects() { startSampleTime = cond::time::to_boost(lastSince); } else { edm::LogInfo(m_name) << "Searching new fill after " << boost::posix_time::to_simple_string(targetTime); - boost::posix_time::ptime startTime = targetTime + boost::posix_time::seconds(1); - query->filterNotNull("start_stable_beam").filterGT("start_time", startTime).filterNotNull("fill_number"); + query->filterNotNull("start_stable_beam").filterNotNull("fill_number"); + if (targetTime > cond::time::to_boost(m_prevStartFillTime)) { + query->filterGE("start_time", targetTime); + } else { + query->filterGT("start_time", targetTime); + } + query->filterLT("start_time", m_endTime); if (m_endFill) query->filterNotNull("end_time"); @@ -523,6 +532,7 @@ void LHCInfoPerLSPopConSourceHandler::getNewObjects() { edm::LogInfo(m_name) << "Added " << niovs << " iovs within the Fill time"; if(niovs){ m_prevEndFillTime = m_endFillTime; + m_prevStartFillTime = m_startFillTime; } m_tmpBuffer.clear(); // iovAdded = true; From dece499287e2a472e6b90b9e7dcaaba7c984e9dc Mon Sep 17 00:00:00 2001 From: Jan Chyczynski Date: Mon, 5 Sep 2022 15:18:47 +0200 Subject: [PATCH 29/39] changed beta star unit in print method to meters --- CondFormats/RunInfo/src/LHCInfoPerLS.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CondFormats/RunInfo/src/LHCInfoPerLS.cc b/CondFormats/RunInfo/src/LHCInfoPerLS.cc index 545304fc55c81..d916cfb517111 100644 --- a/CondFormats/RunInfo/src/LHCInfoPerLS.cc +++ b/CondFormats/RunInfo/src/LHCInfoPerLS.cc @@ -63,8 +63,8 @@ void LHCInfoPerLS::print(std::stringstream& ss) const { << "Run number: " << this->runNumber() << std::endl << "Crossing angle x (urad): " << this->crossingAngleX() << std::endl << "Crossing angle y (urad): " << this->crossingAngleY() << std::endl - << "Beta star x (cm): " << this->betaStarX() << std::endl - << "Beta star y (cm): " << this->betaStarY() << std::endl; + << "Beta star x (m): " << this->betaStarX() << std::endl + << "Beta star y (m): " << this->betaStarY() << std::endl; } std::ostream& operator<<(std::ostream& os, LHCInfoPerLS beamInfo) { From fde9ee5c23d16d27e024be0fad0f056dc590f92a Mon Sep 17 00:00:00 2001 From: Jan Chyczynski Date: Tue, 6 Sep 2022 11:49:23 +0200 Subject: [PATCH 30/39] TMP py scripts changes and old popcon debug --- .../LHCInfoPerFillPopConAnalyzerEndFill.py | 4 ++-- .../LHCInfoPerFillPopConAnalyzerStartFill.py | 4 ++-- .../python/LHCInfoPerLSPopConAnalyzerEndFill.py | 4 ++-- .../LHCInfoPerLSPopConAnalyzerStartFill.py | 4 ++-- .../python/LHCInfoPopConAnalyzerStartFill.py | 2 +- .../RunInfo/src/LHCInfoPopConSourceHandler.cc | 14 ++++++++++---- .../RunInfo/test/LHCInfoPerFillAnalyzer_cfg.py | 15 ++++++++++----- .../RunInfo/test/LHCInfoPerLSAnalyzer_cfg.py | 16 +++++++++++----- 8 files changed, 40 insertions(+), 23 deletions(-) diff --git a/CondTools/RunInfo/python/LHCInfoPerFillPopConAnalyzerEndFill.py b/CondTools/RunInfo/python/LHCInfoPerFillPopConAnalyzerEndFill.py index 75985e4b20b5b..e5291f5ddaa44 100644 --- a/CondTools/RunInfo/python/LHCInfoPerFillPopConAnalyzerEndFill.py +++ b/CondTools/RunInfo/python/LHCInfoPerFillPopConAnalyzerEndFill.py @@ -70,8 +70,8 @@ record = cms.string('LHCInfoPerFillRcd'), name = cms.untracked.string('LHCInfo'), Source = cms.PSet(fill = cms.untracked.uint32(6417), - startTime = cms.untracked.string('2021-09-10 03:10:18.000'), - # endTime = cms.untracked.string('2022-08-19 00:00:00.000'), + startTime = cms.untracked.string('2022-08-18 10:10:18.000'), + endTime = cms.untracked.string('2022-08-19 00:00:00.000'), samplingInterval = cms.untracked.uint32( 600 ), endFill = cms.untracked.bool(True), connectionString = cms.untracked.string("oracle://cms_orcon_adg/CMS_RUNTIME_LOGGER"), diff --git a/CondTools/RunInfo/python/LHCInfoPerFillPopConAnalyzerStartFill.py b/CondTools/RunInfo/python/LHCInfoPerFillPopConAnalyzerStartFill.py index a2f6df179ff06..b8d86b670aaa5 100644 --- a/CondTools/RunInfo/python/LHCInfoPerFillPopConAnalyzerStartFill.py +++ b/CondTools/RunInfo/python/LHCInfoPerFillPopConAnalyzerStartFill.py @@ -70,8 +70,8 @@ record = cms.string('LHCInfoPerFillRcd'), name = cms.untracked.string('LHCInfo'), Source = cms.PSet(fill = cms.untracked.uint32(6417), - startTime = cms.untracked.string('2021-09-10 03:10:18.000'), - # endTime = cms.untracked.string('2022-08-19 00:00:00.000'), + startTime = cms.untracked.string('2022-08-18 10:10:18.000'), + endTime = cms.untracked.string('2022-08-19 00:00:00.000'), samplingInterval = cms.untracked.uint32( 600 ), endFill = cms.untracked.bool(False), connectionString = cms.untracked.string("oracle://cms_orcon_adg/CMS_RUNTIME_LOGGER"), diff --git a/CondTools/RunInfo/python/LHCInfoPerLSPopConAnalyzerEndFill.py b/CondTools/RunInfo/python/LHCInfoPerLSPopConAnalyzerEndFill.py index 3b7ff8f41cd98..d22ce80f9ae1b 100644 --- a/CondTools/RunInfo/python/LHCInfoPerLSPopConAnalyzerEndFill.py +++ b/CondTools/RunInfo/python/LHCInfoPerLSPopConAnalyzerEndFill.py @@ -70,8 +70,8 @@ record = cms.string('LHCInfoPerLSRcd'), name = cms.untracked.string('LHCInfo'), Source = cms.PSet(fill = cms.untracked.uint32(6417), - startTime = cms.untracked.string('2021-09-10 03:10:18.000'), - # endTime = cms.untracked.string('2018-04-06 05:00:00.000'), + startTime = cms.untracked.string('2022-08-18 10:10:18.000'), + endTime = cms.untracked.string('2022-08-19 10:10:18.000'), samplingInterval = cms.untracked.uint32( 600 ), endFill = cms.untracked.bool(True), connectionString = cms.untracked.string("oracle://cms_orcon_adg/CMS_RUNTIME_LOGGER"), diff --git a/CondTools/RunInfo/python/LHCInfoPerLSPopConAnalyzerStartFill.py b/CondTools/RunInfo/python/LHCInfoPerLSPopConAnalyzerStartFill.py index ac1461f80c1b4..41ccb23fcb933 100644 --- a/CondTools/RunInfo/python/LHCInfoPerLSPopConAnalyzerStartFill.py +++ b/CondTools/RunInfo/python/LHCInfoPerLSPopConAnalyzerStartFill.py @@ -70,8 +70,8 @@ record = cms.string('LHCInfoPerLSRcd'), name = cms.untracked.string('LHCInfo'), Source = cms.PSet(fill = cms.untracked.uint32(6417), - startTime = cms.untracked.string('2021-09-10 03:10:18.000'), - # endTime = cms.untracked.string('2018-04-06 05:00:00.000'), + startTime = cms.untracked.string('2022-08-18 10:10:18.000'), + endTime = cms.untracked.string('2022-08-19 10:10:18.000'), samplingInterval = cms.untracked.uint32( 600 ), endFill = cms.untracked.bool(False), connectionString = cms.untracked.string("oracle://cms_orcon_adg/CMS_RUNTIME_LOGGER"), diff --git a/CondTools/RunInfo/python/LHCInfoPopConAnalyzerStartFill.py b/CondTools/RunInfo/python/LHCInfoPopConAnalyzerStartFill.py index 79166c5b8bace..33a5ef6f010f8 100644 --- a/CondTools/RunInfo/python/LHCInfoPopConAnalyzerStartFill.py +++ b/CondTools/RunInfo/python/LHCInfoPopConAnalyzerStartFill.py @@ -70,7 +70,7 @@ record = cms.string('LHCInfoRcd'), name = cms.untracked.string('LHCInfo'), Source = cms.PSet(fill = cms.untracked.uint32(6417), - startTime = cms.untracked.string('2018-04-01 00:00:00.000'), + startTime = cms.untracked.string('2022-08-18 10:00:00.000'), #endTime = cms.untracked.string('2018-03-25 05:00:00.000'), samplingInterval = cms.untracked.uint32( 600 ), endFill = cms.untracked.bool(False), diff --git a/CondTools/RunInfo/src/LHCInfoPopConSourceHandler.cc b/CondTools/RunInfo/src/LHCInfoPopConSourceHandler.cc index 42ed95690c662..cec335f798e94 100644 --- a/CondTools/RunInfo/src/LHCInfoPopConSourceHandler.cc +++ b/CondTools/RunInfo/src/LHCInfoPopConSourceHandler.cc @@ -579,6 +579,8 @@ namespace LHCInfoImpl { std::map>& iovsToTransfer, std::shared_ptr& prevPayload) { size_t niovs = 0; + std::stringstream condIovs; + std::stringstream formattedIovs; for (auto& iov : buffer) { bool add = false; auto payload = iov.second; @@ -593,10 +595,14 @@ namespace LHCInfoImpl { } if (add) { niovs++; + condIovs << since << " "; + formattedIovs << boost::posix_time::to_iso_extended_string(cond::time::to_boost(since)) << " "; iovsToTransfer.insert(std::make_pair(since, payload)); prevPayload = iov.second; } } + edm::LogInfo("transferPayloads") << "TRANSFERED COND IOVS: " << condIovs.str(); + edm::LogInfo("transferPayloads") << "FORMATTED COND IOVS: " << formattedIovs.str(); return niovs; } @@ -661,7 +667,7 @@ void LHCInfoPopConSourceHandler::getNewObjects() { session3.transaction().commit(); } - bool iovAdded = false; + // bool iovAdded = false; while (true) { if (targetSince >= endIov) { edm::LogInfo(m_name) << "Sampling ended at the time " @@ -701,8 +707,8 @@ void LHCInfoPopConSourceHandler::getNewObjects() { foundFill = LHCInfoImpl::makeFillPayload(m_fillPayload, query->result()); if (!foundFill) { edm::LogInfo(m_name) << "No fill found - END of job."; - if (iovAdded) - addEmptyPayload(targetSince); + // if (iovAdded) + // addEmptyPayload(targetSince); break; } startSampleTime = cond::time::to_boost(m_fillPayload->createTime()); @@ -737,7 +743,7 @@ void LHCInfoPopConSourceHandler::getNewObjects() { size_t niovs = LHCInfoImpl::transferPayloads(m_tmpBuffer, m_iovs, m_prevPayload); edm::LogInfo(m_name) << "Added " << niovs << " iovs within the Fill time"; m_tmpBuffer.clear(); - iovAdded = true; + // iovAdded = true; if (m_prevPayload->fillNumber() and m_fillPayload->endTime() != 0ULL) addEmptyPayload(m_fillPayload->endTime()); } diff --git a/CondTools/RunInfo/test/LHCInfoPerFillAnalyzer_cfg.py b/CondTools/RunInfo/test/LHCInfoPerFillAnalyzer_cfg.py index a3a0ab0f19f0b..d08964cb8c9e2 100644 --- a/CondTools/RunInfo/test/LHCInfoPerFillAnalyzer_cfg.py +++ b/CondTools/RunInfo/test/LHCInfoPerFillAnalyzer_cfg.py @@ -1,3 +1,5 @@ +import sys + import FWCore.ParameterSet.Config as cms process = cms.Process('test') @@ -13,16 +15,19 @@ ) ) +iov = int(7133383367994638336 if len(sys.argv) < 3 else sys.argv[2]) +print("iov:", iov) + process.source = cms.Source('EmptyIOVSource', - timetype = cms.string('runnumber'), - firstValue = cms.uint64(1), - lastValue = cms.uint64(1), + timetype = cms.string('timestamp'), + firstValue = cms.uint64(iov ), + lastValue = cms.uint64(iov ), interval = cms.uint64(1) ) # load info from database process.load('CondCore.CondDB.CondDB_cfi') -process.CondDB.connect = 'sqlite_file:LHCInfoPerFill.sqlite' # SQLite input +process.CondDB.connect = 'sqlite_file:../python/lhcinfo_pop_test.db' # SQLite input process.PoolDBESSource = cms.ESSource('PoolDBESSource', process.CondDB, @@ -30,7 +35,7 @@ toGet = cms.VPSet( cms.PSet( record = cms.string('LHCInfoPerFillRcd'), - tag = cms.string('LHCInfoPerFillFake') + tag = cms.string('perFill_10_end') ) ) ) diff --git a/CondTools/RunInfo/test/LHCInfoPerLSAnalyzer_cfg.py b/CondTools/RunInfo/test/LHCInfoPerLSAnalyzer_cfg.py index ca23551c9ca66..6707d025da5eb 100644 --- a/CondTools/RunInfo/test/LHCInfoPerLSAnalyzer_cfg.py +++ b/CondTools/RunInfo/test/LHCInfoPerLSAnalyzer_cfg.py @@ -1,5 +1,7 @@ import FWCore.ParameterSet.Config as cms +import sys + process = cms.Process('test') # minimum logging @@ -13,16 +15,20 @@ ) ) + +iov = int(7133383367994638336 if len(sys.argv) < 3 else sys.argv[2]) +print("iov:", iov) + process.source = cms.Source('EmptyIOVSource', - timetype = cms.string('runnumber'), - firstValue = cms.uint64(1), - lastValue = cms.uint64(1), + timetype = cms.string('timestamp'), + firstValue = cms.uint64(iov ), + lastValue = cms.uint64(iov ), interval = cms.uint64(1) ) # load info from database process.load('CondCore.CondDB.CondDB_cfi') -process.CondDB.connect = 'sqlite_file:LHCInfoPerLS.sqlite' # SQLite input +process.CondDB.connect = 'sqlite_file:../python/lhcinfo_pop_test.db' # SQLite input process.PoolDBESSource = cms.ESSource('PoolDBESSource', process.CondDB, @@ -30,7 +36,7 @@ toGet = cms.VPSet( cms.PSet( record = cms.string('LHCInfoPerLSRcd'), - tag = cms.string('LHCInfoPerLSFake') + tag = cms.string('perLS_3_end') ) ) ) From 59248bb45d89bfde7ffd44d2e5f7972fe6778f17 Mon Sep 17 00:00:00 2001 From: Jan Chyczynski Date: Wed, 7 Sep 2022 14:52:11 +0200 Subject: [PATCH 31/39] LHCInfoCombined and its use in CTPPSProtonProducer --- .../ESProducers/python/ctppsLHCInfo_cff.py | 2 + CondFormats/RunInfo/BuildFile.xml | 2 + .../RunInfo/interface/LHCInfoCombined.h | 76 +++++++++++++++++++ CondFormats/RunInfo/src/LHCInfoCombined.cc | 64 ++++++++++++++++ CondFormats/RunInfo/src/headers.h | 3 +- .../plugins/CTPPSProtonProducer.cc | 29 +++++-- .../python/ctppsProtons_cff.py | 2 + 7 files changed, 170 insertions(+), 8 deletions(-) create mode 100644 CondFormats/RunInfo/interface/LHCInfoCombined.h create mode 100644 CondFormats/RunInfo/src/LHCInfoCombined.cc diff --git a/CalibPPS/ESProducers/python/ctppsLHCInfo_cff.py b/CalibPPS/ESProducers/python/ctppsLHCInfo_cff.py index 3403647fe8463..c9c90ba55aca1 100644 --- a/CalibPPS/ESProducers/python/ctppsLHCInfo_cff.py +++ b/CalibPPS/ESProducers/python/ctppsLHCInfo_cff.py @@ -2,6 +2,8 @@ # by default, LHCInfo is now loaded from CondDB using a GT ctppsLHCInfoLabel = cms.string("") +ctppsLHCInfoPerLSLabel = cms.string("") +ctppsLHCInfoPerFillLabel = cms.string("") ## minimal LHCInfo for 2016 data #ctppsLHCInfoLabel = cms.string("ctpps_minimal") diff --git a/CondFormats/RunInfo/BuildFile.xml b/CondFormats/RunInfo/BuildFile.xml index 20474830eeb08..ae9ac304b6e7a 100644 --- a/CondFormats/RunInfo/BuildFile.xml +++ b/CondFormats/RunInfo/BuildFile.xml @@ -5,6 +5,8 @@ + + diff --git a/CondFormats/RunInfo/interface/LHCInfoCombined.h b/CondFormats/RunInfo/interface/LHCInfoCombined.h new file mode 100644 index 0000000000000..308625704473c --- /dev/null +++ b/CondFormats/RunInfo/interface/LHCInfoCombined.h @@ -0,0 +1,76 @@ +#ifndef CondFormats_RunInfo_LHCInfoCombined_H +#define CondFormats_RunInfo_LHCInfoCombined_H + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/ESWatcher.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" + +#include "CondFormats/RunInfo/interface/LHCInfo.h" +#include "CondFormats/RunInfo/interface/LHCInfoPerLS.h" +#include "CondFormats/RunInfo/interface/LHCInfoPerFill.h" + +#include "CondFormats/DataRecord/interface/LHCInfoPerLSRcd.h" +#include "CondFormats/DataRecord/interface/LHCInfoPerFillRcd.h" +#include "CondFormats/DataRecord/interface/LHCInfoRcd.h" + +#include "CondCore/CondDB/interface/Types.h" + +#include +#include +#include +#include +#include + +class LHCInfoCombined { +public: + + LHCInfoCombined() = default; + + LHCInfoCombined(const LHCInfo& lhcInfo); + LHCInfoCombined(const LHCInfoPerLS& infoPerLS, const LHCInfoPerFill& infoPerFill); + LHCInfoCombined(const edm::EventSetup &iSetup, + const edm::ESGetToken& tokenInfoPerLS, + const edm::ESGetToken& tokenInfoPerFill, + const edm::ESGetToken& tokenInfo); + + void setFromLHCInfo(const LHCInfo& lhcInfo); + void setFromPerLS(const LHCInfoPerLS& infoPerLS); + void setFromPerFill(const LHCInfoPerFill& infoPerFill); + + + //getters + float const crossingAngleX() const; + + float const crossingAngleY() const; + + float const betaStarX() const; + + float const betaStarY() const; + + float const energy() const; + + //setters + void setCrossingAngleX(float const& angleX); + + void setCrossingAngleY(float const& angleY); + + void setBetaStarX(float const& betaStarX); + + void setBetaStarY(float const& betaStarY); + + void setEnergy(float const& energy); + +private: + float crossingAngleX_; + float crossingAngleY_; + float betaStarX_; + float betaStarY_; + float energy_; +}; + +#endif // CondFormats_RunInfo_LHCInfoCombined_H diff --git a/CondFormats/RunInfo/src/LHCInfoCombined.cc b/CondFormats/RunInfo/src/LHCInfoCombined.cc new file mode 100644 index 0000000000000..eb61fe121d74f --- /dev/null +++ b/CondFormats/RunInfo/src/LHCInfoCombined.cc @@ -0,0 +1,64 @@ +#include "CondFormats/RunInfo/interface/LHCInfoCombined.h" + +LHCInfoCombined::LHCInfoCombined(const LHCInfo& lhcInfo) { + setFromLHCInfo(lhcInfo); +} + +LHCInfoCombined::LHCInfoCombined(const LHCInfoPerLS& infoPerLS, const LHCInfoPerFill& infoPerFill) { + setFromPerLS(infoPerLS); + setFromPerFill(infoPerFill); +} + +LHCInfoCombined::LHCInfoCombined(const edm::EventSetup &iSetup, + const edm::ESGetToken& tokenInfoPerLS, + const edm::ESGetToken& tokenInfoPerFill, + const edm::ESGetToken& tokenInfo) { + if(true /* era run3 */) { + edm::ESHandle hLHCInfoPerLS = iSetup.getHandle(tokenInfoPerLS); + edm::ESHandle hLHCInfoFill = iSetup.getHandle(tokenInfoPerFill); + setFromPerLS(*hLHCInfoPerLS); + setFromPerFill(*hLHCInfoFill); + } else { + edm::ESHandle hLHCInfo = iSetup.getHandle(tokenInfo); + setFromLHCInfo(*hLHCInfo); + } +} + +void LHCInfoCombined::setFromLHCInfo(const LHCInfo& lhcInfo) { + setCrossingAngleX(lhcInfo.crossingAngle()); + setCrossingAngleY(0); + setBetaStarX(lhcInfo.betaStar()); + setBetaStarY(lhcInfo.betaStar()); + setEnergy(lhcInfo.energy()); +} +void LHCInfoCombined::setFromPerLS(const LHCInfoPerLS& infoPerLS) { + setCrossingAngleX(infoPerLS.crossingAngleX()); + setCrossingAngleY(infoPerLS.crossingAngleY()); + setBetaStarX(infoPerLS.betaStarX()); + setBetaStarY(infoPerLS.betaStarY()); +} +void LHCInfoCombined::setFromPerFill(const LHCInfoPerFill& infoPerFill) { + setEnergy(infoPerFill.energy()); +} + +//getters +float const LHCInfoCombined::crossingAngleX() const { return crossingAngleX_; } + +float const LHCInfoCombined::crossingAngleY() const { return crossingAngleY_; } + +float const LHCInfoCombined::betaStarX() const { return betaStarX_; } + +float const LHCInfoCombined::betaStarY() const { return betaStarY_; } + +float const LHCInfoCombined::energy() const { return energy_; } + +//setters +void LHCInfoCombined::setCrossingAngleX(float const& angleX) { crossingAngleX_ = angleX; } + +void LHCInfoCombined::setCrossingAngleY(float const& angleY) { crossingAngleY_ = angleY; } + +void LHCInfoCombined::setBetaStarX(float const& betaStarX) { betaStarX_ = betaStarX; } + +void LHCInfoCombined::setBetaStarY(float const& betaStarY) { betaStarY_ = betaStarY; } + +void LHCInfoCombined::setEnergy(float const& energy) { energy_ = energy; } \ No newline at end of file diff --git a/CondFormats/RunInfo/src/headers.h b/CondFormats/RunInfo/src/headers.h index ef15ee4eb69c0..8c63538739804 100644 --- a/CondFormats/RunInfo/src/headers.h +++ b/CondFormats/RunInfo/src/headers.h @@ -7,4 +7,5 @@ #include "CondFormats/RunInfo/interface/LHCInfo.h" #include "CondFormats/RunInfo/interface/LHCInfoPerLS.h" #include "CondFormats/RunInfo/interface/LHCInfoPerFill.h" -#include "CondFormats/RunInfo/interface/LHCInfoVectorizedFields.h" \ No newline at end of file +#include "CondFormats/RunInfo/interface/LHCInfoVectorizedFields.h" +#include "CondFormats/RunInfo/interface/LHCInfoCombined.h" \ No newline at end of file diff --git a/RecoPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc b/RecoPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc index 49927283ea0aa..69058044daf3a 100644 --- a/RecoPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc +++ b/RecoPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc @@ -25,6 +25,11 @@ #include "CondFormats/RunInfo/interface/LHCInfo.h" #include "CondFormats/DataRecord/interface/LHCInfoRcd.h" +#include "CondFormats/RunInfo/interface/LHCInfoCombined.h" +#include "CondFormats/RunInfo/interface/LHCInfoPerLS.h" +#include "CondFormats/DataRecord/interface/LHCInfoPerLSRcd.h" +#include "CondFormats/RunInfo/interface/LHCInfoPerFill.h" +#include "CondFormats/DataRecord/interface/LHCInfoPerFillRcd.h" #include "CondFormats/DataRecord/interface/CTPPSInterpolatedOpticsRcd.h" #include "CondFormats/PPSObjects/interface/LHCInterpolatedOpticalFunctionsSetCollection.h" @@ -51,6 +56,8 @@ class CTPPSProtonProducer : public edm::stream::EDProducer<> { bool pixelDiscardBXShiftedTracks_; + std::string lhcInfoPerLSLabel_; + std::string lhcInfoPerFillLabel_; std::string lhcInfoLabel_; std::string opticsLabel_; std::string ppsAssociationCutsLabel_; @@ -73,6 +80,8 @@ class CTPPSProtonProducer : public edm::stream::EDProducer<> { bool opticsValid_; edm::ESWatcher opticsWatcher_; + edm::ESGetToken lhcInfoPerLSToken_; + edm::ESGetToken lhcInfoPerFillToken_; edm::ESGetToken lhcInfoToken_; edm::ESGetToken opticalFunctionsToken_; edm::ESGetToken geometryToken_; @@ -86,6 +95,8 @@ CTPPSProtonProducer::CTPPSProtonProducer(const edm::ParameterSet &iConfig) pixelDiscardBXShiftedTracks_(iConfig.getParameter("pixelDiscardBXShiftedTracks")), + lhcInfoPerLSLabel_(iConfig.getParameter("lhcInfoPerLSLabel")), + lhcInfoPerFillLabel_(iConfig.getParameter("lhcInfoPerFillLabel")), lhcInfoLabel_(iConfig.getParameter("lhcInfoLabel")), opticsLabel_(iConfig.getParameter("opticsLabel")), ppsAssociationCutsLabel_(iConfig.getParameter("ppsAssociationCutsLabel")), @@ -108,6 +119,8 @@ CTPPSProtonProducer::CTPPSProtonProducer(const edm::ParameterSet &iConfig) iConfig.getParameter("multiRPAlgorithm"), verbosity_), opticsValid_(false), + lhcInfoPerLSToken_(esConsumes(edm::ESInputTag("", lhcInfoPerLSLabel_))), + lhcInfoPerFillToken_(esConsumes(edm::ESInputTag("", lhcInfoPerFillLabel_))), lhcInfoToken_(esConsumes(edm::ESInputTag("", lhcInfoLabel_))), opticalFunctionsToken_(esConsumes( edm::ESInputTag("", opticsLabel_))), @@ -132,6 +145,8 @@ void CTPPSProtonProducer::fillDescriptions(edm::ConfigurationDescriptions &descr desc.add("pixelDiscardBXShiftedTracks", false) ->setComment("whether to discard pixel tracks built from BX-shifted planes"); + desc.add("lhcInfoPerFillLabel", "")->setComment("label of the LHCInfoPerFill record"); + desc.add("lhcInfoPerLSLabel", "")->setComment("label of the LHCInfoPerLS record"); desc.add("lhcInfoLabel", "")->setComment("label of the LHCInfo record"); desc.add("opticsLabel", "")->setComment("label of the optics record"); desc.add("ppsAssociationCutsLabel", "")->setComment("label of the association cuts record"); @@ -188,7 +203,7 @@ void CTPPSProtonProducer::produce(edm::Event &iEvent, const edm::EventSetup &iSe // NB: this avoids loading (possibly non-existing) conditions in workflows without proton data if (!hTracks->empty()) { // get conditions - edm::ESHandle hLHCInfo = iSetup.getHandle(lhcInfoToken_); + LHCInfoCombined lhcInfoCombined(iSetup, lhcInfoPerLSToken_, lhcInfoPerFillToken_, lhcInfoToken_); edm::ESHandle hOpticalFunctions = iSetup.getHandle(opticalFunctionsToken_); @@ -264,7 +279,7 @@ void CTPPSProtonProducer::produce(edm::Event &iEvent, const edm::EventSetup &iSe ssLog << std::endl << "* reconstruction from track " << idx << std::endl; singleRPResultsIndexed[idx] = - algorithm_.reconstructFromSingleRP(CTPPSLocalTrackLiteRef(hTracks, idx), *hLHCInfo, ssLog); + algorithm_.reconstructFromSingleRP(CTPPSLocalTrackLiteRef(hTracks, idx), lhcInfoCombined, ssLog); } } @@ -299,14 +314,14 @@ void CTPPSProtonProducer::produce(edm::Event &iEvent, const edm::EventSetup &iSe bool matching = true; - if (!ac.isSatisfied(ac.qX, tr_i.x(), tr_i.y(), hLHCInfo->crossingAngle(), tr_i.x() - tr_j.x())) + if (!ac.isSatisfied(ac.qX, tr_i.x(), tr_i.y(), lhcInfoCombined.crossingAngleX(), tr_i.x() - tr_j.x())) matching = false; - else if (!ac.isSatisfied(ac.qY, tr_i.x(), tr_i.y(), hLHCInfo->crossingAngle(), tr_i.y() - tr_j.y())) + else if (!ac.isSatisfied(ac.qY, tr_i.x(), tr_i.y(), lhcInfoCombined.crossingAngleX(), tr_i.y() - tr_j.y())) matching = false; - else if (!ac.isSatisfied(ac.qXi, tr_i.x(), tr_i.y(), hLHCInfo->crossingAngle(), pr_i.xi() - pr_j.xi())) + else if (!ac.isSatisfied(ac.qXi, tr_i.x(), tr_i.y(), lhcInfoCombined.crossingAngleX(), pr_i.xi() - pr_j.xi())) matching = false; else if (!ac.isSatisfied( - ac.qThetaY, tr_i.x(), tr_i.y(), hLHCInfo->crossingAngle(), pr_i.thetaY() - pr_j.thetaY())) + ac.qThetaY, tr_i.x(), tr_i.y(), lhcInfoCombined.crossingAngleX(), pr_i.thetaY() - pr_j.thetaY())) matching = false; if (!matching) @@ -424,7 +439,7 @@ void CTPPSProtonProducer::produce(edm::Event &iEvent, const edm::EventSetup &iSe ssLog << std::endl << " time = " << time << " +- " << time_unc << std::endl; // process tracking-RP data - reco::ForwardProton proton = algorithm_.reconstructFromMultiRP(sel_track_for_kin_reco, *hLHCInfo, ssLog); + reco::ForwardProton proton = algorithm_.reconstructFromMultiRP(sel_track_for_kin_reco, lhcInfoCombined, ssLog); // save combined output proton.setContributingLocalTracks(sel_tracks); diff --git a/RecoPPS/ProtonReconstruction/python/ctppsProtons_cff.py b/RecoPPS/ProtonReconstruction/python/ctppsProtons_cff.py index 392d72ab12c30..0f340b7a5378d 100644 --- a/RecoPPS/ProtonReconstruction/python/ctppsProtons_cff.py +++ b/RecoPPS/ProtonReconstruction/python/ctppsProtons_cff.py @@ -10,6 +10,8 @@ from RecoPPS.ProtonReconstruction.ctppsProtons_cfi import * ctppsProtons.lhcInfoLabel = ctppsLHCInfoLabel +ctppsProtons.lhcInfoPerLSLabel = ctppsLHCInfoPerLSLabel +ctppsProtons.lhcInfoPerFillLabel = ctppsLHCInfoPerFillLabel ctppsProtons.pixelDiscardBXShiftedTracks = True ctppsProtons.default_time = -999. From f3b82297243686dd65a70d3d6ccf661a8974f7e2 Mon Sep 17 00:00:00 2001 From: Jan Chyczynski Date: Mon, 12 Sep 2022 15:23:15 +0200 Subject: [PATCH 32/39] changed proton reconstruction functions to use only energy instead of lhcInfo --- .../interface/ProtonReconstructionAlgorithm.h | 5 ++--- .../ProtonReconstruction/plugins/CTPPSProtonProducer.cc | 7 ++++--- .../src/ProtonReconstructionAlgorithm.cc | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/RecoPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h b/RecoPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h index dcdad26c8d629..a983b1faf4074 100644 --- a/RecoPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h +++ b/RecoPPS/ProtonReconstruction/interface/ProtonReconstructionAlgorithm.h @@ -12,7 +12,6 @@ #include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLiteFwd.h" #include "DataFormats/ProtonReco/interface/ForwardProtonFwd.h" -#include "CondFormats/RunInfo/interface/LHCInfo.h" #include "CondFormats/PPSObjects/interface/LHCInterpolatedOpticalFunctionsSet.h" #include "CondFormats/PPSObjects/interface/LHCInterpolatedOpticalFunctionsSetCollection.h" @@ -36,12 +35,12 @@ class ProtonReconstructionAlgorithm { /// run proton reconstruction using single-RP strategy reco::ForwardProton reconstructFromSingleRP(const CTPPSLocalTrackLiteRef &track, - const LHCInfo &lhcInfo, + const float &energy, std::ostream &os) const; /// run proton reconstruction using multiple-RP strategy reco::ForwardProton reconstructFromMultiRP(const CTPPSLocalTrackLiteRefVector &tracks, - const LHCInfo &lhcInfo, + const float &energy, std::ostream &os) const; private: diff --git a/RecoPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc b/RecoPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc index 69058044daf3a..ee001d9670bbf 100644 --- a/RecoPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc +++ b/RecoPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc @@ -278,8 +278,8 @@ void CTPPSProtonProducer::produce(edm::Event &iEvent, const edm::EventSetup &iSe if (verbosity_) ssLog << std::endl << "* reconstruction from track " << idx << std::endl; - singleRPResultsIndexed[idx] = - algorithm_.reconstructFromSingleRP(CTPPSLocalTrackLiteRef(hTracks, idx), lhcInfoCombined, ssLog); + singleRPResultsIndexed[idx] = algorithm_.reconstructFromSingleRP(CTPPSLocalTrackLiteRef(hTracks, idx), + lhcInfoCombined.energy(), ssLog); } } @@ -439,7 +439,8 @@ void CTPPSProtonProducer::produce(edm::Event &iEvent, const edm::EventSetup &iSe ssLog << std::endl << " time = " << time << " +- " << time_unc << std::endl; // process tracking-RP data - reco::ForwardProton proton = algorithm_.reconstructFromMultiRP(sel_track_for_kin_reco, lhcInfoCombined, ssLog); + reco::ForwardProton proton = algorithm_.reconstructFromMultiRP(sel_track_for_kin_reco, + lhcInfoCombined.energy(), ssLog); // save combined output proton.setContributingLocalTracks(sel_tracks); diff --git a/RecoPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc b/RecoPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc index 77243b6510a5e..61793b2915af2 100644 --- a/RecoPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc +++ b/RecoPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc @@ -169,7 +169,7 @@ double ProtonReconstructionAlgorithm::newtonGoalFcn(double xi, //---------------------------------------------------------------------------------------------------- reco::ForwardProton ProtonReconstructionAlgorithm::reconstructFromMultiRP(const CTPPSLocalTrackLiteRefVector &tracks, - const LHCInfo &lhcInfo, + const float &energy, std::ostream &os) const { // make sure optics is available for all tracks for (const auto &it : tracks) { @@ -391,7 +391,7 @@ reco::ForwardProton ProtonReconstructionAlgorithm::reconstructFromMultiRP(const const FP::Point vertex(0., vtx_y, 0.); const double cos_th_sq = 1. - th_x * th_x - th_y * th_y; const double cos_th = (cos_th_sq > 0.) ? sqrt(cos_th_sq) : 1.; - const double p = lhcInfo.energy() * (1. - xi); + const double p = energy * (1. - xi); const FP::Vector momentum(-p * th_x, // the signs reflect change LHC --> CMS convention +p * th_y, sign_z * p * cos_th); @@ -403,7 +403,7 @@ reco::ForwardProton ProtonReconstructionAlgorithm::reconstructFromMultiRP(const //---------------------------------------------------------------------------------------------------- reco::ForwardProton ProtonReconstructionAlgorithm::reconstructFromSingleRP(const CTPPSLocalTrackLiteRef &track, - const LHCInfo &lhcInfo, + const float &energy, std::ostream &os) const { CTPPSDetId rpId(track->rpId()); @@ -441,7 +441,7 @@ reco::ForwardProton ProtonReconstructionAlgorithm::reconstructFromSingleRP(const const FP::Point vertex(0., 0., 0.); const double cos_th_sq = 1. - th_y * th_y; const double cos_th = (cos_th_sq > 0.) ? sqrt(cos_th_sq) : 1.; - const double p = lhcInfo.energy() * (1. - xi); + const double p = energy * (1. - xi); const FP::Vector momentum(0., p * th_y, sign_z * p * cos_th); FP::CovarianceMatrix cm; From 1feaa36df2138adc79e5d0d9c9b9e45eab7eefeb Mon Sep 17 00:00:00 2001 From: Jan Chyczynski Date: Fri, 16 Sep 2022 09:41:31 +0200 Subject: [PATCH 33/39] update test_express_AlCaRecoProducer.sh for Run3 --- .../python/ALCARECOPPSCalMaxTracks_cff.py | 9 ++++++--- .../test/test_express_AlCaRecoProducer.sh | 11 +++++++---- .../test/test_prompt_PPSAlCaReco_output.py | 5 +++-- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Calibration/PPSAlCaRecoProducer/python/ALCARECOPPSCalMaxTracks_cff.py b/Calibration/PPSAlCaRecoProducer/python/ALCARECOPPSCalMaxTracks_cff.py index 8aca8139fe15d..9e9b5abfffff8 100644 --- a/Calibration/PPSAlCaRecoProducer/python/ALCARECOPPSCalMaxTracks_cff.py +++ b/Calibration/PPSAlCaRecoProducer/python/ALCARECOPPSCalMaxTracks_cff.py @@ -14,9 +14,12 @@ from EventFilter.CTPPSRawToDigi.ctppsRawToDigi_cff import totemTimingRawToDigi as _totemTimingRawToDigi from EventFilter.CTPPSRawToDigi.ctppsRawToDigi_cff import ctppsPixelDigis as _ctppsPixelDigis -ctppsDiamondRawToDigiAlCaRecoProducer = _ctppsDiamondRawToDigi.clone(rawDataTag = 'hltPPSCalibrationRaw') -totemTimingRawToDigiAlCaRecoProducer = _totemTimingRawToDigi.clone(rawDataTag = 'hltPPSCalibrationRaw') -ctppsPixelDigisAlCaRecoProducer = _ctppsPixelDigis.clone(inputLabel = 'hltPPSCalibrationRaw') +# ctppsDiamondRawToDigiAlCaRecoProducer = _ctppsDiamondRawToDigi.clone(rawDataTag = 'hltPPSCalibrationRaw') +# totemTimingRawToDigiAlCaRecoProducer = _totemTimingRawToDigi.clone(rawDataTag = 'hltPPSCalibrationRaw') +# ctppsPixelDigisAlCaRecoProducer = _ctppsPixelDigis.clone(inputLabel = 'hltPPSCalibrationRaw') +ctppsDiamondRawToDigiAlCaRecoProducer = _ctppsDiamondRawToDigi.clone(rawDataTag = 'rawDataCollector') +totemTimingRawToDigiAlCaRecoProducer = _totemTimingRawToDigi.clone(rawDataTag = 'rawDataCollector') +ctppsPixelDigisAlCaRecoProducer = _ctppsPixelDigis.clone(inputLabel = 'rawDataCollector') ctppsRawToDigiTaskAlCaRecoProducer = cms.Task( ctppsDiamondRawToDigiAlCaRecoProducer, diff --git a/Calibration/PPSAlCaRecoProducer/test/test_express_AlCaRecoProducer.sh b/Calibration/PPSAlCaRecoProducer/test/test_express_AlCaRecoProducer.sh index 3f4698792197f..ac7f8a0caba12 100755 --- a/Calibration/PPSAlCaRecoProducer/test/test_express_AlCaRecoProducer.sh +++ b/Calibration/PPSAlCaRecoProducer/test/test_express_AlCaRecoProducer.sh @@ -2,11 +2,14 @@ function die { echo $1: status $2; exit $2; } customise_commands="process.GlobalTag.toGet = cms.VPSet()\ +\nprocess.GlobalTag.toGet.append(cms.PSet(record = cms.string(\"LHCInfoPerLSRcd\"),tag = cms.string(\"LHCInfoPerLS_end_2\"), connect = cms.string(\"sqlite_file:/eos/home-j/jchyczyn/new/CMSSW_12_5_0_pre3/src/CondTools/RunInfo/python/lhcinfo_pop_test.db\")))\ +\nprocess.GlobalTag.toGet.append(cms.PSet(record = cms.string(\"LHCInfoPerFillRcd\"),tag = cms.string(\"LHCInfoPerFill_end_2\"), connect = cms.string(\"sqlite_file:/eos/home-j/jchyczyn/new/CMSSW_12_5_0_pre3/src/CondTools/RunInfo/python/lhcinfo_pop_test.db\")))\ +\nprocess.GlobalTag.toGet.append(cms.PSet(record = cms.string(\"LHCInfoRcd\"),tag = cms.string(\"LHCInfo_end_2\"), connect = cms.string(\"sqlite_file:/eos/home-j/jchyczyn/new/CMSSW_12_5_0_pre3/src/CondTools/RunInfo/python/lhcinfo_pop_test.db\")))\ \nprocess.GlobalTag.toGet.append(cms.PSet(record = cms.string(\"AlCaRecoTriggerBitsRcd\"),tag = cms.string(\"AlCaRecoHLTpaths_PPS2022_express_v1\"), connect = cms.string(\"frontier://FrontierProd/CMS_CONDITIONS\")))\ -\nprocess.GlobalTag.toGet.append(cms.PSet(record = cms.string(\"PPSTimingCalibrationLUTRcd\"),tag = cms.string(\"PPSDiamondTimingCalibrationLUT_test\"), connect = cms.string(\"frontier://FrontierProd/CMS_CONDITIONS\")))\ -\nprocess.ALCARECOPPSCalMaxTracksFilter.TriggerResultsTag = cms.InputTag(\"TriggerResults\",\"\",\"HLTX\")" +\nprocess.GlobalTag.toGet.append(cms.PSet(record = cms.string(\"PPSTimingCalibrationLUTRcd\"),tag = cms.string(\"PPSDiamondTimingCalibrationLUT_test\"), connect = cms.string(\"frontier://FrontierProd/CMS_CONDITIONS\")))" +# \nprocess.ALCARECOPPSCalMaxTracksFilter.TriggerResultsTag = cms.InputTag(\"TriggerResults\",\"\",\"HLT\")" -INPUTFILE="/store/group/alca_global/pps_alcareco_producer_tests/outputALCAPPS_single.root" +INPUTFILE="/store/data/Run2022C/ZeroBias/RAW/v1/000/356/615/00000/a4076bff-3bec-459e-bd44-b66538bf5c2b.root" COMMMAND=`xrdfs cms-xrd-global.cern.ch locate $INPUTFILE` STATUS=$? echo "xrdfs command status = "$STATUS @@ -15,7 +18,7 @@ if [ $STATUS -eq 0 ]; then (cmsDriver.py testExpressPPSAlCaRecoProducer -s ALCAPRODUCER:PPSCalMaxTracks,ENDJOB \ --process ALCARECO \ --scenario pp \ - --era ctpps_2018 \ + --era run3_HB \ --conditions auto:run3_data_express \ --data \ --datatier ALCARECO \ diff --git a/Calibration/PPSAlCaRecoProducer/test/test_prompt_PPSAlCaReco_output.py b/Calibration/PPSAlCaRecoProducer/test/test_prompt_PPSAlCaReco_output.py index 9b61d494952b7..cc296881a5d67 100644 --- a/Calibration/PPSAlCaRecoProducer/test/test_prompt_PPSAlCaReco_output.py +++ b/Calibration/PPSAlCaRecoProducer/test/test_prompt_PPSAlCaReco_output.py @@ -1,9 +1,10 @@ import FWCore.ParameterSet.Config as cms # load era modifier to run on 2018 data -from Configuration.Eras.Modifier_ctpps_2018_cff import ctpps_2018 +# from Configuration.Eras.Modifier_ctpps_2018_cff import ctpps_2018 +from Configuration.Eras.Modifier_ctpps_2022_cff import ctpps_2022 -process = cms.Process( 'TEST',ctpps_2018) +process = cms.Process( 'TEST',ctpps_2022) # LHCInfo plotter process.load("Validation.CTPPS.ctppsLHCInfoPlotter_cfi") From 23597a20c9c62e6a560fe6319ce50e9a21b05b6a Mon Sep 17 00:00:00 2001 From: Jan Chyczynski Date: Fri, 16 Sep 2022 15:08:20 +0200 Subject: [PATCH 34/39] added print to LHCInfoCombined --- CondFormats/RunInfo/interface/LHCInfoCombined.h | 4 ++++ CondFormats/RunInfo/src/LHCInfoCombined.cc | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CondFormats/RunInfo/interface/LHCInfoCombined.h b/CondFormats/RunInfo/interface/LHCInfoCombined.h index 308625704473c..456a7e964c826 100644 --- a/CondFormats/RunInfo/interface/LHCInfoCombined.h +++ b/CondFormats/RunInfo/interface/LHCInfoCombined.h @@ -65,6 +65,8 @@ class LHCInfoCombined { void setEnergy(float const& energy); + void print(std::stringstream& ss) const; + private: float crossingAngleX_; float crossingAngleY_; @@ -73,4 +75,6 @@ class LHCInfoCombined { float energy_; }; +std::ostream& operator<<(std::ostream& os, LHCInfoCombined beamInfo); + #endif // CondFormats_RunInfo_LHCInfoCombined_H diff --git a/CondFormats/RunInfo/src/LHCInfoCombined.cc b/CondFormats/RunInfo/src/LHCInfoCombined.cc index eb61fe121d74f..2c0002651d93b 100644 --- a/CondFormats/RunInfo/src/LHCInfoCombined.cc +++ b/CondFormats/RunInfo/src/LHCInfoCombined.cc @@ -61,4 +61,19 @@ void LHCInfoCombined::setBetaStarX(float const& betaStarX) { betaStarX_ = betaSt void LHCInfoCombined::setBetaStarY(float const& betaStarY) { betaStarY_ = betaStarY; } -void LHCInfoCombined::setEnergy(float const& energy) { energy_ = energy; } \ No newline at end of file +void LHCInfoCombined::setEnergy(float const& energy) { energy_ = energy; } + +void LHCInfoCombined::print(std::stringstream& ss) const { + ss << "Crossing angle x (urad): " << this->crossingAngleX() << std::endl + << "Crossing angle y (urad): " << this->crossingAngleY() << std::endl + << "Beta star x (m): " << this->betaStarX() << std::endl + << "Beta star y (m): " << this->betaStarY() << std::endl + << "Energy (GeV): " << this->energy() << std::endl; +} + +std::ostream& operator<<(std::ostream& os, LHCInfoCombined beamInfo) { + std::stringstream ss; + beamInfo.print(ss); + os << ss.str(); + return os; +} From 5e99b08c1b33903b7cb69897024e4a942012e7ca Mon Sep 17 00:00:00 2001 From: Jan Chyczynski Date: Fri, 16 Sep 2022 15:09:31 +0200 Subject: [PATCH 35/39] printing debug info in CTPPSProtonProducer --- .../python/ALCARECOPPSCalMaxTracks_cff.py | 5 ++++- .../ProtonReconstruction/plugins/CTPPSProtonProducer.cc | 7 +++++++ RecoPPS/ProtonReconstruction/python/ctppsProtons_cff.py | 3 +++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Calibration/PPSAlCaRecoProducer/python/ALCARECOPPSCalMaxTracks_cff.py b/Calibration/PPSAlCaRecoProducer/python/ALCARECOPPSCalMaxTracks_cff.py index 9e9b5abfffff8..edb5894ff9f91 100644 --- a/Calibration/PPSAlCaRecoProducer/python/ALCARECOPPSCalMaxTracks_cff.py +++ b/Calibration/PPSAlCaRecoProducer/python/ALCARECOPPSCalMaxTracks_cff.py @@ -1,3 +1,5 @@ +print("in file ALCARECOPPSCalMaxTracks_cff.py") + import FWCore.ParameterSet.Config as cms # 1. HLT filter @@ -88,7 +90,8 @@ ) from RecoPPS.ProtonReconstruction.ctppsProtons_cff import ctppsProtons as _ctppsProtons -ctppsProtonsAlCaRecoProducer = _ctppsProtons.clone(tagLocalTrackLite = 'ctppsLocalTrackLiteProducerAlCaRecoProducer') +ctppsProtonsAlCaRecoProducer = _ctppsProtons.clone(tagLocalTrackLite = 'ctppsLocalTrackLiteProducerAlCaRecoProducer', +verbosity = cms.untracked.uint32(2)) # 5. RECO - final task assembly #------------------------------------------------------ diff --git a/RecoPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc b/RecoPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc index ee001d9670bbf..fbf246577b6d4 100644 --- a/RecoPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc +++ b/RecoPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc @@ -127,6 +127,8 @@ CTPPSProtonProducer::CTPPSProtonProducer(const edm::ParameterSet &iConfig) geometryToken_(esConsumes()), ppsAssociationCutsToken_( esConsumes(edm::ESInputTag("", ppsAssociationCutsLabel_))) { + edm::LogWarning("CTPPSProtonProducer") << "consturcting CTPPSProtonProducer"; + if (doSingleRPReconstruction_) produces(singleRPReconstructionLabel_); @@ -205,6 +207,8 @@ void CTPPSProtonProducer::produce(edm::Event &iEvent, const edm::EventSetup &iSe // get conditions LHCInfoCombined lhcInfoCombined(iSetup, lhcInfoPerLSToken_, lhcInfoPerFillToken_, lhcInfoToken_); + edm::LogWarning("CTPPSProtonProducer") << "LHCInfoCombined: \n" << lhcInfoCombined; + edm::ESHandle hOpticalFunctions = iSetup.getHandle(opticalFunctionsToken_); @@ -461,6 +465,9 @@ void CTPPSProtonProducer::produce(edm::Event &iEvent, const edm::EventSetup &iSe edm::LogInfo("CTPPSProtonProducer") << ssLog.str(); } } + else { + edm::LogWarning("CTPPSProtonProducer") << "tracks already exists, not using LHCInfoCombined"; + } // save output if (doSingleRPReconstruction_) diff --git a/RecoPPS/ProtonReconstruction/python/ctppsProtons_cff.py b/RecoPPS/ProtonReconstruction/python/ctppsProtons_cff.py index 0f340b7a5378d..6e9a8fcae7fe8 100644 --- a/RecoPPS/ProtonReconstruction/python/ctppsProtons_cff.py +++ b/RecoPPS/ProtonReconstruction/python/ctppsProtons_cff.py @@ -9,6 +9,9 @@ # import and adjust proton-reconstructions settings from RecoPPS.ProtonReconstruction.ctppsProtons_cfi import * +print("in file ctppsProtons_cfi") +# print(ctppsProtons) + ctppsProtons.lhcInfoLabel = ctppsLHCInfoLabel ctppsProtons.lhcInfoPerLSLabel = ctppsLHCInfoPerLSLabel ctppsProtons.lhcInfoPerFillLabel = ctppsLHCInfoPerFillLabel From 11ccfd7c8fabb9490cb5a4ff191e74a15418451b Mon Sep 17 00:00:00 2001 From: Jan Chyczynski Date: Tue, 20 Sep 2022 14:13:25 +0200 Subject: [PATCH 36/39] CTPPSProton debug changed from LogInfo to LogWarning, energy debug print added --- .../plugins/CTPPSProtonProducer.cc | 20 ++++++++++++++++--- .../src/ProtonReconstructionAlgorithm.cc | 2 ++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/RecoPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc b/RecoPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc index fbf246577b6d4..1d464e75578fc 100644 --- a/RecoPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc +++ b/RecoPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc @@ -100,7 +100,7 @@ CTPPSProtonProducer::CTPPSProtonProducer(const edm::ParameterSet &iConfig) lhcInfoLabel_(iConfig.getParameter("lhcInfoLabel")), opticsLabel_(iConfig.getParameter("opticsLabel")), ppsAssociationCutsLabel_(iConfig.getParameter("ppsAssociationCutsLabel")), - verbosity_(iConfig.getUntrackedParameter("verbosity", 0)), + verbosity_(iConfig.getUntrackedParameter("verbosity", 2)), doSingleRPReconstruction_(iConfig.getParameter("doSingleRPReconstruction")), doMultiRPReconstruction_(iConfig.getParameter("doMultiRPReconstruction")), singleRPReconstructionLabel_(iConfig.getParameter("singleRPReconstructionLabel")), @@ -208,6 +208,8 @@ void CTPPSProtonProducer::produce(edm::Event &iEvent, const edm::EventSetup &iSe LHCInfoCombined lhcInfoCombined(iSetup, lhcInfoPerLSToken_, lhcInfoPerFillToken_, lhcInfoToken_); edm::LogWarning("CTPPSProtonProducer") << "LHCInfoCombined: \n" << lhcInfoCombined; + edm::LogWarning("CTPPSProtonProducer") << "LogWarning test"; + edm::ESHandle hOpticalFunctions = iSetup.getHandle(opticalFunctionsToken_); @@ -219,7 +221,7 @@ void CTPPSProtonProducer::produce(edm::Event &iEvent, const edm::EventSetup &iSe // re-initialise algorithm upon crossing-angle change if (opticsWatcher_.check(iSetup)) { if (hOpticalFunctions->empty()) { - edm::LogInfo("CTPPSProtonProducer") << "No optical functions available, reconstruction disabled."; + edm::LogWarning("CTPPSProtonProducer") << "No optical functions available, reconstruction disabled."; algorithm_.release(); opticsValid_ = false; } else { @@ -230,6 +232,7 @@ void CTPPSProtonProducer::produce(edm::Event &iEvent, const edm::EventSetup &iSe // do reconstruction only if optics is valid if (opticsValid_) { + edm::LogWarning("CTPPSProtonProducer") << "optics valid"; // prepare log std::ostringstream ssLog; if (verbosity_) @@ -286,6 +289,9 @@ void CTPPSProtonProducer::produce(edm::Event &iEvent, const edm::EventSetup &iSe lhcInfoCombined.energy(), ssLog); } } + else { + edm::LogWarning("CTPPSProtonProducer") << "Not executing reconstructFromSingleRP"; + } // check that exactly two tracking RPs are involved // - 1 is insufficient for multi-RP reconstruction @@ -296,6 +302,7 @@ void CTPPSProtonProducer::produce(edm::Event &iEvent, const edm::EventSetup &iSe // do multi-RP reco if chosen if (doMultiRPReconstruction_ && rpIds.size() == 2) { + // find matching track pairs from different tracking RPs, ordered: i=near, j=far RP std::vector> idx_pairs; std::map idx_pair_multiplicity; @@ -454,6 +461,9 @@ void CTPPSProtonProducer::produce(edm::Event &iEvent, const edm::EventSetup &iSe pOutMultiRP->emplace_back(proton); } } + else { + edm::LogWarning("CTPPSProtonProducer") << "Not executing reconstructFromMultiRP"; + } // save single-RP results (un-indexed) for (const auto &p : singleRPResultsIndexed) @@ -462,8 +472,12 @@ void CTPPSProtonProducer::produce(edm::Event &iEvent, const edm::EventSetup &iSe // dump log if (verbosity_) - edm::LogInfo("CTPPSProtonProducer") << ssLog.str(); + edm::LogWarning("CTPPSProtonProducer") << ssLog.str(); } + else { + edm::LogWarning("CTPPSProtonProducer") << "optics invalid"; + } + } else { edm::LogWarning("CTPPSProtonProducer") << "tracks already exists, not using LHCInfoCombined"; diff --git a/RecoPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc b/RecoPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc index 61793b2915af2..b65081423cf76 100644 --- a/RecoPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc +++ b/RecoPPS/ProtonReconstruction/src/ProtonReconstructionAlgorithm.cc @@ -392,6 +392,7 @@ reco::ForwardProton ProtonReconstructionAlgorithm::reconstructFromMultiRP(const const double cos_th_sq = 1. - th_x * th_x - th_y * th_y; const double cos_th = (cos_th_sq > 0.) ? sqrt(cos_th_sq) : 1.; const double p = energy * (1. - xi); + edm::LogWarning("ProtonRecoAlgo") << "Energy: " << energy << " hexfloat: " << std::hexfloat << energy; const FP::Vector momentum(-p * th_x, // the signs reflect change LHC --> CMS convention +p * th_y, sign_z * p * cos_th); @@ -442,6 +443,7 @@ reco::ForwardProton ProtonReconstructionAlgorithm::reconstructFromSingleRP(const const double cos_th_sq = 1. - th_y * th_y; const double cos_th = (cos_th_sq > 0.) ? sqrt(cos_th_sq) : 1.; const double p = energy * (1. - xi); + edm::LogWarning("ProtonRecoAlgo") << "Energy: " << energy << " hexfloat: " << std::hexfloat << energy; const FP::Vector momentum(0., p * th_y, sign_z * p * cos_th); FP::CovarianceMatrix cm; From 9545c4427cb4f64c30d954b05ef55ccef5ad3ab2 Mon Sep 17 00:00:00 2001 From: Jan Chyczynski Date: Wed, 21 Sep 2022 11:28:45 +0200 Subject: [PATCH 37/39] added optics file to test_express_AlCaRecoProducer.sh --- .../PPSAlCaRecoProducer/test/test_express_AlCaRecoProducer.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Calibration/PPSAlCaRecoProducer/test/test_express_AlCaRecoProducer.sh b/Calibration/PPSAlCaRecoProducer/test/test_express_AlCaRecoProducer.sh index ac7f8a0caba12..83f37d797cedc 100755 --- a/Calibration/PPSAlCaRecoProducer/test/test_express_AlCaRecoProducer.sh +++ b/Calibration/PPSAlCaRecoProducer/test/test_express_AlCaRecoProducer.sh @@ -3,6 +3,7 @@ function die { echo $1: status $2; exit $2; } customise_commands="process.GlobalTag.toGet = cms.VPSet()\ \nprocess.GlobalTag.toGet.append(cms.PSet(record = cms.string(\"LHCInfoPerLSRcd\"),tag = cms.string(\"LHCInfoPerLS_end_2\"), connect = cms.string(\"sqlite_file:/eos/home-j/jchyczyn/new/CMSSW_12_5_0_pre3/src/CondTools/RunInfo/python/lhcinfo_pop_test.db\")))\ +\nprocess.GlobalTag.toGet.append(cms.PSet(record = cms.string(\"CTPPSOpticsRcd\"),tag = cms.string(\"PPSOpticalFunctions_test\"), connect = cms.string(\"sqlite_file:/afs/cern.ch/user/w/wcarvalh/public/CTPPS/optical_functions/validation/Aug22/PPSOpticalFunctions_singleIOV_2022_with_verticals.db\")))\ \nprocess.GlobalTag.toGet.append(cms.PSet(record = cms.string(\"LHCInfoPerFillRcd\"),tag = cms.string(\"LHCInfoPerFill_end_2\"), connect = cms.string(\"sqlite_file:/eos/home-j/jchyczyn/new/CMSSW_12_5_0_pre3/src/CondTools/RunInfo/python/lhcinfo_pop_test.db\")))\ \nprocess.GlobalTag.toGet.append(cms.PSet(record = cms.string(\"LHCInfoRcd\"),tag = cms.string(\"LHCInfo_end_2\"), connect = cms.string(\"sqlite_file:/eos/home-j/jchyczyn/new/CMSSW_12_5_0_pre3/src/CondTools/RunInfo/python/lhcinfo_pop_test.db\")))\ \nprocess.GlobalTag.toGet.append(cms.PSet(record = cms.string(\"AlCaRecoTriggerBitsRcd\"),tag = cms.string(\"AlCaRecoHLTpaths_PPS2022_express_v1\"), connect = cms.string(\"frontier://FrontierProd/CMS_CONDITIONS\")))\ @@ -10,6 +11,7 @@ customise_commands="process.GlobalTag.toGet = cms.VPSet()\ # \nprocess.ALCARECOPPSCalMaxTracksFilter.TriggerResultsTag = cms.InputTag(\"TriggerResults\",\"\",\"HLT\")" INPUTFILE="/store/data/Run2022C/ZeroBias/RAW/v1/000/356/615/00000/a4076bff-3bec-459e-bd44-b66538bf5c2b.root" +# INPUTFILE="/store/group/alca_global/pps_alcareco_producer_tests/outputALCAPPS_single.root" COMMMAND=`xrdfs cms-xrd-global.cern.ch locate $INPUTFILE` STATUS=$? echo "xrdfs command status = "$STATUS @@ -24,7 +26,7 @@ if [ $STATUS -eq 0 ]; then --datatier ALCARECO \ --eventcontent ALCARECO \ --nThreads 8 \ - --number 100 --filein ${INPUTFILE} \ + --number 10000 --filein ${INPUTFILE} \ --fileout file:outputALCAPPS_RECO_express.root \ --customise_commands="$customise_commands") || die 'failed running test_express_AlCaRecoProducer' $? else From d334850f02b3027c0943b09d1ff5ca05614b637e Mon Sep 17 00:00:00 2001 From: Jan Chyczynski Date: Wed, 21 Sep 2022 15:12:02 +0200 Subject: [PATCH 38/39] removed getters and setters from LHCInfoCombined --- .../RunInfo/interface/LHCInfoCombined.h | 34 ++---------- CondFormats/RunInfo/src/LHCInfoCombined.cc | 52 ++++++------------- .../plugins/CTPPSProtonProducer.cc | 12 ++--- 3 files changed, 26 insertions(+), 72 deletions(-) diff --git a/CondFormats/RunInfo/interface/LHCInfoCombined.h b/CondFormats/RunInfo/interface/LHCInfoCombined.h index 456a7e964c826..82194b12ccce0 100644 --- a/CondFormats/RunInfo/interface/LHCInfoCombined.h +++ b/CondFormats/RunInfo/interface/LHCInfoCombined.h @@ -42,37 +42,13 @@ class LHCInfoCombined { void setFromPerLS(const LHCInfoPerLS& infoPerLS); void setFromPerFill(const LHCInfoPerFill& infoPerFill); - - //getters - float const crossingAngleX() const; - - float const crossingAngleY() const; - - float const betaStarX() const; - - float const betaStarY() const; - - float const energy() const; - - //setters - void setCrossingAngleX(float const& angleX); - - void setCrossingAngleY(float const& angleY); - - void setBetaStarX(float const& betaStarX); - - void setBetaStarY(float const& betaStarY); - - void setEnergy(float const& energy); + float crossingAngleX; + float crossingAngleY; + float betaStarX; + float betaStarY; + float energy; void print(std::stringstream& ss) const; - -private: - float crossingAngleX_; - float crossingAngleY_; - float betaStarX_; - float betaStarY_; - float energy_; }; std::ostream& operator<<(std::ostream& os, LHCInfoCombined beamInfo); diff --git a/CondFormats/RunInfo/src/LHCInfoCombined.cc b/CondFormats/RunInfo/src/LHCInfoCombined.cc index 2c0002651d93b..550892621f038 100644 --- a/CondFormats/RunInfo/src/LHCInfoCombined.cc +++ b/CondFormats/RunInfo/src/LHCInfoCombined.cc @@ -25,50 +25,28 @@ LHCInfoCombined::LHCInfoCombined(const edm::EventSetup &iSetup, } void LHCInfoCombined::setFromLHCInfo(const LHCInfo& lhcInfo) { - setCrossingAngleX(lhcInfo.crossingAngle()); - setCrossingAngleY(0); - setBetaStarX(lhcInfo.betaStar()); - setBetaStarY(lhcInfo.betaStar()); - setEnergy(lhcInfo.energy()); + crossingAngleX = lhcInfo.crossingAngle(); + crossingAngleY = 0; + betaStarX = lhcInfo.betaStar(); + betaStarY = lhcInfo.betaStar(); + energy = lhcInfo.energy(); } void LHCInfoCombined::setFromPerLS(const LHCInfoPerLS& infoPerLS) { - setCrossingAngleX(infoPerLS.crossingAngleX()); - setCrossingAngleY(infoPerLS.crossingAngleY()); - setBetaStarX(infoPerLS.betaStarX()); - setBetaStarY(infoPerLS.betaStarY()); + crossingAngleX = infoPerLS.crossingAngleX(); + crossingAngleY = infoPerLS.crossingAngleY(); + betaStarX = infoPerLS.betaStarX(); + betaStarY = infoPerLS.betaStarY(); } void LHCInfoCombined::setFromPerFill(const LHCInfoPerFill& infoPerFill) { - setEnergy(infoPerFill.energy()); + energy = infoPerFill.energy(); } -//getters -float const LHCInfoCombined::crossingAngleX() const { return crossingAngleX_; } - -float const LHCInfoCombined::crossingAngleY() const { return crossingAngleY_; } - -float const LHCInfoCombined::betaStarX() const { return betaStarX_; } - -float const LHCInfoCombined::betaStarY() const { return betaStarY_; } - -float const LHCInfoCombined::energy() const { return energy_; } - -//setters -void LHCInfoCombined::setCrossingAngleX(float const& angleX) { crossingAngleX_ = angleX; } - -void LHCInfoCombined::setCrossingAngleY(float const& angleY) { crossingAngleY_ = angleY; } - -void LHCInfoCombined::setBetaStarX(float const& betaStarX) { betaStarX_ = betaStarX; } - -void LHCInfoCombined::setBetaStarY(float const& betaStarY) { betaStarY_ = betaStarY; } - -void LHCInfoCombined::setEnergy(float const& energy) { energy_ = energy; } - void LHCInfoCombined::print(std::stringstream& ss) const { - ss << "Crossing angle x (urad): " << this->crossingAngleX() << std::endl - << "Crossing angle y (urad): " << this->crossingAngleY() << std::endl - << "Beta star x (m): " << this->betaStarX() << std::endl - << "Beta star y (m): " << this->betaStarY() << std::endl - << "Energy (GeV): " << this->energy() << std::endl; + ss << "Crossing angle x (urad): " << crossingAngleX << std::endl + << "Crossing angle y (urad): " << crossingAngleY << std::endl + << "Beta star x (m): " << betaStarX << std::endl + << "Beta star y (m): " << betaStarY << std::endl + << "Energy (GeV): " << energy << std::endl; } std::ostream& operator<<(std::ostream& os, LHCInfoCombined beamInfo) { diff --git a/RecoPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc b/RecoPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc index 1d464e75578fc..a387690392369 100644 --- a/RecoPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc +++ b/RecoPPS/ProtonReconstruction/plugins/CTPPSProtonProducer.cc @@ -286,7 +286,7 @@ void CTPPSProtonProducer::produce(edm::Event &iEvent, const edm::EventSetup &iSe ssLog << std::endl << "* reconstruction from track " << idx << std::endl; singleRPResultsIndexed[idx] = algorithm_.reconstructFromSingleRP(CTPPSLocalTrackLiteRef(hTracks, idx), - lhcInfoCombined.energy(), ssLog); + lhcInfoCombined.energy, ssLog); } } else { @@ -325,14 +325,14 @@ void CTPPSProtonProducer::produce(edm::Event &iEvent, const edm::EventSetup &iSe bool matching = true; - if (!ac.isSatisfied(ac.qX, tr_i.x(), tr_i.y(), lhcInfoCombined.crossingAngleX(), tr_i.x() - tr_j.x())) + if (!ac.isSatisfied(ac.qX, tr_i.x(), tr_i.y(), lhcInfoCombined.crossingAngleX, tr_i.x() - tr_j.x())) matching = false; - else if (!ac.isSatisfied(ac.qY, tr_i.x(), tr_i.y(), lhcInfoCombined.crossingAngleX(), tr_i.y() - tr_j.y())) + else if (!ac.isSatisfied(ac.qY, tr_i.x(), tr_i.y(), lhcInfoCombined.crossingAngleX, tr_i.y() - tr_j.y())) matching = false; - else if (!ac.isSatisfied(ac.qXi, tr_i.x(), tr_i.y(), lhcInfoCombined.crossingAngleX(), pr_i.xi() - pr_j.xi())) + else if (!ac.isSatisfied(ac.qXi, tr_i.x(), tr_i.y(), lhcInfoCombined.crossingAngleX, pr_i.xi() - pr_j.xi())) matching = false; else if (!ac.isSatisfied( - ac.qThetaY, tr_i.x(), tr_i.y(), lhcInfoCombined.crossingAngleX(), pr_i.thetaY() - pr_j.thetaY())) + ac.qThetaY, tr_i.x(), tr_i.y(), lhcInfoCombined.crossingAngleX, pr_i.thetaY() - pr_j.thetaY())) matching = false; if (!matching) @@ -451,7 +451,7 @@ void CTPPSProtonProducer::produce(edm::Event &iEvent, const edm::EventSetup &iSe // process tracking-RP data reco::ForwardProton proton = algorithm_.reconstructFromMultiRP(sel_track_for_kin_reco, - lhcInfoCombined.energy(), ssLog); + lhcInfoCombined.energy, ssLog); // save combined output proton.setContributingLocalTracks(sel_tracks); From ad057e88a4dc68999a5984110db35a18e5b175ae Mon Sep 17 00:00:00 2001 From: Jan Chyczynski Date: Fri, 23 Sep 2022 14:47:52 +0200 Subject: [PATCH 39/39] removed the new records from dlasses_def.xml --- CondFormats/RunInfo/src/classes_def.xml | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/CondFormats/RunInfo/src/classes_def.xml b/CondFormats/RunInfo/src/classes_def.xml index e5e867d6c3e5c..7e9910b7e080b 100644 --- a/CondFormats/RunInfo/src/classes_def.xml +++ b/CondFormats/RunInfo/src/classes_def.xml @@ -22,22 +22,4 @@ - - - - - - - - - - - - - - - - - -