7#include "CoolKernel/DatabaseId.h"
8#include "CoolKernel/Exception.h"
9#include "CoolKernel/IDatabaseSvc.h"
10#include "CoolKernel/IDatabase.h"
11#include "CoolApplication/Application.h"
12#include "CoolKernel/IFolder.h"
13#include "CoolKernel/FolderSpecification.h"
14#include "CoolKernel/RecordSpecification.h"
15#include "CoolKernel/Record.h"
16#include "CoolKernel/FieldSpecification.h"
17#include "CoolKernel/IObject.h"
18#include "CoolKernel/IObjectIterator.h"
19#include "CoolKernel/IRecordIterator.h"
20#include "CoolKernel/StorageType.h"
21#include "CoolKernel/ChannelSelection.h"
23#include "RelationalAccess/ConnectionService.h"
32#include <unordered_map>
34#ifdef ATLAS_GCC_CHECKERS
47 cool::IDatabasePtr
dbPtr()
const;
62 const std::string dbConnectionString{sourceDb};
67 catch (std::exception &e)
69 std::cout <<
"Cool exception caught: " << e.what() << std::endl;
74 std::cout <<
"creating " << dbConnectionString << std::endl;
77 catch (std::exception &e)
79 std::cout <<
"Cool exception caught: " << e.what() << std::endl;
112 FolderSpec(
const std::string &thename,
const std::string &thetag) :
name(thename),
tag(thetag){};
127 const std::string&
tag()
const;
128 const cool::IFolderPtr &
ptr()
const;
130 std::vector<cool::ChannelId>
channels()
const;
131 std::vector<std::string>
tags()
const;
146 catch (cool::Exception &e)
148 std::cout <<
" Could not get folder " << theFolder.name << std::endl;
158const cool::IFolderPtr &
173 return (cool::FolderVersioning::SINGLE_VERSION ==
m_folderPtr->versioningMode());
182cool::RecordSpecification
194cool::IObjectIteratorPtr
198 const auto hi = cool::ValidityKeyMax;
199 const auto lo = uselastIOV ? (hi-1) : cool::ValidityKeyMin;
200 const auto channelSelection = cool::ChannelSelection::all();
204std::vector<cool::ChannelId>
210std::vector<std::string>
217timeRep(
const cool::ValidityKey &t,
bool isEnd =
false,
bool runLumi =
true)
220 const std::string trail = isEnd ? (
")") : (
"]");
223 if (t == cool::ValidityKeyMin)
225 result =
"ValidityKeyMin";
227 else if (t == cool::ValidityKeyMax)
229 result =
"ValidityKeyMax";
233 long int seconds =
static_cast<long int>(t / 1000000000);
234 std::string timeStr{std::asctime(std::gmtime(&seconds))};
235 result = timeStr +
" UTC";
241 auto lumiblock = t & 0xFFFFFFFF;
242 result =
"[" + std::to_string(
run) +
"," + std::to_string(lumiblock) + trail;
250 std::string sinceStr =
timeRep(obj.since(),
false, runLumi);
251 std::string untilStr =
timeRep(obj.until(),
true, runLumi);
252 return sinceStr +
" - " + untilStr;
259 const cool::IRecord &record = obj.payload();
260 const auto &thisSpec = record.specification();
261 for (cool::UInt32 i = 0; i != thisSpec.size(); ++i)
263 const std::string delimiter = (i == 0) ? (
"") : (
",");
264 std::string typeName = thisSpec[i].storageType().name();
265 result +=
"[\'" + thisSpec[i].name() +
" (" + typeName +
")\' : ";
266 std::ostringstream os;
267 record[i].printValue(os);
274int main(
int argc,
char *argv[])
277 std::string tagName{
"PixelChargeCalibration-DATA-RUN2-UPD4-28"};
278 std::string folderName{
"/PIXEL/ChargeCalibration"};
280 std::string dbName{
"COOLOFL_PIXEL/CONDBR2"};
281 std::string useIOV{
"latest"};
282 bool useLastIOV{
true};
284 for(
int i=1; i<argc; i++){
285 std::string
aux(argv[i]);
286 std::string variable(
aux.substr(0,
aux.find(
"=")));
287 std::string value(
aux.substr(
aux.find(
"=")+1));
288 if (variable.compare(
"tagName") == 0) {
289 tagName = std::move(value);
291 else if(variable.compare(
"folder") == 0) folderName = std::move(value);
292 else if(variable.compare(
"outputFile") == 0)
outputFileName = std::move(value);
293 else if(variable.compare(
"dbName") == 0) dbName = std::move(value);
294 else if(variable.compare(
"IOV") == 0){
298 useIOV = std::move(value);
302 std::cout<<
"ERROR - Option not found:"<<
aux <<
"\n";
312 else if (useIOV.compare(
"all") == 0){
320 printf(
"%-11s: %s\n",
"Tag Name" ,tagName.c_str());
321 printf(
"%-11s: %s\n",
"Folder Name",folderName.c_str()) ;
322 printf(
"%-11s: %s\n",
"DB Name" ,dbName.c_str()) ;
324 printf(
"%-11s: %s\n",
"Last IOV" ,useLastIOV ?
"True" :
"False");
325 printf(
"%-11s: %s\n",
"IOV used" ,useIOV.c_str()) ;
332 cool::IObjectIteratorPtr objectsIterator = f.objectIterator(useLastIOV);
333 std::vector< iovNamePair > myIOVs;
334 while (objectsIterator->goToNext())
336 const cool::IObject &thisObject = objectsIterator->currentRef();
337 std::size_t posPar =
iovToString(thisObject).find(
"]");
338 std::size_t posCom =
iovToString(thisObject).find(
",");
339 std::string name =
iovToString(thisObject).substr(1,posPar-1).replace(posCom-1,1,
"_");
340 std::string display =
iovToString(thisObject) +
" (" + std::to_string(thisObject.channelId()) +
")\n";
342 myIOVs.push_back(std::make_pair(name,display));
348 for(
const auto & [IOVname,iov]:myIOVs){
349 if(IOVname.compare(useIOV)!=0 && useIOV.compare(
"all") != 0){
353 std::cout<<IOVname<<
"\n";
354 const std::string filename= IOVname +
"_"+tagName+
".log";
355 std::ofstream opFile(filename);
360 std::cout<<
"IOV not found - Choose between one of the following:\n";
361 for(
const auto & [IOVname,iov]:myIOVs){
362 std::cout<<IOVname<<
" ";
369 const std::string fileName = tagName +
".log";
370 std::ofstream opFile(fileName);
371 printf(
"%-11s: %s\n",
"RunNumber" ,(myIOVs.back().first).c_str()) ;
372 opFile << myIOVs.back().second <<
"\n";
std::string iovToString(const cool::IObject &obj, bool runLumi=true)
std::string timeRep(const cool::ValidityKey &t, bool isEnd=false, bool runLumi=true)
std::string payloadToString(const cool::IObject &obj)
std::pair< std::string, std::string > iovNamePair
static const std::string outputFileName
Define macros for attributes used to control the static checker.
#define ATLAS_NO_CHECK_FILE_THREAD_SAFETY
DbConnection(const std::string &sourceDb)
const cool::IDatabaseSvc & m_dbSvc
cool::IDatabasePtr m_sourceDbPtr
cool::Application m_coolapp
coral::ConnectionService m_coralsvc
cool::IDatabasePtr dbPtr() const
Folder(const DbConnection &theConnection, const FolderSpec &theFolder)
const DbConnection & m_connection
const cool::IFolderPtr & ptr() const
const FolderSpec & folderSpec() const
cool::RecordSpecification foreignKeySpec()
cool::IObjectIteratorPtr objectIterator(bool) const
const FolderSpec m_folderSpec
std::vector< std::string > tags() const
bool isSingleVersion() const
cool::RecordSpecification payloadSpec() const
specification of the payload entries
cool::IFolderPtr m_folderPtr
std::vector< cool::ChannelId > channels() const
const std::string & tag() const
std::string description() const
FolderSpec(const std::string &thename, const std::string &thetag)