17#include "GaudiKernel/IIncidentSvc.h"
18#include "GaudiKernel/Incident.h"
19#include "GaudiKernel/GaudiException.h"
20#include "GaudiKernel/IToolSvc.h"
23#include "CoralBase/Attribute.h"
24#include "CoralBase/Blob.h"
25#include "CoralBase/AttributeListSpecification.h"
38 m_regSvc(
"IOVRegistrationSvc", name),
63 while((msgqueue_id = msgget(key, 0660)) == -1) {
64 printf(
"waiting for message here.\n");
67 printf(
"Recieving a message ...\n");
70 msgrcv(msgqueue_id,
reinterpret_cast< msgbuf *
>(&qbuf), 80, 123, 0);
72 printf(
"Type: %ld Text: %s\n", qbuf.mtype, qbuf.mtext);
74 msgctl(msgqueue_id, IPC_RMID, 0);
80 msg() << MSG::INFO <<
"IOVDbTestAlg::testCallBack callback invoked for keys: i = " << i <<
" ";
81 for (std::list<std::string>::const_iterator itr=keys.begin(); itr!=keys.end(); ++itr) {
85 return StatusCode::SUCCESS;
94 if (m_writeCondObjs) {
95 m_streamer =
"AthenaOutputStreamTool/" + m_streamName;
112 if (!m_online)
return StatusCode::SUCCESS;
116 ATH_MSG_INFO(
"Registered callback for IOVDbTestAlg::testCallBack" );
119 return StatusCode::SUCCESS;
135 incSvc->fireIncident( Incident(name(), IncidentType::BeginRun, Gaudi::Hive::currentContext()) );
137 return StatusCode::SUCCESS;
148 unsigned long long timestamp = ctx.eventID().time_stamp();
150 elemMap->
set(ctx.eventID().time_stamp(),
"mdt element map");
152 elemMap->
set(ctx.eventID().run_number(), ctx.eventID().event_number(),
"mdt element map");
162 unsigned int offset = 0;
164 for (
unsigned int i = 0; i < 10; ++i) {
167 unsigned long long timestamp = ctx.eventID().time_stamp();
169 elemMap->
set(ctx.eventID().time_stamp() + 10*i,
"mdt element map");
171 elemMap->
set(ctx.eventID().run_number() + i, ctx.eventID().event_number(),
"mdt element map");
174 elemMapColl->
add(2*i+1+i + offset);
178 ATH_CHECK(
detStore()->record(elemMapColl,
"/IOVDbTest/IOVDbTestMDTEleMapColl") );
182 HepGeom::Point3D<double>
x(1.0, 2.0, 3.0);
183 HepGeom::Point3D<double>
y(4.0, 5.0, 6.0);
186 x = HepGeom::Point3D<double>(11.0, 22.0, 33.0);
187 y = HepGeom::Point3D<double>(44.0, 55.0, 66.0);
189 amdbCorr->
set(
x,
y,
"amdb correction");
196 coral::AttributeListSpecification* attrSpec =
new coral::AttributeListSpecification();
197 attrSpec->extend(
"xPosition",
"float");
198 attrSpec->extend(
"id",
"int");
199 attrSpec->extend(
"name",
"string");
201 if (!attrSpec->size()) {
203 return(StatusCode::FAILURE);
212 (*attrList)[
"xPosition"].setValue((
float)
m_run);
213 (*attrList)[
"id"].setValue((
int)7);
214 (*attrList)[
"name"].setValue(std::string(
"TestAttrList"));
217 (*attrList)[
"xPosition"].setValue((
float)125.0);
218 (*attrList)[
"id"].setValue((
int)27);
219 (*attrList)[
"name"].setValue(std::string(
"TestAttrListNEWTAG"));
221 std::ostringstream attrStr1;
223 attrList->toOutputStream( attrStr1 );
232 coral::AttributeListSpecification* fanSpec =
new coral::AttributeListSpecification();
233 fanSpec->extend(
"FanBool",
"bool");
234 fanSpec->extend(
"FanInt",
"int");
235 fanSpec->extend(
"FanUInt",
"unsigned int");
236 fanSpec->extend(
"FanI64",
"long long");
237 fanSpec->extend(
"FanU64",
"unsigned long long");
238 fanSpec->extend(
"FanFloat",
"float");
239 fanSpec->extend(
"FanDouble",
"double");
240 fanSpec->extend(
"FanSmallString",
"string");
241 fanSpec->extend(
"FanBigString",
"string");
242 fanSpec->extend(
"FanBlob",
"blob");
245 (*fanList)[
"FanBool"].data<
bool>()=
true;
246 (*fanList)[
"FanInt"].data<
int>()=-12345;
247 (*fanList)[
"FanUInt"].data<
unsigned int>()=12345;
248 (*fanList)[
"FanI64"].data<
long long>()=-98765432100LL;
249 (*fanList)[
"FanU64"].data<
unsigned long long>()=98765432100LL;
250 (*fanList)[
"FanFloat"].data<
float>()=1.2345;
251 (*fanList)[
"FanDouble"].data<
double>()=1.23456789;
252 (*fanList)[
"FanSmallString"].data<std::string>()=
"small string";
253 (*fanList)[
"FanBigString"].data<std::string>()=
"potentially long string";
255 coral::Blob& blob=(*fanList)[
"FanBlob"].data<coral::Blob>();
256 unsigned int blobsize=2000;
257 blob.resize(blobsize);
258 unsigned char* p=
static_cast<unsigned char*
>(blob.startingAddress());
259 for (
unsigned int i=0;i<blobsize;++i,++p) *p=(i % 256);
261 std::ostringstream fanstr;
262 fanList->toOutputStream(fanstr);
273 coral::AttributeList attrList0(*attrSpec);
274 attrList0[
"xPosition"].setValue((
float)35.0);
275 attrList0[
"id"].setValue((
int)17);
276 attrList0[
"name"].setValue(std::string(
"TestAttrList"));
279 std::ostringstream attrStr2;
280 attrList0.toOutputStream( attrStr2 );
281 ATH_MSG_DEBUG(
"ChanNum " << chanNum <<
" Attribute list " << attrStr2.str() );
282 attrListColl->
add(chanNum, attrList0);
284 coral::AttributeList attrList1(*attrSpec);
285 attrList1[
"xPosition"].setValue((
float)45.0);
286 attrList1[
"id"].setValue((
int)27);
287 attrList1[
"name"].setValue(std::string(
"TestAttrList"));
290 std::ostringstream attrStr3;
291 attrList1.toOutputStream( attrStr3 );
292 ATH_MSG_DEBUG(
"ChanNum " << chanNum <<
" Attribute list " << attrStr3.str() );
293 attrListColl->
add(chanNum, attrList1);
295 coral::AttributeList attrList2(*attrSpec);
296 attrList2[
"xPosition"].setValue((
float)55.0);
297 attrList2[
"id"].setValue((
int)37);
298 attrList2[
"name"].setValue(std::string(
"TestAttrList"));
301 std::ostringstream attrStr4;
302 attrList2.toOutputStream( attrStr4 );
303 ATH_MSG_DEBUG(
"ChanNum " << chanNum <<
" Attribute list " << attrStr4.str() );
304 attrListColl->
add(chanNum, attrList2);
308 coral::AttributeList attrList3(*attrSpec);
309 attrList3[
"xPosition"].setValue((
float)65.0);
310 attrList3[
"id"].setValue((
int)47);
311 attrList3[
"name"].setValue(std::string(
"TestAttrList"));
314 std::ostringstream attrStr5;
315 attrList3.toOutputStream( attrStr5 );
316 ATH_MSG_DEBUG(
"ChanNum " << chanNum <<
" Attribute list " << attrStr5.str() );
317 attrListColl->
add(chanNum, attrList3);
321 attrListColl->
add(chanNum, range);
322 ATH_MSG_DEBUG(
"Add min : since " << range.start().run() <<
" " << range.start().event()
323 <<
" till " << range.stop().run() <<
" " << range.stop().event() );
325 coral::AttributeList attrList4(*attrSpec);
326 attrList4[
"xPosition"].setValue((
float)75.0);
327 attrList4[
"id"].setValue((
int)57);
328 attrList4[
"name"].setValue(std::string(
"TestAttrList"));
331 std::ostringstream attrStr6;
332 attrList4.toOutputStream( attrStr6 );
333 ATH_MSG_DEBUG(
"ChanNum " << chanNum <<
" Attribute list " << attrStr6.str() );
334 attrListColl->
add(chanNum, attrList4);
338 attrListColl->
add(chanNum, range1);
345 citr!=attrListColl->
end();++citr) {
347 std::ostringstream name;
348 name <<
"Name_" << chan;
349 attrListColl->
add(chan,name.str());
353 ATH_CHECK(
detStore()->record(attrListColl,
"/IOVDbTest/IOVDbTestAttrListColl") );
355 return StatusCode::SUCCESS;
377 ATH_CHECK(
detStore()->retrieve(amdbCorr,
"/IOVDbTest/IOVDbTestAMDBCorrection") );
378 ATH_MSG_INFO (
"Retrieved /IOVDbTest/IOVDbTestAMDBCorrection" );
381 HepGeom::Point3D<double> rot = amdbCorr->
getRotation();
384 <<
" trans " << trans.x() <<
" " << trans.y() <<
" " << trans.z()
385 <<
" rot " << rot.x() <<
" " << rot.y() <<
" " << rot.z() );
391 ATH_CHECK(
detStore()->retrieve(amdbCorr,
"/IOVDbTest/IOVDbTestAMDBCorrection-NEWTAG") );
392 ATH_MSG_INFO(
"Retrieved /IOVDbTest/IOVDbTestAMDBCorrection-NEWTAG" );
395 HepGeom::Point3D<double> rot = amdbCorr->
getRotation();
398 <<
" trans " << trans.x() <<
" " << trans.y() <<
" " << trans.z()
399 <<
" rot " << rot.x() <<
" " << rot.y() <<
" " << rot.z() );
411 std::ostringstream attrStr1;
412 attrList->
print( attrStr1 );
417 ATH_CHECK(
detStore()->retrieve(attrList,
"/IOVDbTest/IOVDbTestAttrList-NEWTAG") );
420 std::ostringstream attrStr1;
421 attrList->
print( attrStr1 );
422 ATH_MSG_DEBUG(
"Attribute list NEWTAG: " << attrStr1.str() );
429 std::ostringstream fanstr;
430 attrList->
print( fanstr );
433 const coral::Blob& blob=(*attrList)[
"FanBlob"].data<coral::Blob>();
434 const unsigned char* p=
static_cast<const unsigned char*
>
435 (blob.startingAddress());
437 for (
int i=0;i<blob.size();++i,++p)
if (*p!=(i % 256)) ++nerr;
439 " data mismatches!" );
443 ATH_CHECK(
detStore()->retrieve(attrListColl,
"/IOVDbTest/IOVDbTestAttrListColl") );
447 std::ostringstream attrStr2;
452 for (; first != last; ++first) {
454 if (
msgLvl (MSG::DEBUG)) {
455 std::ostringstream attrStr1;
456 (*first).second.toOutputStream( attrStr1 );
457 msg() << MSG::DEBUG <<
"ChanNum " << (*first).first;
463 msg() << MSG::DEBUG <<
" name " << nitr->second;
465 msg() << MSG::DEBUG <<
466 " Attribute list " << attrStr1.str() <<
endmsg;
472 if (iovIt != attrListColl->
iov_end()) {
473 const IOVRange& range = (*iovIt).second;
474 if(range.start().isTimestamp()) {
475 ATH_MSG_DEBUG(
"Range timestamp : since " << range.start().timestamp()
476 <<
" till " << range.stop().timestamp() );
479 ATH_MSG_DEBUG(
"Range R/E : since " << range.start().run() <<
" "
480 << range.start().event()
481 <<
" till " << range.stop().run() <<
" "
482 << range.stop().event() );
492 if (
detStore()->retrieve(attrList,
"/Simulation/Parameters").isFailure() ) {
498 std::ostringstream attrStr;
499 attrList->
print( attrStr );
503 if (
detStore()->retrieve(attrList,
"/Digitization/Parameters").isFailure()) {
509 std::ostringstream attrStr;
510 attrList->
print( attrStr );
521 ATH_CHECK(
detStore()->retrieve(elemMapColl,
"/IOVDbTest/IOVDbTestMDTEleMapColl") );
526 ATH_MSG_ERROR(
"Must fill in channel numbers! Number of objects: " << elemMapColl->
size()
527 <<
" Number of channels: " << elemMapColl->
chan_size() );
528 return(StatusCode::FAILURE);
531 bool hasIOVs = (elemMapColl->
iov_size() == elemMapColl->
size());
534 for (
unsigned int i = 0; i < elemMapColl->
size(); ++i, ++itChan) {
536 msg() << MSG::INFO <<
"Found " << elemMap->
name()
540 <<
" channel " << (*itChan);
542 msg() << MSG::INFO <<
" iov " << (*itIOV);
548 return StatusCode::SUCCESS;
579 if (
msgLvl (MSG::DEBUG)) {
580 msg() << MSG::DEBUG <<
"Event (run,ev,lb:time): [" << ctx.eventID().run_number() <<
"," << ctx.eventID().event_number();
581 if (
m_printLB)
msg() <<
"," << ctx.eventID().lumi_block();
582 msg() <<
":" << ctx.eventID().time_stamp() <<
"]" <<
endmsg;
588 if (2 != ctx.eventID().run_number() || 5 != ctx.eventID().event_number()) {
589 ATH_MSG_DEBUG(
"Event NOT selected for creating conditions objects " );
590 return StatusCode::SUCCESS;
603 ATH_MSG_DEBUG(
"Calling printCondObjects" <<
m_online<<
"\t"<<ctx.eventID().run_number()<<
"\t"<<ctx.eventID().event_number() );
606 if (
m_online && 2 == ctx.eventID().run_number() && 9 == ctx.eventID().event_number())
611 return StatusCode::SUCCESS;
630 return StatusCode::SUCCESS;
644 typeKeys.emplace_back(
"IOVDbTestMDTEleMap",
"");
645 typeKeys.emplace_back(
"IOVDbTestAmdbCorrection",
"");
646 typeKeys.emplace_back(
"IOVDbTestMDTEleMapColl",
"");
651 for (
unsigned int i = 0; i < typeKeys.size(); ++i) {
652 ATH_MSG_DEBUG( typeKeys[i].first <<
" " << typeKeys[i].second <<
" " );
658 return StatusCode::SUCCESS;
669 std::string tag =
"no tag";
671 tag =
"tag MDTEleMap_" +
m_tagID;
676 ATH_MSG_DEBUG(
"registered IOVDbTestMDTEleMap with " << tag );
679 uint64_t start=
static_cast<long long>(
m_regTime)*1000000000LL;
683 tag =
"tag AmdbCorrection_" +
m_tagID;
688 ATH_MSG_DEBUG(
"registered IOVDbTestAmdbCorrection with " << tag );
697 tag =
"tag AttrList_" +
m_tagID;
700 ATH_CHECK(
m_regSvc->registerIOV(
"AthenaAttributeList",
"/IOVDbTest/IOVDbTestAttrList",
"") );
702 ATH_MSG_DEBUG(
"registered AthenaAttributeList with " << tag );
707 tag =
"tag FancyList_" +
m_tagID;
710 ATH_CHECK(
m_regSvc->registerIOV(
"AthenaAttributeList",
"/IOVDbTest/IOVDbTestFancyList",
"") );
712 ATH_MSG_DEBUG (
"registered Fancy AthenaAttributeList with " << tag );
717 tag =
"tag AttrListColl_" +
m_tagID;
722 ATH_MSG_DEBUG(
"registered CondAttrListCollection with " << tag );
728 tag =
"tag MDTEleMapColl_" +
m_tagID;
733 ATH_MSG_DEBUG(
"registered IOVDbTestMDTEleMapColl with " << tag );
736 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
This is an interface to a tool used to register conditions objects in the Interval of Validity (IOV) ...
StatusCode IOVDbTestAlg::initialize ATLAS_NOT_THREAD_SAFE()
Install fatal handler with default options.
CondMultChanCollection< IOVDbTestMDTEleMap > IOVDbTestMDTEleMapColl
This typedef represents a collection of IOVDbTestMDTEleMap objects.
#define IOVSVC_CALLBACK_ARGS_P(I, K)
short hand for IOVSvc call back argument list, to be used when access to formal arguments is needed,...
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
IOVVec::const_iterator iov_const_iterator
iov_size_type iov_size() const
number of IOVs
void add(ChanNum chanNum)
Adding in channel numbers.
ChanVec::const_iterator chan_const_iterator
chan_const_iterator chan_begin() const
Access to Channel numbers via iterators.
iov_const_iterator iov_begin() const
Access to IOVs via iterators.
an iterator over instances of a given type in StoreGateSvc.
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.
BooleanProperty m_writeNewTag
virtual StatusCode finalize() override
StatusCode streamOutCondObjects()
void waitForSecond() const
BooleanProperty m_twoStepWriteReg
StatusCode testCallBack(IOVSVC_CALLBACK_ARGS)
BooleanProperty m_fancylist
BooleanProperty m_noStream
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)
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
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
const IOVTime & stop() const
const IOVTime & start() const
Basic time unit for IOVSvc.
static constexpr uint64_t MAXTIMESTAMP
static constexpr uint32_t MAXRUN
uint32_t event() const noexcept
static constexpr uint32_t MINEVENT
uint32_t run() const noexcept
static constexpr uint32_t MAXEVENT