CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
popcon::PopCon Class Reference

#include <PopCon.h>

Public Types

typedef cond::Time_t Time_t
 

Public Member Functions

 PopCon (const edm::ParameterSet &pset)
 
template<typename Source >
void write (Source const &source)
 
template<typename T >
void writeOne (T *payload, Time_t time)
 
virtual ~PopCon ()
 

Private Member Functions

void finalize (Time_t lastTill)
 
cond::persistency::Session initialize ()
 

Private Attributes

std::string m_authPath
 
int m_authSys
 
bool m_close
 
edm::Service< cond::service::PoolDBOutputServicem_dbService
 
Time_t m_lastTill
 
cond::LogDBEntry_t m_logDBEntry
 
bool m_LoggingOn
 
std::string m_payload_name
 
std::string m_record
 
std::string m_tag
 
cond::TagInfo_t m_tagInfo
 
std::string m_targetConnectionString
 
cond::persistency::Session m_targetSession
 

Static Private Attributes

static const char *const s_version = "5.0"
 

Detailed Description

Definition at line 34 of file PopCon.h.

Member Typedef Documentation

Definition at line 36 of file PopCon.h.

Constructor & Destructor Documentation

popcon::PopCon::PopCon ( const edm::ParameterSet pset)

Definition at line 12 of file PopCon.cc.

References s_version.

12  :
14  m_targetConnectionString(pset.getUntrackedParameter< std::string >("targetDBConnectionString","")),
15  m_authPath( pset.getUntrackedParameter<std::string>("authenticationPath","")),
16  m_authSys( pset.getUntrackedParameter<int>("authenticationSystem",1)),
17  m_record(pset.getParameter<std::string> ("record")),
19  m_LoggingOn(pset.getUntrackedParameter< bool > ("loggingOn",true)),
20  m_close(pset.getUntrackedParameter< bool > ("closeIOV",false)),
21  m_lastTill(pset.getUntrackedParameter< bool > ("lastTill",0))
22  {
23  //TODO set the policy (cfg or global configuration?)
24  //Policy if corrupted data found
25 
26  edm::LogInfo ("PopCon") << "This is PopCon (Populator of Condition) v" << s_version << ".\n"
27  << "Please report any problem and feature request through the JIRA project CMSCONDDB.\n" ;
28  }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
Time_t m_lastTill
Definition: PopCon.h:83
bool m_close
Definition: PopCon.h:81
std::string m_record
Definition: PopCon.h:69
cond::persistency::Session m_targetSession
Definition: PopCon.h:61
static const char *const s_version
Definition: PopCon.h:85
std::string m_targetConnectionString
Definition: PopCon.h:63
int m_authSys
Definition: PopCon.h:67
std::string m_authPath
Definition: PopCon.h:65
std::string m_payload_name
Definition: PopCon.h:71
bool m_LoggingOn
Definition: PopCon.h:73
popcon::PopCon::~PopCon ( )
virtual

Definition at line 30 of file PopCon.cc.

References cond::persistency::Transaction::commit(), m_targetConnectionString, m_targetSession, and cond::persistency::Session::transaction().

30  {
31  if( !m_targetConnectionString.empty() ) {
33  }
34  }
Transaction & transaction()
Definition: Session.cc:66
cond::persistency::Session m_targetSession
Definition: PopCon.h:61
std::string m_targetConnectionString
Definition: PopCon.h:63

Member Function Documentation

void popcon::PopCon::finalize ( Time_t  lastTill)
private

Definition at line 78 of file PopCon.cc.

References cond::service::PoolDBOutputService::closeIOV(), cond::persistency::Transaction::commit(), m_close, m_dbService, m_lastTill, m_record, m_targetConnectionString, m_targetSession, and cond::persistency::Session::transaction().

Referenced by write().

