CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes
LHCInfoPerLSPopConSourceHandler Class Reference
Inheritance diagram for LHCInfoPerLSPopConSourceHandler:
popcon::PopConSourceHandler< LHCInfoPerLS >

Public Member Functions

void getNewObjects () override
 
std::string id () const override
 
 LHCInfoPerLSPopConSourceHandler (edm::ParameterSet const &pset)
 
 ~LHCInfoPerLSPopConSourceHandler () override=default
 
- Public Member Functions inherited from popcon::PopConSourceHandler< LHCInfoPerLS >
void initialize (const cond::persistency::Session &dbSession, cond::TagInfo_t const &tagInfo, cond::LogDBEntry_t const &logDBEntry)
 
Ref lastPayload () const
 
cond::LogDBEntry_t const & logDBEntry () const
 
std::pair< Container const *, std::string const > operator() (const cond::persistency::Session &session, cond::TagInfo_t const &tagInfo, cond::LogDBEntry_t const &logDBEntry) const
 
 PopConSourceHandler ()
 
Container const & returnData ()
 
cond::TagInfo_t const & tagInfo () const
 
std::string const & userTextLog () const
 
virtual ~PopConSourceHandler ()
 

Static Public Attributes

static constexpr unsigned int kLumisectionsQueryLimit = 4000
 

Private Member Functions

void addEmptyPayload (cond::Time_t iov)
 
void addPayloadToBuffer (cond::OMSServiceResultRef &row)
 
size_t bufferAllLS (const cond::OMSServiceResult &queryResult)
 
size_t bufferFirstStableBeamLS (const cond::OMSServiceResult &queryResult)
 
bool getCTTPSData (cond::persistency::Session &session, const boost::posix_time::ptime &beginFillTime, const boost::posix_time::ptime &endFillTime)
 
size_t getLumiData (const cond::OMSService &oms, unsigned short fillId, const boost::posix_time::ptime &beginFillTime, const boost::posix_time::ptime &endFillTime)
 
bool makeFillPayload (std::unique_ptr< LHCInfoPerLS > &targetPayload, const cond::OMSServiceResult &queryResult)
 

Private Attributes

std::string m_authpath
 
std::string m_connectionString
 
bool m_debug
 
std::string m_dipSchema
 
std::string m_ecalConnectionString
 
bool m_endFillMode = true
 
cond::Time_t m_endFillTime
 
boost::posix_time::ptime m_endTime
 
std::unique_ptr< LHCInfoPerLSm_fillPayload
 
bool m_lastPayloadEmpty = false
 
std::string m_name
 
std::string m_omsBaseUrl
 
cond::Time_t m_prevEndFillTime
 
std::shared_ptr< LHCInfoPerLSm_prevPayload
 
cond::Time_t m_prevStartFillTime
 
unsigned int m_samplingInterval
 
cond::Time_t m_startFillTime
 
boost::posix_time::ptime m_startTime
 
std::vector< std::pair< cond::Time_t, std::shared_ptr< LHCInfoPerLS > > > m_tmpBuffer
 

Additional Inherited Members

- Public Types inherited from popcon::PopConSourceHandler< LHCInfoPerLS >
typedef std::map< Time_t, std::shared_ptr< LHCInfoPerLS > > Container
 
typedef std::unique_ptr< LHCInfoPerLSRef
 
typedef PopConSourceHandler< LHCInfoPerLSself
 
typedef cond::Time_t Time_t
 
typedef LHCInfoPerLS value_type
 
- Protected Member Functions inherited from popcon::PopConSourceHandler< LHCInfoPerLS >
cond::persistency::SessiondbSession () const
 
- Protected Attributes inherited from popcon::PopConSourceHandler< LHCInfoPerLS >
Container m_iovs
 
std::vector< std::pair< LHCInfoPerLS *, Time_t > > m_to_transfer
 
std::string m_userTextLog
 

Detailed Description

Definition at line 138 of file LHCInfoPerLSPopConAnalyzer.cc.

Constructor & Destructor Documentation

◆ LHCInfoPerLSPopConSourceHandler()

LHCInfoPerLSPopConSourceHandler::LHCInfoPerLSPopConSourceHandler ( edm::ParameterSet const &  pset)
inline

Definition at line 140 of file LHCInfoPerLSPopConAnalyzer.cc.

References m_endTime, m_startTime, submitPVValidationJobs::now, muonDTDigis_cfi::pset, and AlCaHLTBitMon_QueryRunRegistry::string.

