diff --git a/CondTools/RunInfo/plugins/LumiSectionFilter.h b/CondTools/RunInfo/interface/LumiSectionFilter.h similarity index 92% rename from CondTools/RunInfo/plugins/LumiSectionFilter.h rename to CondTools/RunInfo/interface/LumiSectionFilter.h index 6b40b3727d6d5..9e9757d5aabec 100644 --- a/CondTools/RunInfo/plugins/LumiSectionFilter.h +++ b/CondTools/RunInfo/interface/LumiSectionFilter.h @@ -1,4 +1,8 @@ +#ifndef CondTools_RunInfo_LumiSectionFilter_h +#define CondTools_RunInfo_LumiSectionFilter_h + #include "CondFormats/Common/interface/TimeConversions.h" +#include "CondCore/CondDB/interface/Time.h" #include #include @@ -57,3 +61,5 @@ struct LumiSectionFilter { typename std::vector>>::const_iterator end; cond::Time_t currentDipTime = 0; }; + +#endif \ No newline at end of file diff --git a/CondTools/RunInfo/plugins/LHCInfoPerFillPopConAnalyzer.cc b/CondTools/RunInfo/plugins/LHCInfoPerFillPopConAnalyzer.cc index 053753a07c3bf..4d5a47a69c09b 100644 --- a/CondTools/RunInfo/plugins/LHCInfoPerFillPopConAnalyzer.cc +++ b/CondTools/RunInfo/plugins/LHCInfoPerFillPopConAnalyzer.cc @@ -3,6 +3,7 @@ #include "CondCore/PopCon/interface/PopConSourceHandler.h" #include "CondFormats/Common/interface/TimeConversions.h" #include "CondFormats/RunInfo/interface/LHCInfoPerFill.h" +#include "CondTools/RunInfo/interface/LumiSectionFilter.h" #include "CondTools/RunInfo/interface/OMSAccess.h" #include "CoralBase/Attribute.h" #include "CoralBase/AttributeList.h" @@ -12,7 +13,6 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/ParameterSet/interface/ParameterSetfwd.h" -#include "LumiSectionFilter.h" #include "RelationalAccess/ICursor.h" #include "RelationalAccess/IQuery.h" #include "RelationalAccess/ISchema.h" @@ -164,8 +164,8 @@ namespace theLHCInfoPerFillImpl { 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()) { + rhs.lhcState() != lhs.lhcState() || rhs.lhcComment() != lhs.lhcComment() || + rhs.ctppsStatus() != lhs.ctppsStatus()) { return false; } return true; diff --git a/CondTools/RunInfo/plugins/LHCInfoPerLSPopConAnalyzer.cc b/CondTools/RunInfo/plugins/LHCInfoPerLSPopConAnalyzer.cc index 5889c23407999..aee338fa89f14 100644 --- a/CondTools/RunInfo/plugins/LHCInfoPerLSPopConAnalyzer.cc +++ b/CondTools/RunInfo/plugins/LHCInfoPerLSPopConAnalyzer.cc @@ -4,7 +4,7 @@ #include "CondCore/PopCon/interface/PopConSourceHandler.h" #include "CondFormats/Common/interface/TimeConversions.h" #include "CondFormats/RunInfo/interface/LHCInfoPerLS.h" -#include "CondTools/RunInfo/interface/OMSAccess.h" +#include "CondTools/RunInfo/interface/LumiSectionFilter.h" #include "CondTools/RunInfo/interface/OMSAccess.h" #include "CoralBase/Attribute.h" #include "CoralBase/AttributeList.h" @@ -34,75 +34,12 @@ typedef popcon::PopConAnalyzer LHCInfoPerLSPopC DEFINE_FWK_MODULE(LHCInfoPerLSPopConAnalyzer); namespace theLHCInfoPerLSImpl { - - 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; } - 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; - }; - 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()) + if (rhs.fillNumber() != lhs.fillNumber() || rhs.runNumber() != lhs.runNumber() || + rhs.crossingAngleX() != lhs.crossingAngleX() || rhs.crossingAngleY() != lhs.crossingAngleY() || + rhs.betaStarX() != lhs.betaStarX() || rhs.betaStarY() != lhs.betaStarY()) { return false; + } return true; } @@ -479,7 +416,7 @@ class LHCInfoPerLSPopConSourceHandler : public popcon::PopConSourceHandler filter(m_tmpBuffer); while (CTPPSDataCursor.next()) { if (m_debug) { std::ostringstream CTPPS; diff --git a/CondTools/RunInfo/src/LHCInfoPopConSourceHandler.cc b/CondTools/RunInfo/src/LHCInfoPopConSourceHandler.cc index 0a3dd4a221eb2..4b40d5a12074f 100644 --- a/CondTools/RunInfo/src/LHCInfoPopConSourceHandler.cc +++ b/CondTools/RunInfo/src/LHCInfoPopConSourceHandler.cc @@ -1,17 +1,18 @@ -#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/LHCInfoPopConSourceHandler.h" +#include "CondTools/RunInfo/interface/LumiSectionFilter.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/AttributeList.h" #include "CoralBase/AttributeSpecification.h" #include "CoralBase/TimeStamp.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "RelationalAccess/ICursor.h" +#include "RelationalAccess/IQuery.h" +#include "RelationalAccess/ISchema.h" +#include "RelationalAccess/ISessionProxy.h" #include #include #include @@ -91,7 +92,7 @@ LHCInfoPopConSourceHandler::LHCInfoPopConSourceHandler(edm::ParameterSet const& //L2: try with different m_name LHCInfoPopConSourceHandler::~LHCInfoPopConSourceHandler() {} -namespace LHCInfoImpl { +namespace theLHCInfoImpl { struct IOVComp { bool operator()(const cond::Time_t& x, const std::pair>& y) { @@ -148,7 +149,7 @@ namespace LHCInfoImpl { return ret; } -} // namespace LHCInfoImpl +} // namespace theLHCInfoImpl size_t LHCInfoPopConSourceHandler::getLumiData(const cond::OMSService& oms, unsigned short fillId, @@ -177,63 +178,6 @@ size_t LHCInfoPopConSourceHandler::getLumiData(const cond::OMSService& oms, return nlumi; } -namespace LHCInfoImpl { - 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; } - LHCInfo& 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 LHCInfoImpl - void LHCInfoPopConSourceHandler::getDipData(const cond::OMSService& oms, const boost::posix_time::ptime& beginFillTime, const boost::posix_time::ptime& endFillTime) { @@ -340,7 +284,7 @@ bool LHCInfoPopConSourceHandler::getCTTPSData(cond::persistency::Session& sessio float crossingAngle = 0., betastar = 0.; bool ret = false; - LHCInfoImpl::LumiSectionFilter filter(m_tmpBuffer); + LumiSectionFilter filter(m_tmpBuffer); while (CTPPSDataCursor.next()) { if (m_debug) { std::ostringstream CTPPS; @@ -388,7 +332,7 @@ bool LHCInfoPopConSourceHandler::getCTTPSData(cond::persistency::Session& sessio return ret; } -namespace LHCInfoImpl { +namespace theLHCInfoImpl { static const std::map vecMap = { {"Beam1/beamPhaseMean", 1}, {"Beam2/beamPhaseMean", 2}, {"Beam1/cavPhaseMean", 3}, {"Beam2/cavPhaseMean", 4}}; void setElementData(cond::Time_t since, @@ -424,7 +368,7 @@ namespace LHCInfoImpl { } } } -} // namespace LHCInfoImpl +} // namespace theLHCInfoImpl bool LHCInfoPopConSourceHandler::getEcalData(cond::persistency::Session& session, const boost::posix_time::ptime& lowerTime, @@ -474,7 +418,7 @@ bool LHCInfoPopConSourceHandler::getEcalData(cond::persistency::Session& session unsigned int elementNr = 0; float value = 0.; std::set initializedVectors; - LHCInfoImpl::LumiSectionFilter filter(m_tmpBuffer); + LumiSectionFilter filter(m_tmpBuffer); bool ret = false; if (m_prevPayload.get()) { for (auto& lumiSlot : m_tmpBuffer) { @@ -516,7 +460,7 @@ bool LHCInfoPopConSourceHandler::getEcalData(cond::persistency::Session& session iovMap.insert(std::make_pair(changeTime, filter.current()->first)); for (auto it = filter.current(); it != m_tmpBuffer.end(); it++) { LHCInfo& payload = *(it->second); - LHCInfoImpl::setElementData(it->first, dipVal, elementNr, value, payload, initializedVectors); + theLHCInfoImpl::setElementData(it->first, dipVal, elementNr, value, payload, initializedVectors); } } //} @@ -550,28 +494,15 @@ void LHCInfoPopConSourceHandler::addEmptyPayload(cond::Time_t iov) { } } -namespace LHCInfoImpl { +namespace theLHCInfoImpl { bool comparePayloads(const LHCInfo& rhs, const LHCInfo& lhs) { - if (rhs.fillNumber() != lhs.fillNumber()) - return false; - if (rhs.delivLumi() != lhs.delivLumi()) - return false; - if (rhs.recLumi() != lhs.recLumi()) - return false; - if (rhs.instLumi() != lhs.instLumi()) - return false; - if (rhs.instLumiError() != lhs.instLumiError()) - return false; - if (rhs.crossingAngle() != rhs.crossingAngle()) - return false; - if (rhs.betaStar() != rhs.betaStar()) - return false; - if (rhs.lhcState() != rhs.lhcState()) - return false; - if (rhs.lhcComment() != rhs.lhcComment()) - return false; - if (rhs.ctppsStatus() != rhs.ctppsStatus()) + if (rhs.fillNumber() != lhs.fillNumber() || rhs.delivLumi() != lhs.delivLumi() || rhs.recLumi() != lhs.recLumi() || + rhs.instLumi() != lhs.instLumi() || rhs.instLumiError() != lhs.instLumiError() || + rhs.crossingAngle() != lhs.crossingAngle() || rhs.betaStar() != lhs.betaStar() || + rhs.lhcState() != lhs.lhcState() || rhs.lhcComment() != lhs.lhcComment() || + rhs.ctppsStatus() != lhs.ctppsStatus()) { return false; + } return true; } @@ -600,7 +531,7 @@ namespace LHCInfoImpl { return niovs; } -} // namespace LHCInfoImpl +} // namespace theLHCInfoImpl void LHCInfoPopConSourceHandler::getNewObjects() { //reference to the last payload in the tag @@ -683,7 +614,7 @@ void LHCInfoPopConSourceHandler::getNewObjects() { query->filterEQ("fill_number", m_prevPayload->fillNumber()); bool foundFill = query->execute(); if (foundFill) - foundFill = LHCInfoImpl::makeFillPayload(m_fillPayload, query->result()); + foundFill = theLHCInfoImpl::makeFillPayload(m_fillPayload, query->result()); if (!foundFill) { edm::LogError(m_name) << "Could not find fill #" << m_prevPayload->fillNumber(); break; @@ -704,7 +635,7 @@ void LHCInfoPopConSourceHandler::getNewObjects() { query->filterNotNull("end_time"); bool foundFill = query->execute(); if (foundFill) - foundFill = LHCInfoImpl::makeFillPayload(m_fillPayload, query->result()); + foundFill = theLHCInfoImpl::makeFillPayload(m_fillPayload, query->result()); if (!foundFill) { edm::LogInfo(m_name) << "No fill found - END of job."; if (iovAdded) @@ -740,7 +671,7 @@ void LHCInfoPopConSourceHandler::getNewObjects() { getEcalData(session2, startSampleTime, endSampleTime, updateEcal); session2.transaction().commit(); // - size_t niovs = LHCInfoImpl::transferPayloads(m_tmpBuffer, m_iovs, m_prevPayload); + size_t niovs = theLHCInfoImpl::transferPayloads(m_tmpBuffer, m_iovs, m_prevPayload); edm::LogInfo(m_name) << "Added " << niovs << " iovs within the Fill time"; m_tmpBuffer.clear(); iovAdded = true;