29
29
#include < exception>
30
30
31
31
#include < iomanip>
32
+ #include < limits>
32
33
33
34
#include < nlohmann/json.hpp>
34
35
@@ -123,8 +124,9 @@ namespace {
123
124
CondDBESSource::CondDBESSource (const edm::ParameterSet& iConfig)
124
125
: m_jsonDumpFilename(iConfig.getUntrackedParameter<std::string>(" JsonDumpFileName" , " " )),
125
126
m_connection(),
126
- m_connectionString(" " ),
127
- m_frontierKey(" " ),
127
+ m_connectionString(iConfig.getParameter<std::string>(" connect" )),
128
+ m_globalTag(iConfig.getParameter<std::string>(" globaltag" )),
129
+ m_frontierKey(iConfig.getUntrackedParameter<std::string>(" frontierKey" , " " )),
128
130
m_lastRun(0 ), // for the stat
129
131
m_lastLumi(0 ), // for the stat
130
132
m_policy(NOREFRESH),
@@ -147,69 +149,65 @@ CondDBESSource::CondDBESSource(const edm::ParameterSet& iConfig)
147
149
148
150
/* parameter set parsing
149
151
*/
150
- std::string globaltag (" " );
151
- if (iConfig.exists (" globaltag" )) {
152
- globaltag = iConfig.getParameter <std::string>(" globaltag" );
153
- // the global tag _requires_ a connection string
154
- m_connectionString = iConfig.getParameter <std::string>(" connect" );
155
-
156
- if (!globaltag.empty ()) {
157
- edm::Service<edm::SiteLocalConfig> siteLocalConfig;
158
- if (siteLocalConfig.isAvailable ()) {
159
- if (siteLocalConfig->useLocalConnectString ()) {
160
- std::string const & localConnectPrefix = siteLocalConfig->localConnectPrefix ();
161
- std::string const & localConnectSuffix = siteLocalConfig->localConnectSuffix ();
162
- m_connectionString = localConnectPrefix + globaltag + localConnectSuffix;
163
- }
152
+ if (!m_globalTag.empty ()) {
153
+ edm::Service<edm::SiteLocalConfig> siteLocalConfig;
154
+ if (siteLocalConfig.isAvailable ()) {
155
+ if (siteLocalConfig->useLocalConnectString ()) {
156
+ std::string const & localConnectPrefix = siteLocalConfig->localConnectPrefix ();
157
+ std::string const & localConnectSuffix = siteLocalConfig->localConnectSuffix ();
158
+ m_connectionString = localConnectPrefix + m_globalTag + localConnectSuffix;
164
159
}
165
160
}
166
- } else if (iConfig.exists (" connect" )) // default connection string
167
- m_connectionString = iConfig.getParameter <std::string>(" connect" );
168
-
169
- // frontier key
170
- m_frontierKey = iConfig.getUntrackedParameter <std::string>(" frontierKey" , " " );
161
+ }
171
162
172
163
// snapshot
173
164
boost::posix_time::ptime snapshotTime;
174
- if (iConfig.exists (" snapshotTime" )) {
175
- std::string snapshotTimeString = iConfig.getParameter <std::string>(" snapshotTime" );
176
- if (!snapshotTimeString.empty ())
177
- snapshotTime = boost::posix_time::time_from_string (snapshotTimeString);
165
+ std::string snapshotTimeString = iConfig.getParameter <std::string>(" snapshotTime" );
166
+ if (!snapshotTimeString.empty ()) {
167
+ snapshotTime = boost::posix_time::time_from_string (snapshotTimeString);
178
168
}
179
169
180
170
// connection configuration
181
- if (iConfig.exists (" DBParameters" )) {
182
- edm::ParameterSet connectionPset = iConfig.getParameter <edm::ParameterSet>(" DBParameters" );
183
- m_connection.setParameters (connectionPset);
184
- }
171
+ edm::ParameterSet connectionPset = iConfig.getParameter <edm::ParameterSet>(" DBParameters" );
172
+ m_connection.setParameters (connectionPset);
185
173
m_connection.configure ();
186
174
187
175
// load specific record/tag info - it will overwrite the global tag ( if any )
188
176
std::map<std::string, cond::GTEntry_t> replacements;
189
177
std::map<std::string, boost::posix_time::ptime> specialSnapshots;
190
- if (iConfig.exists (" toGet" )) {
191
- typedef std::vector<edm::ParameterSet> Parameters;
192
- Parameters toGet = iConfig.getParameter <Parameters>(" toGet" );
178
+
179
+ typedef std::vector<edm::ParameterSet> Parameters;
180
+ Parameters toGet = iConfig.getParameter <Parameters>(" toGet" );
181
+ if (!toGet.empty ()) {
193
182
for (Parameters::iterator itToGet = toGet.begin (); itToGet != toGet.end (); ++itToGet) {
194
183
std::string recordname = itToGet->getParameter <std::string>(" record" );
195
184
if (recordname.empty ())
196
185
throw cond::Exception (" ESSource: The record name has not been provided in a \" toGet\" entry." );
186
+
197
187
std::string labelname = itToGet->getUntrackedParameter <std::string>(" label" , " " );
198
188
std::string pfn (" " );
199
- if (m_connectionString.empty () || itToGet->exists (" connect" ))
200
- pfn = itToGet->getParameter <std::string>(" connect" );
201
- std::string tag (" " );
189
+ const auto & recordConnection = itToGet->getParameter <std::string>(" connect" );
190
+ if (m_connectionString.empty () || !recordConnection.empty ()) {
191
+ pfn = recordConnection;
192
+ }
193
+ std::string tag = itToGet->getParameter <std::string>(" tag" );
202
194
std::string fqTag (" " );
203
- if (itToGet-> exists ( " tag " )) {
204
- tag = itToGet-> getParameter <std::string>( " tag" );
195
+
196
+ if (! tag. empty ()) {
205
197
fqTag = cond::persistency::fullyQualifiedTag (tag, pfn);
206
198
}
199
+
207
200
boost::posix_time::ptime tagSnapshotTime =
208
201
boost::posix_time::time_from_string (std::string (cond::time ::MAX_TIMESTAMP));
209
- if (itToGet->exists (" snapshotTime" ))
210
- tagSnapshotTime = boost::posix_time::time_from_string (itToGet->getParameter <std::string>(" snapshotTime" ));
211
- if (itToGet->exists (" refreshTime" )) {
212
- cond::Time_t refreshTime = itToGet->getParameter <unsigned long long >(" refreshTime" );
202
+
203
+ const auto & snapshotTimeTagString = itToGet->getParameter <std::string>(" snapshotTime" );
204
+ if (!snapshotTimeTagString.empty ()) {
205
+ tagSnapshotTime = boost::posix_time::time_from_string (snapshotTimeTagString);
206
+ }
207
+
208
+ const auto & refreshTimeTag = itToGet->getParameter <unsigned long long >(" refreshTime" );
209
+ if (refreshTimeTag != std::numeric_limits<unsigned long long >::max ()) {
210
+ cond::Time_t refreshTime = refreshTimeTag;
213
211
m_refreshTimeForRecord.insert (std::make_pair (recordname, std::make_pair (refreshTime, true )));
214
212
}
215
213
@@ -225,10 +223,10 @@ CondDBESSource::CondDBESSource(const edm::ParameterSet& iConfig)
225
223
std::vector<std::string> connectList;
226
224
std::vector<std::string> pfnPrefixList;
227
225
std::vector<std::string> pfnPostfixList;
228
- if (!globaltag .empty ()) {
226
+ if (!m_globalTag .empty ()) {
229
227
std::string pfnPrefix (iConfig.getUntrackedParameter <std::string>(" pfnPrefix" , " " ));
230
228
std::string pfnPostfix (iConfig.getUntrackedParameter <std::string>(" pfnPostfix" , " " ));
231
- boost::split (globaltagList, globaltag , boost::is_any_of (" |" ), boost::token_compress_off);
229
+ boost::split (globaltagList, m_globalTag , boost::is_any_of (" |" ), boost::token_compress_off);
232
230
fillList (m_connectionString, connectList, globaltagList.size (), " connection" );
233
231
fillList (pfnPrefix, pfnPrefixList, globaltagList.size (), " pfnPrefix" );
234
232
fillList (pfnPostfix, pfnPostfixList, globaltagList.size (), " pfnPostfix" );
@@ -741,6 +739,45 @@ void CondDBESSource::fillTagCollectionFromDB(const std::vector<std::string>& con
741
739
}
742
740
}
743
741
742
+ void CondDBESSource::fillDescriptions (edm::ConfigurationDescriptions& descriptions) {
743
+ edm::ParameterSetDescription desc;
744
+
745
+ edm::ParameterSetDescription dbParams;
746
+ dbParams.addUntracked <std::string>(" authenticationPath" , " " );
747
+ dbParams.addUntracked <int >(" authenticationSystem" , 0 );
748
+ dbParams.addUntracked <std::string>(" security" , " " );
749
+ dbParams.addUntracked <int >(" messageLevel" , 0 );
750
+ dbParams.addUntracked <int >(" connectionTimeout" , 0 );
751
+ desc.add (" DBParameters" , dbParams);
752
+
753
+ desc.add <std::string>(" connect" , std::string (" frontier://FrontierProd/CMS_CONDITIONS" ));
754
+ desc.add <std::string>(" globaltag" , " " );
755
+ desc.add <std::string>(" snapshotTime" , " " );
756
+ desc.addUntracked <std::string>(" frontierKey" , " " );
757
+
758
+ edm::ParameterSetDescription toGetDesc;
759
+ toGetDesc.add <std::string>(" record" , " " );
760
+ toGetDesc.add <std::string>(" tag" , " " );
761
+ toGetDesc.add <std::string>(" snapshotTime" , " " );
762
+ toGetDesc.add <std::string>(" connect" , " " );
763
+ toGetDesc.add <unsigned long long >(" refreshTime" , std::numeric_limits<unsigned long long >::max ());
764
+ toGetDesc.addUntracked <std::string>(" label" , " " );
765
+
766
+ std::vector<edm::ParameterSet> default_toGet (1 );
767
+ desc.addVPSet (" toGet" , toGetDesc, default_toGet);
768
+
769
+ desc.addUntracked <std::string>(" JsonDumpFileName" , " " );
770
+ desc.addUntracked <bool >(" DumpStat" , false );
771
+ desc.addUntracked <bool >(" ReconnectEachRun" , false );
772
+ desc.addUntracked <bool >(" RefreshAlways" , false );
773
+ desc.addUntracked <bool >(" RefreshEachRun" , false );
774
+ desc.addUntracked <bool >(" RefreshOpenIOVs" , false );
775
+ desc.addUntracked <std::string>(" pfnPostfix" , " " );
776
+ desc.addUntracked <std::string>(" pfnPrefix" , " " );
777
+
778
+ descriptions.add (" default_CondDBESource" , desc);
779
+ }
780
+
744
781
// backward compatibility for configuration files
745
782
class PoolDBESSource : public CondDBESSource {
746
783
public:
0 commit comments