78  {
79 
80  if (m_close) {
81  // avoid to close it before lastSince
82  if (m_lastTill>lastTill) lastTill=m_lastTill;
83  m_dbService->closeIOV(lastTill,m_record);
84  }
85  if( !m_targetConnectionString.empty() ) {
87  }
88  }
void closeIOV(Time_t lastTill, const std::string &recordName, bool withlogging=false)
Time_t m_lastTill
Definition: PopCon.h:83
bool m_close
Definition: PopCon.h:81
std::string m_record
Definition: PopCon.h:69
Transaction & transaction()
Definition: Session.cc:66
cond::persistency::Session m_targetSession
Definition: PopCon.h:61
std::string m_targetConnectionString
Definition: PopCon.h:63
edm::Service< cond::service::PoolDBOutputService > m_dbService
Definition: PopCon.h:59
cond::persistency::Session popcon::PopCon::initialize ( )
private

Definition at line 37 of file PopCon.cc.

References cond::persistency::ConnectionPool::configure(), cond::persistency::Session::connectionString(), cond::persistency::ConnectionPool::createSession(), Exception, cond::persistency::Session::existsIov(), cond::persistency::IOVProxy::getLast(), edm::Service< T >::isAvailable(), plotBeamSpotDB::last, cond::TagInfo_t::lastInterval, cond::TagInfo_t::lastPayloadToken, m_authPath, m_authSys, m_dbService, m_payload_name, m_record, m_tag, m_tagInfo, m_targetConnectionString, m_targetSession, cond::TagInfo_t::name, cond::Iov_t::payloadId, cond::persistency::Session::readIov(), cond::persistency::IOVProxy::sequenceSize(), cond::service::PoolDBOutputService::session(), cond::persistency::ConnectionPool::setAuthenticationPath(), cond::persistency::ConnectionPool::setAuthenticationSystem(), cond::Iov_t::since, cond::TagInfo_t::size, cond::persistency::Transaction::start(), AlCaHLTBitMon_QueryRunRegistry::string, cond::service::PoolDBOutputService::tag(), cond::Iov_t::till, and cond::persistency::Session::transaction().

Referenced by write().

37  {
38  edm::LogInfo ("PopCon")<<"payload name "<<m_payload_name<<std::endl;
39  if(!m_dbService.isAvailable() ) throw Exception("DBService not available");
40  const std::string & connectionStr = m_dbService->session().connectionString();
44  else {
48  connPool.configure();
51  }
55  m_tagInfo.size = iov.sequenceSize();
56  if( m_tagInfo.size>0 ){
57  cond::Iov_t last = iov.getLast();
60  }
61 
62  edm::LogInfo ("PopCon") << "destination DB: " << connectionStr
63  << ", target DB: " << ( m_targetConnectionString.empty() ? connectionStr : m_targetConnectionString ) << "\n"
64  << "TAG: " << m_tag
65  << ", last since/till: " << m_tagInfo.lastInterval.first
66  << "/" << m_tagInfo.lastInterval.second
67  << ", size: " << m_tagInfo.size << "\n" << std::endl;
68  } else {
69  edm::LogInfo ("PopCon") << "destination DB: " << connectionStr
70  << ", target DB: " << ( m_targetConnectionString.empty() ? connectionStr : m_targetConnectionString ) << "\n"
71  << "TAG: " << m_tag
72  << "; First writer to this new tag." << std::endl;
73  }
74  return m_targetSession;
75  }
void start(bool readOnly=true)
Definition: Session.cc:22
cond::persistency::Session session() const
Time_t since
Definition: Types.h:55
size_t size
Definition: Types.h:77
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:19
std::string m_tag
Definition: PopCon.h:75
std::string m_record
Definition: PopCon.h:69
Transaction & transaction()
Definition: Session.cc:66
std::string tag(const std::string &recordName)
cond::persistency::Session m_targetSession
Definition: PopCon.h:61
std::string name
Definition: Types.h:73
cond::ValidityInterval lastInterval
Definition: Types.h:75
IOVProxy readIov(const std::string &tag, bool full=false)
Definition: Session.cc:81
void setAuthenticationSystem(int authSysCode)
bool isAvailable() const
Definition: Service.h:46
Hash payloadId
Definition: Types.h:57
Session createSession(const std::string &connectionString, bool writeCapable=false)
std::string m_targetConnectionString
Definition: PopCon.h:63
cond::TagInfo_t m_tagInfo
Definition: PopCon.h:77
std::string connectionString()
Definition: Session.cc:224
int m_authSys
Definition: PopCon.h:67
std::string lastPayloadToken
Definition: Types.h:76
bool existsIov(const std::string &tag)
Definition: Session.cc:97
std::string m_authPath
Definition: PopCon.h:65
void setAuthenticationPath(const std::string &p)
std::string m_payload_name
Definition: PopCon.h:71
edm::Service< cond::service::PoolDBOutputService > m_dbService
Definition: PopCon.h:59
Time_t till
Definition: Types.h:56
template<typename Source >
void popcon::PopCon::write ( Source const &  source)

