ATLAS Offline Software
Loading...
Searching...
No Matches
IOVDbTestAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "IOVDbTestAlg.h"
6
7// IOVDbTest includes
12
13// Athena includes
15
16// Gaudi includes
17#include "GaudiKernel/IIncidentSvc.h"
18#include "GaudiKernel/Incident.h"
19#include "GaudiKernel/GaudiException.h"
20#include "GaudiKernel/IToolSvc.h"
21
22// AttributeList
23#include "CoralBase/Attribute.h"
24#include "CoralBase/Blob.h"
25#include "CoralBase/AttributeListSpecification.h"
28
29// for online testing
30#include <sys/ipc.h>
31#include <sys/msg.h>
32
33
35
36IOVDbTestAlg::IOVDbTestAlg(const std::string& name, ISvcLocator* pSvcLocator) :
37 AthReentrantAlgorithm(name, pSvcLocator),
38 m_regSvc("IOVRegistrationSvc", name),
39 m_streamer ("CondStream1")
40{
41}
42
43// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
44
47
48// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
50 struct mymsgbuf {
51 long mtype;
52 char mtext[80];
53 };
54
55 key_t key;
56 int msgqueue_id;
57 struct mymsgbuf qbuf;
58
59 /* Create unique key via call to ftok() */
60 key = ftok(".", 'm');
61
62 /* Open the queue */
63 while((msgqueue_id = msgget(key, 0660)) == -1) {
64 printf("waiting for message here.\n");
65 sleep(3);
66 }
67 printf("Recieving a message ...\n");
68
69 qbuf.mtype = 123;
70 msgrcv(msgqueue_id, reinterpret_cast< msgbuf *>(&qbuf), 80, 123, 0);
71
72 printf("Type: %ld Text: %s\n", qbuf.mtype, qbuf.mtext);
73
74 msgctl(msgqueue_id, IPC_RMID, 0); // clearing the message
75
76}
77
78// Not thread-safe due to binding DataHandle.
80 ATH_MSG_DEBUG( "in initialize()" );
81
82 // Get Output Stream tool for writing
83 if (m_writeCondObjs) {
84 m_streamer = "AthenaOutputStreamTool/" + m_streamName;
85 ATH_CHECK( m_streamer.retrieve() );
86 }
87
88 // Get the IOVRegistrationSvc when needed
89 if (m_regIOV) {
90 ATH_CHECK( m_regSvc.retrieve() );
91 ATH_MSG_DEBUG( "Found IOVRegistrationSvc " );
92 ATH_MSG_INFO( "Tag to be used: " << m_tagID.value() );
93 }
94
95 if (m_readInInit) {
97 ATH_MSG_DEBUG( "Read with BeginRun " );
98 }
99
100 return StatusCode::SUCCESS;
101}
102
103// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
104
106 ATH_MSG_INFO( "in readWithBeginRun()" );
107
108 // As a result of the restructuring the EventIncident class (dropping the reference to EventInfo)
109 // the old mechanism of overriding run&event&time is no longer working.
110 // If we need this functionality, then we need to find a new way of implementing it.
111 // For the time being this function simply fires a BeginRun incident using the EventContext, without overriding anything
112
113 ServiceHandle<IIncidentSvc> incSvc("IncidentSvc", name() );
114 ATH_CHECK( incSvc.retrieve() );
115
116 incSvc->fireIncident( Incident(name(), IncidentType::BeginRun, Gaudi::Hive::currentContext()) );
117
118 return StatusCode::SUCCESS;
119}
120
121// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
122
123StatusCode IOVDbTestAlg::createCondObjects(const EventContext& ctx) const
124{
125 ATH_MSG_INFO ("in createCondObjects()");
126
127 // Create IOVDbTestMDTEleMap
129 unsigned long long timestamp = ctx.eventID().time_stamp();
130 if (timestamp)
131 elemMap->set(ctx.eventID().time_stamp(),"mdt element map");
132 else
133 elemMap->set(ctx.eventID().run_number(), ctx.eventID().event_number(), "mdt element map");
134
135
136 // Must provide a key which is used as the name to create the folder
137 ATH_CHECK( detStore()->record(elemMap, "/IOVDbTest/IOVDbTestMDTEleMap") );
138
139 // Create IOVDbTestMDTEleMapColl
141
142 // Add in 10 maps, set indices
143 unsigned int offset = 0;
144 if (m_createExtraChans) offset = 100;
145 for (unsigned int i = 0; i < 10; ++i) {
147
148 unsigned long long timestamp = ctx.eventID().time_stamp();
149 if (timestamp)
150 elemMap->set(ctx.eventID().time_stamp() + 10*i, "mdt element map");
151 else
152 elemMap->set(ctx.eventID().run_number() + i, ctx.eventID().event_number(), "mdt element map");
153
154 elemMapColl->push_back(elemMap);
155 elemMapColl->add(2*i+1+i + offset);
156 }
157
158 // Must provide a key which is used as the name to create the folder
159 ATH_CHECK( detStore()->record(elemMapColl, "/IOVDbTest/IOVDbTestMDTEleMapColl") );
160
161 // Create IOVDbTestAmdbCorrection
163 HepGeom::Point3D<double> x(1.0, 2.0, 3.0);
164 HepGeom::Point3D<double> y(4.0, 5.0, 6.0);
165 if (m_writeNewTag) {
166 // writing with new tag, set to different values
167 x = HepGeom::Point3D<double>(11.0, 22.0, 33.0);
168 y = HepGeom::Point3D<double>(44.0, 55.0, 66.0);
169 }
170 amdbCorr->set(x, y, "amdb correction");
171
172 ATH_CHECK( detStore()->record(amdbCorr, "/IOVDbTest/IOVDbTestAMDBCorrection") );
173
174 // Create an attribute list
175
176 // Create spec
177 coral::AttributeListSpecification* attrSpec = new coral::AttributeListSpecification();
178 attrSpec->extend("xPosition", "float");
179 attrSpec->extend("id", "int");
180 attrSpec->extend("name", "string");
181
182 if (!attrSpec->size()) {
183 ATH_MSG_ERROR (" Attribute list specification is empty");
184 return(StatusCode::FAILURE);
185 }
186
187 // FIX this
188 //std::ostringstream attrStr;
189 //attrSpec->print( attrStr );
190 //log << MSG::DEBUG << "Attribute spec " << attrStr.str() << endmsg;
191
192 AthenaAttributeList* attrList = new AthenaAttributeList(*attrSpec);
193 (*attrList)["xPosition"].setValue((float)m_run);
194 (*attrList)["id"].setValue((int)7);
195 (*attrList)["name"].setValue(std::string("TestAttrList"));
196 if (m_writeNewTag) {
197 // writing with new tag, set to different values
198 (*attrList)["xPosition"].setValue((float)125.0);
199 (*attrList)["id"].setValue((int)27);
200 (*attrList)["name"].setValue(std::string("TestAttrListNEWTAG"));
201 }
202 std::ostringstream attrStr1;
203 // FIXME
204 attrList->toOutputStream( attrStr1 );
205 // attrList->print(std::cout);
206 ATH_MSG_DEBUG( "Attribute list " << attrStr1.str() );
207
208 ATH_CHECK( detStore()->record(attrList, "/IOVDbTest/IOVDbTestAttrList") );
209
210 // optionally create a second 'fancy' attributelist testing more datatypes
211 // including bool, CLOB and BLOB types
212 if (m_fancylist) {
213 coral::AttributeListSpecification* fanSpec = new coral::AttributeListSpecification();
214 fanSpec->extend("FanBool","bool");
215 fanSpec->extend("FanInt","int");
216 fanSpec->extend("FanUInt","unsigned int");
217 fanSpec->extend("FanI64","long long");
218 fanSpec->extend("FanU64","unsigned long long");
219 fanSpec->extend("FanFloat","float");
220 fanSpec->extend("FanDouble","double");
221 fanSpec->extend("FanSmallString","string");
222 fanSpec->extend("FanBigString","string");
223 fanSpec->extend("FanBlob","blob");
224 AthenaAttributeList* fanList=new AthenaAttributeList(*fanSpec);
225 // set values, note new style access methods
226 (*fanList)["FanBool"].data<bool>()=true;
227 (*fanList)["FanInt"].data<int>()=-12345;
228 (*fanList)["FanUInt"].data<unsigned int>()=12345;
229 (*fanList)["FanI64"].data<long long>()=-98765432100LL;
230 (*fanList)["FanU64"].data<unsigned long long>()=98765432100LL;
231 (*fanList)["FanFloat"].data<float>()=1.2345;
232 (*fanList)["FanDouble"].data<double>()=1.23456789;
233 (*fanList)["FanSmallString"].data<std::string>()="small string";
234 (*fanList)["FanBigString"].data<std::string>()="potentially long string";
235 // special construction to set blob type
236 coral::Blob& blob=(*fanList)["FanBlob"].data<coral::Blob>();
237 unsigned int blobsize=2000;
238 blob.resize(blobsize);
239 unsigned char* p=static_cast<unsigned char*>(blob.startingAddress());
240 for (unsigned int i=0;i<blobsize;++i,++p) *p=(i % 256);
241 // print out attributelist
242 std::ostringstream fanstr;
243 fanList->toOutputStream(fanstr);
244 ATH_MSG_DEBUG( "Fancy Attribute list " << fanstr.str() );
245 ATH_CHECK( detStore()->record(fanList, "/IOVDbTest/IOVDbTestFancyList") );
246 }
247
248 // Create an attribute list collection
249
250 // Use existing spec
251 CondAttrListCollection* attrListColl = new CondAttrListCollection(true);
252
253 // Add three attr lists
254 coral::AttributeList attrList0(*attrSpec);
255 attrList0["xPosition"].setValue((float)35.0);
256 attrList0["id"].setValue((int)17);
257 attrList0["name"].setValue(std::string("TestAttrList"));
259
260 std::ostringstream attrStr2;
261 attrList0.toOutputStream( attrStr2 );
262 ATH_MSG_DEBUG( "ChanNum " << chanNum << " Attribute list " << attrStr2.str() );
263 attrListColl->add(chanNum, attrList0);
264
265 coral::AttributeList attrList1(*attrSpec);
266 attrList1["xPosition"].setValue((float)45.0);
267 attrList1["id"].setValue((int)27);
268 attrList1["name"].setValue(std::string("TestAttrList"));
269 chanNum = 26;
270
271 std::ostringstream attrStr3;
272 attrList1.toOutputStream( attrStr3 );
273 ATH_MSG_DEBUG( "ChanNum " << chanNum << " Attribute list " << attrStr3.str() );
274 attrListColl->add(chanNum, attrList1);
275
276 coral::AttributeList attrList2(*attrSpec);
277 attrList2["xPosition"].setValue((float)55.0);
278 attrList2["id"].setValue((int)37);
279 attrList2["name"].setValue(std::string("TestAttrList"));
280 chanNum = 36;
281
282 std::ostringstream attrStr4;
283 attrList2.toOutputStream( attrStr4 );
284 ATH_MSG_DEBUG( "ChanNum " << chanNum << " Attribute list " << attrStr4.str() );
285 attrListColl->add(chanNum, attrList2);
286
288 // Two more channels
289 coral::AttributeList attrList3(*attrSpec);
290 attrList3["xPosition"].setValue((float)65.0);
291 attrList3["id"].setValue((int)47);
292 attrList3["name"].setValue(std::string("TestAttrList"));
293 chanNum = 46;
294
295 std::ostringstream attrStr5;
296 attrList3.toOutputStream( attrStr5 );
297 ATH_MSG_DEBUG( "ChanNum " << chanNum << " Attribute list " << attrStr5.str() );
298 attrListColl->add(chanNum, attrList3);
299
300 // Add in new IOV with min run == 4
302 attrListColl->add(chanNum, range);
303 ATH_MSG_DEBUG( "Add min : since " << range.start().run() << " " << range.start().event()
304 << " till " << range.stop().run() << " " << range.stop().event() );
305
306 coral::AttributeList attrList4(*attrSpec);
307 attrList4["xPosition"].setValue((float)75.0);
308 attrList4["id"].setValue((int)57);
309 attrList4["name"].setValue(std::string("TestAttrList"));
310 chanNum = 56;
311
312 std::ostringstream attrStr6;
313 attrList4.toOutputStream( attrStr6 );
314 ATH_MSG_DEBUG( "ChanNum " << chanNum << " Attribute list " << attrStr6.str() );
315 attrListColl->add(chanNum, attrList4);
316
317 // Add in new IOV with min run == 5
319 attrListColl->add(chanNum, range1);
320 ATH_MSG_DEBUG( "Add min : since " << range1.start().run() << " " << range1.start().event() << " till " << range1.stop().run() << " " << range1.stop().event() );
321 }
322 // add names to the channels if needed
323 if (m_nameChans) {
324 ATH_MSG_DEBUG( "Name channels in CondAttrListCollection" );
325 for (CondAttrListCollection::const_iterator citr=attrListColl->begin();
326 citr!=attrListColl->end();++citr) {
327 CondAttrListCollection::ChanNum chan=citr->first;
328 std::ostringstream name;
329 name << "Name_" << chan;
330 attrListColl->add(chan,name.str());
331 }
332 }
333
334 ATH_CHECK( detStore()->record(attrListColl, "/IOVDbTest/IOVDbTestAttrListColl") );
335
336 return StatusCode::SUCCESS;
337}
338// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
339
340
342 ATH_MSG_INFO( "in printCondObjects()" );
343
344 // IOVDbTestMDTEleMap
345 const IOVDbTestMDTEleMap* elemMap = nullptr;
346 ATH_CHECK( detStore()->retrieve(elemMap, "/IOVDbTest/IOVDbTestMDTEleMap") );
347 ATH_MSG_INFO( "Retrieved IOVDbTestMDTEleMap " );
348
349 ATH_MSG_INFO( "Found " << elemMap->name()
350 << " run " << elemMap->runNumber()
351 << " event " << elemMap->eventNumber()
352 << " time " << elemMap->timeStamp() );
353
354
355
356 // IOVDbTestAmdbCorrection
357 const IOVDbTestAmdbCorrection* amdbCorr = nullptr;
358 ATH_CHECK( detStore()->retrieve(amdbCorr, "/IOVDbTest/IOVDbTestAMDBCorrection") );
359 ATH_MSG_INFO ("Retrieved /IOVDbTest/IOVDbTestAMDBCorrection" );
360
361 HepGeom::Point3D<double> trans = amdbCorr->getTranslation();
362 HepGeom::Point3D<double> rot = amdbCorr->getRotation();
363
364 ATH_MSG_INFO( "Found " << amdbCorr->name()
365 << " trans " << trans.x() << " " << trans.y() << " " << trans.z()
366 << " rot " << rot.x() << " " << rot.y() << " " << rot.z() );
367
368
369 if (m_readNewTag) {
370 // IOVDbTestAmdbCorrection
371 const IOVDbTestAmdbCorrection* amdbCorr = nullptr;
372 ATH_CHECK( detStore()->retrieve(amdbCorr, "/IOVDbTest/IOVDbTestAMDBCorrection-NEWTAG") );
373 ATH_MSG_INFO( "Retrieved /IOVDbTest/IOVDbTestAMDBCorrection-NEWTAG" );
374
375 HepGeom::Point3D<double> trans = amdbCorr->getTranslation();
376 HepGeom::Point3D<double> rot = amdbCorr->getRotation();
377
378 ATH_MSG_INFO( "Found " << amdbCorr->name()
379 << " trans " << trans.x() << " " << trans.y() << " " << trans.z()
380 << " rot " << rot.x() << " " << rot.y() << " " << rot.z() );
381 }
382
383
384 const AthenaAttributeList* attrList = nullptr;
385 const CondAttrListCollection* attrListColl = nullptr;
386
388 // AttrList
389 ATH_CHECK( detStore()->retrieve(attrList, "/IOVDbTest/IOVDbTestAttrList") );
390 ATH_MSG_DEBUG( "Retrieved IOVDbTestAttrList" );
391
392 std::ostringstream attrStr1;
393 attrList->print( attrStr1 );
394 ATH_MSG_DEBUG( "Attribute list " << attrStr1.str() );
395
396 if (m_readNewTag) {
397 // AttrList
398 ATH_CHECK( detStore()->retrieve(attrList, "/IOVDbTest/IOVDbTestAttrList-NEWTAG") );
399 ATH_MSG_DEBUG( "Retrieved IOVDbTestAttrList-NEWTAG" );
400
401 std::ostringstream attrStr1;
402 attrList->print( attrStr1 );
403 ATH_MSG_DEBUG( "Attribute list NEWTAG: " << attrStr1.str() );
404 }
405
406 // fancy attributelist
407 if (m_fancylist) {
408 ATH_MSG_DEBUG( detStore()->retrieve(attrList, "/IOVDbTest/IOVDbTestFancyList") );
409 ATH_MSG_DEBUG( "Retrieved IOVDbTestFancyList" );
410 std::ostringstream fanstr;
411 attrList->print( fanstr );
412 ATH_MSG_DEBUG( "Fancy Attribute list " << fanstr.str() );
413 // for the blob type, check the actual data is correct
414 const coral::Blob& blob=(*attrList)["FanBlob"].data<coral::Blob>();
415 const unsigned char* p=static_cast<const unsigned char*>
416 (blob.startingAddress());
417 int nerr=0;
418 for (int i=0;i<blob.size();++i,++p) if (*p!=(i % 256)) ++nerr;
419 if (nerr>0) ATH_MSG_ERROR( "Blob has " << nerr <<
420 " data mismatches!" );
421 }
422
423 // AttrListColl
424 ATH_CHECK( detStore()->retrieve(attrListColl, "/IOVDbTest/IOVDbTestAttrListColl") );
425 ATH_MSG_DEBUG( "Retrieved IOVDbTestAttrListColl" );
426
427
428 std::ostringstream attrStr2;
429
430 // Loop over collection
431 CondAttrListCollection::const_iterator first = attrListColl->begin();
432 CondAttrListCollection::const_iterator last = attrListColl->end();
433 for (; first != last; ++first) {
434
435 if (msgLvl (MSG::DEBUG)) {
436 std::ostringstream attrStr1;
437 (*first).second.toOutputStream( attrStr1 );
438 msg() << MSG::DEBUG << "ChanNum " << (*first).first;
439 // print out the name if present
440 if (attrListColl->name_size()>0) {
442 nitr=attrListColl->chanNamePair((*first).first);
443 if (nitr!=attrListColl->name_end())
444 msg() << MSG::DEBUG << " name " << nitr->second;
445 }
446 msg() << MSG::DEBUG <<
447 " Attribute list " << attrStr1.str() << endmsg;
448 }
449
450 // Print out range if it exits
451 CondAttrListCollection::ChanNum chanNum = (*first).first;
452 CondAttrListCollection::iov_const_iterator iovIt = attrListColl->chanIOVPair(chanNum);
453 if (iovIt != attrListColl->iov_end()) {
454 const IOVRange& range = (*iovIt).second;
455 if(range.start().isTimestamp()) {
456 ATH_MSG_DEBUG( "Range timestamp : since " << range.start().timestamp()
457 << " till " << range.stop().timestamp() );
458 }
459 else {
460 ATH_MSG_DEBUG( "Range R/E : since " << range.start().run() << " "
461 << range.start().event()
462 << " till " << range.stop().run() << " "
463 << range.stop().event() );
464 }
465 }
466 else {
467 ATH_MSG_DEBUG( "No range found " );
468 }
469 }
470
471 // Simulation and digitization parameters:
472
473 if ( detStore()->retrieve(attrList, "/Simulation/Parameters").isFailure() ) {
474 // May not have been added - just a warning
475 ATH_MSG_WARNING( "Could not retrieve Simulation parameters" );
476 }
477 else {
478 ATH_MSG_DEBUG( "Retrieved Simulation parameters" );
479 std::ostringstream attrStr;
480 attrList->print( attrStr );
481 ATH_MSG_DEBUG( "Attribute list " << attrStr.str() );
482 }
483
484 if (detStore()->retrieve(attrList, "/Digitization/Parameters").isFailure()) {
485 // May not have been added - just a warning
486 ATH_MSG_WARNING( "Could not retrieve Digitization parameters" );
487 }
488 else {
489 ATH_MSG_DEBUG( "Retrieved Digitization parameters" );
490 std::ostringstream attrStr;
491 attrList->print( attrStr );
492 ATH_MSG_DEBUG( "Attribute list " << attrStr.str() );
493 }
494 }
495
496
497 // IOVDbTestMDTEleMapColl
498
499// if (m_readWriteCool) {
500
501 const IOVDbTestMDTEleMapColl* elemMapColl = nullptr;
502 ATH_CHECK( detStore()->retrieve(elemMapColl, "/IOVDbTest/IOVDbTestMDTEleMapColl") );
503 ATH_MSG_INFO( "Retrieved IOVDbTestMDTEleMapColl " );
504
505 // Make sure the channel vector is filled
506 if (elemMapColl->size() != elemMapColl->chan_size()) {
507 ATH_MSG_ERROR( "Must fill in channel numbers! Number of objects: " << elemMapColl->size()
508 << " Number of channels: " << elemMapColl->chan_size() );
509 return(StatusCode::FAILURE);
510 }
511 // Print out IOVs if they are there
512 bool hasIOVs = (elemMapColl->iov_size() == elemMapColl->size());
515 for (unsigned int i = 0; i < elemMapColl->size(); ++i, ++itChan) {
516 const IOVDbTestMDTEleMap* elemMap = (*elemMapColl)[i];
517 msg() << MSG::INFO << "Found " << elemMap->name()
518 << " run " << elemMap->runNumber()
519 << " event " << elemMap->eventNumber()
520 << " time " << elemMap->timeStamp()
521 << " channel " << (*itChan);
522 if(hasIOVs) {
523 msg() << MSG::INFO << " iov " << (*itIOV);
524 ++itIOV;
525 }
526 msg() << MSG::INFO << endmsg;
527 }
528// }
529 return StatusCode::SUCCESS;
530}
531
532// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
533
534StatusCode IOVDbTestAlg::execute (const EventContext& ctx) const {
535
536 // There are different scenario for conditions data:
537 //
538 // A) Calculating and writing conditions
539 //
540 // 1) Loop over events and accumulate "averages"
541 //
542 // 2) At the desired moment, e.g. after N events or at the end
543 // of the job, calculate the conditions data to be written
544 // out by creating the corresponding objects and store in the
545 // DetectorStore
546 //
547 // 3) Write out objects with the IAthenaOutputStreamTool - done
548 // in finalize.
549 //
550 // 4) Finally, one must "register" the objects written out in
551 // the IOV DB. This writes and IOV and a ref to each object,
552 // and is done in the finalize method.
553 //
554 // B) Reading back in conditions data to analyse it
555 //
556 // 1) Aside from specifying the correct jobOptions, this is
557 // simply done by doing a standard StoreGate retrieve from
558 // the DetectorStore.
559
560 if (msgLvl (MSG::DEBUG)) {
561 msg() << MSG::DEBUG << "Event (run,ev,lb:time): [" << ctx.eventID().run_number() << "," << ctx.eventID().event_number();
562 if (m_printLB) msg() << "," << ctx.eventID().lumi_block();
563 msg() << ":" << ctx.eventID().time_stamp() << "]" << endmsg;
564 }
565
567
568 // We create the conditions objects only at run == 2, event == 5
569 if (2 != ctx.eventID().run_number() || 5 != ctx.eventID().event_number()) {
570 ATH_MSG_DEBUG( "Event NOT selected for creating conditions objects " );
571 return StatusCode::SUCCESS;
572 }
573
574 ATH_MSG_DEBUG( "Creating condtions objects " );
576
577 // Read objects from DetectorStore
578 if(!m_noStream){
580 }
581 }
582 else {
583
584 ATH_MSG_DEBUG( "Calling printCondObjects" <<m_online<< "\t"<<ctx.eventID().run_number()<<"\t"<<ctx.eventID().event_number() );
585
586 // Read objects from DetectorStore
587 if (m_online && 2 == ctx.eventID().run_number() && 9 == ctx.eventID().event_number())
590 }
591
592 return StatusCode::SUCCESS;
593}
594
595// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
596
598 ATH_MSG_INFO( "in finalize()" );
599
600 if (m_writeCondObjs) {
601 // Stream out and register objects here
602 ATH_MSG_DEBUG( "Stream out objects directly " );
604 ATH_MSG_DEBUG( "Streamed out OK " );
605 }
606 if(m_regIOV) {
608 ATH_MSG_DEBUG( "Register OK " );
609 }
610
611 return StatusCode::SUCCESS;
612}
613
614
615
616// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
617
618StatusCode
620 ATH_MSG_DEBUG( "entering streamOutCondObjects " );
621 ATH_CHECK( m_streamer->connectOutput() );
622
624 if (!m_writeOnlyCool) {
625 typeKeys.emplace_back("IOVDbTestMDTEleMap", "");
626 typeKeys.emplace_back("IOVDbTestAmdbCorrection", "");
627 typeKeys.emplace_back("IOVDbTestMDTEleMapColl", "");
628 }
629 typeKeys.resize(3);
630
631 ATH_MSG_DEBUG( "Stream out for pairs:" );
632 for (unsigned int i = 0; i < typeKeys.size(); ++i) {
633 ATH_MSG_DEBUG( typeKeys[i].first << " " << typeKeys[i].second << " " );
634 }
635
636 ATH_CHECK( m_streamer->streamObjects(typeKeys) );
637 ATH_CHECK( m_streamer->commitOutput() );
638
639 return StatusCode::SUCCESS;
640}
641
642
643// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
644
645StatusCode
647 ATH_MSG_DEBUG( "entering registerCondObject " );
648
649 // Register the IOV DB with the conditions data written out
650 std::string tag = "no tag";
651 if (m_tagID!="") {
652 tag = "tag MDTEleMap_" + m_tagID;
653 ATH_CHECK( m_regSvc->registerIOV("IOVDbTestMDTEleMap", "MDTEleMap_"+m_tagID,m_run,IOVTime::MAXRUN,IOVTime::MINEVENT,IOVTime::MAXEVENT) );
654 } else {
655 ATH_CHECK( m_regSvc->registerIOV("IOVDbTestMDTEleMap", "") );
656 }
657 ATH_MSG_DEBUG( "registered IOVDbTestMDTEleMap with " << tag );
658
659 // For IOVDbTestAmdbCorrection use time (in sec)
660 uint64_t start=static_cast<long long>(m_regTime)*1000000000LL;
661 uint64_t stop = IOVTime::MAXTIMESTAMP;
662 tag = "no tag";
663 if (m_tagID!="") {
664 tag = "tag AmdbCorrection_" + m_tagID;
665 ATH_CHECK( m_regSvc->registerIOV("IOVDbTestAmdbCorrection", "AmdbCorrection_"+m_tagID, start, stop) );
666 } else {
667 ATH_CHECK( m_regSvc->registerIOV("IOVDbTestAmdbCorrection", "", start, stop) );
668 }
669 ATH_MSG_DEBUG( "registered IOVDbTestAmdbCorrection with " << tag );
670 if (m_readWriteCool) {
671
672 // Can only write out AttrList's if this is NOT write and reg in two steps
673 if (!m_twoStepWriteReg) {
674
675 // Using COOL, write out attrlist and collection of attrlists
676 tag = "no tag";
677 if (m_tagID!="") {
678 tag = "tag AttrList_" + m_tagID;
679 ATH_CHECK( m_regSvc->registerIOV("AthenaAttributeList","/IOVDbTest/IOVDbTestAttrList","AttrList_"+m_tagID,m_run,IOVTime::MAXRUN,IOVTime::MINEVENT,IOVTime::MAXEVENT) );
680 } else {
681 ATH_CHECK( m_regSvc->registerIOV("AthenaAttributeList","/IOVDbTest/IOVDbTestAttrList","") );
682 }
683 ATH_MSG_DEBUG( "registered AthenaAttributeList with " << tag );
684 if (m_fancylist) {
685 // register Fancy AttributeList
686 tag = "no tag";
687 if (m_tagID!="") {
688 tag = "tag FancyList_" + m_tagID;
689 ATH_CHECK( m_regSvc->registerIOV("AthenaAttributeList","/IOVDbTest/IOVDbTestFancyList","FancyList_"+m_tagID,m_run,IOVTime::MAXRUN,IOVTime::MINEVENT,IOVTime::MAXEVENT) );
690 } else {
691 ATH_CHECK( m_regSvc->registerIOV("AthenaAttributeList", "/IOVDbTest/IOVDbTestFancyList","") );
692 }
693 ATH_MSG_DEBUG ( "registered Fancy AthenaAttributeList with " << tag );
694 }
695 // attrlist collection
696 tag = "no tag";
697 if (m_tagID!="") {
698 tag = "tag AttrListColl_" + m_tagID;
699 ATH_CHECK( m_regSvc->registerIOV("CondAttrListCollection","AttrListColl_"+m_tagID,m_run,IOVTime::MAXRUN,IOVTime::MINEVENT,IOVTime::MAXEVENT) );
700 } else {
701 ATH_CHECK( m_regSvc->registerIOV("CondAttrListCollection", "") );
702 }
703 ATH_MSG_DEBUG( "registered CondAttrListCollection with " << tag );
704 }
705
706 // mdtMapColl
707 tag = "no tag";
708 if (m_tagID!="") {
709 tag = "tag MDTEleMapColl_" + m_tagID;
710 ATH_CHECK( m_regSvc->registerIOV("IOVDbTestMDTEleMapColl","MDTEleMapColl_"+m_tagID,m_run,IOVTime::MAXRUN,IOVTime::MINEVENT,IOVTime::MAXEVENT) );
711 } else {
712 ATH_CHECK( m_regSvc->registerIOV("IOVDbTestMDTEleMapColl","") );
713 }
714 ATH_MSG_DEBUG( "registered IOVDbTestMDTEleMapColl with " << tag );
715 }
716
717 return StatusCode::SUCCESS;
718
719}
720
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
Interface to an output stream tool.
This is an interface to a tool used to register conditions objects in the Interval of Validity (IOV) ...
CondMultChanCollection< IOVDbTestMDTEleMap > IOVDbTestMDTEleMapColl
This typedef represents a collection of IOVDbTestMDTEleMap objects.
#define y
#define x
const ServiceHandle< StoreGateSvc > & detStore() const
bool msgLvl(const MSG::Level lvl) const
An algorithm that can be simultaneously executed in multiple threads.
An AttributeList represents a logical row of attributes in a metadata table.
void print(std::ostream &os) const
print to simulate function provided by old POOL AttributeList
This class is a collection of AttributeLists where each one is associated with a channel number.
const_iterator end() const
name_size_type name_size() const
number of Chan/Name pairs
bool add(ChanNum chanNum, const AttributeList &attributeList)
Adding in chan/attrList pairs.
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
iov_const_iterator iov_end() const
name_const_iterator name_end() const
name_const_iterator chanNamePair(ChanNum chanNum) const
Access to Chan/Name pairs via channel number: returns map iterator.
iov_const_iterator chanIOVPair(ChanNum chanNum) const
Access to Chan/IOV pairs via channel number: returns map iterator.
ChanAttrListMap::const_iterator const_iterator
ChanNameMap::const_iterator name_const_iterator
ChanIOVMap::const_iterator iov_const_iterator
chan_size_type chan_size() const
number of channels
iov_size_type iov_size() const
number of IOVs
void add(ChanNum chanNum)
Adding in channel numbers.
chan_const_iterator chan_begin() const
Access to Channel numbers via iterators.
iov_const_iterator iov_begin() const
Access to IOVs via iterators.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
std::vector< TypeKeyPair > TypeKeyPairs
BooleanProperty m_writeNewTag
BooleanProperty m_regIOV
virtual StatusCode finalize() override
StatusCode streamOutCondObjects()
IntegerProperty m_run
void waitForSecond() const
BooleanProperty m_twoStepWriteReg
StringProperty m_tagID
virtual StatusCode initialize() override
BooleanProperty m_online
BooleanProperty m_fancylist
BooleanProperty m_noStream
BooleanProperty m_readInInit
BooleanProperty m_createExtraChans
BooleanProperty m_writeCondObjs
StatusCode readWithBeginRun()
virtual StatusCode execute(const EventContext &ctx) const override
BooleanProperty m_readWriteCool
IOVDbTestAlg(const std::string &name, ISvcLocator *pSvcLocator)
virtual ~IOVDbTestAlg()
BooleanProperty m_printLB
ToolHandle< IAthenaOutputStreamTool > m_streamer
IntegerProperty m_regTime
BooleanProperty m_readNewTag
ServiceHandle< IIOVRegistrationSvc > m_regSvc
StatusCode registerCondObjects()
BooleanProperty m_nameChans
StatusCode printCondObjects() const
StringProperty m_streamName
BooleanProperty m_writeOnlyCool
StatusCode createCondObjects(const EventContext &ctx) const
HepGeom::Point3D< double > getTranslation() const
void set(const HepGeom::Point3D< double > &trans, const HepGeom::Point3D< double > &rot, const std::string &name)
HepGeom::Point3D< double > getRotation() const
const std::string & name() const
void set(int runNumber, int eventNumber, const std::string &name)
const std::string & name() const
Validity Range object.
Definition IOVRange.h:30
const IOVTime & stop() const
Definition IOVRange.h:39
const IOVTime & start() const
Definition IOVRange.h:38
Basic time unit for IOVSvc.
Definition IOVTime.h:33
static constexpr uint64_t MAXTIMESTAMP
Definition IOVTime.h:58
static constexpr uint32_t MAXRUN
Definition IOVTime.h:48
uint32_t event() const noexcept
Definition IOVTime.h:106
static constexpr uint32_t MINEVENT
Definition IOVTime.h:50
uint32_t run() const noexcept
Definition IOVTime.h:105
static constexpr uint32_t MAXEVENT
Definition IOVTime.h:51