141  : m_debug(pset.getUntrackedParameter<bool>("debug", false)),
142  m_startTime(),
143  m_endTime(),
144  m_samplingInterval((unsigned int)pset.getUntrackedParameter<unsigned int>("samplingInterval", 300)),
145  m_endFillMode(pset.getUntrackedParameter<bool>("endFill", true)),
146  m_name(pset.getUntrackedParameter<std::string>("name", "LHCInfoPerLSPopConSourceHandler")),
147  m_connectionString(pset.getUntrackedParameter<std::string>("connectionString", "")),
148  m_dipSchema(pset.getUntrackedParameter<std::string>("DIPSchema", "")),
149  m_authpath(pset.getUntrackedParameter<std::string>("authenticationPath", "")),
150  m_omsBaseUrl(pset.getUntrackedParameter<std::string>("omsBaseUrl", "")),
151  m_fillPayload(),
152  m_prevPayload(),
153  m_tmpBuffer() {
154  if (!pset.getUntrackedParameter<std::string>("startTime").empty()) {
155  m_startTime = boost::posix_time::time_from_string(pset.getUntrackedParameter<std::string>("startTime"));
156  }
157  boost::posix_time::ptime now = boost::posix_time::second_clock::local_time();
158  m_endTime = now;
159  if (!pset.getUntrackedParameter<std::string>("endTime").empty()) {
160  m_endTime = boost::posix_time::time_from_string(pset.getUntrackedParameter<std::string>("endTime"));
161  if (m_endTime > now)
162  m_endTime = now;
163  }
164  }
std::shared_ptr< LHCInfoPerLS > m_prevPayload
std::vector< std::pair< cond::Time_t, std::shared_ptr< LHCInfoPerLS > > > m_tmpBuffer
std::unique_ptr< LHCInfoPerLS > m_fillPayload

◆ ~LHCInfoPerLSPopConSourceHandler()

LHCInfoPerLSPopConSourceHandler::~LHCInfoPerLSPopConSourceHandler ( )
overridedefault

Member Function Documentation

◆ addEmptyPayload()

void LHCInfoPerLSPopConSourceHandler::addEmptyPayload ( cond::Time_t  iov)
inlineprivate

Definition at line 343 of file LHCInfoPerLSPopConAnalyzer.cc.

References PVValHelper::add(), popcon::PopConSourceHandler< LHCInfoPerLS >::m_iovs, m_lastPayloadEmpty, m_name, m_prevEndFillTime, m_prevPayload, m_prevStartFillTime, and cond::time::to_boost().

Referenced by getNewObjects().

343  {
344  bool add = false;
345  if (m_iovs.empty()) {
346  if (!m_lastPayloadEmpty)
347  add = true;
348  } else {
349  auto lastAdded = m_iovs.rbegin()->second;
350  if (lastAdded->fillNumber() != 0) {
351  add = true;
352  }
353  }
354  if (add) {
355  auto newPayload = std::make_shared<LHCInfoPerLS>();
356  m_iovs.insert(std::make_pair(iov, newPayload));
357  m_prevPayload = newPayload;
358  m_prevEndFillTime = 0;
360  edm::LogInfo(m_name) << "Added empty payload with IOV" << iov << " ( "
361  << boost::posix_time::to_iso_extended_string(cond::time::to_boost(iov)) << " )";
362  }
363  }
std::shared_ptr< LHCInfoPerLS > m_prevPayload
Log< level::Info, false > LogInfo
void add(std::map< std::string, TH1 *> &h, TH1 *hist)
boost::posix_time::ptime to_boost(Time_t iValue)

◆ addPayloadToBuffer()

void LHCInfoPerLSPopConSourceHandler::addPayloadToBuffer ( cond::OMSServiceResultRef row)
inlineprivate

Definition at line 379 of file LHCInfoPerLSPopConAnalyzer.cc.

References cond::time::from_boost(), cond::OMSServiceResultRef::get(), cond::time::lumiTime(), m_fillPayload, and m_tmpBuffer.

Referenced by bufferAllLS(), bufferFirstStableBeamLS(), and getLumiData().

379  {
380  auto lumiTime = row.get<boost::posix_time::ptime>("start_time");
381  LHCInfoPerLS* thisLumiSectionInfo = new LHCInfoPerLS(*m_fillPayload);
382  m_tmpBuffer.emplace_back(std::make_pair(cond::time::from_boost(lumiTime), thisLumiSectionInfo));
383  }
T get(const std::string &attributeName)
Definition: OMSAccess.h:114
std::vector< std::pair< cond::Time_t, std::shared_ptr< LHCInfoPerLS > > > m_tmpBuffer
Time_t lumiTime(unsigned int run, unsigned int lumiId)
Definition: Time.cc:66
Time_t from_boost(boost::posix_time::ptime bt)
std::unique_ptr< LHCInfoPerLS > m_fillPayload

◆ bufferAllLS()

