ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Private Types | Static Private Member Functions | Private Attributes | Friends | List of all members
IOVDbNamespace::Cool2Json Class Reference

#include <Cool2Json.h>

Collaboration diagram for IOVDbNamespace::Cool2Json:

Public Member Functions

 Cool2Json (const cool::IFolderPtr &pFolder, const cool::ValidityKey &since, const cool::ValidityKey &until, const cool::ChannelSelection &m_chansel, const std::string &folderTag)
 
std::string description () const
 Folder description string. More...
 
const std::string & payloadSpec () const
 Payload specification for this folder. More...
 
std::string payload ()
 Payload (data for the given channel selection and iov) More...
 
std::string iov () const
 Formatted iov as '[<since>, <until>]'. More...
 
unsigned int nchans () const
 Number of channels in the folder. More...
 
std::string iovBase () const
 'time' (ns of epoch) or 'run-lumi' More...
 
const std::string & tag () const
 Simply the tag string passed to the constructor. More...
 

Static Public Member Functions

static std::string open ()
 json open tag, '{' More...
 
static std::string close ()
 json close tag, '}' More...
 
static std::string delimiter ()
 json standard delimiter ', ' More...
 

Private Types

enum  FolderType {
  AttrList =0, AttrListColl, PoolRef, PoolRefColl,
  CoraCool, CoolVector, JSON, NUM_FOLDER_TYPES
}
 

Static Private Member Functions

static std::string formatCvp (const cool::IObjectIteratorPtr &itr)
 
static std::string formatAttrList (const cool::IObjectIteratorPtr &itr)
 
static std::string formatPoolRef (const cool::IObjectIteratorPtr &itr)
 

Private Attributes

const cool::IFolderPtr m_pFolder
 
const cool::ValidityKey m_start
 
const cool::ValidityKey m_stop
 
const cool::ChannelSelection m_chansel
 
const std::string m_tag
 
const std::string m_desc
 
const std::string m_spec
 
unsigned int m_nchans
 

Friends

std::ostream & operator<< (std::ostream &o, const Cool2Json &c)
 

Detailed Description

Definition at line 26 of file Cool2Json.h.

Member Enumeration Documentation

◆ FolderType

Enumerator
AttrList 
AttrListColl 
PoolRef 
PoolRefColl 
CoraCool 
CoolVector 
JSON 
NUM_FOLDER_TYPES 

Definition at line 70 of file Cool2Json.h.

70  {
71  AttrList=0,
73  PoolRef,
75  CoraCool,
76  CoolVector,
77  JSON,
79  };

Constructor & Destructor Documentation

◆ Cool2Json()

IOVDbNamespace::Cool2Json::Cool2Json ( const cool::IFolderPtr &  pFolder,
const cool::ValidityKey &  since,
const cool::ValidityKey &  until,
const cool::ChannelSelection &  m_chansel,
const std::string &  folderTag 
)

Definition at line 59 of file Cool2Json.cxx.

63  :
64  m_pFolder(pFolder),
65  m_start(since),
66  m_stop(until),
67  m_chansel(chansel),
68  m_tag(folderTag),
69  m_desc(pFolder->description()),
70  m_spec(spec2String(pFolder)),
71  m_nchans(0){
72  const auto & channums=pFolder->listChannels();
73  //find channels in the chansel which are chan nums
74  //theres no 'size' method in the ChannelSelection class
75  for (const auto &i:channums){
76  m_nchans+=m_chansel.inSelection(i);//bool casts to 0 or 1
77  }
78  }

Member Function Documentation

◆ close()

static std::string IOVDbNamespace::Cool2Json::close ( )
static

json close tag, '}'

◆ delimiter()

static std::string IOVDbNamespace::Cool2Json::delimiter ( )
static

json standard delimiter ', '

◆ description()

std::string IOVDbNamespace::Cool2Json::description ( ) const

Folder description string.

Definition at line 81 of file Cool2Json.cxx.

81  {
82  std::string saneXml=sanitiseXml(m_desc);
83  std::string out = "\"node_description\" : \"";
84  out += saneXml;
85  out += '\"';
86  return out;
87  }

◆ formatAttrList()

std::string IOVDbNamespace::Cool2Json::formatAttrList ( const cool::IObjectIteratorPtr &  itr)
staticprivate

Definition at line 175 of file Cool2Json.cxx.

175  {
176  const cool::IObject& ref=itr->currentRef();
177  const coral::AttributeList& atrlist=ref.payload().attributeList();
178  std::string sep="";
179  return IOVDbNamespace::jsonAttributeList(atrlist);
180  }

◆ formatCvp()

std::string IOVDbNamespace::Cool2Json::formatCvp ( const cool::IObjectIteratorPtr &  itr)
staticprivate

Definition at line 157 of file Cool2Json.cxx.

