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 75 of file LHCInfoPerLSPopConAnalyzer.cc.

Constructor & Destructor Documentation

◆ LHCInfoPerLSPopConSourceHandler()

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

Definition at line 77 of file LHCInfoPerLSPopConAnalyzer.cc.

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

78  : m_debug(pset.getUntrackedParameter<bool>("debug", false)),
79  m_startTime(),
80  m_endTime(),
81  m_samplingInterval((unsigned int)pset.getUntrackedParameter<unsigned int>("samplingInterval", 300)),
82  m_endFillMode(pset.getUntrackedParameter<bool>("endFill", true)),
83  m_name(pset.getUntrackedParameter<std::string>("name", "LHCInfoPerLSPopConSourceHandler")),
84  m_connectionString(pset.getUntrackedParameter<std::string>("connectionString", "")),
85  m_dipSchema(pset.getUntrackedParameter<std::string>("DIPSchema", "")),
86  m_authpath(pset.getUntrackedParameter<std::string>("authenticationPath", "")),
87  m_omsBaseUrl(pset.getUntrackedParameter<std::string>("omsBaseUrl", "")),
88  m_fillPayload(),
89  m_prevPayload(),
90  m_tmpBuffer() {
91  if (!pset.getUntrackedParameter<std::string>("startTime").empty()) {
92  m_startTime = boost::posix_time::time_from_string(pset.getUntrackedParameter<std::string>("startTime"));
93  }
94  boost::posix_time::ptime now = boost::posix_time::second_clock::local_time();
95  m_endTime = now;
96  if (!pset.getUntrackedParameter<std::string>("endTime").empty()) {
97  m_endTime = boost::posix_time::time_from_string(pset.getUntrackedParameter<std::string>("endTime"));
98  if (m_endTime > now)
99  m_endTime = now;
100  }
101  }
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 280 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().

280  {
281  bool add = false;
282  if (m_iovs.empty()) {
283  if (!m_lastPayloadEmpty)
284  add = true;
285  } else {
286  auto lastAdded = m_iovs.rbegin()->second;
287  if (lastAdded->fillNumber() != 0) {
288  add = true;
289  }
290  }
291  if (add) {
292  auto newPayload = std::make_shared<LHCInfoPerLS>();
293  m_iovs.insert(std::make_pair(iov, newPayload));
294  m_prevPayload = newPayload;
295  m_prevEndFillTime = 0;
297  edm::LogInfo(m_name) << "Added empty payload with IOV" << iov << " ( "
298  << boost::posix_time::to_iso_extended_string(cond::time::to_boost(iov)) << " )";
299  }
300  }
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 316 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().

316  {
317  auto lumiTime = row.get<boost::posix_time::ptime>("start_time");
318  LHCInfoPerLS* thisLumiSectionInfo = new LHCInfoPerLS(*m_fillPayload);
319  m_tmpBuffer.emplace_back(std::make_pair(cond::time::from_boost(lumiTime), thisLumiSectionInfo));
320  }
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 322 of file LHCInfoPerLSPopConAnalyzer.cc.

References addPayloadToBuffer(), and alignCSCRings::r.

Referenced by getLumiData().

322  {
323  for (auto r : queryResult) {
325  }
326  return queryResult.size();
327  }
void addPayloadToBuffer(cond::OMSServiceResultRef &row)

◆ bufferFirstStableBeamLS()

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

Definition at line 329 of file LHCInfoPerLSPopConAnalyzer.cc.

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

329  {
330  for (auto r : queryResult) {
331  if (r.get<std::string>("beams_stable") == "true") {
333  edm::LogInfo(m_name) << "Buffered first lumisection of stable beam: LS: "
334  << r.get<std::string>("lumisection_number")
335  << " run: " << r.get<std::string>("run_number");
336  return 1;
337  }
338  }
339  return 0;
340  }
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 372 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().

