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