157  {
158  std::string os;
159  const cool::IObject& ref=itr->currentRef();
160  cool::IRecordIterator& pitr=ref.payloadIterator();
161  auto pvec=pitr.fetchAllAsVector();
162  std::string sep="";
163  os+='[';//vector of vectors
164  for (const auto & vitr:*pvec){
165  os+=sep;
166  const coral::AttributeList& atrlist=(vitr)->attributeList();
168  if (sep.empty()) sep =IOVDbNamespace::s_delimiterJson;
169  }
170  os+=']';
171  return os;
172  }

◆ formatPoolRef()

std::string IOVDbNamespace::Cool2Json::formatPoolRef ( const cool::IObjectIteratorPtr &  itr)
staticprivate

Definition at line 183 of file Cool2Json.cxx.

183  {
184  const cool::IObject& ref=itr->currentRef();
185  const coral::AttributeList& atrlist=ref.payload().attributeList();
186  std::ostringstream os;
187  atrlist[0].toOutputStream(os);
188  auto res=os.str();
189  const std::string sep(" : ");
190  const auto separatorPosition = res.find(sep);
191  const std::string payloadOnly=res.substr(separatorPosition+3);
192  return quote(payloadOnly);
193  }

◆ iov()

std::string IOVDbNamespace::Cool2Json::iov ( ) const

Formatted iov as '[<since>, <until>]'.

Definition at line 196 of file Cool2Json.cxx.

196  {
197  std::string iovString("\"iov\" : ");
198  return iovString+"["+std::to_string(m_start)+", "+std::to_string(m_stop)+"]";
199  }

◆ iovBase()

std::string IOVDbNamespace::Cool2Json::iovBase ( ) const

'time' (ns of epoch) or 'run-lumi'

Definition at line 142 of file Cool2Json.cxx.

142  {
143  std::string result("");
144  //run-lumi and run-event can both be found in our database, but the meaning is run-lumi
145  if (m_desc.find("<timeStamp>run-lumi</timeStamp>") != std::string::npos) result = "run-lumi";
146  if (m_desc.find("<timeStamp>run-event</timeStamp>") != std::string::npos) result = "run-lumi";
147  if (m_desc.find("<timeStamp>time</timeStamp>") != std::string::npos) result = "time";
148  return result;
149  }

◆ nchans()

unsigned int IOVDbNamespace::Cool2Json::nchans ( ) const

Number of channels in the folder.

Definition at line 137 of file Cool2Json.cxx.

137  {
138  return m_nchans;
139  }

◆ open()

static std::string IOVDbNamespace::Cool2Json::open ( )
static

json open tag, '{'

◆ payload()

std::string IOVDbNamespace::Cool2Json::payload ( )

Payload (data for the given channel selection and iov)

Definition at line 96 of file Cool2Json.cxx.

96  {
97  std::string result("\"data_array\" : [");
98  cool::IObjectIteratorPtr itr=m_pFolder->browseObjects(m_start,m_stop,m_chansel,m_tag);
100  std::string sep="";
101  while (itr->goToNext()){
102  const cool::IObject& ref=itr->currentRef();
103  result+=sep;
104  const long long cId=ref.channelId();
105  result+=s_openJson+quote(std::to_string(cId))+" : ";
106  switch (ftype){
108  result+=formatCvp(itr);
109  break;
111  result +=formatAttrList(itr);
112  break;
114  result +=formatAttrList(itr);
115  break;
117  result +=formatPoolRef(itr);
118  break;
120  result += formatAttrList(itr);
121  break;
123  result += " CoraCool";
124  break;
125  default:
126  result+=" a_data_value";
127  }
128  if (sep.empty()) sep=",";
129  result+=s_closeJson;
130  }
131  result+=']';
132  itr->close();
133  return result;
134  }

◆ payloadSpec()

const std::string & IOVDbNamespace::Cool2Json::payloadSpec ( ) const

Payload specification for this folder.

Definition at line 90 of file Cool2Json.cxx.

90  {
91  return m_spec;
92  }

◆ tag()

const std::string & IOVDbNamespace::Cool2Json::tag ( ) const

Simply the tag string passed to the constructor.

Definition at line 152 of file Cool2Json.cxx.

152  {
153  return m_tag;
154  }

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  o,
const Cool2Json c 
)
friend

Definition at line 201 of file Cool2Json.cxx.

201  {
202  o << c.description() << std::endl;
203  return o;
204  }

Member Data Documentation

◆ m_chansel

const cool::ChannelSelection IOVDbNamespace::Cool2Json::m_chansel
private

Definition at line 83 of file Cool2Json.h.

◆ m_desc

const std::string IOVDbNamespace::Cool2Json::m_desc
private

Definition at line 85 of file Cool2Json.h.

◆ m_nchans

unsigned int IOVDbNamespace::Cool2Json::m_nchans
private

Definition at line 87 of file Cool2Json.h.

◆ m_pFolder

const cool::IFolderPtr IOVDbNamespace::Cool2Json::m_pFolder
private

Definition at line 80 of file Cool2Json.h.

◆ m_spec

const std::string IOVDbNamespace::Cool2Json::m_spec
private

Definition at line 86 of file Cool2Json.h.

◆ m_start

const cool::ValidityKey IOVDbNamespace::Cool2Json::m_start
private