size_t LHCInfoPerLSPopConSourceHandler::bufferAllLS ( const cond::OMSServiceResult queryResult)
inlineprivate

Definition at line 385 of file LHCInfoPerLSPopConAnalyzer.cc.

References addPayloadToBuffer(), and alignCSCRings::r.

Referenced by getLumiData().

385  {
386  for (auto r : queryResult) {
388  }
389  return queryResult.size();
390  }
void addPayloadToBuffer(cond::OMSServiceResultRef &row)

◆ bufferFirstStableBeamLS()

size_t LHCInfoPerLSPopConSourceHandler::bufferFirstStableBeamLS ( const cond::OMSServiceResult queryResult)
inlineprivate

Definition at line 392 of file LHCInfoPerLSPopConAnalyzer.cc.

References addPayloadToBuffer(), m_name, alignCSCRings::r, and AlCaHLTBitMon_QueryRunRegistry::string.

392  {
393  for (auto r : queryResult) {
394  if (r.get<std::string>("beams_stable") == "true") {
396  edm::LogInfo(m_name) << "Buffered first lumisection of stable beam: LS: "
397  << r.get<std::string>("lumisection_number")
398  << " run: " << r.get<std::string>("run_number");
399  return 1;
400  }
401  }
402  return 0;
403  }
void addPayloadToBuffer(cond::OMSServiceResultRef &row)
Log< level::Info, false > LogInfo

◆ getCTTPSData()

bool LHCInfoPerLSPopConSourceHandler::getCTTPSData ( cond::persistency::Session session,
const boost::posix_time::ptime &  beginFillTime,
const boost::posix_time::ptime &  endFillTime 
)
inlineprivate

Definition at line 435 of file LHCInfoPerLSPopConAnalyzer.cc.

References cond::persistency::Session::coralSession(), ALCARECOTkAlBeamHalo_cff::filter, cond::time::from_boost(), m_debug, m_tmpBuffer, jetsAK4_Puppi_cff::payload, runTheMatrix::ret, convertSQLiteXML::runNumber, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by getNewObjects().

