CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
LHCInfoPopConSourceHandler Class Reference

#include <LHCInfoPopConSourceHandler.h>

Inheritance diagram for LHCInfoPopConSourceHandler:
popcon::PopConSourceHandler< LHCInfo >

Public Member Functions

void getNewObjects () override
 
std::string id () const override
 
 LHCInfoPopConSourceHandler (const edm::ParameterSet &pset)
 
 ~LHCInfoPopConSourceHandler () override
 
- Public Member Functions inherited from popcon::PopConSourceHandler< LHCInfo >
void convertFromOld ()
 
SummarydummySummary (typename OldContainer::value_type const &) const
 
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 ()
 
void sort ()
 
cond::TagInfo_t const & tagInfo () const
 
std::string const & userTextLog () const
 
virtual ~PopConSourceHandler ()
 

Private Member Functions

void addEmptyPayload (cond::Time_t iov)
 
void addPayload (LHCInfo &newPayload, cond::Time_t iov)
 
bool getCTTPSData (cond::persistency::Session &session, const boost::posix_time::ptime &targetTime, LHCInfo &payload)
 
bool getCurrentFillData (cond::persistency::Session &session, const boost::posix_time::ptime &targetTime, LHCInfo &payload)
 
bool getDipData (cond::persistency::Session &session, const boost::posix_time::ptime &targetTime, LHCInfo &payload)
 
bool getEcalData (cond::persistency::Session &session, const boost::posix_time::ptime &targetTime, LHCInfo &payload)
 
bool getFillData (cond::persistency::Session &session, const boost::posix_time::ptime &targetTime, bool next, LHCInfo &payload)
 
bool getLumiData (cond::persistency::Session &session, const boost::posix_time::ptime &targetTime, LHCInfo &payload)
 
bool getNextFillData (cond::persistency::Session &session, const boost::posix_time::ptime &targetTime, LHCInfo &payload)
 

Private Attributes

std::string m_authpath
 
std::string m_connectionString
 
bool m_debug
 
std::string m_dipSchema
 
std::string m_ecalConnectionString
 
boost::posix_time::ptime m_endTime
 
bool m_lastPayloadEmpty = false
 
std::string m_name
 
std::vector< std::unique_ptr< LHCInfo > > m_payloadBuffer
 
unsigned int m_samplingInterval
 
boost::posix_time::ptime m_startTime
 

Additional Inherited Members

- Public Types inherited from popcon::PopConSourceHandler< LHCInfo >
typedef std::vector< Triplet > Container
 
typedef std::vector< std::pair< LHCInfo *, cond::Time_t > > OldContainer
 
typedef PopConSourceHandler< LHCInfoself
 
typedef cond::Summary Summary
 
typedef cond::Time_t Time_t
 
typedef LHCInfo value_type
 
- Protected Member Functions inherited from popcon::PopConSourceHandler< LHCInfo >
int add (value_type *payload, Summary *summary, Time_t time)
 
cond::persistency::SessiondbSession () const
 
- Protected Attributes inherited from popcon::PopConSourceHandler< LHCInfo >
OldContainer m_to_transfer
 
std::string m_userTextLog
 

Detailed Description

Definition at line 10 of file LHCInfoPopConSourceHandler.h.

Constructor & Destructor Documentation

LHCInfoPopConSourceHandler::LHCInfoPopConSourceHandler ( const edm::ParameterSet pset)

Definition at line 20 of file LHCInfoPopConSourceHandler.cc.

References edm::ParameterSet::exists(), edm::ParameterSet::getUntrackedParameter(), m_endTime, m_startTime, cmsPerfSuiteHarvest::now, and AlCaHLTBitMon_QueryRunRegistry::string.

20  :
21  m_debug( pset.getUntrackedParameter<bool>( "debug", false ) )
22  ,m_startTime()
23  ,m_endTime()
24  ,m_samplingInterval( (unsigned int)pset.getUntrackedParameter<unsigned int>( "samplingInterval", 300 ) )
25  ,m_name( pset.getUntrackedParameter<std::string>( "name", "LHCInfoPopConSourceHandler" ) )
26  ,m_connectionString(pset.getUntrackedParameter<std::string>("connectionString",""))
27  ,m_ecalConnectionString(pset.getUntrackedParameter<std::string>("ecalConnectionString",""))
28  ,m_dipSchema(pset.getUntrackedParameter<std::string>("DIPSchema",""))
29  ,m_authpath(pset.getUntrackedParameter<std::string>("authenticationPath",""))
30  ,m_payloadBuffer() {
31  if( pset.exists("startTime") ){
32  m_startTime = boost::posix_time::time_from_string( pset.getUntrackedParameter<std::string>("startTime" ) );
33  }
34  boost::posix_time::ptime now = boost::posix_time::second_clock::local_time();
35  m_endTime = now;
36  if( pset.exists("endTime") ){
37  m_endTime = boost::posix_time::time_from_string( pset.getUntrackedParameter<std::string>("endTime" ) );
38  if(m_endTime>now) m_endTime = now;
39  }
40 }
T getUntrackedParameter(std::string const &, T const &) const
boost::posix_time::ptime m_startTime
bool exists(std::string const &parameterName) const
checks if a parameter exists
boost::posix_time::ptime m_endTime
std::vector< std::unique_ptr< LHCInfo > > m_payloadBuffer
LHCInfoPopConSourceHandler::~LHCInfoPopConSourceHandler ( )
override

Definition at line 43 of file LHCInfoPopConSourceHandler.cc.

43 {}

Member Function Documentation

void LHCInfoPopConSourceHandler::addEmptyPayload ( cond::Time_t  iov)
private

Definition at line 574 of file LHCInfoPopConSourceHandler.cc.

References popcon::PopConSourceHandler< LHCInfo >::add(), LHCInfo::fillNumber(), m_lastPayloadEmpty, m_payloadBuffer, and popcon::PopConSourceHandler< LHCInfo >::m_to_transfer.

Referenced by getNewObjects().

574  {
575  bool add = false;
576  if( m_to_transfer.empty() ){
577  if( !m_lastPayloadEmpty ) add = true;
578  } else {
579  LHCInfo* lastAdded = m_to_transfer.back().first;
580  if( lastAdded->fillNumber() != 0 ) {
581  add = true;
582  }
583  }
584  if( add ) {
585  LHCInfo* newPayload = new LHCInfo();
586  m_payloadBuffer.emplace_back(newPayload);
587  m_to_transfer.push_back( std::make_pair( newPayload, iov ) );
588  }
589 }
unsigned short const fillNumber() const
Definition: LHCInfo.cc:148
std::vector< std::unique_ptr< LHCInfo > > m_payloadBuffer
int add(value_type *payload, Summary *summary, Time_t time)
void LHCInfoPopConSourceHandler::addPayload ( LHCInfo newPayload,
cond::Time_t  iov 
)
private

Definition at line 591 of file LHCInfoPopConSourceHandler.cc.

References popcon::PopConSourceHandler< LHCInfo >::add(), LHCInfo::equals(), and popcon::PopConSourceHandler< LHCInfo >::m_to_transfer.

Referenced by getNewObjects().

591  {
592  bool add = false;
593  if( m_to_transfer.empty() ){
594  add = true;
595  } else {
596  LHCInfo* lastAdded = m_to_transfer.back().first;
597  if( !lastAdded->equals( newPayload ) ) {
598  add = true;
599  }
600  }
601  if( add ) {
602  m_to_transfer.push_back( std::make_pair( &newPayload, iov ) );
603  }
604 }
bool equals(const LHCInfo &rhs) const
Definition: LHCInfo.cc:565
int add(value_type *payload, Summary *summary, Time_t time)
bool LHCInfoPopConSourceHandler::getCTTPSData ( cond::persistency::Session session,
const boost::posix_time::ptime &  targetTime,
LHCInfo payload 
)
private