Definition at line 123 of file PopCon.h.

References popcon::displayHelper(), popcon::displayIovHelper(), finalize(), initialize(), m_dbService, m_logDBEntry, m_LoggingOn, m_record, m_tagInfo, jetCorrFactors_cfi::payload, tauJetCorrections_cff::payloads, alignCSCRings::s, s_version, cond::service::PoolDBOutputService::setLogHeaderForRecord(), source, and ntuplemaker::time.

Referenced by pkg.AbstractPkg::generate(), HcalSiPMParametersPopConAnalyzer::write(), HcalTPChannelParametersPopConAnalyzer::write(), HcalSiPMCharacteristicsPopConAnalyzer::write(), HcalTPParametersPopConAnalyzer::write(), ExTestEcalChannelStatusAnalyzer::write(), HcalFrontEndMapPopConAnalyzer::write(), CastorPedestalWidthsPopConAnalyzer::write(), HcalTimeCorrsPopConAnalyzer::write(), HcalFlagHFDigiTimeParamsPopConAnalyzer::write(), HcalGainsPopConAnalyzer::write(), HcalValidationCorrsPopConAnalyzer::write(), HcalRecoParamsPopConAnalyzer::write(), HcalQIETypesPopConAnalyzer::write(), HcalQIEDataPopConAnalyzer::write(), HcalPFCorrsPopConAnalyzer::write(), HcalPedestalWidthsPopConAnalyzer::write(), HcalPedestalsPopConAnalyzer::write(), HcalMCParamsPopConAnalyzer::write(), HcalElectronicsMapPopConAnalyzer::write(), HcalLUTCorrsPopConAnalyzer::write(), HcalLongRecoParamsPopConAnalyzer::write(), CastorQIEDataPopConAnalyzer::write(), HcalGainWidthsPopConAnalyzer::write(), HcalZSThresholdsPopConAnalyzer::write(), HcalTimingParamsPopConAnalyzer::write(), HcalRespCorrsPopConAnalyzer::write(), CastorChannelQualityPopConAnalyzer::write(), HcalDcsValuesPopConAnalyzer::write(), HcalDcsMapPopConAnalyzer::write(), HcalChannelQualityPopConAnalyzer::write(), HcalLutMetadataPopConAnalyzer::write(), CastorRecoParamsPopConAnalyzer::write(), CastorElectronicsMapPopConAnalyzer::write(), CastorPedestalsPopConAnalyzer::write(), HcalL1TriggerObjectsPopConAnalyzer::write(), CastorGainWidthsPopConAnalyzer::write(), CastorSaturationCorrsPopConAnalyzer::write(), CastorGainsPopConAnalyzer::write(), HcalZDCLowGainFractionsPopConAnalyzer::write(), popcon::PopConAnalyzer< HcalTPParametersHandler >::write(), and querying.connection::write_and_commit().

