5#include "CoolKernel/IFolderSpecification.h"
7#include "CoolKernel/IObject.h"
8#include "CoolKernel/IObjectIterator.h"
9#include "CoolKernel/IRecord.h"
10#include "CoolKernel/IRecordIterator.h"
11#include "CoralBase/AttributeList.h"
12#include "CoralBase/AttributeListSpecification.h"
13#include "CoralBase/Attribute.h"
14#include "CoralBase/AttributeSpecification.h"
15#include "CoralBase/Blob.h"
16#include "TStopwatch.h"
34#include <nlohmann/json.hpp>
35using json = nlohmann::json;
38 spec2String(
const cool::IFolderPtr & pFolder){
40 const std::string ob=
"";
41 const std::string objName=
"\"folder_payloadspec\": \"";
42 std::string
result=ob+objName;
43 const auto & rspec = pFolder->payloadSpecification();
45 json chJson = json::array();
46 for (
unsigned int i(0);
i<rspec.size();++
i){
47 const auto &
f = rspec[
i];
49 obj[
f.name()] =
f.storageType().name();
50 chJson.push_back(obj);
60 const cool::ValidityKey & since,
61 const cool::ValidityKey & until,
62 const cool::ChannelSelection & chansel,
63 const std::string& folderTag):
70 m_spec(spec2String(pFolder)),
72 const auto & channums=pFolder->listChannels();
75 for (
const auto &i:channums){
83 saneXml = std::regex_replace(saneXml, std::regex(
"\\\\\""),
"\"");
84 std::string out =
"\"node_description\" : \"";
98 std::string
result(
"\"data_array\" : [");
102 while (itr->goToNext()){
103 const cool::IObject&
ref=itr->currentRef();
105 const long long cId=
ref.channelId();
129 if (sep.empty()) sep=
",";
146 if (
m_desc.find(
"<timeStamp>run-lumi</timeStamp>") != std::string::npos)
result =
"run-lumi";
147 if (
m_desc.find(
"<timeStamp>run-event</timeStamp>") != std::string::npos)
result =
"run-lumi";
148 if (
m_desc.find(
"<timeStamp>time</timeStamp>") != std::string::npos)
result =
"time";
160 const cool::IObject&
ref=itr->currentRef();
161 cool::IRecordIterator& pitr=
ref.payloadIterator();
162 auto pvec=pitr.fetchAllAsVector();
165 for (
const auto & vitr:*
pvec){
167 const coral::AttributeList& atrlist=(vitr)->attributeList();
177 const cool::IObject&
ref=itr->currentRef();
178 const coral::AttributeList& atrlist=
ref.payload().attributeList();
185 const cool::IObject&
ref=itr->currentRef();
186 const coral::AttributeList& atrlist=
ref.payload().attributeList();
187 std::ostringstream os;
188 atrlist[0].toOutputStream(os);
190 const std::string sep(
" : ");
191 const auto separatorPosition =
res.find(sep);
192 const std::string payloadOnly=
res.substr(separatorPosition+3);
193 return quote(payloadOnly);
198 std::string iovString(
"\"iov\" : ");
199 return iovString+
"["+std::to_string(
m_start)+
", "+std::to_string(
m_stop)+
"]";
203 o << c.description() << std::endl;
const boost::regex ref(r_ef)
This file contains the class definition for the AthenaAttrListAddress class.
This file contains the class definition for the CondAttrListCollAddress class.
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
This file contains the class definition for the CondAttrListVecAddress class.
A CondAttrListVec is an Athena DataObject holding a vector of CORAL AttributeLists,...
std::pair< std::vector< unsigned int >, bool > res
unsigned int nchans() const
Number of channels in the folder.
const std::string & tag() const
Simply the tag string passed to the constructor.
std::string iov() const
Formatted iov as '[<since>, <until>]'.
const cool::ChannelSelection m_chansel
Cool2Json(const cool::IFolderPtr &pFolder, const cool::ValidityKey &since, const cool::ValidityKey &until, const cool::ChannelSelection &m_chansel, const std::string &folderTag)
static std::string formatPoolRef(const cool::IObjectIteratorPtr &itr)
std::string description() const
Folder description string.
const std::string & payloadSpec() const
Payload specification for this folder.
static std::string formatAttrList(const cool::IObjectIteratorPtr &itr)
static std::string formatCvp(const cool::IObjectIteratorPtr &itr)
const cool::ValidityKey m_stop
const cool::IFolderPtr m_pFolder
std::string iovBase() const
'time' (ns of epoch) or 'run-lumi'
std::string payload()
Payload (data for the given channel selection and iov)
const cool::ValidityKey m_start
FolderType determineFolderType(const std::string &folderDescription, const std::string &spec, const std::vector< cool::ChannelId > &chans)
Determine folder type with optional check using clid service to check clid matches typename.
std::string quote(const std::string &sentence)
Enclose a string in ".
std::string jsonAttributeList(const coral::AttributeList &atrlist)
Produce a representation of a coral::AttributeList as a json string.
std::ostream & operator<<(std::ostream &o, const Cool2Json &c)
static const std::string s_delimiterJson
json standard delimiter ', '
std::string sanitiseXml(const std::string &pseudoXmlString)
for use when converting cool folder description JSON
static const std::string s_closeJson
json close tag, '}'
static const std::string s_openJson
json open tag, '{'