Definition at line 81 of file Cool2Json.h.

◆ m_stop

const cool::ValidityKey IOVDbNamespace::Cool2Json::m_stop
private

Definition at line 82 of file Cool2Json.h.

◆ m_tag

const std::string IOVDbNamespace::Cool2Json::m_tag
private

Definition at line 84 of file Cool2Json.h.


The documentation for this class was generated from the following files:
IOVDbNamespace::Cool2Json::m_nchans
unsigned int m_nchans
Definition: Cool2Json.h:87
get_generator_info.result
result
Definition: get_generator_info.py:21
IOVDbNamespace::Cool2Json::formatCvp
static std::string formatCvp(const cool::IObjectIteratorPtr &itr)
Definition: Cool2Json.cxx:157
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
IOVDbNamespace::PoolRefColl
@ PoolRefColl
Definition: FolderTypes.h:31
IOVDbNamespace::PoolRef
@ PoolRef
Definition: FolderTypes.h:30
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
IOVDbNamespace::Cool2Json::m_desc
const std::string m_desc
Definition: Cool2Json.h:85
IOVDbNamespace::Cool2Json::m_stop
const cool::ValidityKey m_stop
Definition: Cool2Json.h:82
IOVDbNamespace::Cool2Json::CoolVector
@ CoolVector
Definition: Cool2Json.h:76
dq_defect_copy_defect_database.since
def since
Definition: dq_defect_copy_defect_database.py:54
dq_defect_copy_defect_database.until
def until
Definition: dq_defect_copy_defect_database.py:55
IOVDbNamespace::Cool2Json::m_pFolder
const cool::IFolderPtr m_pFolder
Definition: Cool2Json.h:80
lumiFormat.i
int i
Definition: lumiFormat.py:92
res
std::pair< std::vector< unsigned int >, bool > res
Definition: JetGroupProductTest.cxx:14
IOVDbNamespace::Cool2Json::m_start
const cool::ValidityKey m_start
Definition: Cool2Json.h:81
IOVDbNamespace::CoolVector
@ CoolVector
Definition: FolderTypes.h:33
IOVDbNamespace::CoraCool
@ CoraCool
Definition: FolderTypes.h:32
IOVDbNamespace::AttrListColl
@ AttrListColl
Definition: FolderTypes.h:29
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
IOVDbNamespace::Cool2Json::JSON
@ JSON
Definition: Cool2Json.h:77
grepfile.sep
sep
Definition: grepfile.py:38
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
IOVDbNamespace::Cool2Json::m_spec
const std::string m_spec
Definition: Cool2Json.h:86
IOVDbNamespace::jsonAttributeList
std::string jsonAttributeList(const coral::AttributeList &atrlist)
Produce a representation of a coral::AttributeList as a json string.
Definition: IOVDbJsonStringFunctions.cxx:40
IOVDbNamespace::Cool2Json::m_tag
const std::string m_tag
Definition: Cool2Json.h:84
IOVDbNamespace::Cool2Json::CoraCool
@ CoraCool
Definition: Cool2Json.h:75
CaloCondBlobAlgs_fillNoiseFromASCII.folderTag
folderTag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:52
ref
const boost::regex ref(r_ef)
IOVDbNamespace::Cool2Json::formatPoolRef
static std::string formatPoolRef(const cool::IObjectIteratorPtr &itr)
Definition: Cool2Json.cxx:183
IOVDbNamespace::Cool2Json::formatAttrList
static std::string formatAttrList(const cool::IObjectIteratorPtr &itr)
Definition: Cool2Json.cxx:175
IOVDbNamespace::AttrList
@ AttrList
Definition: FolderTypes.h:28
IOVDbNamespace::Cool2Json::NUM_FOLDER_TYPES
@ NUM_FOLDER_TYPES
Definition: Cool2Json.h:78
IOVDbNamespace::Cool2Json::AttrListColl
@ AttrListColl
Definition: Cool2Json.h:72
IOVDbNamespace::Cool2Json::PoolRef
@ PoolRef
Definition: Cool2Json.h:73
pvec
std::array< fp_t, 2 > pvec
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:9
IOVDbNamespace::determineFolderType
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.
Definition: FolderTypes.cxx:16
IOVDbNamespace::quote
std::string quote(const std::string &sentence)
Enclose a string in ".
Definition: IOVDbStringFunctions.cxx:85
IOVDbNamespace::sanitiseXml
std::string sanitiseXml(const std::string &pseudoXmlString)
for use when converting cool folder description JSON
Definition: IOVDbStringFunctions.cxx:135
IOVDbNamespace::Cool2Json::AttrList
@ AttrList
Definition: Cool2Json.h:71
IOVDbNamespace::Cool2Json::PoolRefColl
@ PoolRefColl
Definition: Cool2Json.h:74
python.compressB64.c
def c
Definition: compressB64.py:93
IOVDbNamespace::Cool2Json::m_chansel
const cool::ChannelSelection m_chansel
Definition: Cool2Json.h:83
IOVDbNamespace::FolderType
FolderType
Definition: FolderTypes.h:26