374  {
375  //run the fifth query against the CTPPS schema
376  //Initializing the CMS_CTP_CTPPS_COND schema.
377  coral::ISchema& CTPPS = session.coralSession().schema("CMS_PPS_SPECT_COND");
378  //execute query for CTPPS Data
379  std::unique_ptr<coral::IQuery> CTPPSDataQuery(CTPPS.newQuery());
380  //FROM clause
381  CTPPSDataQuery->addToTableList(std::string("PPS_LHC_MACHINE_PARAMS"));
382  //SELECT clause
383  CTPPSDataQuery->addToOutputList(std::string("DIP_UPDATE_TIME"));
384  CTPPSDataQuery->addToOutputList(std::string("LUMI_SECTION"));
385  CTPPSDataQuery->addToOutputList(std::string("RUN_NUMBER"));
386  CTPPSDataQuery->addToOutputList(std::string("XING_ANGLE_P5_X_URAD"));
387  CTPPSDataQuery->addToOutputList(std::string("XING_ANGLE_P5_Y_URAD"));
388  CTPPSDataQuery->addToOutputList(std::string("BETA_STAR_P5_X_M"));
389  CTPPSDataQuery->addToOutputList(std::string("BETA_STAR_P5_Y_M"));
390  //WHERE CLAUSE
391  coral::AttributeList CTPPSDataBindVariables;
392  CTPPSDataBindVariables.extend<coral::TimeStamp>(std::string("beginFillTime"));
393  CTPPSDataBindVariables.extend<coral::TimeStamp>(std::string("endFillTime"));
394  CTPPSDataBindVariables[std::string("beginFillTime")].data<coral::TimeStamp>() = coral::TimeStamp(beginFillTime);
395  CTPPSDataBindVariables[std::string("endFillTime")].data<coral::TimeStamp>() = coral::TimeStamp(endFillTime);
396  std::string conditionStr = std::string("DIP_UPDATE_TIME>= :beginFillTime and DIP_UPDATE_TIME< :endFillTime");
397  CTPPSDataQuery->setCondition(conditionStr, CTPPSDataBindVariables);
398  //ORDER BY clause
399  CTPPSDataQuery->addToOrderList(std::string("DIP_UPDATE_TIME"));
400  //define query output
401  coral::AttributeList CTPPSDataOutput;
402  CTPPSDataOutput.extend<coral::TimeStamp>(std::string("DIP_UPDATE_TIME"));
403  CTPPSDataOutput.extend<int>(std::string("LUMI_SECTION"));
404  CTPPSDataOutput.extend<int>(std::string("RUN_NUMBER"));
405  CTPPSDataOutput.extend<float>(std::string("XING_ANGLE_P5_X_URAD"));
406  CTPPSDataOutput.extend<float>(std::string("XING_ANGLE_P5_Y_URAD"));
407  CTPPSDataOutput.extend<float>(std::string("BETA_STAR_P5_X_M"));
408  CTPPSDataOutput.extend<float>(std::string("BETA_STAR_P5_Y_M"));
409  CTPPSDataQuery->defineOutput(CTPPSDataOutput);
410  //execute the query
411  coral::ICursor& CTPPSDataCursor = CTPPSDataQuery->execute();
412  cond::Time_t dipTime = 0;
413  unsigned int lumiSection = 0;
415  float crossingAngleX = 0., betaStarX = 0.;
416  float crossingAngleY = 0., betaStarY = 0.;
417 
418  bool ret = false;
420  while (CTPPSDataCursor.next()) {
421  if (m_debug) {
422  std::ostringstream CTPPS;
423  CTPPSDataCursor.currentRow().toOutputStream(CTPPS);
424  }
425  coral::Attribute const& dipTimeAttribute = CTPPSDataCursor.currentRow()[std::string("DIP_UPDATE_TIME")];
426  if (!dipTimeAttribute.isNull()) {
427  dipTime = cond::time::from_boost(dipTimeAttribute.data<coral::TimeStamp>().time());
428  if (filter.process(dipTime)) {
429  ret = true;
430  coral::Attribute const& lumiSectionAttribute = CTPPSDataCursor.currentRow()[std::string("LUMI_SECTION")];
431  if (!lumiSectionAttribute.isNull()) {
432  lumiSection = lumiSectionAttribute.data<int>();
433  }
434  coral::Attribute const& runNumberAttribute = CTPPSDataCursor.currentRow()[std::string("RUN_NUMBER")];
435  if (!runNumberAttribute.isNull()) {
436  runNumber = runNumberAttribute.data<int>();
437  }
438  coral::Attribute const& crossingAngleXAttribute =
439  CTPPSDataCursor.currentRow()[std::string("XING_ANGLE_P5_X_URAD")];
440  if (!crossingAngleXAttribute.isNull()) {
441  crossingAngleX = crossingAngleXAttribute.data<float>();
442  }
443  coral::Attribute const& crossingAngleYAttribute =
444  CTPPSDataCursor.currentRow()[std::string("XING_ANGLE_P5_Y_URAD")];
445  if (!crossingAngleYAttribute.isNull()) {
446  crossingAngleY = crossingAngleYAttribute.data<float>();
447  }
448  coral::Attribute const& betaStarXAttribute = CTPPSDataCursor.currentRow()[std::string("BETA_STAR_P5_X_M")];
449  if (!betaStarXAttribute.isNull()) {
450  betaStarX = betaStarXAttribute.data<float>();
451  }
452  coral::Attribute const& betaStarYAttribute = CTPPSDataCursor.currentRow()[std::string("BETA_STAR_P5_Y_M")];
453  if (!betaStarYAttribute.isNull()) {
454  betaStarY = betaStarYAttribute.data<float>();
455  }
456  for (auto it = filter.current(); it != m_tmpBuffer.end(); it++) {
457  // set the current values to all of the payloads of the lumi section samples after the current since
458  LHCInfoPerLS& payload = *(it->second);
459  payload.setCrossingAngleX(crossingAngleX);
460  payload.setCrossingAngleY(crossingAngleY);
461  payload.setBetaStarX(betaStarX);
462  payload.setBetaStarY(betaStarY);
463  payload.setLumiSection(lumiSection);
464  payload.setRunNumber(runNumber);
465  }
466  }
467  }
468  }
469  return ret;
470  }
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 342 of file LHCInfoPerLSPopConAnalyzer.cc.

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

