Back to home page

Project CMSSW displayed by LXR

 
 

    


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   // starting date for sampling
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   // for reading from relational database source
0046   std::string m_connectionString;
0047   std::string m_authpath;
0048   std::string m_omsBaseUrl;
0049   // Allows for basic test of durigFill mode when there is no Stable Beams in LHC
0050   // makes duringFill interpret fills as ongoing fill and writing their last LS
0051   // (disabling the check if the last LS is in stable beams,
0052   // although still only fills with stable beams are being processed
0053   // also, still only up to one payload will be written)
0054   const bool m_debugLogic;
0055   // values for the default payload which is inserted after the last processed fill
0056   // has ended and there's no ongoing stable beam yet:
0057   float m_defaultCrossingAngleX;
0058   float m_defaultCrossingAngleY;
0059   float m_defaultBetaStarX;
0060   float m_defaultBetaStarY;
0061   float m_minBetaStar;       // meters
0062   float m_maxBetaStar;       // meters
0063   float m_minCrossingAngle;  // urad
0064   float m_maxCrossingAngle;  // urad
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   // mapping of lumisections IDs (pairs of runnumber an LS number) found in OMS to
0077   // the IDs they've been assignd from PPS DB value pair(-1, -1) means lumisection
0078   // corresponding to the key exists in OMS but no lumisection was matched from PPS
0079   std::map<std::pair<cond::Time_t, unsigned int>, std::pair<cond::Time_t, unsigned int>> m_lsIdMap;
0080 };
0081 
0082 #endif