File indexing completed on 2024-11-07 06:12:39
0001 #ifndef LHCInfoPerLSPopConSourceHandler_h
0002 #define LHCInfoPerLSPopConSourceHandler_h
0003
0004 #include "CondCore/PopCon/interface/PopConSourceHandler.h"
0005 #include "CondFormats/RunInfo/interface/LHCInfoPerLS.h"
0006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0007 #include "CondTools/RunInfo/interface/OMSAccess.h"
0008 #include <map>
0009 #include <memory>
0010 #include <string>
0011 #include <utility>
0012 #include <vector>
0013
0014 class LHCInfoPerLSPopConSourceHandler : public popcon::PopConSourceHandler<LHCInfoPerLS> {
0015 public:
0016 LHCInfoPerLSPopConSourceHandler(edm::ParameterSet const& pset);
0017 ~LHCInfoPerLSPopConSourceHandler() override;
0018 void getNewObjects() override;
0019 std::string id() const override;
0020
0021 private:
0022 void populateIovs();
0023 void filterInvalidPayloads();
0024 bool isPayloadValid(const LHCInfoPerLS& payload) const;
0025 void addEmptyPayload(cond::Time_t iov);
0026 void addDefaultPayload(cond::Time_t iov, unsigned short fill, const cond::OMSService& oms);
0027 void addDefaultPayload(cond::Time_t iov, unsigned short fill, int run, unsigned short lumi);
0028 bool makeFillPayload(std::unique_ptr<LHCInfoPerLS>& targetPayload, const cond::OMSServiceResult& queryResult);
0029 void addPayloadToBuffer(cond::OMSServiceResultRef& row);
0030 size_t bufferAllLS(const cond::OMSServiceResult& queryResult);
0031 size_t getLumiData(const cond::OMSService& oms,
0032 unsigned short fillId,
0033 const boost::posix_time::ptime& beginFillTime,
0034 const boost::posix_time::ptime& endFillTime);
0035 bool getCTPPSData(cond::persistency::Session& session,
0036 const boost::posix_time::ptime& beginFillTime,
0037 const boost::posix_time::ptime& endFillTime);
0038
0039 bool m_debug;
0040
0041 boost::posix_time::ptime m_startTime;
0042 boost::posix_time::ptime m_endTime;
0043 bool m_endFillMode = true;
0044 std::string m_name;
0045
0046 std::string m_connectionString;
0047 std::string m_authpath;
0048 std::string m_omsBaseUrl;
0049
0050
0051
0052
0053
0054 const bool m_debugLogic;
0055
0056
0057 float m_defaultCrossingAngleX;
0058 float m_defaultCrossingAngleY;
0059 float m_defaultBetaStarX;
0060 float m_defaultBetaStarY;
0061 float m_minBetaStar;
0062 float m_maxBetaStar;
0063 float m_minCrossingAngle;
0064 float m_maxCrossingAngle;
0065
0066 std::unique_ptr<LHCInfoPerLS> m_fillPayload;
0067 std::shared_ptr<LHCInfoPerLS> m_prevPayload;
0068 cond::Time_t m_startFillTime;
0069 cond::Time_t m_endFillTime;
0070 cond::Time_t m_prevEndFillTime = 0;
0071 cond::Time_t m_prevStartFillTime;
0072 cond::Time_t m_startStableBeamTime;
0073 cond::Time_t m_endStableBeamTime;
0074 std::vector<std::pair<cond::Time_t, std::shared_ptr<LHCInfoPerLS>>> m_tmpBuffer;
0075 bool m_lastPayloadEmpty = false;
0076
0077
0078
0079 std::map<std::pair<cond::Time_t, unsigned int>, std::pair<cond::Time_t, unsigned int>> m_lsIdMap;
0080 };
0081
0082 #endif