Definition at line 423 of file LHCInfoPopConSourceHandler.cc.

References cond::persistency::Session::coralSession(), m_debug, seconds(), LHCInfo::setCtppsStatus(), LHCInfo::setLhcComment(), LHCInfo::setLhcState(), LHCInfo::setLumiSection(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by getNewObjects().

425  {
426  //run the fifth query against the CTPPS schema
427  //Initializing the CMS_CTP_CTPPS_COND schema.
428  coral::ISchema& CTPPS = session.coralSession().schema("CMS_CTP_CTPPS_COND");
429  //execute query for CTPPS Data
430  std::unique_ptr<coral::IQuery> CTPPSDataQuery( CTPPS.newQuery() );
431  //FROM clause
432  CTPPSDataQuery->addToTableList( std::string( "CTPPS_LHC_MACHINE_PARAMS" ) );
433  //SELECT clause
434  CTPPSDataQuery->addToOutputList( std::string( "LHC_STATE" ) );
435  CTPPSDataQuery->addToOutputList( std::string( "LHC_COMMENT" ) );
436  CTPPSDataQuery->addToOutputList( std::string( "CTPPS_STATUS" ) );
437  CTPPSDataQuery->addToOutputList( std::string( "LUMI_SECTION" ) );
438  //WHERE CLAUSE
439  coral::AttributeList CTPPSDataBindVariables;
440  CTPPSDataBindVariables.extend<coral::TimeStamp>( std::string( "targetTime" ) );
441  CTPPSDataBindVariables[ std::string( "targetTime" ) ].data<coral::TimeStamp>() = coral::TimeStamp( targetTime + boost::posix_time::seconds(1));
442  std::string conditionStr = std::string( "DIP_UPDATE_TIME<= :targetTime" );
443  CTPPSDataQuery->setCondition( conditionStr, CTPPSDataBindVariables );
444  //ORDER BY clause
445  CTPPSDataQuery->addToOrderList( std::string( "DIP_UPDATE_TIME DESC" ) ); //Only the latest value is fetched.
446  //define query output
447  coral::AttributeList CTPPSDataOutput;
448  CTPPSDataOutput.extend<std::string>( std::string( "LHC_STATE" ) );
449  CTPPSDataOutput.extend<std::string>( std::string( "LHC_COMMENT" ) );
450  CTPPSDataOutput.extend<std::string>( std::string( "CTPPS_STATUS" ) );
451  CTPPSDataOutput.extend<int>( std::string( "LUMI_SECTION" ) );
452  CTPPSDataQuery->limitReturnedRows( 1 ); //Only one entry per payload.
453  CTPPSDataQuery->defineOutput( CTPPSDataOutput );
454  //execute the query
455  coral::ICursor& CTPPSDataCursor = CTPPSDataQuery->execute();
456  std::string lhcState = "", lhcComment = "", ctppsStatus = "";
457  unsigned int lumiSection = 0;
458 
459  bool ret = false;
460  if( CTPPSDataCursor.next() ) {
461  ret = true;
462  if( m_debug ) {
463  std::ostringstream CTPPS;
464  CTPPSDataCursor.currentRow().toOutputStream( CTPPS );
465  }
466  coral::Attribute const & lhcStateAttribute = CTPPSDataCursor.currentRow()[ std::string( "LHC_STATE" ) ];
467  if( !lhcStateAttribute.isNull() ) {
468  lhcState = lhcStateAttribute.data<std::string>();
469  }
470 
471  coral::Attribute const & lhcCommentAttribute = CTPPSDataCursor.currentRow()[ std::string( "LHC_COMMENT" ) ];
472  if( !lhcCommentAttribute.isNull() ) {
473  lhcComment = lhcCommentAttribute.data<std::string>();
474  }
475 
476  coral::Attribute const & ctppsStatusAttribute = CTPPSDataCursor.currentRow()[ std::string( "CTPPS_STATUS" ) ];
477  if( !ctppsStatusAttribute.isNull() ) {
478  ctppsStatus = ctppsStatusAttribute.data<std::string>();
479  }
480 
481  coral::Attribute const & lumiSectionAttribute = CTPPSDataCursor.currentRow()[ std::string( "LUMI_SECTION" ) ];
482  if( !lumiSectionAttribute.isNull() ) {
483  lumiSection = lumiSectionAttribute.data<int>();
484  }
485  payload.setLhcState( lhcState );
486  payload.setLhcComment( lhcComment );
487  payload.setCtppsStatus( ctppsStatus );
488  payload.setLumiSection( lumiSection );
489  }
490  return ret;
491 
492  }
void setLumiSection(unsigned int const &lumiSection)
Definition: LHCInfo.cc:398
double seconds()
void setLhcComment(std::string const &lhcComment)
Definition: LHCInfo.cc:390
void setLhcState(std::string const &lhcState)
Definition: LHCInfo.cc:386
coral::ISessionProxy & coralSession()
Definition: Session.cc:228
void setCtppsStatus(std::string const &ctppsStatus)
Definition: LHCInfo.cc:394
bool LHCInfoPopConSourceHandler::getCurrentFillData ( cond::persistency::Session session,
const boost::posix_time::ptime &  targetTime,
LHCInfo payload 
)
private

Definition at line 237 of file LHCInfoPopConSourceHandler.cc.

References getFillData().

Referenced by getNewObjects().

239  {
240  return getFillData( session, targetTime, false, payload );
241 }
bool getFillData(cond::persistency::Session &session, const boost::posix_time::ptime &targetTime, bool next, LHCInfo &payload)
bool LHCInfoPopConSourceHandler::getDipData ( cond::persistency::Session session,
const boost::posix_time::ptime &  targetTime,
LHCInfo payload 
)
private

Definition at line 311 of file LHCInfoPopConSourceHandler.cc.

References LHCInfo::availableBunchSlots, cond::persistency::Session::coralSession(), LHCInfo::endTime(), m_debug, m_dipSchema, seconds(), LHCInfo::setBunchBitsetForBeam1(), LHCInfo::setBunchBitsetForBeam2(), LHCInfo::setLumiPerBX(), AlCaHLTBitMon_QueryRunRegistry::string, and cond::time::to_boost().

Referenced by getNewObjects().

313  {
314  //run the third and fourth query against the schema hosting detailed DIP information
315  coral::ISchema& beamCondSchema = session.coralSession().schema( m_dipSchema );
316  //start the transaction against the DIP "deep" database backend schema
317  //prepare the WHERE clause for both queries
318  coral::AttributeList bunchConfBindVariables;
319  bunchConfBindVariables.extend<coral::TimeStamp>(std::string("targetTime"));
320  bunchConfBindVariables[ std::string( "targetTime")].data<coral::TimeStamp>()= coral::TimeStamp( targetTime + boost::posix_time::seconds(1) );
321  std::string conditionStr = std::string( "DIPTIME <= :targetTime" );
322  //define the output types for both queries
323  coral::AttributeList bunchConfOutput;
324  bunchConfOutput.extend<coral::TimeStamp>( std::string( "DIPTIME" ) );
325  bunchConfOutput.extend<unsigned short>( std::string( "BUCKET" ) );
326  //execute query for Beam 1
327  std::unique_ptr<coral::IQuery> bunchConf1Query(beamCondSchema.newQuery());
328  bunchConf1Query->addToTableList( std::string( "LHC_CIRCBUNCHCONFIG_BEAM1" ), std::string( "BEAMCONF\", TABLE( BEAMCONF.VALUE ) \"BUCKETS" ) );
329  bunchConf1Query->addToOutputList( std::string( "BEAMCONF.DIPTIME" ), std::string( "DIPTIME" ) );
330  bunchConf1Query->addToOutputList( std::string( "BUCKETS.COLUMN_VALUE" ), std::string( "BUCKET" ) );
331  bunchConf1Query->setCondition( conditionStr, bunchConfBindVariables );
332  bunchConf1Query->addToOrderList( std::string( "DIPTIME DESC" ) );
333  bunchConf1Query->limitReturnedRows( LHCInfo::availableBunchSlots ); //maximum number of filled bunches
334  bunchConf1Query->defineOutput( bunchConfOutput );
335  coral::ICursor& bunchConf1Cursor = bunchConf1Query->execute();
336 
337  std::bitset<LHCInfo::bunchSlots+1> bunchConfiguration1( 0ULL );
338  bool ret = false;
339  while( bunchConf1Cursor.next() ) {
340  ret = true;
341  if( m_debug ) {
342  std::ostringstream b1s;
343  bunchConf1Cursor.currentRow().toOutputStream( b1s );
344  }
345  if( bunchConf1Cursor.currentRow()[ std::string( "BUCKET" ) ].data<unsigned short>() != 0 ) {
346  unsigned short slot = ( bunchConf1Cursor.currentRow()[ std::string( "BUCKET" ) ].data<unsigned short>() - 1 ) / 10 + 1;
347  bunchConfiguration1[ slot ] = true;
348  }
349  }
350 
351  if(ret){
352  payload.setBunchBitsetForBeam1( bunchConfiguration1 );
353  }
354 
355  //execute query for Beam 2
356  std::unique_ptr<coral::IQuery> bunchConf2Query(beamCondSchema.newQuery());
357  bunchConf2Query->addToTableList( std::string( "LHC_CIRCBUNCHCONFIG_BEAM2" ), std::string( "BEAMCONF\", TABLE( BEAMCONF.VALUE ) \"BUCKETS" ) );
358  bunchConf2Query->addToOutputList( std::string( "BEAMCONF.DIPTIME" ), std::string( "DIPTIME" ) );
359  bunchConf2Query->addToOutputList( std::string( "BUCKETS.COLUMN_VALUE" ), std::string( "BUCKET" ) );
360  bunchConf2Query->setCondition( conditionStr, bunchConfBindVariables );
361  bunchConf2Query->addToOrderList( std::string( "DIPTIME DESC" ) );
362  bunchConf2Query->limitReturnedRows( LHCInfo::availableBunchSlots ); //maximum number of filled bunches
363  bunchConf2Query->defineOutput( bunchConfOutput );
364  coral::ICursor& bunchConf2Cursor = bunchConf2Query->execute();
365 
366  std::bitset<LHCInfo::bunchSlots+1> bunchConfiguration2( 0ULL );
367  ret = false;
368  while( bunchConf2Cursor.next() ) {
369  ret = true;
370  if( m_debug ) {
371  std::ostringstream b2s;
372  bunchConf2Cursor.currentRow().toOutputStream( b2s );
373  }
374  if( bunchConf2Cursor.currentRow()[ std::string( "BUCKET" ) ].data<unsigned short>() != 0 ) {
375  unsigned short slot = ( bunchConf2Cursor.currentRow()[ std::string( "BUCKET" ) ].data<unsigned short>() - 1 ) / 10 + 1;
376  bunchConfiguration2[ slot ] = true;
377  }
378  }
379  if(ret){
380  payload.setBunchBitsetForBeam2( bunchConfiguration2 );
381  }
382 
383  //execute query for lumiPerBX
384  std::unique_ptr<coral::IQuery> lumiDataQuery(beamCondSchema.newQuery());
385  lumiDataQuery->addToTableList( std::string( "CMS_LHC_LUMIPERBUNCH" ), std::string( "LUMIPERBUNCH\", TABLE( LUMIPERBUNCH.LUMI_BUNCHINST ) \"VALUE" ) );
386  lumiDataQuery->addToOutputList( std::string( "LUMIPERBUNCH.DIPTIME" ), std::string( "DIPTIME" ) );
387  lumiDataQuery->addToOutputList( std::string( "VALUE.COLUMN_VALUE" ), std::string( "LUMI/BUNCH" ) );
388  coral::AttributeList lumiDataBindVariables;
389  lumiDataBindVariables.extend<coral::TimeStamp>( std::string( "targetTime" ) );
390  lumiDataBindVariables[ std::string( "targetTime" ) ].data<coral::TimeStamp>() = coral::TimeStamp( targetTime + boost::posix_time::seconds(1) );
391  lumiDataBindVariables.extend<coral::TimeStamp>( std::string( "beamDumpTimeStamp" ) );
392  lumiDataBindVariables[ std::string( "beamDumpTimeStamp" ) ].data<coral::TimeStamp>() = coral::TimeStamp(cond::time::to_boost(payload.endTime()));
393  conditionStr = std::string( "DIPTIME BETWEEN :targetTime AND :beamDumpTimeStamp" );
394  lumiDataQuery->setCondition( conditionStr, lumiDataBindVariables );
395  lumiDataQuery->addToOrderList( std::string( "DIPTIME DESC" ) );
396  lumiDataQuery->limitReturnedRows(3564); //Maximum number of bunches.
397  //define query output
398  coral::AttributeList lumiDataOutput;
399  lumiDataOutput.extend<coral::TimeStamp>( std::string( "TIME" ) );
400  lumiDataOutput.extend<float>( std::string( "VALUE" ) );
401  lumiDataQuery->defineOutput( lumiDataOutput );
402  //execute the query
403  coral::ICursor& lumiDataCursor = lumiDataQuery->execute();
404 
405  std::vector<float> lumiPerBX;
406  ret = false;
407  while( lumiDataCursor.next() ) {
408  ret = true;
409  if( m_debug ) {
410  std::ostringstream lpBX;
411  lumiDataCursor.currentRow().toOutputStream( lpBX );
412  }
413  if( lumiDataCursor.currentRow()[ std::string( "VALUE" ) ].data<float>() != 0.00 ) {
414  lumiPerBX.push_back(lumiDataCursor.currentRow()[ std::string( "VALUE" ) ].data<float>());
415  }
416  }
417  if( ret){
418  payload.setLumiPerBX( lumiPerBX );
419  }
420  return ret;
421  }
double seconds()
void setLumiPerBX(std::vector< float > const &lumiPerBX)
Definition: LHCInfo.cc:382
static size_t const availableBunchSlots
Definition: LHCInfo.h:34
cond::Time_t const endTime() const
Definition: LHCInfo.cc:228
coral::ISessionProxy & coralSession()
Definition: Session.cc:228
void setBunchBitsetForBeam1(std::bitset< bunchSlots+1 > const &bunchConfiguration)
Definition: LHCInfo.cc:550
void setBunchBitsetForBeam2(std::bitset< bunchSlots+1 > const &bunchConfiguration)
Definition: LHCInfo.cc:554
boost::posix_time::ptime to_boost(Time_t iValue)
bool LHCInfoPopConSourceHandler::getEcalData ( cond::persistency::Session session,
const boost::posix_time::ptime &  targetTime,
LHCInfo payload 
)
private

Definition at line 493 of file LHCInfoPopConSourceHandler.cc.

References ECAL, m_debug, cond::persistency::Session::nominalSchema(), LHCInfo::setBeam1RF(), LHCInfo::setBeam1VC(), LHCInfo::setBeam2RF(), LHCInfo::setBeam2VC(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by getNewObjects().

495  {
496  //run the sixth query against the CMS_DCS_ENV_PVSS_COND schema
497  //Initializing the CMS_DCS_ENV_PVSS_COND schema.
498  coral::ISchema& ECAL = session.nominalSchema();
499  //start the transaction against the fill logging schema
500  //execute query for ECAL Data
501  std::unique_ptr<coral::IQuery> ECALDataQuery( ECAL.newQuery() );
502  //FROM clause
503  ECALDataQuery->addToTableList( std::string( "BEAM_PHASE" ) );
504  //SELECT clause
505  ECALDataQuery->addToOutputList( std::string( "DIP_value" ) );
506  ECALDataQuery->addToOutputList( std::string( "element_nr" ) );
507  //WHERE CLAUSE
508  coral::AttributeList ECALDataBindVariables;
509  std::string conditionStr = std::string( "DIP_value LIKE '%beamPhaseMean%' OR DIP_value LIKE '%cavPhaseMean%'" );
510 
511  ECALDataQuery->setCondition( conditionStr, ECALDataBindVariables );
512  //ORDER BY clause
513  ECALDataQuery->addToOrderList( std::string( "CHANGE_DATE" ) );
514  ECALDataQuery->addToOrderList( std::string( "DIP_value" ) );
515  ECALDataQuery->addToOrderList( std::string( "element_nr" ) );
516  //define query output
517  coral::AttributeList ECALDataOutput;
518  ECALDataOutput.extend<std::string>( std::string( "DIP_value" ) );
519  ECALDataOutput.extend<float>( std::string( "element_nr" ) );
520  ECALDataQuery->limitReturnedRows( 14256 ); //3564 entries per vector.
521  ECALDataQuery->defineOutput( ECALDataOutput );
522  //execute the query
523  coral::ICursor& ECALDataCursor = ECALDataQuery->execute();
524  std::vector<float> beam1VC, beam2VC, beam1RF, beam2RF;
525  std::string dipVal = "";
526  std::map<std::string, int> vecMap;
527  vecMap[std::string("Beam1/beamPhaseMean")] = 1;
528  vecMap[std::string("Beam2/beamPhaseMean")] = 2;
529  vecMap[std::string("Beam1/cavPhaseMean")] = 3;
530  vecMap[std::string("Beam2/cavPhaseMean")] = 4;
531 
532  bool ret = false;
533  while( ECALDataCursor.next() ) {
534  ret = true;
535  if( m_debug ) {
536  std::ostringstream ECAL;
537  ECALDataCursor.currentRow().toOutputStream( ECAL );
538  }
539  coral::Attribute const & dipValAttribute = ECALDataCursor.currentRow()[ std::string( "DIP_value" ) ];
540  if( !dipValAttribute.isNull() ) {
541  dipVal = dipValAttribute.data<std::string>();
542  }
543 
544  coral::Attribute const & elementNrAttribute = ECALDataCursor.currentRow()[ std::string( "element_nr" ) ];
545  if( !elementNrAttribute.isNull() ){
546  switch( vecMap[dipVal] )
547  {
548  case 1:
549  beam1VC.push_back(elementNrAttribute.data<float>());
550  break;
551  case 2:
552  beam2VC.push_back(elementNrAttribute.data<float>());
553  break;
554  case 3:
555  beam1RF.push_back(elementNrAttribute.data<float>());
556  break;
557  case 4:
558  beam2RF.push_back(elementNrAttribute.data<float>());
559  break;
560  default:
561  break;
562  }
563  }
564  }
565  if( ret){
566  payload.setBeam1VC(beam1VC);
567  payload.setBeam2VC(beam2VC);
568  payload.setBeam1RF(beam1RF);
569  payload.setBeam2RF(beam2RF);
570  }
571  return ret;
572 }
void setBeam1RF(std::vector< float > const &beam1RF)
Definition: LHCInfo.cc:410
void setBeam1VC(std::vector< float > const &beam1VC)
Definition: LHCInfo.cc:402
coral::ISchema & nominalSchema()
Definition: Session.cc:233
void setBeam2RF(std::vector< float > const &beam2RF)
Definition: LHCInfo.cc:414
void setBeam2VC(std::vector< float > const &beam2VC)
Definition: LHCInfo.cc:406
bool LHCInfoPopConSourceHandler::getFillData ( cond::persistency::Session session,
const boost::posix_time::ptime &  targetTime,
bool  next,
LHCInfo payload 
)
private

Definition at line 53 of file LHCInfoPopConSourceHandler.cc.

References LHCInfo::COSMICS, cond::time::from_boost(), LHCInfo::GAP, LHCInfo::IONS, m_debug, cond::persistency::Session::nominalSchema(), LHCInfo::NONE, LHCInfo::PB82, LHCInfo::PROTON, LHCInfo::PROTONS, seconds(), LHCInfo::setBeginTime(), LHCInfo::setBetaStar(), LHCInfo::setBunchesInBeam1(), LHCInfo::setBunchesInBeam2(), LHCInfo::setCollidingBunches(), LHCInfo::setCreationTime(), LHCInfo::setCrossingAngle(), LHCInfo::setEndTime(), LHCInfo::setEnergy(), LHCInfo::setFill(), LHCInfo::setFillType(), LHCInfo::setInjectionScheme(), LHCInfo::setIntensityForBeam1(), LHCInfo::setIntensityForBeam2(), LHCInfo::setParticleTypeForBeam1(), LHCInfo::setParticleTypeForBeam2(), LHCInfo::setTargetBunches(), AlCaHLTBitMon_QueryRunRegistry::string, ntuplemaker::time, and LHCInfo::UNKNOWN.

Referenced by getCurrentFillData(), and getNextFillData().

56  {
57  coral::ISchema& runTimeLoggerSchema = session.nominalSchema();
58  //prepare the query for table 1:
59  std::unique_ptr<coral::IQuery> fillDataQuery( runTimeLoggerSchema.newQuery() );
60  //FROM clause
61  fillDataQuery->addToTableList( std::string( "RUNTIME_SUMMARY" ) );
62  //SELECT clause
63  fillDataQuery->addToOutputList( std::string( "LHCFILL" ) );
64  fillDataQuery->addToOutputList( std::string( "NBUNCHESBEAM1" ) );
65  fillDataQuery->addToOutputList( std::string( "NBUNCHESBEAM2" ) );
66  fillDataQuery->addToOutputList( std::string( "NCOLLIDINGBUNCHES" ) );
67  fillDataQuery->addToOutputList( std::string( "NTARGETBUNCHES" ) );
68  fillDataQuery->addToOutputList( std::string( "RUNTIME_TYPE_ID" ) );
69  fillDataQuery->addToOutputList( std::string( "PARTY1" ) );
70  fillDataQuery->addToOutputList( std::string( "PARTY2" ) );
71  fillDataQuery->addToOutputList( std::string( "CROSSINGANGLE" ) );
72  fillDataQuery->addToOutputList( std::string( "BETASTAR" ) );
73  fillDataQuery->addToOutputList( std::string( "INTENSITYBEAM1" ) );
74  fillDataQuery->addToOutputList( std::string( "INTENSITYBEAM2" ) );
75  fillDataQuery->addToOutputList( std::string( "ENERGY" ) );
76  fillDataQuery->addToOutputList( std::string( "CREATETIME" ) );
77  fillDataQuery->addToOutputList( std::string( "BEGINTIME" ) );
78  fillDataQuery->addToOutputList( std::string( "ENDTIME" ) );
79  fillDataQuery->addToOutputList( std::string( "INJECTIONSCHEME" ) );
80  //WHERE clause
81  coral::AttributeList fillDataBindVariables;
82  fillDataBindVariables.extend<coral::TimeStamp>(std::string("targetTime"));
83  fillDataBindVariables[ std::string( "targetTime")].data<coral::TimeStamp>()= coral::TimeStamp( targetTime + boost::posix_time::seconds(1) );
84  //by imposing BEGINTIME IS NOT NULL, we remove fills which never went into stable beams,
85  //or the most recent one, just declared but not yet in stable beams
86  std::string conditionStr( "BEGINTIME IS NOT NULL AND BEGINTIME <= :targetTime AND ENDTIME> :targetTime AND LHCFILL IS NOT NULL" );
87  if( next ){
88  conditionStr = "BEGINTIME IS NOT NULL AND BEGINTIME > :targetTime AND LHCFILL IS NOT NULL AND ENDTIME IS NOT NULL";
89  }
90  fillDataQuery->setCondition( conditionStr, fillDataBindVariables );
91  //ORDER BY clause
92  fillDataQuery->addToOrderList( std::string( "BEGINTIME" ) );
93  //define query output
94  coral::AttributeList fillDataOutput;
95  fillDataOutput.extend<unsigned short>( std::string( "LHCFILL" ) );
96  fillDataOutput.extend<unsigned short>( std::string( "NBUNCHESBEAM1" ) );
97  fillDataOutput.extend<unsigned short>( std::string( "NBUNCHESBEAM2" ) );
98  fillDataOutput.extend<unsigned short>( std::string( "NCOLLIDINGBUNCHES" ) );
99  fillDataOutput.extend<unsigned short>( std::string( "NTARGETBUNCHES" ) );
100  fillDataOutput.extend<int>( std::string( "RUNTIME_TYPE_ID" ) );
101  fillDataOutput.extend<int>( std::string( "PARTY1" ) );
102  fillDataOutput.extend<int>( std::string( "PARTY2" ) );
103  fillDataOutput.extend<float>( std::string( "CROSSINGANGLE" ) );
104  fillDataOutput.extend<float>( std::string( "BETASTAR" ) );
105  fillDataOutput.extend<float>( std::string( "INTENSITYBEAM1" ) );
106  fillDataOutput.extend<float>( std::string( "INTENSITYBEAM2" ) );
107  fillDataOutput.extend<float>( std::string( "ENERGY" ) );
108  fillDataOutput.extend<coral::TimeStamp>( std::string( "CREATETIME" ) );
109  fillDataOutput.extend<coral::TimeStamp>( std::string( "BEGINTIME" ) );
110  fillDataOutput.extend<coral::TimeStamp>( std::string( "ENDTIME" ) );
111  fillDataOutput.extend<std::string>( std::string( "INJECTIONSCHEME" ) );
112  fillDataQuery->defineOutput( fillDataOutput );
113  fillDataQuery->limitReturnedRows( 1 );
114  //execute the query
115  coral::ICursor& fillDataCursor = fillDataQuery->execute();
116  //
117  unsigned short currentFill = 0;
118  unsigned short bunches1 = 0, bunches2 = 0, collidingBunches = 0, targetBunches = 0;
120  LHCInfo::ParticleTypeId particleType1 = LHCInfo::NONE, particleType2 = LHCInfo::NONE;
121  float crossingAngle = 0., betastar = 0., intensityBeam1 = 0., intensityBeam2 = 0., energy = 0.;
122  coral::TimeStamp stableBeamStartTimeStamp, beamDumpTimeStamp;
123  cond::Time_t creationTime = 0ULL, stableBeamStartTime = 0ULL, beamDumpTime = 0ULL;
124  std::string injectionScheme( "None" );
125  std::ostringstream ss;
126  bool ret = false;
127  if( fillDataCursor.next() ) {
128  ret = true;
129  if( m_debug ) {
130  std::ostringstream qs;
131  fillDataCursor.currentRow().toOutputStream( qs );
132  }
133  coral::Attribute const & fillAttribute = fillDataCursor.currentRow()[ std::string( "LHCFILL" ) ];
134  if( !fillAttribute.isNull() ){
135  currentFill = fillAttribute.data<unsigned short>();
136  }
137  coral::Attribute const & bunches1Attribute = fillDataCursor.currentRow()[ std::string( "NBUNCHESBEAM1" ) ];
138  if( !bunches1Attribute.isNull() ) {
139  bunches1 = bunches1Attribute.data<unsigned short>();
140  }
141  coral::Attribute const & bunches2Attribute = fillDataCursor.currentRow()[ std::string( "NBUNCHESBEAM2" ) ];
142  if( !bunches2Attribute.isNull() ) {
143  bunches2 = bunches2Attribute.data<unsigned short>();
144  }
145  coral::Attribute const & collidingBunchesAttribute = fillDataCursor.currentRow()[ std::string( "NCOLLIDINGBUNCHES" ) ];
146  if( !collidingBunchesAttribute.isNull() ) {
147  collidingBunches = collidingBunchesAttribute.data<unsigned short>();
148  }
149  coral::Attribute const & targetBunchesAttribute = fillDataCursor.currentRow()[ std::string( "NTARGETBUNCHES" ) ];
150  if( !targetBunchesAttribute.isNull() ) {
151  targetBunches = targetBunchesAttribute.data<unsigned short>();
152  }
153  //RUNTIME_TYPE_ID IS NOT NULL
154  fillType = static_cast<LHCInfo::FillTypeId>( fillDataCursor.currentRow()[ std::string( "RUNTIME_TYPE_ID" ) ].data<int>() );
155  coral::Attribute const & particleType1Attribute = fillDataCursor.currentRow()[ std::string( "PARTY1" ) ];
156  if( !particleType1Attribute.isNull() ) {
157  particleType1 = static_cast<LHCInfo::ParticleTypeId>( particleType1Attribute.data<int>() );
158  }
159  coral::Attribute const & particleType2Attribute = fillDataCursor.currentRow()[ std::string( "PARTY2" ) ];
160  if( !particleType2Attribute.isNull() ) {
161  particleType2 = static_cast<LHCInfo::ParticleTypeId>( particleType2Attribute.data<int>() );
162  }
163  coral::Attribute const & crossingAngleAttribute = fillDataCursor.currentRow()[ std::string( "CROSSINGANGLE" ) ];
164  if( !crossingAngleAttribute.isNull() ) {
165  crossingAngle = crossingAngleAttribute.data<float>();
166  }
167  coral::Attribute const & betastarAttribute = fillDataCursor.currentRow()[ std::string( "BETASTAR" ) ];
168  if( !betastarAttribute.isNull() ) {
169  betastar = betastarAttribute.data<float>();
170  }
171  coral::Attribute const & intensityBeam1Attribute = fillDataCursor.currentRow()[ std::string( "INTENSITYBEAM1" ) ];
172  if( !intensityBeam1Attribute.isNull() ) {
173  intensityBeam1 = intensityBeam1Attribute.data<float>();
174  }
175  coral::Attribute const & intensityBeam2Attribute = fillDataCursor.currentRow()[ std::string( "INTENSITYBEAM2" ) ];
176  if( !intensityBeam2Attribute.isNull() ) {
177  intensityBeam2 = intensityBeam2Attribute.data<float>();
178  }
179  coral::Attribute const & energyAttribute = fillDataCursor.currentRow()[ std::string( "ENERGY" ) ];
180  if( !energyAttribute.isNull() ){
181  energy = energyAttribute.data<float>();
182  }
183  }
184  if( ret ){
185  //CREATETIME IS NOT NULL
186  creationTime = cond::time::from_boost( fillDataCursor.currentRow()[ std::string( "CREATETIME" ) ].data<coral::TimeStamp>().time() );
187  //BEGINTIME is imposed to be NOT NULL in the WHERE clause
188  stableBeamStartTimeStamp = fillDataCursor.currentRow()[ std::string( "BEGINTIME" ) ].data<coral::TimeStamp>();
189  stableBeamStartTime = cond::time::from_boost( stableBeamStartTimeStamp.time() );
190  coral::Attribute const & beamDumpTimeAttribute = fillDataCursor.currentRow()[ std::string( "ENDTIME" ) ];
191  if( !beamDumpTimeAttribute.isNull() ) {
192  beamDumpTimeStamp = beamDumpTimeAttribute.data<coral::TimeStamp>();
193  beamDumpTime = cond::time::from_boost( beamDumpTimeStamp.time() );
194  }
195  coral::Attribute const & injectionSchemeAttribute = fillDataCursor.currentRow()[ std::string( "INJECTIONSCHEME" ) ];
196  if( !injectionSchemeAttribute.isNull() ) {
197  injectionScheme = injectionSchemeAttribute.data<std::string>();
198  }
199  //fix an inconsistency in RunTimeLogger: if the fill type is defined, the particle type should reflect it!
200  if( fillType != LHCInfo::UNKNOWN && ( particleType1 == LHCInfo::NONE || particleType2 == LHCInfo::NONE ) ) {
201  switch( fillType ) {
202  case LHCInfo::PROTONS :
203  particleType1 = LHCInfo::PROTON;
204  particleType2 = LHCInfo::PROTON;
205  break;
206  case LHCInfo::IONS :
207  particleType1 = LHCInfo::PB82;
208  particleType2 = LHCInfo::PB82;
209  break;
210  case LHCInfo::UNKNOWN :
211  case LHCInfo::COSMICS :
212  case LHCInfo::GAP :
213  break;
214  }
215  }
216  payload.setFill( currentFill, true );
217  payload.setBunchesInBeam1( bunches1 );
218  payload.setBunchesInBeam2( bunches2 );
219  payload.setCollidingBunches( collidingBunches );
220  payload.setTargetBunches( targetBunches );
221  payload.setFillType( fillType );
222  payload.setParticleTypeForBeam1( particleType1 );
223  payload.setParticleTypeForBeam2( particleType2 );
224  payload.setCrossingAngle( crossingAngle );
225  payload.setBetaStar( betastar );
226  payload.setIntensityForBeam1( intensityBeam1 );
227  payload.setIntensityForBeam2( intensityBeam2 );
228  payload.setEnergy( energy );
229  payload.setCreationTime( creationTime );
230  payload.setBeginTime( stableBeamStartTime );
231  payload.setEndTime( beamDumpTime );
232  payload.setInjectionScheme( injectionScheme );
233  }
234  return ret;
235 }
void setBeginTime(cond::Time_t const &beginTime)
Definition: LHCInfo.cc:370
void setEnergy(float const &energy)
Definition: LHCInfo.cc:346
double seconds()
void setParticleTypeForBeam2(ParticleTypeId const &particleType)
Definition: LHCInfo.cc:326
void setBunchesInBeam1(unsigned short const &bunches)
Definition: LHCInfo.cc:302
void setFill(unsigned short const &lhcFill, bool const &fromData)
Definition: LHCInfo.cc:105
unsigned long long Time_t
Definition: Time.h:16
void setBetaStar(float const &betaStar)
Definition: LHCInfo.cc:334
coral::ISchema & nominalSchema()
Definition: Session.cc:233
void setBunchesInBeam2(unsigned short const &bunches)
Definition: LHCInfo.cc:306
void setCollidingBunches(unsigned short const &collidingBunches)
Definition: LHCInfo.cc:310
Time_t from_boost(boost::posix_time::ptime bt)
ParticleType
Definition: LHCInfo.h:15
void setParticleTypeForBeam1(ParticleTypeId const &particleType)
Definition: LHCInfo.cc:322
void setInjectionScheme(std::string const &injectionScheme)
Definition: LHCInfo.cc:378
void setCreationTime(cond::Time_t const &createTime)
Definition: LHCInfo.cc:366
void setTargetBunches(unsigned short const &targetBunches)
Definition: LHCInfo.cc:314
void setIntensityForBeam1(float const &intensity)
Definition: LHCInfo.cc:338
void setEndTime(cond::Time_t const &endTime)
Definition: LHCInfo.cc:374
void setIntensityForBeam2(float const &intensity)
Definition: LHCInfo.cc:342
void setFillType(FillTypeId const &fillType)
Definition: LHCInfo.cc:318
void setCrossingAngle(float const &angle)
Definition: LHCInfo.cc:330
FillType
Definition: LHCInfo.h:14
bool LHCInfoPopConSourceHandler::getLumiData ( cond::persistency::Session session,
const boost::posix_time::ptime &  targetTime,
LHCInfo payload 
)
private

Definition at line 249 of file LHCInfoPopConSourceHandler.cc.

References muonGEMDigis_cfi::instLumi, cond::persistency::Session::nominalSchema(), seconds(), LHCInfo::setDelivLumi(), LHCInfo::setInstLumi(), LHCInfo::setInstLumiError(), LHCInfo::setRecLumi(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by getNewObjects().

251  {
252  coral::ISchema& runTimeLoggerSchema = session.nominalSchema();
253  //prepare the query for table 2:
254  std::unique_ptr<coral::IQuery> fillDataQuery2( runTimeLoggerSchema.newQuery() );
255  //FROM clause
256  fillDataQuery2->addToTableList( std::string( "LUMI_SECTIONS" ) );
257  //SELECT clause
258  fillDataQuery2->addToOutputList( std::string( "DELIVLUMI" ) );
259  fillDataQuery2->addToOutputList( std::string( "LIVELUMI" ) );
260  fillDataQuery2->addToOutputList( std::string( "INSTLUMI" ) );
261  fillDataQuery2->addToOutputList( std::string( "INSTLUMIERROR" ) );
262  //WHERE clause
263  coral::AttributeList fillDataBindVariables;
264  fillDataBindVariables.extend<coral::TimeStamp>(std::string("targetTime"));
265  fillDataBindVariables[ std::string( "targetTime")].data<coral::TimeStamp>()= coral::TimeStamp( targetTime + boost::posix_time::seconds(1) );
266  std::string conditionStr = "DELIVLUMI IS NOT NULL AND STARTTIME < :targetTime AND STOPTIME> :targetTime";
267  fillDataQuery2->setCondition( conditionStr, fillDataBindVariables );
268  //ORDER BY clause
269  fillDataQuery2->addToOrderList( std::string( "LHCFILL" ) );
270  //fillDataQuery2->groupBy( std::string( "LHCFILL" ) );
271  //define query output*/
272  coral::AttributeList fillDataOutput2;
273  fillDataOutput2.extend<float>( std::string( "DELIVEREDLUMI" ) );
274  fillDataOutput2.extend<float>( std::string( "RECORDEDLUMI" ) );
275  fillDataOutput2.extend<float>( std::string( "INSTLUMI" ) );
276  fillDataOutput2.extend<float>( std::string( "INSTLUMIERROR" ) );
277  fillDataQuery2->defineOutput( fillDataOutput2 );
278  //execute the query
279  coral::ICursor& fillDataCursor2 = fillDataQuery2->execute();
280 
281  float delivLumi = 0., recLumi = 0., instLumi = 0, instLumiErr = 0.;
282  bool ret = false;
283  if( fillDataCursor2.next()){
284  ret = true;
285  coral::Attribute const & delivLumiAttribute = fillDataCursor2.currentRow()[ std::string( "DELIVEREDLUMI" ) ];
286  if( !delivLumiAttribute.isNull() ){
287  delivLumi = delivLumiAttribute.data<float>() / 1000.;
288  }
289  coral::Attribute const & recLumiAttribute = fillDataCursor2.currentRow()[ std::string( "RECORDEDLUMI" ) ];
290  if( !recLumiAttribute.isNull() ){
291  recLumi = recLumiAttribute.data<float>() / 1000.;
292  }
293  coral::Attribute const & instLumiAttribute = fillDataCursor2.currentRow()[ std::string( "INSTLUMI" ) ];
294  if( !instLumiAttribute.isNull() ){
295  instLumi = instLumiAttribute.data<float>() / 1000.;
296  }
297  coral::Attribute const & instLumiErrAttribute = fillDataCursor2.currentRow()[ std::string( "INSTLUMIERROR" ) ];
298  if( !instLumiErrAttribute.isNull() ){
299  instLumiErr = instLumiErrAttribute.data<float>() / 1000.;
300  }
301  if( delivLumi > 0. ){
302  payload.setDelivLumi( delivLumi );
303  payload.setRecLumi( recLumi );
304  payload.setInstLumi( instLumi );
305  payload.setInstLumiError( instLumiErr );
306  }
307  }
308  return ret;
309 }
void setInstLumi(float const &instLumi)
Definition: LHCInfo.cc:358
double seconds()
void setInstLumiError(float const &instLumiError)
Definition: LHCInfo.cc:362
void setDelivLumi(float const &delivLumi)
Definition: LHCInfo.cc:350
coral::ISchema & nominalSchema()
Definition: Session.cc:233
void setRecLumi(float const &recLumi)
Definition: LHCInfo.cc:354
void LHCInfoPopConSourceHandler::getNewObjects ( )
overridevirtual

Implements popcon::PopConSourceHandler< LHCInfo >.

Definition at line 607 of file LHCInfoPopConSourceHandler.cc.

References addEmptyPayload(), addPayload(), cond::persistency::Transaction::commit(), cond::persistency::ConnectionPool::configure(), cond::persistency::ConnectionPool::createSession(), popcon::PopConSourceHandler< LHCInfo >::dbSession(), Debug, cond::persistency::Session::fetchPayload(), cond::time::from_boost(), getCTTPSData(), getCurrentFillData(), getDipData(), getEcalData(), getLumiData(), getNextFillData(), LHCInfoImpl::getNextIov(), cond::TagInfo_t::lastInterval, popcon::PopConSourceHandler< LHCInfo >::lastPayload(), cond::TagInfo_t::lastPayloadToken, m_authpath, m_connectionString, m_debug, m_ecalConnectionString, m_endTime, m_lastPayloadEmpty, m_name, m_payloadBuffer, m_samplingInterval, m_startTime, SiStripPI::max, cond::time::MAX_VAL(), dataset::name, cond::TagInfo_t::name, nullptr, jets_cff::payload, dataDML::session, cond::persistency::ConnectionPool::setAuthenticationPath(), cond::persistency::ConnectionPool::setMessageVerbosity(), cond::TagInfo_t::size, cond::persistency::Transaction::start(), popcon::PopConSourceHandler< LHCInfo >::tagInfo(), cond::time::to_boost(), cond::TagInfo_t::token, and cond::persistency::Session::transaction().

607  {
608  //reference to the last payload in the tag
609  Ref previousFill;
610 
611  //if a new tag is created, transfer fake fill from 1 to the first fill for the first time
612  if ( tagInfo().name.empty() ) {
613  edm::LogInfo( m_name ) << "New tag "<< tagInfo().name << "; from " << m_name << "::getNewObjects";
614  } else {
615  //check what is already inside the database
616  edm::LogInfo( m_name ) << "got info for tag " << tagInfo().name
617  << ", IOVSequence token " << tagInfo().token
618  << ": size " << tagInfo().size
619  << ", last object valid since " << tagInfo().lastInterval.first
620  << " ( "<< boost::posix_time::to_iso_extended_string( cond::time::to_boost( tagInfo().lastInterval.first ) )
621  << " ); from " << m_name << "::getNewObjects";
622  }
623 
624  cond::Time_t lastIov = tagInfo().lastInterval.first;
625  if( lastIov == 0 ){
626  // for a new or empty tag, an empty payload should be added on top with since=1
627  addEmptyPayload( 1 );
628  } else {
629  edm::LogInfo( m_name ) << "The last Iov in tag " << tagInfo().name
630  << " valid since " << lastIov
631  << "from " << m_name << "::getNewObjects";
632  }
633 
635  if( !m_startTime.is_not_a_date_time() ){
637  if( targetIov < tgtIov ) targetIov = tgtIov;
638  }
639 
641  if( !m_endTime.is_not_a_date_time() ){
643  }
644  edm::LogInfo(m_name) <<"Starting sampling at "<<boost::posix_time::to_simple_string(cond::time::to_boost(targetIov));
645  std::unique_ptr<LHCInfo> currentFillPayload;
646 
647  //retrieve the data from the relational database source
649  //configure the connection
650  if( m_debug ) {
651  connection.setMessageVerbosity( coral::Debug );
652  } else {
653  connection.setMessageVerbosity( coral::Error );
654  }
655  connection.setAuthenticationPath( m_authpath );
656  connection.configure();
657  //create the sessions
659  cond::persistency::Session session2 = connection.createSession( m_ecalConnectionString, false );
660  //start the transaction against the fill logging schema
661  if( !tagInfo().lastPayloadToken.empty() ){
663  session3.transaction().start(true);
664  std::shared_ptr<LHCInfo> lastPayload = session3.fetchPayload<LHCInfo>( tagInfo().lastPayloadToken );
665  session3.transaction().commit();
666  if( lastPayload->fillNumber() != 0 ){
667  currentFillPayload.reset(lastPayload->cloneFill());
668  } else {
669  m_lastPayloadEmpty = true;
670  }
671  }
672  if( currentFillPayload.get() == nullptr ){
673  currentFillPayload.reset( new LHCInfo() );
674  session.transaction().start(true);
675  bool foundFill = getCurrentFillData( session, cond::time::to_boost(targetIov ), *currentFillPayload );
676  session.transaction().commit();
677  if( foundFill ){
678  edm::LogInfo( m_name ) <<"Found a fill at current time.";
679  cond::Time_t firstIov = currentFillPayload->beginTime();
680  firstIov = std::max( firstIov,lastIov );
681  targetIov = std::max( targetIov,firstIov);
682  } else {
683  edm::LogInfo( m_name ) <<"No fill found at current time."<<std::endl;
684  currentFillPayload.reset();
685  addEmptyPayload( targetIov );
686  targetIov = LHCInfoImpl::getNextIov( targetIov, m_samplingInterval );
687  }
688  }
689 
690  while( true ){
691  if( targetIov >= endIov ){
692  edm::LogInfo( m_name ) <<"Sampling ended at the pre-setted time "<<boost::posix_time::to_simple_string(cond::time::to_boost( endIov ));
693  break;
694  }
695  boost::posix_time::ptime targetTime = cond::time::to_boost( targetIov );
696  if( !currentFillPayload.get() ){
697  currentFillPayload.reset( new LHCInfo() );
698  session.transaction().start(true);
699  edm::LogInfo( m_name ) <<"Searching new fill after "<<boost::posix_time::to_simple_string(targetTime);
700  bool foundFill = getNextFillData( session, targetTime, *currentFillPayload );
701  session.transaction().commit();
702  if ( !foundFill ){
703  currentFillPayload.reset();
704  edm::LogInfo( m_name )<<"No fill found...";
705  addEmptyPayload( targetIov );
706  break;
707  }
708  cond::Time_t newTargetIov = currentFillPayload->beginTime();
709  edm::LogInfo( m_name ) <<"Found new fill at "<<boost::posix_time::to_simple_string(cond::time::to_boost(newTargetIov));
710  if( newTargetIov > targetIov ){
711  addEmptyPayload( targetIov );
712  targetIov = newTargetIov;
713  }
714  }
715  bool more = true;
716  while( more ){
717  targetTime = cond::time::to_boost( targetIov );
718  edm::LogInfo( m_name )<<"Getting sample at:"<<boost::posix_time::to_simple_string(targetTime);
719  LHCInfo* payload = currentFillPayload->cloneFill();
720  m_payloadBuffer.emplace_back( payload );
721  session.transaction().start(true);
722  getLumiData( session, targetTime, *payload );
723  getDipData( session, targetTime, *payload );
724  getCTTPSData( session, targetTime, *payload );
725  session.transaction().commit();
726  session2.transaction().start(true);
727  getEcalData( session2, targetTime, *payload );
728  session2.transaction().commit();
729  addPayload( *payload, targetIov );
730  targetIov = LHCInfoImpl::getNextIov( targetIov, m_samplingInterval );
731  cond::Time_t endSampling = currentFillPayload->endTime();
732  if( endSampling == 0 ) endSampling = cond::time::from_boost( boost::posix_time::second_clock::local_time() );
733  if( targetIov > endSampling ){
734  edm::LogInfo( m_name )<<"End of sampling for current fill: endTime is "<<
735  boost::posix_time::to_simple_string(cond::time::to_boost(endSampling));
736  targetIov = endSampling;
737  currentFillPayload = nullptr;
738  more = false;
739  }
740  if( targetIov >= endIov ){
741  more = false;
742  }
743  }
744  }
745 }
cond::persistency::Session & dbSession() const
edm::ErrorSummaryEntry Error
bool getNextFillData(cond::persistency::Session &session, const boost::posix_time::ptime &targetTime, LHCInfo &payload)
boost::posix_time::ptime m_startTime
void start(bool readOnly=true)
Definition: Session.cc:22
bool getLumiData(cond::persistency::Session &session, const boost::posix_time::ptime &targetTime, LHCInfo &payload)
size_t size
Definition: Types.h:77
#define nullptr
Transaction & transaction()
Definition: Session.cc:66
std::string name
Definition: Types.h:73
cond::ValidityInterval lastInterval
Definition: Types.h:75
unsigned long long Time_t
Definition: Time.h:16
boost::posix_time::ptime m_endTime
Session createSession(const std::string &connectionString, bool writeCapable=false)
bool getEcalData(cond::persistency::Session &session, const boost::posix_time::ptime &targetTime, LHCInfo &payload)
cond::Time_t getNextIov(cond::Time_t prevIov, unsigned int samplingInterval)
void setMessageVerbosity(coral::MsgLevel level)
Time_t from_boost(boost::posix_time::ptime bt)
bool getCTTPSData(cond::persistency::Session &session, const boost::posix_time::ptime &targetTime, LHCInfo &payload)
bool getCurrentFillData(cond::persistency::Session &session, const boost::posix_time::ptime &targetTime, LHCInfo &payload)
void addPayload(LHCInfo &newPayload, cond::Time_t iov)
std::string lastPayloadToken
Definition: Types.h:76
std::vector< std::unique_ptr< LHCInfo > > m_payloadBuffer
void setAuthenticationPath(const std::string &p)
const bool Debug
const Time_t MAX_VAL(std::numeric_limits< Time_t >::max())
std::string token
Definition: Types.h:74
boost::posix_time::ptime to_boost(Time_t iValue)
cond::TagInfo_t const & tagInfo() const
bool getDipData(cond::persistency::Session &session, const boost::posix_time::ptime &targetTime, LHCInfo &payload)
std::shared_ptr< T > fetchPayload(const cond::Hash &payloadHash)
Definition: Session.h:215
bool LHCInfoPopConSourceHandler::getNextFillData ( cond::persistency::Session session,
const boost::posix_time::ptime &  targetTime,
LHCInfo payload 
)
private

Definition at line 243 of file LHCInfoPopConSourceHandler.cc.

References getFillData().

Referenced by getNewObjects().

245  {
246  return getFillData( session, targetTime, true, payload );
247 }
bool getFillData(cond::persistency::Session &session, const boost::posix_time::ptime &targetTime, bool next, LHCInfo &payload)
std::string LHCInfoPopConSourceHandler::id ( ) const
overridevirtual

Implements popcon::PopConSourceHandler< LHCInfo >.

Definition at line 747 of file LHCInfoPopConSourceHandler.cc.

References m_name.

747  {
748  return m_name;
749 }

Member Data Documentation

std::string LHCInfoPopConSourceHandler::m_authpath
private

Definition at line 37 of file LHCInfoPopConSourceHandler.h.

Referenced by getNewObjects().

std::string LHCInfoPopConSourceHandler::m_connectionString
private

Definition at line 36 of file LHCInfoPopConSourceHandler.h.

Referenced by getNewObjects().

bool LHCInfoPopConSourceHandler::m_debug
private
std::string LHCInfoPopConSourceHandler::m_dipSchema
private

Definition at line 37 of file LHCInfoPopConSourceHandler.h.

Referenced by getDipData().

std::string LHCInfoPopConSourceHandler::m_ecalConnectionString
private

Definition at line 36 of file LHCInfoPopConSourceHandler.h.

Referenced by getNewObjects().

boost::posix_time::ptime LHCInfoPopConSourceHandler::m_endTime
private

Definition at line 31 of file LHCInfoPopConSourceHandler.h.

Referenced by getNewObjects(), and LHCInfoPopConSourceHandler().

bool LHCInfoPopConSourceHandler::m_lastPayloadEmpty = false
private

Definition at line 39 of file LHCInfoPopConSourceHandler.h.

Referenced by addEmptyPayload(), and getNewObjects().

std::string LHCInfoPopConSourceHandler::m_name
private

Definition at line 34 of file LHCInfoPopConSourceHandler.h.

Referenced by getNewObjects(), and id().

std::vector<std::unique_ptr<LHCInfo> > LHCInfoPopConSourceHandler::m_payloadBuffer
private

Definition at line 38 of file LHCInfoPopConSourceHandler.h.

Referenced by addEmptyPayload(), and getNewObjects().

unsigned int LHCInfoPopConSourceHandler::m_samplingInterval
private

Definition at line 33 of file LHCInfoPopConSourceHandler.h.

Referenced by getNewObjects().

boost::posix_time::ptime LHCInfoPopConSourceHandler::m_startTime
private

Definition at line 30 of file LHCInfoPopConSourceHandler.h.

Referenced by getNewObjects(), and LHCInfoPopConSourceHandler().