1+ #ifndef LHCInfoPerLSPopConSourceHandler_h
2+ #define LHCInfoPerLSPopConSourceHandler_h
3+
4+ #include " CondCore/PopCon/interface/PopConSourceHandler.h"
5+ #include " CondFormats/RunInfo/interface/LHCInfoPerLS.h"
6+ #include " FWCore/ParameterSet/interface/ParameterSet.h"
7+ #include " CondTools/RunInfo/interface/OMSAccess.h"
8+ #include < map>
9+ #include < memory>
10+ #include < string>
11+ #include < utility>
12+ #include < vector>
13+
14+ class LHCInfoPerLSPopConSourceHandler : public popcon ::PopConSourceHandler<LHCInfoPerLS> {
15+ public:
16+ LHCInfoPerLSPopConSourceHandler (edm::ParameterSet const & pset);
17+ ~LHCInfoPerLSPopConSourceHandler () override ;
18+ void getNewObjects () override ;
19+ std::string id () const override ;
20+
21+ private:
22+ void populateIovs ();
23+ void filterInvalidPayloads ();
24+ bool isPayloadValid (const LHCInfoPerLS& payload) const ;
25+ void addEmptyPayload (cond::Time_t iov);
26+ void addDefaultPayload (cond::Time_t iov, unsigned short fill, const cond::OMSService& oms);
27+ void addDefaultPayload (cond::Time_t iov, unsigned short fill, int run, unsigned short lumi);
28+ bool makeFillPayload (std::unique_ptr<LHCInfoPerLS>& targetPayload, const cond::OMSServiceResult& queryResult);
29+ void addPayloadToBuffer (cond::OMSServiceResultRef& row);
30+ size_t bufferAllLS (const cond::OMSServiceResult& queryResult);
31+ size_t getLumiData (const cond::OMSService& oms,
32+ unsigned short fillId,
33+ const boost::posix_time::ptime& beginFillTime,
34+ const boost::posix_time::ptime& endFillTime);
35+ bool getCTPPSData (cond::persistency::Session& session,
36+ const boost::posix_time::ptime& beginFillTime,
37+ const boost::posix_time::ptime& endFillTime);
38+
39+ bool m_debug;
40+ // starting date for sampling
41+ boost::posix_time::ptime m_startTime;
42+ boost::posix_time::ptime m_endTime;
43+ bool m_endFillMode = true ;
44+ std::string m_name;
45+ // for reading from relational database source
46+ std::string m_connectionString;
47+ std::string m_authpath;
48+ std::string m_omsBaseUrl;
49+ // Allows for basic test of durigFill mode when there is no Stable Beams in LHC
50+ // makes duringFill interpret fills as ongoing fill and writing their last LS
51+ // (disabling the check if the last LS is in stable beams,
52+ // although still only fills with stable beams are being processed
53+ // also, still only up to one payload will be written)
54+ const bool m_debugLogic;
55+ // values for the default payload which is inserted after the last processed fill
56+ // has ended and there's no ongoing stable beam yet:
57+ float m_defaultCrossingAngleX;
58+ float m_defaultCrossingAngleY;
59+ float m_defaultBetaStarX;
60+ float m_defaultBetaStarY;
61+ float m_minBetaStar; // meters
62+ float m_maxBetaStar; // meters
63+ float m_minCrossingAngle; // urad
64+ float m_maxCrossingAngle; // urad
65+
66+ std::unique_ptr<LHCInfoPerLS> m_fillPayload;
67+ std::shared_ptr<LHCInfoPerLS> m_prevPayload;
68+ cond::Time_t m_startFillTime;
69+ cond::Time_t m_endFillTime;
70+ cond::Time_t m_prevEndFillTime = 0 ;
71+ cond::Time_t m_prevStartFillTime;
72+ cond::Time_t m_startStableBeamTime;
73+ cond::Time_t m_endStableBeamTime;
74+ std::vector<std::pair<cond::Time_t, std::shared_ptr<LHCInfoPerLS>>> m_tmpBuffer;
75+ bool m_lastPayloadEmpty = false ;
76+ // mapping of lumisections IDs (pairs of runnumber an LS number) found in OMS to
77+ // the IDs they've been assignd from PPS DB value pair(-1, -1) means lumisection
78+ // corresponding to the key exists in OMS but no lumisection was matched from PPS
79+ std::map<std::pair<cond::Time_t, unsigned int >, std::pair<cond::Time_t, unsigned int >> m_lsIdMap;
80+ };
81+
82+ #endif
0 commit comments