CMS 3D CMS Logo

PopCon.h
Go to the documentation of this file.
1 #ifndef POPCON_POPCON_H
2 #define POPCON_POPCON_H
3 //
4 // Author: Vincenzo Innocente
5 // Original Author: Marcin BOGUSZ
6 //
7 
10 
12 
14 
16 
17 #include <algorithm>
18 #include <functional>
19 #include <string>
20 #include <vector>
21 
22 #include <iostream>
23 
24 namespace popcon {
25 
26  /* Populator of the Condition DB
27  *
28  */
29  class PopCon {
30  public:
32 
34 
35  virtual ~PopCon();
36 
37  template <typename Source>
38  void write(Source const& source);
39 
40  private:
42  void finalize(Time_t lastTill);
43 
44  private:
46 
48 
50 
52 
53  int m_authSys;
54 
56 
58 
60 
62 
64 
66 
67  bool m_close;
68 
70 
71  static constexpr const char* const s_version = "5.0";
72  };
73 
74  template <typename Source>
75  void PopCon::write(Source const& source) {
76  typedef typename Source::value_type value_type;
77  typedef typename Source::Container Container;
78 
79  std::pair<Container const*, std::string const> ret = source(initialize(), m_tagInfo, m_logDBEntry);
80  Container const& iovs = *ret.first;
81 
82  if (m_LoggingOn) {
83  std::string msg("Nothing to transfer;");
84  size_t niovs = iovs.size();
85  if (niovs) {
86  std::ostringstream s;
87  if (niovs == 1) {
88  s << "Since " << (*iovs.begin()).first << "; ";
89  } else {
90  s << "first payload Since " << (*iovs.begin()).first << ", "
91  << "last payload Since " << (*iovs.rbegin()).first << "; ";
92  }
93  msg = s.str();
94  }
95  std::ostringstream s;
96  s << "PopCon v" << s_version << "; " << msg << ret.second;
98  }
99  for (auto it : iovs)
100  edm::LogInfo("PopCon") << "Since " << it.first << std::endl;
101 
103 
104  finalize(iovs.empty() ? Time_t(0) : iovs.rbegin()->first);
105  }
106 
107 } // namespace popcon
108 
109 #endif // POPCON_POPCON_H
cond::LogDBEntry_t m_logDBEntry
Definition: PopCon.h:65
void finalize(Time_t lastTill)
Definition: PopCon.cc:73
Time_t m_lastTill
Definition: PopCon.h:69
ret
prodAgent to be discontinued
bool m_close
Definition: PopCon.h:67
cond::Time_t Time_t
Definition: PopCon.h:31
std::string m_tag
Definition: PopCon.h:61
std::string m_record
Definition: PopCon.h:55
void write(Source const &source)
Definition: PopCon.h:75
cond::persistency::Session m_targetSession
Definition: PopCon.h:47
unsigned long long Time_t
Definition: Time.h:14
std::string m_targetConnectionString
Definition: PopCon.h:49
cond::TagInfo_t m_tagInfo
Definition: PopCon.h:63
PopCon(const edm::ParameterSet &pset)
Definition: PopCon.cc:12
void setLogHeaderForRecord(const std::string &recordName, const std::string &provenance, const std::string &usertext)
Log< level::Info, false > LogInfo
static constexpr const char *const s_version
Definition: PopCon.h:71
int m_authSys
Definition: PopCon.h:53
cond::persistency::Session initialize()
Definition: PopCon.cc:35
tuple msg
Definition: mps_check.py:286
std::string m_authPath
Definition: PopCon.h:51
void writeMany(const std::map< Time_t, std::shared_ptr< T > > &iovAndPayloads, const std::string &recordName)
virtual ~PopCon()
Definition: PopCon.cc:29
edm::AssociationVector< reco::JetRefBaseProd, Values > Container
std::string m_payload_name
Definition: PopCon.h:57
static std::string const source
Definition: EdmProvDump.cc:49
edm::Service< cond::service::PoolDBOutputService > m_dbService
Definition: PopCon.h:45
bool m_LoggingOn
Definition: PopCon.h:59