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
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) {
62 }
63
64 void
65 StatusFlagCOOLBase::
66 setUntil(cool::Int64
run, cool::Int64 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
76 }
77
78 void
79 StatusFlagCOOLBase::
80 setIOV(cool::Int64
run) {
81 this->setSince(
run, 0);
82 this->setUntil(
run, cool::UInt32Max);
83
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
98 StatusFlagCOOLBase::
99 flush() {
100
101 }
102
103 void
104 StatusFlagCOOLBase::
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
132 m_coolDb->closeDatabase();
133 std::cout << "Cleared!" << std::endl;
134 }
135
136 void
137 StatusFlagCOOLBase::
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);
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) {
155 try {
156 cool::ChannelSelection
selection = cool::ChannelSelection(channelId);
157 cool::IObjectIteratorPtr
objects = m_coolFolder->browseObjects(m_since, m_until - 1,
selection, tag_name);
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 }
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);
174 return INT_MAX;
175 } else {
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}
const std::string selection
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...