Referenced by getNewObjects().

345  {
346  auto query = oms.query("lumisections");
347  query->addOutputVars({"start_time", "run_number", "beams_stable", "lumisection_number"});
348  query->filterEQ("fill_number", fillId);
349  query->filterGT("start_time", beginFillTime).filterLT("start_time", endFillTime);
351  size_t nlumi = 0;
352  if (query->execute()) {
353  auto queryResult = query->result();
354  if (m_endFillMode) {
355  nlumi = bufferAllLS(queryResult);
356  } else if (!queryResult.empty()) {
357  auto newestPayload = queryResult.back();
358  if (newestPayload.get<std::string>("beams_stable") == "true") {
359  addPayloadToBuffer(newestPayload);
360  nlumi = 1;
361  edm::LogInfo(m_name) << "Buffered most recent lumisection:"
362  << " LS: " << newestPayload.get<std::string>("lumisection_number")
363  << " run: " << newestPayload.get<std::string>("run_number");
364  }
365  }
366  edm::LogInfo(m_name) << "Found " << queryResult.size() << " lumisections during the fill " << fillId;
367  } else {
368  edm::LogInfo(m_name) << "OMS query for lumisections of fill " << fillId << "failed, status:" << query->status();
369  }
370  return nlumi;
371  }
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 105 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().