437  {
438  //run the fifth query against the CTPPS schema
439  //Initializing the CMS_CTP_CTPPS_COND schema.
440  coral::ISchema& CTPPS = session.coralSession().schema("CMS_PPS_SPECT_COND");
441  //execute query for CTPPS Data
442  std::unique_ptr<coral::IQuery> CTPPSDataQuery(CTPPS.newQuery());
443  //FROM clause
444  CTPPSDataQuery->addToTableList(std::string("PPS_LHC_MACHINE_PARAMS"));
445  //SELECT clause
446  CTPPSDataQuery->addToOutputList(std::string("DIP_UPDATE_TIME"));
447  CTPPSDataQuery->addToOutputList(std::string("LUMI_SECTION"));
448  CTPPSDataQuery->addToOutputList(std::string("RUN_NUMBER"));
449  CTPPSDataQuery->addToOutputList(std::string("XING_ANGLE_P5_X_URAD"));
450  CTPPSDataQuery->addToOutputList(std::string("XING_ANGLE_P5_Y_URAD"));
451  CTPPSDataQuery->addToOutputList(std::string("BETA_STAR_P5_X_M"));
452  CTPPSDataQuery->addToOutputList(std::string("BETA_STAR_P5_Y_M"));
453  //WHERE CLAUSE
454  coral::AttributeList CTPPSDataBindVariables;
455  CTPPSDataBindVariables.extend<coral::TimeStamp>(std::string("beginFillTime"));
456  CTPPSDataBindVariables.extend<coral::TimeStamp>(std::string("endFillTime"));
457  CTPPSDataBindVariables[std::string("beginFillTime")].data<coral::TimeStamp>() = coral::TimeStamp(beginFillTime);
458  CTPPSDataBindVariables[std::string("endFillTime")].data<coral::TimeStamp>() = coral::TimeStamp(endFillTime);
459  std::string conditionStr = std::string("DIP_UPDATE_TIME>= :beginFillTime and DIP_UPDATE_TIME< :endFillTime");
460  CTPPSDataQuery->setCondition(conditionStr, CTPPSDataBindVariables);
461  //ORDER BY clause
462  CTPPSDataQuery->addToOrderList(std::string("DIP_UPDATE_TIME"));
463  //define query output
464  coral::AttributeList CTPPSDataOutput;
465  CTPPSDataOutput.extend<coral::TimeStamp>(std::string("DIP_UPDATE_TIME"));
466  CTPPSDataOutput.extend<int>(std::string("LUMI_SECTION"));
467  CTPPSDataOutput.extend<int>(std::string("RUN_NUMBER"));
468  CTPPSDataOutput.extend<float>(std::string("XING_ANGLE_P5_X_URAD"));
469  CTPPSDataOutput.extend<float>(std::string("XING_ANGLE_P5_Y_URAD"));
470  CTPPSDataOutput.extend<float>(std::string("BETA_STAR_P5_X_M"));
471  CTPPSDataOutput.extend<float>(std::string("BETA_STAR_P5_Y_M"));
472  CTPPSDataQuery->defineOutput(CTPPSDataOutput);
473  //execute the query
474  coral::ICursor& CTPPSDataCursor = CTPPSDataQuery->execute();
475  cond::Time_t dipTime = 0;
476  unsigned int lumiSection = 0;
478  float crossingAngleX = 0., betaStarX = 0.;
479  float crossingAngleY = 0., betaStarY = 0.;
480 
481  bool ret = false;
483  while (CTPPSDataCursor.next()) {
484  if (m_debug) {
485  std::ostringstream CTPPS;
486  CTPPSDataCursor.currentRow().toOutputStream(CTPPS);
487  }
488  coral::Attribute const& dipTimeAttribute = CTPPSDataCursor.currentRow()[std::string("DIP_UPDATE_TIME")];
489  if (!dipTimeAttribute.isNull()) {
490  dipTime = cond::time::from_boost(dipTimeAttribute.data<coral::TimeStamp>().time());
491  if (filter.process(dipTime)) {
492  ret = true;
493  coral::Attribute const& lumiSectionAttribute = CTPPSDataCursor.currentRow()[std::string("LUMI_SECTION")];
494  if (!lumiSectionAttribute.isNull()) {
495  lumiSection = lumiSectionAttribute.data<int>();
496  }
497  coral::Attribute const& runNumberAttribute = CTPPSDataCursor.currentRow()[std::string("RUN_NUMBER")];
498  if (!runNumberAttribute.isNull()) {
499  runNumber = runNumberAttribute.data<int>();
500  }
501  coral::Attribute const& crossingAngleXAttribute =
502  CTPPSDataCursor.currentRow()[std::string("XING_ANGLE_P5_X_URAD")];
503  if (!crossingAngleXAttribute.isNull()) {
504  crossingAngleX = crossingAngleXAttribute.data<float>();
505  }
506  coral::Attribute const& crossingAngleYAttribute =
507  CTPPSDataCursor.currentRow()[std::string("XING_ANGLE_P5_Y_URAD")];
508  if (!crossingAngleYAttribute.isNull()) {
509  crossingAngleY = crossingAngleYAttribute.data<float>();
510  }
511  coral::Attribute const& betaStarXAttribute = CTPPSDataCursor.currentRow()[std::string("BETA_STAR_P5_X_M")];
512  if (!betaStarXAttribute.isNull()) {
513  betaStarX = betaStarXAttribute.data<float>();
514  }
515  coral::Attribute const& betaStarYAttribute = CTPPSDataCursor.currentRow()[std::string("BETA_STAR_P5_Y_M")];
516  if (!betaStarYAttribute.isNull()) {
517  betaStarY = betaStarYAttribute.data<float>();
518  }
519  for (auto it = filter.current(); it != m_tmpBuffer.end(); it++) {
520  // set the current values to all of the payloads of the lumi section samples after the current since
521  LHCInfoPerLS& payload = *(it->second);
522  payload.setCrossingAngleX(crossingAngleX);
523  payload.setCrossingAngleY(crossingAngleY);
524  payload.setBetaStarX(betaStarX);
525  payload.setBetaStarY(betaStarY);
526  payload.setLumiSection(lumiSection);
527  payload.setRunNumber(runNumber);
528  }
529  }
530  }
531  }
532  return ret;
533  }
ret
prodAgent to be discontinued
std::vector< std::pair< cond::Time_t, std::shared_ptr< LHCInfoPerLS > > > m_tmpBuffer
unsigned long long Time_t
Definition: Time.h:14
Time_t from_boost(boost::posix_time::ptime bt)
coral::ISessionProxy & coralSession()
Definition: Session.cc:218

◆ getLumiData()

size_t LHCInfoPerLSPopConSourceHandler::getLumiData ( const cond::OMSService oms,
unsigned short  fillId,
const boost::posix_time::ptime &  beginFillTime,
const boost::posix_time::ptime &  endFillTime 
)
inlineprivate

Definition at line 405 of file LHCInfoPerLSPopConAnalyzer.cc.

