test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PopCon.h
Go to the documentation of this file.
1 
2 #ifndef POPCON_POPCON_H
3 #define POPCON_POPCON_H
4 //
5 // Author: Vincenzo Innocente
6 // Original Author: Marcin BOGUSZ
7 //
8 
9 
12 
14 
16 
18 
19 #include <boost/bind.hpp>
20 #include <algorithm>
21 #include <vector>
22 #include <string>
23 
24 
25 #include<iostream>
26 
27 
28 namespace popcon {
29 
30 
31  /* Populator of the Condition DB
32  *
33  */
34  class PopCon {
35  public:
37  //typedef cond::Summary Summary;
38 
40 
41  virtual ~PopCon();
42 
43  template<typename Source>
44  void write(Source const & source);
45 
46  template<typename T>
47  void writeOne(T * payload, Time_t time);
48 
49 
50 
51 
52  private:
54  void finalize(Time_t lastTill);
55 
56 
57  private:
58 
60 
62 
64 
66 
67  int m_authSys;
68 
70 
72 
74 
76 
78 
80 
81  bool m_close;
82 
84 
85  static constexpr const char* const s_version = "5.0";
86  };
87 
88 
89  template<typename T>
90  void PopCon::writeOne(T * payload, Time_t time) {
91  m_dbService->writeOne(payload, time, m_record, m_LoggingOn);
92  }
93 
94 
95  template<typename Container>
97  typename Container::const_iterator it;
98  for (it = payloads.begin(); it != payloads.end(); it++)
99  edm::LogInfo ("PopCon")<< "Since " << (*it).time << std::endl;
100  }
101 
102 
103  template<typename Container>
105  if (payloads.empty()) return std::string("Nothing to transfer;");
106  std::ostringstream s;
107  // when only 1 payload is transferred;
108  if ( payloads.size()==1)
109  s << "Since " << (*payloads.begin()).time << "; " ;
110  else{
111  // when more than one payload are transferred;
112  s << "first payload Since " << (*payloads.begin()).time << ", "
113  << "last payload Since " << (*payloads.rbegin()).time << "; " ;
114  }
115  return s.str();
116  }
117 
118 
119 
120 
121 
122  template<typename Source>
123  void PopCon::write(Source const & source) {
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;
135  m_dbService->setLogHeaderForRecord(m_record,source.id(),s.str());
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  }
149 
150 }
151 
152 #endif // POPCON_POPCON_H
153 
154 
tuple ret
prodAgent to be discontinued
cond::LogDBEntry_t m_logDBEntry
Definition: PopCon.h:79
void finalize(Time_t lastTill)
Definition: PopCon.cc:76
Time_t m_lastTill
Definition: PopCon.h:83
bool m_close
Definition: PopCon.h:81
cond::Time_t Time_t
Definition: PopCon.h:36
std::string m_tag
Definition: PopCon.h:75
std::string m_record
Definition: PopCon.h:69
void write(Source const &source)
Definition: PopCon.h:123
#define constexpr
cond::persistency::Session m_targetSession
Definition: PopCon.h:61
unsigned long long Time_t
Definition: Time.h:16
void writeOne(T *payload, Time_t time)
Definition: PopCon.h:90
void displayHelper(Container const &payloads)
Definition: PopCon.h:96
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
std::string m_targetConnectionString
Definition: PopCon.h:63
cond::TagInfo_t m_tagInfo
Definition: PopCon.h:77
PopCon(const edm::ParameterSet &pset)
Definition: PopCon.cc:10
void setLogHeaderForRecord(const std::string &recordName, const std::string &provenance, const std::string &usertext)
int m_authSys
Definition: PopCon.h:67
cond::persistency::Session initialize()
Definition: PopCon.cc:35
std::string m_authPath
Definition: PopCon.h:65
virtual ~PopCon()
Definition: PopCon.cc:28
const std::string displayIovHelper(Container const &payloads)
Definition: PopCon.h:104
static const char *const s_version
Definition: PopCon.h:85
long double T
edm::AssociationVector< reco::JetRefBaseProd, Values > Container
std::string m_payload_name
Definition: PopCon.h:71
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