CMS 3D CMS Logo

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 
11 
13 
15 
17 
18 #include <boost/bind.hpp>
19 #include <algorithm>
20 #include <vector>
21 #include <string>
22 
23 #include <iostream>
24 
25 namespace popcon {
26 
27  /* Populator of the Condition DB
28  *
29  */
30  class PopCon {
31  public:
33  //typedef cond::Summary Summary;
34 
36 
37  virtual ~PopCon();
38 
39  template <typename Source>
40  void write(Source const& source);
41 
42  template <typename T>
43  void writeOne(T* payload, Time_t time);
44 
45  private:
47  void finalize(Time_t lastTill);
48 
49  private:
51 
53 
55 
57 
58  int m_authSys;
59 
61 
63 
65 
67 
69 
71 
72  bool m_close;
73 
75 
76  static constexpr const char* const s_version = "5.0";
77  };
78 
79  template <typename T>
82  }
83 
84  template <typename Container>
86  typename Container::const_iterator it;
87  for (it = payloads.begin(); it != payloads.end(); it++)
88  edm::LogInfo("PopCon") << "Since " << (*it).time << std::endl;
89  }
90 
91  template <typename Container>
93  if (payloads.empty())
94  return std::string("Nothing to transfer;");
95  std::ostringstream s;
96  // when only 1 payload is transferred;
97  if (payloads.size() == 1)
98  s << "Since " << (*payloads.begin()).time << "; ";
99  else {
100  // when more than one payload are transferred;
101  s << "first payload Since " << (*payloads.begin()).time << ", "
102  << "last payload Since " << (*payloads.rbegin()).time << "; ";
103  }
104  return s.str();
105  }
106 
107  template <typename Source>
108  void PopCon::write(Source const& source) {
109  typedef typename Source::value_type value_type;
110  typedef typename Source::Container Container;
111 
112  std::pair<Container const*, std::string const> ret = source(initialize(), m_tagInfo, m_logDBEntry);
113  Container const& payloads = *ret.first;
114 
115  if (m_LoggingOn) {
116  std::ostringstream s;
117  s << "PopCon v" << s_version << "; " << displayIovHelper(payloads) << ret.second;
118  //s << "PopCon v" << s_version << "; " << cond::userInfo() << displayIovHelper(payloads) << ret.second;
120  }
122 
123  std::for_each(payloads.begin(),
124  payloads.end(),
125  boost::bind(&popcon::PopCon::writeOne<value_type>,
126  this,
127  boost::bind(&Container::value_type::payload, _1),
128  boost::bind(&Container::value_type::time, _1)));
129 
130  finalize(payloads.empty() ? Time_t(0) : payloads.back().time);
131  }
132 
133 } // namespace popcon
134 
135 #endif // POPCON_POPCON_H
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:355
popcon::PopCon::PopCon
PopCon(const edm::ParameterSet &pset)
Definition: PopCon.cc:12
popcon::PopCon::m_tag
std::string m_tag
Definition: PopCon.h:66
MessageLogger.h
popcon::PopCon::s_version
static constexpr const char *const s_version
Definition: PopCon.h:76
popcon::PopCon::m_authPath
std::string m_authPath
Definition: PopCon.h:56
popcon::displayIovHelper
const std::string displayIovHelper(Container const &payloads)
Definition: PopCon.h:92
edm::LogInfo
Definition: MessageLogger.h:254
popcon::PopCon::m_LoggingOn
bool m_LoggingOn
Definition: PopCon.h:64
popcon::PopCon::m_targetConnectionString
std::string m_targetConnectionString
Definition: PopCon.h:54
popcon::PopCon::m_logDBEntry
cond::LogDBEntry_t m_logDBEntry
Definition: PopCon.h:70
reco::JetExtendedAssociation::Container
edm::AssociationVector< reco::JetRefBaseProd, Values > Container
Definition: JetExtendedAssociation.h:29
popcon::PopCon::m_close
bool m_close
Definition: PopCon.h:72
alignCSCRings.s
s
Definition: alignCSCRings.py:92
PoolDBOutputService.h
popcon::PopCon::m_targetSession
cond::persistency::Session m_targetSession
Definition: PopCon.h:52
Service.h
popcon::PopCon::m_authSys
int m_authSys
Definition: PopCon.h:58
tauJetCorrections_cff.payloads
payloads
Definition: tauJetCorrections_cff.py:4
source
static const std::string source
Definition: EdmProvDump.cc:47
popcon::PopCon::~PopCon
virtual ~PopCon()
Definition: PopCon.cc:29
jets_cff.payload
payload
Definition: jets_cff.py:34
popcon::PopCon::m_payload_name
std::string m_payload_name
Definition: PopCon.h:62
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
Time.h
edm::ParameterSet
Definition: ParameterSet.h:36
popcon::PopCon::write
void write(Source const &source)
Definition: PopCon.h:108
cond::persistency::Session
Definition: Session.h:63
cond::Time_t
unsigned long long Time_t
Definition: Time.h:14
popcon::PopCon::m_lastTill
Time_t m_lastTill
Definition: PopCon.h:74
edm::Service< cond::service::PoolDBOutputService >
popcon::PopCon::finalize
void finalize(Time_t lastTill)
Definition: PopCon.cc:73
reco::JetExtendedAssociation::value_type
Container::value_type value_type
Definition: JetExtendedAssociation.h:30
popcon::PopCon::m_record
std::string m_record
Definition: PopCon.h:60
popcon::PopCon::writeOne
void writeOne(T *payload, Time_t time)
Definition: PopCon.h:80
cond::service::PoolDBOutputService::setLogHeaderForRecord
void setLogHeaderForRecord(const std::string &recordName, const std::string &provenance, const std::string &usertext)
Definition: PoolDBOutputService.cc:329
popcon
Definition: Exception.h:6
popcon::PopCon::m_dbService
edm::Service< cond::service::PoolDBOutputService > m_dbService
Definition: PopCon.h:50
T
long double T
Definition: Basic3DVectorLD.h:48
cond::service::PoolDBOutputService::writeOne
Hash writeOne(const T *payload, Time_t time, const std::string &recordName)
Definition: PoolDBOutputService.h:56
popcon::PopCon::Time_t
cond::Time_t Time_t
Definition: PopCon.h:32
ParameterSetfwd.h
popcon::PopCon::initialize
cond::persistency::Session initialize()
Definition: PopCon.cc:35
popcon::displayHelper
void displayHelper(Container const &payloads)
Definition: PopCon.h:85
cond::LogDBEntry_t
Definition: Types.h:86
popcon::PopCon::m_tagInfo
cond::TagInfo_t m_tagInfo
Definition: PopCon.h:68
popcon::PopCon
Definition: PopCon.h:30
cond::TagInfo_t
Definition: Types.h:69
ntuplemaker.time
time
Definition: ntuplemaker.py:310
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
CollectionTags_cfi.Source
Source
Definition: CollectionTags_cfi.py:11