References addPayloadToBuffer(), bufferAllLS(), kLumisectionsQueryLimit, m_endFillMode, m_name, cond::OMSService::query(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by getNewObjects().

408  {
409  auto query = oms.query("lumisections");
410  query->addOutputVars({"start_time", "run_number", "beams_stable", "lumisection_number"});
411  query->filterEQ("fill_number", fillId);
412  query->filterGT("start_time", beginFillTime).filterLT("start_time", endFillTime);
414  size_t nlumi = 0;
415  if (query->execute()) {
416  auto queryResult = query->result();
417  if (m_endFillMode) {
418  nlumi = bufferAllLS(queryResult);
419  } else if (!queryResult.empty()) {
420  auto newestPayload = queryResult.back();
421  if (newestPayload.get<std::string>("beams_stable") == "true") {
422  addPayloadToBuffer(newestPayload);
423  nlumi = 1;
424  edm::LogInfo(m_name) << "Buffered most recent lumisection:"
425  << " LS: " << newestPayload.get<std::string>("lumisection_number")
426  << " run: " << newestPayload.get<std::string>("run_number");
427  }
428  }
429  edm::LogInfo(m_name) << "Found " << queryResult.size() << " lumisections during the fill " << fillId;
430  } else {
431  edm::LogInfo(m_name) << "OMS query for lumisections of fill " << fillId << "failed, status:" << query->status();
432  }
433  return nlumi;
434  }
std::unique_ptr< OMSServiceQuery > query(const std::string &function) const
Definition: OMSAccess.cc:129
Definition: query.py:1
size_t bufferAllLS(const cond::OMSServiceResult &queryResult)
void addPayloadToBuffer(cond::OMSServiceResultRef &row)
Log< level::Info, false > LogInfo
static constexpr unsigned int kLumisectionsQueryLimit

◆ getNewObjects()

void LHCInfoPerLSPopConSourceHandler::getNewObjects ( )
inlineoverridevirtual

Implements popcon::PopConSourceHandler< LHCInfoPerLS >.

Definition at line 168 of file LHCInfoPerLSPopConAnalyzer.cc.

References addEmptyPayload(), cond::persistency::Transaction::commit(), cond::persistency::ConnectionPool::configure(), cond::OMSService::connect(), cond::persistency::ConnectionPool::createSession(), popcon::PopConSourceHandler< LHCInfoPerLS >::dbSession(), Debug, cond::persistency::Session::fetchPayload(), cond::time::from_boost(), getCTTPSData(), getLumiData(), cond::TagInfo_t::lastInterval, m_authpath, m_connectionString, m_debug, m_endFillMode, m_endFillTime, m_endTime, m_fillPayload, popcon::PopConSourceHandler< LHCInfoPerLS >::m_iovs, m_name, m_omsBaseUrl, m_prevEndFillTime, m_prevPayload, m_prevStartFillTime, m_startFillTime, m_startTime, m_tmpBuffer, makeFillPayload(), cond::TagInfo_t::name, cond::Iov_t::payloadId, cond::OMSService::query(), mps_fire::result, cond::persistency::ConnectionPool::setAuthenticationPath(), cond::persistency::ConnectionPool::setMessageVerbosity(), cond::Iov_t::since, cond::TagInfo_t::size, findQualityFiles::size, cond::persistency::Transaction::start(), popcon::PopConSourceHandler< LHCInfoPerLS >::tagInfo(), cond::time::to_boost(), cond::persistency::Session::transaction(), and theLHCInfoPerLSImpl::transferPayloads().

168  {
169  //if a new tag is created, transfer fake fill from 1 to the first fill for the first time
170  if (tagInfo().size == 0) {
171  edm::LogInfo(m_name) << "New tag " << tagInfo().name << "; from " << m_name << "::getNewObjects";
172  } else {
173  //check what is already inside the database
174  edm::LogInfo(m_name) << "got info for tag " << tagInfo().name << ": size " << tagInfo().size
175  << ", last object valid since " << tagInfo().lastInterval.since << " ( "
176  << boost::posix_time::to_iso_extended_string(
177  cond::time::to_boost(tagInfo().lastInterval.since))
178  << " ); from " << m_name << "::getNewObjects";
179  }
180 
181  cond::Time_t lastSince = tagInfo().lastInterval.since;
182  if (tagInfo().isEmpty()) {
183  // for a new or empty tag, an empty payload should be added on top with since=1
184  addEmptyPayload(1);
185  lastSince = 1;
186  } else {
187  edm::LogInfo(m_name) << "The last Iov in tag " << tagInfo().name << " valid since " << lastSince << "from "
188  << m_name << "::getNewObjects";
189  }
190 
191  boost::posix_time::ptime executionTime = boost::posix_time::second_clock::local_time();
192  cond::Time_t targetSince = 0;
193  cond::Time_t executionTimeIov = cond::time::from_boost(executionTime);
194  if (!m_startTime.is_not_a_date_time()) {
195  targetSince = cond::time::from_boost(m_startTime);
196  }
197  if (lastSince > targetSince)
198  targetSince = lastSince;
199 
200  edm::LogInfo(m_name) << "Starting sampling at "
201  << boost::posix_time::to_simple_string(cond::time::to_boost(targetSince));
202 
203  //retrieve the data from the relational database source
205  //configure the connection
206  if (m_debug) {
207  connection.setMessageVerbosity(coral::Debug);
208  } else {
209  connection.setMessageVerbosity(coral::Error);
210  }
211  connection.setAuthenticationPath(m_authpath);
212  connection.configure();
213  //create the sessions
214  cond::persistency::Session session = connection.createSession(m_connectionString, false);
215  // fetch last payload when available
216  if (!tagInfo().lastInterval.payloadId.empty()) {
218  session3.transaction().start(true);
220  session3.transaction().commit();
221 
222  // find startFillTime and endFillTime of the most recent fill already saved in the tag
223  if (m_prevPayload->fillNumber() != 0) {
224  cond::OMSService oms;
225  oms.connect(m_omsBaseUrl);
226  auto query = oms.query("fills");
227  query->addOutputVar("end_time");
228  query->filterEQ("fill_number", m_prevPayload->fillNumber());
229  bool foundFill = query->execute();
230  if (foundFill) {
231  auto result = query->result();
232 
233  if (!result.empty()) {
234  auto endFillTime = (*result.begin()).get<boost::posix_time::ptime>("end_time");
236  auto startFillTime = (*result.begin()).get<boost::posix_time::ptime>("start_time");
238  } else {
239  foundFill = false;
240  }
241  }
242  if (!foundFill) {
243  edm::LogError(m_name) << "Could not find end time of fill #" << m_prevPayload->fillNumber();
244  }
245  } else {
246  m_prevEndFillTime = 0;
248  }
249  }
250 
251  while (true) {
252  if (targetSince >= executionTimeIov) {
253  edm::LogInfo(m_name) << "Sampling ended at the time "
254  << boost::posix_time::to_simple_string(cond::time::to_boost(executionTimeIov));
255  break;
256  }
257  boost::posix_time::ptime targetTime = cond::time::to_boost(targetSince);
258  boost::posix_time::ptime startSampleTime;
259  boost::posix_time::ptime endSampleTime;
260 
261  cond::OMSService oms;
262  oms.connect(m_omsBaseUrl);
263  auto query = oms.query("fills");
264 
265  if (!m_endFillMode and m_prevPayload->fillNumber() and m_prevEndFillTime == 0ULL) {
266  // continue processing unfinished fill with some payloads already in the tag
267  edm::LogInfo(m_name) << "Searching started fill #" << m_prevPayload->fillNumber();
268  query->filterEQ("fill_number", m_prevPayload->fillNumber());
269  bool foundFill = query->execute();
270  if (foundFill)
271  foundFill = makeFillPayload(m_fillPayload, query->result());
272  if (!foundFill) {
273  edm::LogError(m_name) << "Could not find fill #" << m_prevPayload->fillNumber();
274  break;
275  }
276  startSampleTime = cond::time::to_boost(lastSince);
277  } else {
278  edm::LogInfo(m_name) << "Searching new fill after " << boost::posix_time::to_simple_string(targetTime);
279  query->filterNotNull("start_stable_beam").filterNotNull("fill_number");
280  if (targetTime > cond::time::to_boost(m_prevStartFillTime)) {
281  query->filterGE("start_time", targetTime);
282  } else {
283  query->filterGT("start_time", targetTime);
284  }
285 
286  query->filterLT("start_time", m_endTime);
287  if (m_endFillMode)
288  query->filterNotNull("end_time");
289  bool foundFill = query->execute();
290  if (foundFill)
291  foundFill = makeFillPayload(m_fillPayload, query->result());
292  if (!foundFill) {
293  edm::LogInfo(m_name) << "No fill found - END of job.";
294  break;
295  }
296  startSampleTime = cond::time::to_boost(m_startFillTime);
297  }
298 
299  unsigned short lhcFill = m_fillPayload->fillNumber();
300  bool ongoingFill = m_endFillTime == 0ULL;
301  if (ongoingFill) {
302  edm::LogInfo(m_name) << "Found ongoing fill " << lhcFill << " created at "
304  endSampleTime = executionTime;
305  targetSince = executionTimeIov;
306  } else {
307  edm::LogInfo(m_name) << "Found fill " << lhcFill << " created at " << cond::time::to_boost(m_startFillTime)
308  << " ending at " << cond::time::to_boost(m_endFillTime);
309  endSampleTime = cond::time::to_boost(m_endFillTime);
310  targetSince = m_endFillTime;
311  }
312 
313  if (m_endFillMode || ongoingFill) {
314  getLumiData(oms, lhcFill, startSampleTime, endSampleTime);
315 
316  if (!m_tmpBuffer.empty()) {
317  boost::posix_time::ptime flumiStart = cond::time::to_boost(m_tmpBuffer.front().first);
318  boost::posix_time::ptime flumiStop = cond::time::to_boost(m_tmpBuffer.back().first);
319  edm::LogInfo(m_name) << "First buffered lumi starts at " << flumiStart << " last lumi starts at "
320  << flumiStop;
321  session.transaction().start(true);
322  getCTTPSData(session, startSampleTime, endSampleTime);
323  session.transaction().commit();
324  }
325  }
326 
328  edm::LogInfo(m_name) << "Added " << niovs << " iovs within the Fill time";
329  if (niovs) {
332  }
333  m_tmpBuffer.clear();
334  if (m_prevPayload->fillNumber() and !ongoingFill)
336  }
337  }
size
Write out results.
edm::ErrorSummaryEntry Error
bool makeFillPayload(std::unique_ptr< LHCInfoPerLS > &targetPayload, const cond::OMSServiceResult &queryResult)
Iov_t lastInterval
Definition: Types.h:73
std::unique_ptr< OMSServiceQuery > query(const std::string &function) const
Definition: OMSAccess.cc:129
std::shared_ptr< LHCInfoPerLS > m_prevPayload
void start(bool readOnly=true)
Definition: Session.cc:18
Time_t since
Definition: Types.h:53
size_t size
Definition: Types.h:74
std::unique_ptr< T > fetchPayload(const cond::Hash &payloadHash)
Definition: Session.h:213
std::vector< std::pair< cond::Time_t, std::shared_ptr< LHCInfoPerLS > > > m_tmpBuffer
Log< level::Error, false > LogError
Transaction & transaction()
Definition: Session.cc:52
std::string name
Definition: Types.h:72
Definition: query.py:1
cond::TagInfo_t const & tagInfo() const
bool getCTTPSData(cond::persistency::Session &session, const boost::posix_time::ptime &beginFillTime, const boost::posix_time::ptime &endFillTime)
unsigned long long Time_t
Definition: Time.h:14
size_t transferPayloads(const std::vector< std::pair< cond::Time_t, std::shared_ptr< LHCInfoPerLS >>> &buffer, std::map< cond::Time_t, std::shared_ptr< LHCInfoPerLS >> &iovsToTransfer, std::shared_ptr< LHCInfoPerLS > &prevPayload)
Hash payloadId
Definition: Types.h:55
Session createSession(const std::string &connectionString, bool writeCapable=false)
void setMessageVerbosity(coral::MsgLevel level)
Time_t from_boost(boost::posix_time::ptime bt)
Log< level::Info, false > LogInfo
cond::persistency::Session & dbSession() const
std::unique_ptr< LHCInfoPerLS > m_fillPayload
void connect(const std::string &baseUrl)
Definition: OMSAccess.cc:128
void setAuthenticationPath(const std::string &p)
const bool Debug
boost::posix_time::ptime to_boost(Time_t iValue)
size_t getLumiData(const cond::OMSService &oms, unsigned short fillId, const boost::posix_time::ptime &beginFillTime, const boost::posix_time::ptime &endFillTime)

◆ id()

std::string LHCInfoPerLSPopConSourceHandler::id ( ) const
inlineoverridevirtual

◆ makeFillPayload()

bool LHCInfoPerLSPopConSourceHandler::makeFillPayload ( std::unique_ptr< LHCInfoPerLS > &  targetPayload,
const cond::OMSServiceResult queryResult 
)
inlineprivate

Definition at line 365 of file LHCInfoPerLSPopConAnalyzer.cc.

References cond::OMSServiceResult::begin(), cond::OMSServiceResult::empty(), cond::time::from_boost(), m_endFillTime, m_startFillTime, and runTheMatrix::ret.

Referenced by getNewObjects().

365  {
366  bool ret = false;
367  if (!queryResult.empty()) {
368  auto row = *queryResult.begin();
369  auto currentFill = row.get<unsigned short>("fill_number");
370  m_startFillTime = cond::time::from_boost(row.get<boost::posix_time::ptime>("start_time"));
371  m_endFillTime = cond::time::from_boost(row.get<boost::posix_time::ptime>("end_time"));
372  targetPayload = std::make_unique<LHCInfoPerLS>();
373  targetPayload->setFillNumber(currentFill);
374  ret = true;
375  }
376  return ret;
377  }
ret
prodAgent to be discontinued
bool empty() const
Definition: OMSAccess.cc:69
Time_t from_boost(boost::posix_time::ptime bt)
OMSServiceResultIterator begin() const
Definition: OMSAccess.cc:32

Member Data Documentation

◆ kLumisectionsQueryLimit

constexpr unsigned int LHCInfoPerLSPopConSourceHandler::kLumisectionsQueryLimit = 4000
static

Definition at line 340 of file LHCInfoPerLSPopConAnalyzer.cc.

Referenced by getLumiData().

◆ m_authpath

std::string LHCInfoPerLSPopConSourceHandler::m_authpath
private

Definition at line 546 of file LHCInfoPerLSPopConAnalyzer.cc.

Referenced by getNewObjects().

◆ m_connectionString

std::string LHCInfoPerLSPopConSourceHandler::m_connectionString
private

Definition at line 545 of file LHCInfoPerLSPopConAnalyzer.cc.

Referenced by getNewObjects().

◆ m_debug

bool LHCInfoPerLSPopConSourceHandler::m_debug
private

Definition at line 536 of file LHCInfoPerLSPopConAnalyzer.cc.

Referenced by getCTTPSData(), and getNewObjects().

◆ m_dipSchema

std::string LHCInfoPerLSPopConSourceHandler::m_dipSchema
private

Definition at line 546 of file LHCInfoPerLSPopConAnalyzer.cc.

◆ m_ecalConnectionString

std::string LHCInfoPerLSPopConSourceHandler::m_ecalConnectionString
private

Definition at line 545 of file LHCInfoPerLSPopConAnalyzer.cc.

◆ m_endFillMode

bool LHCInfoPerLSPopConSourceHandler::m_endFillMode = true
private

Definition at line 542 of file LHCInfoPerLSPopConAnalyzer.cc.

Referenced by getLumiData(), and getNewObjects().

◆ m_endFillTime

cond::Time_t LHCInfoPerLSPopConSourceHandler::m_endFillTime
private

Definition at line 551 of file LHCInfoPerLSPopConAnalyzer.cc.

Referenced by getNewObjects(), and makeFillPayload().

◆ m_endTime

boost::posix_time::ptime LHCInfoPerLSPopConSourceHandler::m_endTime
private

◆ m_fillPayload

std::unique_ptr<LHCInfoPerLS> LHCInfoPerLSPopConSourceHandler::m_fillPayload
private

Definition at line 548 of file LHCInfoPerLSPopConAnalyzer.cc.

Referenced by addPayloadToBuffer(), and getNewObjects().

◆ m_lastPayloadEmpty

bool LHCInfoPerLSPopConSourceHandler::m_lastPayloadEmpty = false
private

Definition at line 555 of file LHCInfoPerLSPopConAnalyzer.cc.

Referenced by addEmptyPayload().

◆ m_name

std::string LHCInfoPerLSPopConSourceHandler::m_name
private

◆ m_omsBaseUrl

std::string LHCInfoPerLSPopConSourceHandler::m_omsBaseUrl
private

Definition at line 547 of file LHCInfoPerLSPopConAnalyzer.cc.

Referenced by getNewObjects().

◆ m_prevEndFillTime

cond::Time_t LHCInfoPerLSPopConSourceHandler::m_prevEndFillTime
private

Definition at line 552 of file LHCInfoPerLSPopConAnalyzer.cc.

Referenced by addEmptyPayload(), and getNewObjects().

◆ m_prevPayload

std::shared_ptr<LHCInfoPerLS> LHCInfoPerLSPopConSourceHandler::m_prevPayload
private

Definition at line 549 of file LHCInfoPerLSPopConAnalyzer.cc.

Referenced by addEmptyPayload(), and getNewObjects().

◆ m_prevStartFillTime

cond::Time_t LHCInfoPerLSPopConSourceHandler::m_prevStartFillTime
private

Definition at line 553 of file LHCInfoPerLSPopConAnalyzer.cc.

Referenced by addEmptyPayload(), and getNewObjects().

◆ m_samplingInterval

unsigned int LHCInfoPerLSPopConSourceHandler::m_samplingInterval
private

Definition at line 541 of file LHCInfoPerLSPopConAnalyzer.cc.

◆ m_startFillTime

cond::Time_t LHCInfoPerLSPopConSourceHandler::m_startFillTime
private

Definition at line 550 of file LHCInfoPerLSPopConAnalyzer.cc.

Referenced by getNewObjects(), and makeFillPayload().

◆ m_startTime

boost::posix_time::ptime LHCInfoPerLSPopConSourceHandler::m_startTime
private

◆ m_tmpBuffer

std::vector<std::pair<cond::Time_t, std::shared_ptr<LHCInfoPerLS> > > LHCInfoPerLSPopConSourceHandler::m_tmpBuffer
private

Definition at line 554 of file LHCInfoPerLSPopConAnalyzer.cc.

Referenced by addPayloadToBuffer(), getCTTPSData(), and getNewObjects().