105  {
106  //if a new tag is created, transfer fake fill from 1 to the first fill for the first time
107  if (tagInfo().size == 0) {
108  edm::LogInfo(m_name) << "New tag " << tagInfo().name << "; from " << m_name << "::getNewObjects";
109  } else {
110  //check what is already inside the database
111  edm::LogInfo(m_name) << "got info for tag " << tagInfo().name << ": size " << tagInfo().size
112  << ", last object valid since " << tagInfo().lastInterval.since << " ( "
113  << boost::posix_time::to_iso_extended_string(
114  cond::time::to_boost(tagInfo().lastInterval.since))
115  << " ); from " << m_name << "::getNewObjects";
116  }
117 
118  cond::Time_t lastSince = tagInfo().lastInterval.since;
119  if (tagInfo().isEmpty()) {
120  // for a new or empty tag, an empty payload should be added on top with since=1
121  addEmptyPayload(1);
122  lastSince = 1;
123  } else {
124  edm::LogInfo(m_name) << "The last Iov in tag " << tagInfo().name << " valid since " << lastSince << "from "
125  << m_name << "::getNewObjects";
126  }
127 
128  boost::posix_time::ptime executionTime = boost::posix_time::second_clock::local_time();
129  cond::Time_t targetSince = 0;
130  cond::Time_t executionTimeIov = cond::time::from_boost(executionTime);
131  if (!m_startTime.is_not_a_date_time()) {
132  targetSince = cond::time::from_boost(m_startTime);
133  }
134  if (lastSince > targetSince)
135  targetSince = lastSince;
136 
137  edm::LogInfo(m_name) << "Starting sampling at "
138  << boost::posix_time::to_simple_string(cond::time::to_boost(targetSince));
139 
140  //retrieve the data from the relational database source
142  //configure the connection
143  if (m_debug) {
144  connection.setMessageVerbosity(coral::Debug);
145  } else {
146  connection.setMessageVerbosity(coral::Error);
147  }
148  connection.setAuthenticationPath(m_authpath);
149  connection.configure();
150  //create the sessions
151  cond::persistency::Session session = connection.createSession(m_connectionString, false);
152  // fetch last payload when available
153  if (!tagInfo().lastInterval.payloadId.empty()) {
155  session3.transaction().start(true);
157  session3.transaction().commit();
158 
159  // find startFillTime and endFillTime of the most recent fill already saved in the tag
160  if (m_prevPayload->fillNumber() != 0) {
161  cond::OMSService oms;
162  oms.connect(m_omsBaseUrl);
163  auto query = oms.query("fills");
164  query->addOutputVar("end_time");
165  query->filterEQ("fill_number", m_prevPayload->fillNumber());
166  bool foundFill = query->execute();
167  if (foundFill) {
168  auto result = query->result();
169 
170  if (!result.empty()) {
171  auto endFillTime = (*result.begin()).get<boost::posix_time::ptime>("end_time");
173  auto startFillTime = (*result.begin()).get<boost::posix_time::ptime>("start_time");
175  } else {
176  foundFill = false;
177  }
178  }
179  if (!foundFill) {
180  edm::LogError(m_name) << "Could not find end time of fill #" << m_prevPayload->fillNumber();
181  }
182  } else {
183  m_prevEndFillTime = 0;
185  }
186  }
187 
188  while (true) {
189  if (targetSince >= executionTimeIov) {
190  edm::LogInfo(m_name) << "Sampling ended at the time "
191  << boost::posix_time::to_simple_string(cond::time::to_boost(executionTimeIov));
192  break;
193  }
194  boost::posix_time::ptime targetTime = cond::time::to_boost(targetSince);
195  boost::posix_time::ptime startSampleTime;
196  boost::posix_time::ptime endSampleTime;
197 
198  cond::OMSService oms;
199  oms.connect(m_omsBaseUrl);
200  auto query = oms.query("fills");
201 
202  if (!m_endFillMode and m_prevPayload->fillNumber() and m_prevEndFillTime == 0ULL) {
203  // continue processing unfinished fill with some payloads already in the tag
204  edm::LogInfo(m_name) << "Searching started fill #" << m_prevPayload->fillNumber();
205  query->filterEQ("fill_number", m_prevPayload->fillNumber());
206  bool foundFill = query->execute();
207  if (foundFill)
208  foundFill = makeFillPayload(m_fillPayload, query->result());
209  if (!foundFill) {
210  edm::LogError(m_name) << "Could not find fill #" << m_prevPayload->fillNumber();
211  break;
212  }
213  startSampleTime = cond::time::to_boost(lastSince);
214  } else {
215  edm::LogInfo(m_name) << "Searching new fill after " << boost::posix_time::to_simple_string(targetTime);
216  query->filterNotNull("start_stable_beam").filterNotNull("fill_number");
217  if (targetTime > cond::time::to_boost(m_prevStartFillTime)) {
218  query->filterGE("start_time", targetTime);
219  } else {
220  query->filterGT("start_time", targetTime);
221  }
222 
223  query->filterLT("start_time", m_endTime);
224  if (m_endFillMode)
225  query->filterNotNull("end_time");
226  bool foundFill = query->execute();
227  if (foundFill)
228  foundFill = makeFillPayload(m_fillPayload, query->result());
229  if (!foundFill) {
230  edm::LogInfo(m_name) << "No fill found - END of job.";
231  break;
232  }
233  startSampleTime = cond::time::to_boost(m_startFillTime);
234  }
235 
236  unsigned short lhcFill = m_fillPayload->fillNumber();
237  bool ongoingFill = m_endFillTime == 0ULL;
238  if (ongoingFill) {
239  edm::LogInfo(m_name) << "Found ongoing fill " << lhcFill << " created at "
241  endSampleTime = executionTime;
242  targetSince = executionTimeIov;
243  } else {
244  edm::LogInfo(m_name) << "Found fill " << lhcFill << " created at " << cond::time::to_boost(m_startFillTime)
245  << " ending at " << cond::time::to_boost(m_endFillTime);
246  endSampleTime = cond::time::to_boost(m_endFillTime);
247  targetSince = m_endFillTime;
248  }
249 
250  if (m_endFillMode || ongoingFill) {
251  getLumiData(oms, lhcFill, startSampleTime, endSampleTime);
252 
253  if (!m_tmpBuffer.empty()) {
254  boost::posix_time::ptime flumiStart = cond::time::to_boost(m_tmpBuffer.front().first);
255  boost::posix_time::ptime flumiStop = cond::time::to_boost(m_tmpBuffer.back().first);
256  edm::LogInfo(m_name) << "First buffered lumi starts at " << flumiStart << " last lumi starts at "
257  << flumiStop;
258  session.transaction().start(true);
259  getCTTPSData(session, startSampleTime, endSampleTime);
260  session.transaction().commit();
261  }
262  }
263 
265  edm::LogInfo(m_name) << "Added " << niovs << " iovs within the Fill time";
266  if (niovs) {
269  }
270  m_tmpBuffer.clear();
271  if (m_prevPayload->fillNumber() and !ongoingFill)
273  }
274  }
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 302 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().

