From 583f2c23836835972f25eab1a8e06b1caa76e3ca Mon Sep 17 00:00:00 2001 From: Jan Chyczynski Date: Fri, 23 Sep 2022 14:47:52 +0200 Subject: [PATCH] PPS_definitions_of_LHCInfoPerFill_and_LHCInfoPerLS_records --- CondCore/RunInfoPlugins/src/plugin.cc | 6 + CondCore/Utilities/plugins/Module_2XML.cc | 2 + CondCore/Utilities/src/CondFormats.h | 3 + .../DataRecord/interface/LHCInfoPerFillRcd.h | 25 + .../DataRecord/interface/LHCInfoPerLSRcd.h | 26 + .../DataRecord/src/LHCInfoPerFillRcd.cc | 15 + CondFormats/DataRecord/src/LHCInfoPerLSRcd.cc | 16 + CondFormats/RunInfo/BuildFile.xml | 1 + .../RunInfo/interface/LHCInfoPerFill.h | 244 +++++++++ CondFormats/RunInfo/interface/LHCInfoPerLS.h | 74 +++ .../interface/LHCInfoVectorizedFields.h | 44 ++ CondFormats/RunInfo/src/LHCInfoPerFill.cc | 485 ++++++++++++++++++ CondFormats/RunInfo/src/LHCInfoPerLS.cc | 100 ++++ .../RunInfo/src/LHCInfoVectorizedFields.cc | 99 ++++ .../src/T_EventSetup_LHCInfoPerFill.cc | 4 + .../RunInfo/src/T_EventSetup_LHCInfoPerLS.cc | 4 + CondFormats/RunInfo/src/headers.h | 3 + .../RunInfo/test/testSerializationRunInfo.cpp | 3 + CondTools/RunInfo/plugins/BuildFile.xml | 17 + .../RunInfo/plugins/LHCInfoPerFillAnalyzer.cc | 42 ++ .../RunInfo/plugins/LHCInfoPerFillWriter.cc | 63 +++ .../RunInfo/plugins/LHCInfoPerLSAnalyzer.cc | 42 ++ .../RunInfo/plugins/LHCInfoPerLSWriter.cc | 47 ++ .../test/LHCInfoPerFillAnalyzer_cfg.py | 42 ++ .../RunInfo/test/LHCInfoPerFillWriter_cfg.py | 31 ++ .../RunInfo/test/LHCInfoPerLSAnalyzer_cfg.py | 42 ++ .../RunInfo/test/LHCInfoPerLSWriter_cfg.py | 31 ++ 27 files changed, 1511 insertions(+) create mode 100644 CondFormats/DataRecord/interface/LHCInfoPerFillRcd.h create mode 100644 CondFormats/DataRecord/interface/LHCInfoPerLSRcd.h create mode 100644 CondFormats/DataRecord/src/LHCInfoPerFillRcd.cc create mode 100644 CondFormats/DataRecord/src/LHCInfoPerLSRcd.cc create mode 100644 CondFormats/RunInfo/interface/LHCInfoPerFill.h create mode 100644 CondFormats/RunInfo/interface/LHCInfoPerLS.h create mode 100644 CondFormats/RunInfo/interface/LHCInfoVectorizedFields.h create mode 100644 CondFormats/RunInfo/src/LHCInfoPerFill.cc create mode 100644 CondFormats/RunInfo/src/LHCInfoPerLS.cc create mode 100644 CondFormats/RunInfo/src/LHCInfoVectorizedFields.cc create mode 100644 CondFormats/RunInfo/src/T_EventSetup_LHCInfoPerFill.cc create mode 100644 CondFormats/RunInfo/src/T_EventSetup_LHCInfoPerLS.cc 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/CondCore/RunInfoPlugins/src/plugin.cc b/CondCore/RunInfoPlugins/src/plugin.cc index 519e4fac7eb30..a7821a6a4dd64 100644 --- a/CondCore/RunInfoPlugins/src/plugin.cc +++ b/CondCore/RunInfoPlugins/src/plugin.cc @@ -10,6 +10,10 @@ #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" +#include "CondFormats/DataRecord/interface/LHCInfoPerFillRcd.h" +#include "CondFormats/RunInfo/interface/LHCInfoPerFill.h" REGISTER_PLUGIN(RunSummaryRcd, RunSummary); REGISTER_PLUGIN(RunInfoRcd, RunInfo); @@ -17,3 +21,5 @@ REGISTER_PLUGIN(L1TriggerScalerRcd, L1TriggerScaler); REGISTER_PLUGIN(MixingRcd, MixingModuleConfig); REGISTER_PLUGIN(FillInfoRcd, FillInfo); REGISTER_PLUGIN(LHCInfoRcd, LHCInfo); +REGISTER_PLUGIN(LHCInfoPerLSRcd, LHCInfoPerLS); +REGISTER_PLUGIN(LHCInfoPerFillRcd, LHCInfoPerFill); \ No newline at end of file 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" 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/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/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/DataRecord/src/LHCInfoPerLSRcd.cc b/CondFormats/DataRecord/src/LHCInfoPerLSRcd.cc new file mode 100644 index 0000000000000..bda8c25a75bb9 --- /dev/null +++ b/CondFormats/DataRecord/src/LHCInfoPerLSRcd.cc @@ -0,0 +1,16 @@ +// -*- C++ -*- +// +// Package: DataRecord +// Class : LHCInfoPerLSRcd +// +// Implementation: +// [Notes on implementation] +// +// Author: +// Created: Tue Feb 15 2022 +// $Id$ + +#include "CondFormats/DataRecord/interface/LHCInfoPerLSRcd.h" +#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" + +EVENTSETUP_RECORD_REG(LHCInfoPerLSRcd); 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/interface/LHCInfoPerFill.h b/CondFormats/RunInfo/interface/LHCInfoPerFill.h new file mode 100644 index 0000000000000..472e4bf3c8dbe --- /dev/null +++ b/CondFormats/RunInfo/interface/LHCInfoPerFill.h @@ -0,0 +1,244 @@ +#ifndef CondFormats_RunInfo_LHCInfoPerFill_H +#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 +#include +#include +#include + +class LHCInfoPerFill : public LHCInfoVectorizedFields { +public: + enum FillType { UNKNOWN = 0, PROTONS, IONS, COSMICS, GAP }; + enum ParticleType { NONE = 0, PROTON, PB82, AR18, D, XE54 }; + + enum IntParamIndex { + LHC_FILL = 0, + BUNCHES_1, + BUNCHES_2, + COLLIDING_BUNCHES, + TARGET_BUNCHES, + FILL_TYPE, + PARTICLES_1, + PARTICLES_2, + ISIZE + }; + enum FloatParamIndex { + INTENSITY_1 = 0, + 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 }; + + typedef FillType FillTypeId; + typedef ParticleType ParticleTypeId; + 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: + 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/interface/LHCInfoPerLS.h b/CondFormats/RunInfo/interface/LHCInfoPerLS.h new file mode 100644 index 0000000000000..5d78f567a876b --- /dev/null +++ b/CondFormats/RunInfo/interface/LHCInfoPerLS.h @@ -0,0 +1,74 @@ +#ifndef CondFormats_RunInfo_LHCInfoPerLS_H +#define CondFormats_RunInfo_LHCInfoPerLS_H + +#include "CondFormats/Serialization/interface/Serializable.h" +#include "CondFormats/RunInfo/interface/LHCInfoVectorizedFields.h" + +#include "CondCore/CondDB/interface/Types.h" + +#include +#include +#include +#include +#include + +class LHCInfoPerLS : public LHCInfoVectorizedFields { +public: + enum IntParamIndex { LHC_FILL = 0, LUMI_SECTION, ISIZE }; + enum FloatParamIndex { CROSSING_ANGLE_X = 0, CROSSING_ANGLE_Y, BETA_STAR_X, 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; + + float const betaStarX() const; + + float const betaStarY() const; + + cond::Time_t runNumber() const; + + //setters + void setFillNumber(unsigned short const& lhcFill); + + void setLumiSection(unsigned int const& lumiSection); + + void setCrossingAngleX(float const& angle); + + void setCrossingAngleY(float const& angle); + + void setBetaStarX(float const& betaStar); + + void setBetaStarY(float const& betaStar); + + void setRunNumber(cond::Time_t const& runNumber); + + //sets all values in one go + void setInfo(unsigned short const& lhcFill, + unsigned int const& lumiSection, + float const& angleX, + float const& angleY, + float const& betaX, + float const& betaY, + cond::Time_t const& runNumber); + + bool equals(const LHCInfoPerLS& rhs) const; + + bool empty() const; + + //dumping values on output stream + void print(std::stringstream& ss) const; + + COND_SERIALIZABLE; +}; + +std::ostream& operator<<(std::ostream&, LHCInfoPerLS lhcInfo); + +#endif // CondFormats_RunInfo_LHCInfoPerLS_H diff --git a/CondFormats/RunInfo/interface/LHCInfoVectorizedFields.h b/CondFormats/RunInfo/interface/LHCInfoVectorizedFields.h new file mode 100644 index 0000000000000..16a33c96d71c9 --- /dev/null +++ b/CondFormats/RunInfo/interface/LHCInfoVectorizedFields.h @@ -0,0 +1,44 @@ +#ifndef CondFormats_RunInfo_LHCInfoVectorizedFields_H +#define CondFormats_RunInfo_LHCInfoVectorizedFields_H + +#include "CondFormats/Serialization/interface/Serializable.h" +#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); + + 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 new file mode 100644 index 0000000000000..de274693987fb --- /dev/null +++ b/CondFormats/RunInfo/src/LHCInfoPerFill.cc @@ -0,0 +1,485 @@ +#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() : 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_stringParams[INJECTION_SCHEME].push_back(std::string("None")); +} + +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; +} + +//getters +unsigned short const LHCInfoPerFill::fillNumber() const { return LHCInfoPerFill::getOneParam(m_intParams, LHC_FILL); } + +unsigned short const LHCInfoPerFill::bunchesInBeam1() const { + return LHCInfoPerFill::getOneParam(m_intParams, BUNCHES_1); +} + +unsigned short const LHCInfoPerFill::bunchesInBeam2() const { + return LHCInfoPerFill::getOneParam(m_intParams, BUNCHES_2); +} + +unsigned short const LHCInfoPerFill::collidingBunches() const { + return LHCInfoPerFill::getOneParam(m_intParams, COLLIDING_BUNCHES); +} + +unsigned short const LHCInfoPerFill::targetBunches() const { + return LHCInfoPerFill::getOneParam(m_intParams, TARGET_BUNCHES); +} + +LHCInfoPerFill::FillTypeId const LHCInfoPerFill::fillType() const { + return static_cast(LHCInfoPerFill::getOneParam(m_intParams, FILL_TYPE)); +} + +LHCInfoPerFill::ParticleTypeId const LHCInfoPerFill::particleTypeForBeam1() const { + return static_cast(LHCInfoPerFill::getOneParam(m_intParams, PARTICLES_1)); +} + +LHCInfoPerFill::ParticleTypeId const LHCInfoPerFill::particleTypeForBeam2() const { + return static_cast(LHCInfoPerFill::getOneParam(m_intParams, PARTICLES_2)); +} + +float const LHCInfoPerFill::intensityForBeam1() const { + return LHCInfoPerFill::getOneParam(m_floatParams, INTENSITY_1); +} + +float const LHCInfoPerFill::intensityForBeam2() const { + return LHCInfoPerFill::getOneParam(m_floatParams, INTENSITY_2); +} + +float const LHCInfoPerFill::energy() const { return LHCInfoPerFill::getOneParam(m_floatParams, ENERGY); } + +float const LHCInfoPerFill::delivLumi() const { return LHCInfoPerFill::getOneParam(m_floatParams, DELIV_LUMI); } + +float const LHCInfoPerFill::recLumi() const { return LHCInfoPerFill::getOneParam(m_floatParams, REC_LUMI); } + +float const LHCInfoPerFill::instLumi() const { return LHCInfoPerFill::getOneParam(m_floatParams, INST_LUMI); } + +float const LHCInfoPerFill::instLumiError() const { return LHCInfoPerFill::getOneParam(m_floatParams, INST_LUMI_ERR); } + +cond::Time_t const LHCInfoPerFill::createTime() const { return LHCInfoPerFill::getOneParam(m_timeParams, CREATE_TIME); } + +cond::Time_t const LHCInfoPerFill::beginTime() const { return LHCInfoPerFill::getOneParam(m_timeParams, BEGIN_TIME); } + +cond::Time_t const LHCInfoPerFill::endTime() const { return LHCInfoPerFill::getOneParam(m_timeParams, END_TIME); } + +std::string const& LHCInfoPerFill::injectionScheme() const { + return LHCInfoPerFill::getOneParam(m_stringParams, INJECTION_SCHEME); +} + +std::vector const& LHCInfoPerFill::lumiPerBX() const { + return LHCInfoPerFill::getParams(m_floatParams, LUMI_PER_B); +} + +std::string const& LHCInfoPerFill::lhcState() const { return LHCInfoPerFill::getOneParam(m_stringParams, LHC_STATE); } + +std::string const& LHCInfoPerFill::lhcComment() const { + return LHCInfoPerFill::getOneParam(m_stringParams, LHC_COMMENT); +} + +std::string const& LHCInfoPerFill::ctppsStatus() const { + return LHCInfoPerFill::getOneParam(m_stringParams, CTPPS_STATUS); +} + +std::vector const& LHCInfoPerFill::beam1VC() const { return LHCInfoPerFill::getParams(m_floatParams, BEAM1_VC); } + +std::vector const& LHCInfoPerFill::beam2VC() const { return LHCInfoPerFill::getParams(m_floatParams, BEAM2_VC); } + +std::vector const& LHCInfoPerFill::beam1RF() const { return LHCInfoPerFill::getParams(m_floatParams, BEAM1_RF); } + +std::vector const& LHCInfoPerFill::beam2RF() const { return LHCInfoPerFill::getParams(m_floatParams, BEAM2_RF); } + +std::vector& LHCInfoPerFill::beam1VC() { return LHCInfoPerFill::accessParams(m_floatParams, BEAM1_VC); } + +std::vector& LHCInfoPerFill::beam2VC() { return LHCInfoPerFill::accessParams(m_floatParams, BEAM2_VC); } + +std::vector& LHCInfoPerFill::beam1RF() { return LHCInfoPerFill::accessParams(m_floatParams, BEAM1_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. +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) { + LHCInfoPerFill::setOneParam(m_intParams, LHC_FILL, static_cast(lhcFill)); +} + +//setters +void LHCInfoPerFill::setBunchesInBeam1(unsigned short const& bunches) { + LHCInfoPerFill::setOneParam(m_intParams, BUNCHES_1, static_cast(bunches)); +} + +void LHCInfoPerFill::setBunchesInBeam2(unsigned short const& bunches) { + LHCInfoPerFill::setOneParam(m_intParams, BUNCHES_2, static_cast(bunches)); +} + +void LHCInfoPerFill::setCollidingBunches(unsigned short const& collidingBunches) { + LHCInfoPerFill::setOneParam(m_intParams, COLLIDING_BUNCHES, static_cast(collidingBunches)); +} + +void LHCInfoPerFill::setTargetBunches(unsigned short const& targetBunches) { + LHCInfoPerFill::setOneParam(m_intParams, TARGET_BUNCHES, static_cast(targetBunches)); +} + +void LHCInfoPerFill::setFillType(LHCInfoPerFill::FillTypeId const& fillType) { + LHCInfoPerFill::setOneParam(m_intParams, FILL_TYPE, static_cast(fillType)); +} + +void LHCInfoPerFill::setParticleTypeForBeam1(LHCInfoPerFill::ParticleTypeId const& particleType) { + LHCInfoPerFill::setOneParam(m_intParams, PARTICLES_1, static_cast(particleType)); +} + +void LHCInfoPerFill::setParticleTypeForBeam2(LHCInfoPerFill::ParticleTypeId const& particleType) { + LHCInfoPerFill::setOneParam(m_intParams, PARTICLES_2, static_cast(particleType)); +} + +void LHCInfoPerFill::setIntensityForBeam1(float const& intensity) { + LHCInfoPerFill::setOneParam(m_floatParams, INTENSITY_1, intensity); +} + +void LHCInfoPerFill::setIntensityForBeam2(float const& intensity) { + LHCInfoPerFill::setOneParam(m_floatParams, INTENSITY_2, intensity); +} + +void LHCInfoPerFill::setEnergy(float const& energy) { LHCInfoPerFill::setOneParam(m_floatParams, ENERGY, energy); } + +void LHCInfoPerFill::setDelivLumi(float const& delivLumi) { + LHCInfoPerFill::setOneParam(m_floatParams, DELIV_LUMI, delivLumi); +} + +void LHCInfoPerFill::setRecLumi(float const& recLumi) { LHCInfoPerFill::setOneParam(m_floatParams, REC_LUMI, recLumi); } + +void LHCInfoPerFill::setInstLumi(float const& instLumi) { + LHCInfoPerFill::setOneParam(m_floatParams, INST_LUMI, instLumi); +} + +void LHCInfoPerFill::setInstLumiError(float const& instLumiError) { + LHCInfoPerFill::setOneParam(m_floatParams, INST_LUMI_ERR, instLumiError); +} + +void LHCInfoPerFill::setCreationTime(cond::Time_t const& createTime) { + LHCInfoPerFill::setOneParam(m_timeParams, CREATE_TIME, createTime); +} + +void LHCInfoPerFill::setBeginTime(cond::Time_t const& beginTime) { + LHCInfoPerFill::setOneParam(m_timeParams, BEGIN_TIME, beginTime); +} + +void LHCInfoPerFill::setEndTime(cond::Time_t const& endTime) { + LHCInfoPerFill::setOneParam(m_timeParams, END_TIME, endTime); +} + +void LHCInfoPerFill::setInjectionScheme(std::string const& injectionScheme) { + LHCInfoPerFill::setOneParam(m_stringParams, INJECTION_SCHEME, injectionScheme); +} + +void LHCInfoPerFill::setLumiPerBX(std::vector const& lumiPerBX) { + LHCInfoPerFill::setParams(m_floatParams, LUMI_PER_B, lumiPerBX); +} + +void LHCInfoPerFill::setLhcState(std::string const& lhcState) { + LHCInfoPerFill::setOneParam(m_stringParams, LHC_STATE, lhcState); +} + +void LHCInfoPerFill::setLhcComment(std::string const& lhcComment) { + LHCInfoPerFill::setOneParam(m_stringParams, LHC_COMMENT, lhcComment); +} + +void LHCInfoPerFill::setCtppsStatus(std::string const& ctppsStatus) { + LHCInfoPerFill::setOneParam(m_stringParams, CTPPS_STATUS, ctppsStatus); +} + +void LHCInfoPerFill::setBeam1VC(std::vector const& beam1VC) { + LHCInfoPerFill::setParams(m_floatParams, BEAM1_VC, beam1VC); +} + +void LHCInfoPerFill::setBeam2VC(std::vector const& beam2VC) { + LHCInfoPerFill::setParams(m_floatParams, BEAM2_VC, beam2VC); +} + +void LHCInfoPerFill::setBeam1RF(std::vector const& beam1RF) { + LHCInfoPerFill::setParams(m_floatParams, BEAM1_RF, beam1RF); +} + +void LHCInfoPerFill::setBeam2RF(std::vector const& beam2RF) { + LHCInfoPerFill::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(); } diff --git a/CondFormats/RunInfo/src/LHCInfoPerLS.cc b/CondFormats/RunInfo/src/LHCInfoPerLS.cc new file mode 100644 index 0000000000000..2171297918220 --- /dev/null +++ b/CondFormats/RunInfo/src/LHCInfoPerLS.cc @@ -0,0 +1,100 @@ +#include "CondFormats/RunInfo/interface/LHCInfoPerLS.h" +//#include "CondFormats/Common/interface/TimeConversions.h" +#include +#include +#include +#include + +LHCInfoPerLS::LHCInfoPerLS() : LHCInfoVectorizedFields(ISIZE, FSIZE, TSIZE, SSIZE) {} + +//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); } + +float const LHCInfoPerLS::betaStarX() const { return LHCInfoPerLS::getOneParam(m_floatParams, BETA_STAR_X); } + +float const LHCInfoPerLS::betaStarY() const { return LHCInfoPerLS::getOneParam(m_floatParams, BETA_STAR_Y); } + +cond::Time_t LHCInfoPerLS::runNumber() const { return LHCInfoPerLS::getOneParam(m_timeParams, RUN_NUMBER); } + +//setters +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); +} + +void LHCInfoPerLS::setCrossingAngleY(float const& angle) { + LHCInfoPerLS::setOneParam(m_floatParams, CROSSING_ANGLE_Y, angle); +} + +void LHCInfoPerLS::setBetaStarX(float const& betaStar) { + LHCInfoPerLS::setOneParam(m_floatParams, BETA_STAR_X, betaStar); +} + +void LHCInfoPerLS::setBetaStarY(float const& betaStar) { + LHCInfoPerLS::setOneParam(m_floatParams, BETA_STAR_Y, betaStar); +} + +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 const& lhcFill, + unsigned int const& lumiSection, + float const& angleX, + float const& angleY, + float const& betaX, + 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 (m): " << this->betaStarX() << std::endl + << "Beta star y (m): " << this->betaStarY() << std::endl; +} + +std::ostream& operator<<(std::ostream& os, LHCInfoPerLS beamInfo) { + std::stringstream ss; + beamInfo.print(ss); + os << ss.str(); + return os; +} + +bool LHCInfoPerLS::equals(const LHCInfoPerLS& 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; + return true; +} + +bool LHCInfoPerLS::empty() const { return m_intParams[0].empty(); } diff --git a/CondFormats/RunInfo/src/LHCInfoVectorizedFields.cc b/CondFormats/RunInfo/src/LHCInfoVectorizedFields.cc new file mode 100644 index 0000000000000..632d1c691adb1 --- /dev/null +++ b/CondFormats/RunInfo/src/LHCInfoVectorizedFields.cc @@ -0,0 +1,99 @@ +#include "CondFormats/RunInfo/interface/LHCInfoVectorizedFields.h" +#include "CondCore/CondDB/interface/Exception.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()) + throw cond::Exception("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 cond::Exception("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 cond::Exception("Parameter with index " + std::to_string(index) + " is out of range."); + const std::vector& inner = params[index]; + if (inner.empty()) + throw cond::Exception("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 cond::Exception("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 cond::Exception("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/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/T_EventSetup_LHCInfoPerLS.cc b/CondFormats/RunInfo/src/T_EventSetup_LHCInfoPerLS.cc new file mode 100644 index 0000000000000..e63f84c38bda5 --- /dev/null +++ b/CondFormats/RunInfo/src/T_EventSetup_LHCInfoPerLS.cc @@ -0,0 +1,4 @@ +#include "CondFormats/RunInfo/interface/LHCInfoPerLS.h" +#include "FWCore/Utilities/interface/typelookup.h" + +TYPELOOKUP_DATA_REG(LHCInfoPerLS); diff --git a/CondFormats/RunInfo/src/headers.h b/CondFormats/RunInfo/src/headers.h index ed905d61e435a..ef15ee4eb69c0 100644 --- a/CondFormats/RunInfo/src/headers.h +++ b/CondFormats/RunInfo/src/headers.h @@ -5,3 +5,6 @@ #include "CondFormats/RunInfo/interface/MixingModuleConfig.h" #include "CondFormats/RunInfo/interface/FillInfo.h" #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 diff --git a/CondFormats/RunInfo/test/testSerializationRunInfo.cpp b/CondFormats/RunInfo/test/testSerializationRunInfo.cpp index f12858e8f7720..2d2b4763fd637 100644 --- a/CondFormats/RunInfo/test/testSerializationRunInfo.cpp +++ b/CondFormats/RunInfo/test/testSerializationRunInfo.cpp @@ -5,6 +5,9 @@ int main() { testSerialization(); testSerialization(); + testSerialization(); + testSerialization(); + testSerialization(); testSerialization(); testSerialization(); testSerialization(); diff --git a/CondTools/RunInfo/plugins/BuildFile.xml b/CondTools/RunInfo/plugins/BuildFile.xml index cd0651742643b..6fff2bf931f54 100644 --- a/CondTools/RunInfo/plugins/BuildFile.xml +++ b/CondTools/RunInfo/plugins/BuildFile.xml @@ -50,3 +50,20 @@ + + + + + + + + + + + + + + + + + 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..915b6b685d4b9 --- /dev/null +++ b/CondTools/RunInfo/plugins/LHCInfoPerFillWriter.cc @@ -0,0 +1,63 @@ +#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(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({0.000114139, 0.000114139}); + lhcInfoPerFill.setLhcState("some lhcState"); + lhcInfoPerFill.setLhcComment("some lhcComment"); + lhcInfoPerFill.setCtppsStatus("some ctppsStatus"); + + // 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..68f5aa0c519b4 --- /dev/null +++ b/CondTools/RunInfo/plugins/LHCInfoPerLSWriter.cc @@ -0,0 +1,47 @@ +#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.setFillNumber(7066); + lhcInfoPerLS.setLumiSection(1); + lhcInfoPerLS.setCrossingAngleX(170); + lhcInfoPerLS.setCrossingAngleY(170); + lhcInfoPerLS.setBetaStarX(11); + lhcInfoPerLS.setBetaStarY(11); + lhcInfoPerLS.setRunNumber(301765); + + // 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..a3a0ab0f19f0b --- /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 info 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..9ee905d9ff524 --- /dev/null +++ b/CondTools/RunInfo/test/LHCInfoPerFillWriter_cfg.py @@ -0,0 +1,31 @@ +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) +) + +# 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..ca23551c9ca66 --- /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 info 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..d617d8f322700 --- /dev/null +++ b/CondTools/RunInfo/test/LHCInfoPerLSWriter_cfg.py @@ -0,0 +1,31 @@ +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) +) + +# 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 +)