123  {
124  typedef typename Source::value_type value_type;
125  typedef typename Source::Container Container;
126 
127  std::pair<Container const *, std::string const> ret = source(initialize(),
129  Container const & payloads = *ret.first;
130 
131  if(m_LoggingOn) {
132  std::ostringstream s;
133  s << "PopCon v" << s_version << "; " << displayIovHelper(payloads) << ret.second;
134  //s << "PopCon v" << s_version << "; " << cond::userInfo() << displayIovHelper(payloads) << ret.second;
136  }
137  displayHelper(payloads);
138 
139  std::for_each(payloads.begin(),payloads.end(),
140  boost::bind(&popcon::PopCon::writeOne<value_type>,this,
141  boost::bind(&Container::value_type::payload,_1),
142  boost::bind(&Container::value_type::time,_1)
143  )
144  );
145 
146 
147  finalize(payloads.empty() ? Time_t(0): payloads.back().time);
148  }
cond::LogDBEntry_t m_logDBEntry
Definition: PopCon.h:79
void finalize(Time_t lastTill)
Definition: PopCon.cc:78
cond::Time_t Time_t
Definition: PopCon.h:36
std::string m_record
Definition: PopCon.h:69
static const char *const s_version
Definition: PopCon.h:85
payload
payload postfix for testing
void displayHelper(Container const &payloads)
Definition: PopCon.h:96
cond::TagInfo_t m_tagInfo
Definition: PopCon.h:77
void setLogHeaderForRecord(const std::string &recordName, const std::string &provenance, const std::string &usertext)
cond::persistency::Session initialize()
Definition: PopCon.cc:37
const std::string displayIovHelper(Container const &payloads)
Definition: PopCon.h:104
edm::AssociationVector< reco::JetRefBaseProd, Values > Container
static std::string const source
Definition: EdmProvDump.cc:43
edm::Service< cond::service::PoolDBOutputService > m_dbService
Definition: PopCon.h:59
bool m_LoggingOn
Definition: PopCon.h:73
template<typename T >
void popcon::PopCon::writeOne ( T payload,
Time_t  time 
)

Definition at line 90 of file PopCon.h.

References m_dbService, m_LoggingOn, m_record, and cond::service::PoolDBOutputService::writeOne().

90  {
92  }
std::string m_record
Definition: PopCon.h:69
payload
payload postfix for testing
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
edm::Service< cond::service::PoolDBOutputService > m_dbService
Definition: PopCon.h:59
bool m_LoggingOn
Definition: PopCon.h:73

Member Data Documentation

std::string popcon::PopCon::m_authPath
private

Definition at line 65 of file PopCon.h.

Referenced by initialize().

int popcon::PopCon::m_authSys
private

Definition at line 67 of file PopCon.h.

Referenced by initialize().

bool popcon::PopCon::m_close
private

Definition at line 81 of file PopCon.h.

Referenced by finalize().

edm::Service<cond::service::PoolDBOutputService> popcon::PopCon::m_dbService
private

Definition at line 59 of file PopCon.h.

Referenced by finalize(), initialize(), write(), and writeOne().

Time_t popcon::PopCon::m_lastTill
private

Definition at line 83 of file PopCon.h.

Referenced by finalize().

cond::LogDBEntry_t popcon::PopCon::m_logDBEntry
private

Definition at line 79 of file PopCon.h.

Referenced by write().

bool popcon::PopCon::m_LoggingOn
private

Definition at line 73 of file PopCon.h.

Referenced by write(), and writeOne().

std::string popcon::PopCon::m_payload_name
private

Definition at line 71 of file PopCon.h.

Referenced by initialize().

std::string popcon::PopCon::m_record
private

Definition at line 69 of file PopCon.h.

Referenced by finalize(), initialize(), write(), and writeOne().

std::string popcon::PopCon::m_tag
private

Definition at line 75 of file PopCon.h.

Referenced by initialize().

cond::TagInfo_t popcon::PopCon::m_tagInfo
private

Definition at line 77 of file PopCon.h.

Referenced by initialize(), and write().

std::string popcon::PopCon::m_targetConnectionString
private

Definition at line 63 of file PopCon.h.

Referenced by finalize(), initialize(), and ~PopCon().

cond::persistency::Session popcon::PopCon::m_targetSession
private

Definition at line 61 of file PopCon.h.

Referenced by finalize(), initialize(), and ~PopCon().

const char *const popcon::PopCon::s_version = "5.0"
staticprivate

Definition at line 85 of file PopCon.h.

Referenced by PopCon(), and write().