@@ -35,7 +35,8 @@ namespace theLHCInfoPerLSImpl {
3535 std::shared_ptr<LHCInfoPerLS>& prevPayload,
3636 const std::map<pair<cond::Time_t, unsigned int >, pair<cond::Time_t, unsigned int >>& lsIdMap,
3737 cond::Time_t startStableBeamTime,
38- cond::Time_t endStableBeamTime) {
38+ cond::Time_t endStableBeamTime,
39+ cond::Time_t lastSince) {
3940 int lsMissingInPPS = 0 ;
4041 int xAngleBothZero = 0 , xAngleBothNonZero = 0 , xAngleNegative = 0 ;
4142 int betaNegative = 0 ;
@@ -46,6 +47,7 @@ namespace theLHCInfoPerLSImpl {
4647 bool add = false ;
4748 auto payload = iov.second ;
4849 cond::Time_t since = iov.first ;
50+ // check if payload is different from the last one added to avoid duplicates
4951 if (iovsToTransfer.empty ()) {
5052 add = true ;
5153 } else {
@@ -54,6 +56,14 @@ namespace theLHCInfoPerLSImpl {
5456 add = true ;
5557 }
5658 }
59+ // skip payloads with IOV <= lastSince to avoid violating synchornization rules
60+ if (since <= lastSince) {
61+ add = false ;
62+ edm::LogWarning (" transferPayloads" )
63+ << " Skipping upload of payload with IOV <= last IOV of the destination tag: "
64+ << " (since=" << since << " , lastSince=" << lastSince << " )\n "
65+ << *payload;
66+ }
5767 auto id = make_pair (payload->runNumber (), payload->lumiSection ());
5868 bool stableBeam = since >= startStableBeamTime && since <= endStableBeamTime;
5969 bool isMissing = lsIdMap.find (id) != lsIdMap.end () && id != lsIdMap.at (id);
@@ -164,22 +174,18 @@ void LHCInfoPerLSPopConSourceHandler::handleInvalidPayloads() {
164174 // but iterating through the whole map is implemented just in case the way it's used changes
165175 auto it = m_iovs.begin ();
166176 while (it != m_iovs.end ()) {
167- std::stringstream payloadData;
168- payloadData << " LS = " << it->second ->lumiSection () << " , run = " << it->second ->runNumber () << " , "
169- << " xAngleX = " << it->second ->crossingAngleX () << " urad, "
170- << " xAngleY = " << it->second ->crossingAngleY () << " urad, "
171- << " beta*X = " << it->second ->betaStarX () << " m, "
172- << " beta*Y = " << it->second ->betaStarY () << " m" ;
173- if (!isPayloadValid (*(it->second ))) {
174- std::string msg = " Skipping upload of payload with invalid values: " + payloadData.str ();
177+ auto payload = it->second ;
178+ if (!isPayloadValid (*payload)) {
179+ std::ostringstream msg;
180+ msg << " Skipping upload of payload with invalid values: " << *payload;
175181 if (m_throwOnInvalid) {
176- throw cms::Exception (" LHCInfoPerLSPopConSourceHandler" ) << msg;
182+ throw cms::Exception (" LHCInfoPerLSPopConSourceHandler" ) << msg. str () ;
177183 } else {
178- edm::LogWarning (m_name) << msg;
184+ edm::LogWarning (m_name) << msg. str () ;
179185 }
180186 m_iovs.erase (it++); // note: post-increment necessary to avoid using invalidated iterators
181187 } else {
182- edm::LogInfo (m_name) << " Payload to be uploaded: " << payloadData. str () ;
188+ edm::LogInfo (m_name) << " Payload to be uploaded: " << *payload ;
183189 ++it;
184190 }
185191 }
@@ -241,6 +247,7 @@ void LHCInfoPerLSPopConSourceHandler::populateIovs() {
241247 // create the sessions
242248 cond::persistency::Session session = connection.createSession (m_connectionString, false );
243249 // fetch last payload when available
250+
244251 if (!tagInfo ().lastInterval .payloadId .empty ()) {
245252 cond::persistency::Session session3 = dbSession ();
246253 session3.transaction ().start (true );
@@ -394,7 +401,7 @@ void LHCInfoPerLSPopConSourceHandler::populateIovs() {
394401 }
395402
396403 size_t niovs = theLHCInfoPerLSImpl::transferPayloads (
397- m_tmpBuffer, m_iovs, m_prevPayload, m_lsIdMap, m_startStableBeamTime, m_endStableBeamTime);
404+ m_tmpBuffer, m_iovs, m_prevPayload, m_lsIdMap, m_startStableBeamTime, m_endStableBeamTime, lastSince );
398405 edm::LogInfo (m_name) << " Added " << niovs << " iovs within the Fill time" ;
399406 m_tmpBuffer.clear ();
400407 m_lsIdMap.clear ();
@@ -523,6 +530,9 @@ size_t LHCInfoPerLSPopConSourceHandler::getLumiData(const cond::OMSService& oms,
523530 auto query = oms.query (" lumisections" );
524531 query->addOutputVars ({" start_time" , " run_number" , " beams_stable" , " lumisection_number" });
525532 query->filterEQ (" fill_number" , fillId);
533+ // note: the filtering on OMS side works in precision of milliseconds but the values return by OMS have precision of seconds
534+ // this makes the GT and GE behave unexpectedly
535+ // (GT for 10:00:00 can return also 10:00:00 and GE can skip it depending on the milliseconds part of the value stored in OMS)
526536 query->filterGT (" start_time" , beginFillTime).filterLT (" start_time" , endFillTime);
527537 query->limit (cond::lhcInfoHelper::kLumisectionsQueryLimit );
528538 size_t nlumi = 0 ;
@@ -546,6 +556,7 @@ size_t LHCInfoPerLSPopConSourceHandler::getLumiData(const cond::OMSService& oms,
546556 }
547557 return nlumi;
548558}
559+
549560bool LHCInfoPerLSPopConSourceHandler::getCTPPSData (cond::persistency::Session& session,
550561 const boost::posix_time::ptime& beginFillTime,
551562 const boost::posix_time::ptime& endFillTime) {
0 commit comments