29 {
30 void CoolMdt::initialize() {m_fist_folder = true;}
31
32 cool::IDatabasePtr
33 CoolMdt::
34 coolDbInstance(const std::string& dbStr, bool readOnly) {
35 try {
36
37 cool::IDatabaseSvc&
dbSvc = this->databaseService();
38
39 return dbSvc.openDatabase(dbStr.c_str(), readOnly);
40 }
41 catch (cool::DatabaseDoesNotExist&) {
42 std::cerr << "Error! Database does not exist!" << std::endl;
43 throw;
44 }
45 }
46
47 cool::IFolderPtr
48 CoolMdt::
49 coolFolderInstance(const std::string& folderStr) {
50 try {
51 cool::IFolderPtr
folder = m_coolDb->getFolder(folderStr.c_str());
52
54 }
55 catch (cool::FolderNotFound&) {
56 std::cerr << "Error! Folder '" << folderStr << "' does not exist!" << std::endl;
57 throw;
58 }
59 }
60
61 void
62 CoolMdt::coolDbFolder(const std::string& dbStr, const std::string& folderStr) {
63 m_coolDb = this->coolDbInstance(dbStr, false);
64 m_coolFolder = this->coolFolderInstance(folderStr);
65 }
66
67 void
68 CoolMdt::
69 setSince(cool::Int64
run, cool::Int64 lumi) {
71 }
72
73 void
74 CoolMdt::
75 setUntil(cool::Int64
run, cool::Int64 lumi) {
77 }
78
79 void
80 CoolMdt::
81 setIOV(cool::Int64 runS, cool::Int64 lumiS, cool::Int64 runU, cool::Int64 lumiU) {
82 this->setSince(runS, lumiS);
83 this->setUntil(runU, lumiU);
84 this->printIOV();
85 }
86
87 void
88 CoolMdt::
89 setIOV(cool::Int64
run) {
90 this->setSince(
run, 0);
91 this->setUntil(
run, 4294967295U);
92 this->printIOV();
93 }
94
95 void
96 CoolMdt::
97 printIOV() {
98 cool::Int64 runS = m_since >> 32;
99 cool::Int64 lumiS = m_since - (runS << 32);
100 cool::Int64 runU = m_until >> 32;
101 cool::Int64 lumiU = m_until - (runU << 32);
102 std::cout << "Using IOVrange [(" << runS << "," << lumiS << "),(" << runU << "," << lumiU << ")] " << "[" <<
103 m_since << "," << m_until << "]" << std::endl;
104 }
105
106 void
107 CoolMdt::
108 CoolOpen(const std::string& dbStr) {
109 m_coolDb = this->coolDbInstance(dbStr, false);
110 }
111
112 CoolMdt::
113 ~CoolMdt () {
114 m_coolFolder->flushStorageBuffer();
115 m_coolDb->closeDatabase();
116
117 }
118
119 cool::RecordSpecification
120 CoolMdt::
121 createSpecDataDead() {
122
123 cool::RecordSpecification
spec;
124 spec.extend(
"Chamber_Name", cool::StorageType::String255);
125 spec.extend(
"Dead_multilayer", cool::StorageType::String255);
126 spec.extend(
"Dead_layer", cool::StorageType::String255);
127 spec.extend(
"Dead_mezz", cool::StorageType::String255);
128 spec.extend(
"Dead_asd", cool::StorageType::String255);
129 spec.extend(
"Dead_tube", cool::StorageType::String4k);
130
131 if (m_fist_folder) {
132 m_coolFolder = this->coolFolderInstance("/OFFLINE/DQMFOFFLINE/DQMFOFFLINE_DEAD");
133 m_coolFolder->setupStorageBuffer();
134
135 m_fist_folder = false;
136 }
137 if (!(spec == m_coolFolder->payloadSpecification())) {
138 std::cerr << "ERROR Source and destination folder specifications differ." << std::endl;
139 }
140
142 }
143
144 coral::AttributeList
145 CoolMdt::
146 createPayloadDataDead(const std::string& ChamberName,
147 const std::string& DeadMultilayer,
148 const std::string& DeadLayer,
149 const std::string& DeadMezz,
150 const std::string& DeadAsd,
151 const std::string& DeadTube,
152 const cool::RecordSpecification& spec) {
153
154
155 coral::AttributeList
payload = cool::Record(spec).attributeList();
156
157 payload[
"Chamber_Name"].data<cool::String255>() = ChamberName;
158 payload[
"Dead_multilayer"].data<cool::String255>() = DeadMultilayer;
159 payload[
"Dead_layer"].data<cool::String255>() = DeadLayer;
160 payload[
"Dead_mezz"].data<cool::String255>() = DeadMezz;
161 payload[
"Dead_asd"].data<cool::String255>() = DeadAsd;
162 payload[
"Dead_tube"].data<cool::String4k>() = DeadTube;
163
165 }
166
167
168
169 cool::RecordSpecification
170 CoolMdt::
171 createSpecDataNoisy() {
172
173 cool::RecordSpecification
spec;
174 spec.extend(
"Chamber_Name", cool::StorageType::String255);
175 spec.extend(
"Noisy_multilayer", cool::StorageType::String255);
176 spec.extend(
"Noisy_layer", cool::StorageType::String255);
177 spec.extend(
"Noisy_mezz", cool::StorageType::String255);
178 spec.extend(
"Noisy_asd", cool::StorageType::String255);
179 spec.extend(
"Noisy_tube", cool::StorageType::String4k);
180
181 if (m_fist_folder) {
182 m_coolFolder = this->coolFolderInstance("/OFFLINE/DQMFOFFLINE/DQMFOFFLINE_NOISY");
183 m_coolFolder->setupStorageBuffer();
184
185 m_fist_folder = false;
186 }
187 if (!(spec == m_coolFolder->payloadSpecification())) {
188 std::cerr << "ERROR Source and destination folder specifications differ." << std::endl;
189 }
190
192 }
193
194 coral::AttributeList
195 CoolMdt::
196 createPayloadDataNoisy(const std::string& ChamberName,
197 const std::string& NoisyMultilayer,
198 const std::string& NoisyLayer,
199 const std::string& NoisyMezz,
200 const std::string& NoisyAsd,
201 const std::string& NoisyTube,
202 const cool::RecordSpecification& spec) {
203
204
205 coral::AttributeList
payload = cool::Record(spec).attributeList();
206
207 payload[
"Chamber_Name"].data<cool::String255>() = ChamberName;
208 payload[
"Noisy_multilayer"].data<cool::String255>() = NoisyMultilayer;
209 payload[
"Noisy_layer"].data<cool::String255>() = NoisyLayer;
210 payload[
"Noisy_mezz"].data<cool::String255>() = NoisyMezz;
211 payload[
"Noisy_asd"].data<cool::String255>() = NoisyAsd;
212 payload[
"Noisy_tube"].data<cool::String4k>() = NoisyTube;
213
215 }
216
217
218
219
220 void
221 CoolMdt::
223 try {
224 cool::IObjectIteratorPtr
objects = m_coolFolder->browseObjects(m_since, m_until,
selection,
"");
226 const cool::IObject& element =
objects->currentRef();
227 std::cout << element << std::endl;
228 }
229 }
230 catch (cool::Exception& e) {
231 std::cout <<
"Unknown exception caught!" <<
e.what() << std::endl;
232 std::cout << " dentro create payload" << std::endl;
233 }
234 }
235
236 std::string
237 CoolMdt::
238 dumpField(cool::ChannelId channelId, const std::string & field) {
240 try {
241 cool::ChannelSelection
selection = cool::ChannelSelection(channelId);
242 cool::IObjectIteratorPtr
objects = m_coolFolder->browseObjects(m_since, m_until,
selection,
"");
244 const cool::IObject& element =
objects->currentRef();
245 result = element.payloadValue(field);
246 }
247 }
248 catch (cool::Exception& e) {
249 std::cout <<
"Unknown exception caught!" <<
e.what() << std::endl;
250 }
252 }
253
254 int
255 CoolMdt::
256 dumpCode(const std::string& channelName) {
257 std::string
result = this->dumpField(this->getCoolFolder()->
channelId(channelName.c_str()),
"Code");
259 }
260
261 void
262 CoolMdt::
263 dumpall() {
264 this->
dump(cool::ChannelSelection::all());
265 }
266
267 void
268 CoolMdt::
269 insertDeadFlag_withTag(cool::Int64
run,
270 cool::ChannelId channelId,
271 const std::string& ChamberName,
272 const std::string& DeadMultilayer,
273 const std::string& DeadLayer,
274 const std::string& DeadMezz,
275 const std::string& DeadAsd,
276 const std::string& DeadTube,
277 const std::string& cool_tag) {
278 try {
279 cool::RecordSpecification
spec = this->createSpecDataDead();
280 coral::AttributeList
payload = this->createPayloadDataDead(ChamberName, DeadMultilayer, DeadLayer, DeadMezz,
281 DeadAsd, DeadTube, spec);
282 cool::ValidityKey since_u = (
run << 32);
283 cool::ValidityKey until_u = (
run + 1) << 32;
284 m_coolFolder->storeObject(since_u, until_u, cool::Record(
285 m_coolFolder->payloadSpecification(), payload), channelId, cool_tag);
286
287 }
288 catch (cool::Exception& e) {
289 std::cerr << " dentro create insert" << std::endl;
290 std::cerr <<
"Unknown exception caught!" <<
e.what() << std::endl;
291 }
292 }
293
294 void
295 CoolMdt::
296 insertDeadFlag(cool::Int64
run,
297 cool::ChannelId channelId,
298 const std::string& ChamberName,
299 const std::string& DeadMultilayer,
300 const std::string& DeadLayer,
301 const std::string& DeadMezz,
302 const std::string& DeadAsd,
303 const std::string& DeadTube) {
304 std::cout << "Trying to store payload [channel " << std::endl;
305 try {
306 cool::RecordSpecification
spec = this->createSpecDataDead();
307 coral::AttributeList
payload = this->createPayloadDataDead(ChamberName, DeadMultilayer, DeadLayer, DeadMezz,
308 DeadAsd, DeadTube, spec);
309 cool::ValidityKey since_u = (
run << 32);
310 cool::ValidityKey until_u = (
run + 1) << 32;
311 m_coolFolder->storeObject(since_u, until_u, cool::Record(m_coolFolder->payloadSpecification(), payload),
312 channelId);
313
314 }
315 catch (cool::Exception& e) {
316 std::cerr << " dentro create insert" << std::endl;
317 std::cerr <<
"Unknown exception caught!" <<
e.what() << std::endl;
318 }
319 }
320
321
322
323
324
325 void
326 CoolMdt::
327 insertNoisyFlag_withTag(cool::Int64
run,
328 cool::ChannelId channelId,
329 const std::string& ChamberName,
330 const std::string& NoisyMultilayer,
331 const std::string& NoisyLayer,
332 const std::string& NoisyMezz,
333 const std::string& NoisyAsd,
334 const std::string& NoisyTube,
335 const std::string& cool_tag) {
336 try {
337 cool::RecordSpecification
spec = this->createSpecDataNoisy();
338 coral::AttributeList
payload = this->createPayloadDataNoisy(ChamberName, NoisyMultilayer, NoisyLayer, NoisyMezz,
339 NoisyAsd, NoisyTube, spec);
340 cool::ValidityKey since_u = (
run << 32);
341 cool::ValidityKey until_u = (
run + 1) << 32;
342 m_coolFolder->storeObject(since_u, until_u, cool::Record(
343 m_coolFolder->payloadSpecification(), payload), channelId, cool_tag);
344
345 }
346 catch (cool::Exception& e) {
347 std::cerr << " dentro create insert" << std::endl;
348 std::cerr <<
"Unknown exception caught!" <<
e.what() << std::endl;
349 }
350 }
351
352 void
353 CoolMdt::
354 insertNoisyFlag(cool::Int64
run,
355 cool::ChannelId channelId,
356 const std::string& ChamberName,
357 const std::string& NoisyMultilayer,
358 const std::string& NoisyLayer,
359 const std::string& NoisyMezz,
360 const std::string& NoisyAsd,
361 const std::string& NoisyTube) {
362 std::cout << "Trying to store payload [channel " << std::endl;
363 try {
364 cool::RecordSpecification
spec = this->createSpecDataNoisy();
365 coral::AttributeList
payload = this->createPayloadDataNoisy(ChamberName, NoisyMultilayer, NoisyLayer, NoisyMezz,
366 NoisyAsd, NoisyTube, spec);
367 cool::ValidityKey since_u = (
run << 32);
368 cool::ValidityKey until_u = (
run + 1) << 32;
369 m_coolFolder->storeObject(since_u, until_u, cool::Record(m_coolFolder->payloadSpecification(), payload),
370 channelId);
371
372 }
373 catch (cool::Exception& e) {
374 std::cerr << " dentro create insert" << std::endl;
375 std::cerr <<
"Unknown exception caught!" <<
e.what() << std::endl;
376 }
377 }
378
379 cool::IFolderPtr
380 CoolMdt::
381 getCoolFolder() {
382 return this->m_coolFolder;
383 }
384
385 cool::IDatabasePtr
386 CoolMdt::
387 getCoolDb() {
388 return this->m_coolDb;
389 }
390}
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...
int run(int argc, char *argv[])