ATLAS Offline Software
Functions
StatusFlagCOOLBase.cxx File Reference
#include "DataQualityUtils/StatusFlagCOOLBase.h"
#include "CoralBase/Attribute.h"
#include "CoolKernel/IDatabase.h"
#include "CoolKernel/IFolder.h"
#include "CoolKernel/IObjectIterator.h"
#include "CoolKernel/IObject.h"
#include "CoolKernel/Record.h"
#include "CoolKernel/Exception.h"
#include "CoolKernel/IDatabaseSvc.h"
#include "CoolKernel/StorageType.h"
#include "CoolKernel/ConstRecordAdapter.h"

Go to the source code of this file.

Functions

 ClassImp (dqutils::StatusFlagCOOLBase) namespace dqutils
 

Function Documentation

◆ ClassImp()

Definition at line 25 of file StatusFlagCOOLBase.cxx.

27  {
28  cool::IDatabasePtr
29  StatusFlagCOOLBase::
30  coolDbInstance(const std::string& dbStr, bool readOnly) {
31  try {
32  std::cout << "Opening database '" << dbStr << "'...";
33  cool::IDatabaseSvc& dbSvc = this->databaseService();
34  std::cout << "done." << std::endl;
35  return dbSvc.openDatabase(dbStr.c_str(), readOnly);
36  }
37  catch (cool::DatabaseDoesNotExist&) {
38  std::cout << "Error! Database does not exist!" << std::endl;
39  throw;
40  }
41  }
42 
43  cool::IFolderPtr
44  StatusFlagCOOLBase::
45  coolFolderInstance(const std::string& folderStr) {
46  try {
47  cool::IFolderPtr folder = m_coolDb->getFolder(folderStr.c_str());
48  std::cout << "Browsing objects of '" << folderStr << "'" << std::endl;
49  //folder->setupStorageBuffer();
50  return folder;
51  }
52  catch (cool::FolderNotFound&) {
53  std::cout << "Error! Folder '" << folderStr << "' does not exist!" << std::endl;
54  throw;
55  }
56  }
57 
58  void
59  StatusFlagCOOLBase::
60  setSince(cool::Int64 run, cool::Int64 lumi) {
61  m_since = ((run << 32) + lumi);
62  }
63 
64  void
65  StatusFlagCOOLBase::
66  setUntil(cool::Int64 run, cool::Int64 lumi) {
67  m_until = ((run << 32) + lumi);
68  }
69 
70  void
71  StatusFlagCOOLBase::
72  setIOV(cool::Int64 runS, cool::Int64 lumiS, cool::Int64 runU, cool::Int64 lumiU) {
73  this->setSince(runS, lumiS);
74  this->setUntil(runU, lumiU);
75  //this->printIOV();
76  }
77 
78  void
79  StatusFlagCOOLBase::
80  setIOV(cool::Int64 run) {
81  this->setSince(run, 0);
82  this->setUntil(run, cool::UInt32Max);
83  //this->printIOV();
84  }
85 
86  void
87  StatusFlagCOOLBase::
88  printIOV() {
89  cool::Int64 runS = m_since >> 32;
90  cool::Int64 lumiS = m_since - (runS << 32);
91  cool::Int64 runU = m_until >> 32;
92  cool::Int64 lumiU = m_until - (runU << 32);
93  std::cout << "Using IOVrange [(" << runS << "," << lumiS << "),(" << runU << "," << lumiU << ")[ " << "[" <<
94  m_since << "," << m_until << "[" << std::endl;
95  }
96 
97  void
99  flush() {
100  //m_coolFolder->flushStorageBuffer();
101  }
102 
103  void
105  Initialize(const std::string& dbStr, const std::string& folderStr, int runS, int lumiS, int runU, int lumiU) {
106  m_coolDb = this->coolDbInstance(dbStr, false);
107  m_coolFolder = this->coolFolderInstance(folderStr);
108  this->setIOV(runS, lumiS, runU, lumiU);
109  }
110 
111  StatusFlagCOOLBase::
112  StatusFlagCOOLBase (const std::string& dbStr, const std::string& folderStr, int runS, int lumiS, int runU,
113  int lumiU) {
114  Initialize(dbStr, folderStr, runS, lumiS, runU, lumiU);
115  }
116 
117  StatusFlagCOOLBase::
118  StatusFlagCOOLBase(int runS, int lumiS, int runU, int lumiU) {
119  Initialize("COOLOFL_GLOBAL/OFLP200", "/GLOBAL/DETSTATUS/SHIFTOFL",
120  runS, lumiS, runU, lumiU);
121  }
122 
123  StatusFlagCOOLBase::
124  StatusFlagCOOLBase() {
125  Initialize("COOLOFL_GLOBAL/OFLP200", "/GLOBAL/DETSTATUS/SHIFTOFL",
126  0, 0, 0, 0);
127  }
128 
129  StatusFlagCOOLBase::
130  ~StatusFlagCOOLBase () {
131  //m_coolFolder->flushStorageBuffer();
132  m_coolDb->closeDatabase();
133  std::cout << "Cleared!" << std::endl;
134  }
135 
136  void
138  dump(cool::ChannelSelection selection, std::string tag_name) {
139  try {
140  cool::IObjectIteratorPtr objects = m_coolFolder->browseObjects(m_since, m_until - 1, selection, tag_name);
141  while (objects->goToNext()) {
142  const cool::IObject& element = objects->currentRef();
143  std::cout << element << std::endl;
144  }
145  }
146  catch (cool::Exception& e) {
147  std::cout << "Unknown exception caught!" << e.what() << std::endl;
148  }
149  }
150 
151  std::string
152  StatusFlagCOOLBase::
153  dumpField(cool::ChannelId channelId, std::string field, std::string tag_name) {
154  std::string result = "";
155  try {
156  cool::ChannelSelection selection = cool::ChannelSelection(channelId);
157  cool::IObjectIteratorPtr objects = m_coolFolder->browseObjects(m_since, m_until - 1, selection, tag_name);
158  while (objects->goToNext()) {
159  const cool::IObject& element = objects->currentRef();
160  result = element.payloadValue(field);
161  }
162  }
163  catch (cool::Exception& e) {
164  std::cout << "Unknown exception caught!" << e.what() << std::endl;
165  }
166  return result;
167  }
168 
169  int
170  StatusFlagCOOLBase::
171  dumpCode(const std::string& channelName, const std::string& tag_name) {
172  std::string result = this->dumpField(this->getCoolFolder()->channelId(channelName.c_str()), "Code", tag_name);
173  if (result == "") {
174  return INT_MAX;
175  } else {
176  return atoi(result.c_str());
177  }
178  }
179 
180  void
181  StatusFlagCOOLBase::
182  dumpall(const std::string& tag_name) {
183  this->dump(cool::ChannelSelection::all(), tag_name);
184  }
185 
186  void
187  StatusFlagCOOLBase::
188  insert_helper(cool::ChannelId channelId, coral::AttributeList& payload,
189  const std::string& tag_name) {
190  cool::ConstRecordAdapter record(m_coolFolder->payloadSpecification(), payload);
191  if (tag_name == "HEAD") {
192  m_coolFolder->storeObject(m_since, m_until, cool::Record(m_coolFolder->payloadSpecification(), payload),
193  channelId);
194  } else {
195  m_coolFolder->storeObject(m_since, m_until, cool::Record(
196  m_coolFolder->payloadSpecification(), payload), channelId, tag_name, true);
197  }
198  }
199 
200  cool::IFolderPtr
201  StatusFlagCOOLBase::
202  getCoolFolder() {
203  return this->m_coolFolder;
204  }
205 
206  cool::IDatabasePtr
207  StatusFlagCOOLBase::
208  getCoolDb() {
209  return this->m_coolDb;
210  }
211 } //namespace dqutils
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
get_generator_info.result
result
Definition: get_generator_info.py:21
LArConditions2Ntuple.objects
objects
Definition: LArConditions2Ntuple.py:59
FullCPAlgorithmsTest_eljob.flush
flush
Definition: FullCPAlgorithmsTest_eljob.py:182
ReadOfcFromCool.field
field
Definition: ReadOfcFromCool.py:48
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
run_Egamma1_LArStrip_Fex.dump
dump
Definition: run_Egamma1_LArStrip_Fex.py:88
run
Definition: run.py:1
CaloCondBlobAlgs_fillNoiseFromASCII.channelId
channelId
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:122
CaloNoise_fillDB.dbSvc
dbSvc
Definition: CaloNoise_fillDB.py:108
selection
const std::string selection
Definition: fbtTestBasics.cxx:74
jobOptions.Initialize
Initialize
Definition: jobOptions.pA.py:28
Cut::all
@ all
Definition: SUSYToolsAlg.cxx:67
PixelModuleFeMask_create_db.payload
string payload
Definition: PixelModuleFeMask_create_db.py:69
lumiFormat.lumi
lumi
Definition: lumiFormat.py:106
CaloCondBlobAlgs_fillNoiseFromASCII.folder
folder
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:56
CxxUtils::atoi
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
Definition: Control/CxxUtils/Root/StringUtils.cxx:85