302  {
303  bool ret = false;
304  if (!queryResult.empty()) {
305  auto row = *queryResult.begin();
306  auto currentFill = row.get<unsigned short>("fill_number");
307  m_startFillTime = cond::time::from_boost(row.get<boost::posix_time::ptime>("start_time"));
308  m_endFillTime = cond::time::from_boost(row.get<boost::posix_time::ptime>("end_time"));
309  targetPayload = std::make_unique<LHCInfoPerLS>();
310  targetPayload->setFillNumber(currentFill);
311  ret = true;
312  }
313  return ret;
314  }
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 277 of file LHCInfoPerLSPopConAnalyzer.cc.

Referenced by getLumiData().

◆ m_authpath

std::string LHCInfoPerLSPopConSourceHandler::m_authpath
private

Definition at line 483 of file LHCInfoPerLSPopConAnalyzer.cc.

Referenced by getNewObjects().

◆ m_connectionString

std::string LHCInfoPerLSPopConSourceHandler::m_connectionString
private

Definition at line 482 of file LHCInfoPerLSPopConAnalyzer.cc.

Referenced by getNewObjects().

◆ m_debug

bool LHCInfoPerLSPopConSourceHandler::m_debug
private

Definition at line 473 of file LHCInfoPerLSPopConAnalyzer.cc.

Referenced by getCTTPSData(), and getNewObjects().

◆ m_dipSchema

std::string LHCInfoPerLSPopConSourceHandler::m_dipSchema
private

Definition at line 483 of file LHCInfoPerLSPopConAnalyzer.cc.

◆ m_ecalConnectionString

std::string LHCInfoPerLSPopConSourceHandler::m_ecalConnectionString
private

Definition at line 482 of file LHCInfoPerLSPopConAnalyzer.cc.

◆ m_endFillMode

bool LHCInfoPerLSPopConSourceHandler::m_endFillMode = true
private

Definition at line 479 of file LHCInfoPerLSPopConAnalyzer.cc.

Referenced by getLumiData(), and getNewObjects().

◆ m_endFillTime

cond::Time_t LHCInfoPerLSPopConSourceHandler::m_endFillTime
private

Definition at line 488 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 485 of file LHCInfoPerLSPopConAnalyzer.cc.

Referenced by addPayloadToBuffer(), and getNewObjects().

◆ m_lastPayloadEmpty

bool LHCInfoPerLSPopConSourceHandler::m_lastPayloadEmpty = false
private

Definition at line 492 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 484 of file LHCInfoPerLSPopConAnalyzer.cc.

Referenced by getNewObjects().

◆ m_prevEndFillTime

cond::Time_t LHCInfoPerLSPopConSourceHandler::m_prevEndFillTime
private

Definition at line 489 of file LHCInfoPerLSPopConAnalyzer.cc.

Referenced by addEmptyPayload(), and getNewObjects().

◆ m_prevPayload

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

Definition at line 486 of file LHCInfoPerLSPopConAnalyzer.cc.

Referenced by addEmptyPayload(), and getNewObjects().

◆ m_prevStartFillTime

cond::Time_t LHCInfoPerLSPopConSourceHandler::m_prevStartFillTime
private

Definition at line 490 of file LHCInfoPerLSPopConAnalyzer.cc.

Referenced by addEmptyPayload(), and getNewObjects().

◆ m_samplingInterval

unsigned int LHCInfoPerLSPopConSourceHandler::m_samplingInterval
private

Definition at line 478 of file LHCInfoPerLSPopConAnalyzer.cc.

◆ m_startFillTime

cond::Time_t LHCInfoPerLSPopConSourceHandler::m_startFillTime
private

Definition at line 487 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 491 of file LHCInfoPerLSPopConAnalyzer.cc.

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