17#include "CoralBase/Attribute.h"
18#include "CoralBase/Blob.h"
19#include "CoralBase/AttributeListSpecification.h"
32 m_regSvc(
"IOVRegistrationSvc", name),
57 while((msgqueue_id = msgget(key, 0660)) == -1) {
58 printf(
"waiting for message here.\n");
61 printf(
"Recieving a message ...\n");
64 msgrcv(msgqueue_id,
reinterpret_cast< msgbuf *
>(&qbuf), 80, 123, 0);
66 printf(
"Type: %ld Text: %s\n", qbuf.mtype, qbuf.mtext);
68 msgctl(msgqueue_id, IPC_RMID, 0);
89 return StatusCode::SUCCESS;
100 unsigned long long timestamp = ctx.eventID().time_stamp();
102 elemMap->
set(ctx.eventID().time_stamp(),
"mdt element map");
104 elemMap->
set(ctx.eventID().run_number(), ctx.eventID().event_number(),
"mdt element map");
114 unsigned int offset = 0;
116 for (
unsigned int i = 0; i < 10; ++i) {
119 unsigned long long timestamp = ctx.eventID().time_stamp();
121 elemMap->
set(ctx.eventID().time_stamp() + 10*i,
"mdt element map");
123 elemMap->
set(ctx.eventID().run_number() + i, ctx.eventID().event_number(),
"mdt element map");
126 elemMapColl->
add(2*i+1+i + offset);
130 ATH_CHECK(
detStore()->record(elemMapColl,
"/IOVDbTest/IOVDbTestMDTEleMapColl") );
134 HepGeom::Point3D<double>
x(1.0, 2.0, 3.0);
135 HepGeom::Point3D<double>
y(4.0, 5.0, 6.0);
138 x = HepGeom::Point3D<double>(11.0, 22.0, 33.0);
139 y = HepGeom::Point3D<double>(44.0, 55.0, 66.0);
141 amdbCorr->
set(
x,
y,
"amdb correction");
148 coral::AttributeListSpecification* attrSpec =
new coral::AttributeListSpecification();
149 attrSpec->extend(
"xPosition",
"float");
150 attrSpec->extend(
"id",
"int");
151 attrSpec->extend(
"name",
"string");
153 if (!attrSpec->size()) {
155 return(StatusCode::FAILURE);
164 (*attrList)[
"xPosition"].setValue((
float)
m_run);
165 (*attrList)[
"id"].setValue((
int)7);
166 (*attrList)[
"name"].setValue(std::string(
"TestAttrList"));
169 (*attrList)[
"xPosition"].setValue((
float)125.0);
170 (*attrList)[
"id"].setValue((
int)27);
171 (*attrList)[
"name"].setValue(std::string(
"TestAttrListNEWTAG"));
173 std::ostringstream attrStr1;
175 attrList->toOutputStream( attrStr1 );
184 coral::AttributeListSpecification* fanSpec =
new coral::AttributeListSpecification();
185 fanSpec->extend(
"FanBool",
"bool");
186 fanSpec->extend(
"FanInt",
"int");
187 fanSpec->extend(
"FanUInt",
"unsigned int");
188 fanSpec->extend(
"FanI64",
"long long");
189 fanSpec->extend(
"FanU64",
"unsigned long long");
190 fanSpec->extend(
"FanFloat",
"float");
191 fanSpec->extend(
"FanDouble",
"double");
192 fanSpec->extend(
"FanSmallString",
"string");
193 fanSpec->extend(
"FanBigString",
"string");
194 fanSpec->extend(
"FanBlob",
"blob");
197 (*fanList)[
"FanBool"].data<
bool>()=
true;
198 (*fanList)[
"FanInt"].data<
int>()=-12345;
199 (*fanList)[
"FanUInt"].data<
unsigned int>()=12345;
200 (*fanList)[
"FanI64"].data<
long long>()=-98765432100LL;
201 (*fanList)[
"FanU64"].data<
unsigned long long>()=98765432100LL;
202 (*fanList)[
"FanFloat"].data<
float>()=1.2345;
203 (*fanList)[
"FanDouble"].data<
double>()=1.23456789;
204 (*fanList)[
"FanSmallString"].data<std::string>()=
"small string";
205 (*fanList)[
"FanBigString"].data<std::string>()=
"potentially long string";
207 coral::Blob& blob=(*fanList)[
"FanBlob"].data<coral::Blob>();
208 unsigned int blobsize=2000;
209 blob.resize(blobsize);
210 unsigned char* p=
static_cast<unsigned char*
>(blob.startingAddress());
211 for (
unsigned int i=0;i<blobsize;++i,++p) *p=(i % 256);
213 std::ostringstream fanstr;
214 fanList->toOutputStream(fanstr);
225 coral::AttributeList attrList0(*attrSpec);
226 attrList0[
"xPosition"].setValue((
float)35.0);
227 attrList0[
"id"].setValue((
int)17);
228 attrList0[
"name"].setValue(std::string(
"TestAttrList"));
231 std::ostringstream attrStr2;
232 attrList0.toOutputStream( attrStr2 );
233 ATH_MSG_DEBUG(
"ChanNum " << chanNum <<
" Attribute list " << attrStr2.str() );
234 attrListColl->
add(chanNum, attrList0);
236 coral::AttributeList attrList1(*attrSpec);
237 attrList1[
"xPosition"].setValue((
float)45.0);
238 attrList1[
"id"].setValue((
int)27);
239 attrList1[
"name"].setValue(std::string(
"TestAttrList"));
242 std::ostringstream attrStr3;
243 attrList1.toOutputStream( attrStr3 );
244 ATH_MSG_DEBUG(
"ChanNum " << chanNum <<
" Attribute list " << attrStr3.str() );
245 attrListColl->
add(chanNum, attrList1);
247 coral::AttributeList attrList2(*attrSpec);
248 attrList2[
"xPosition"].setValue((
float)55.0);
249 attrList2[
"id"].setValue((
int)37);
250 attrList2[
"name"].setValue(std::string(
"TestAttrList"));
253 std::ostringstream attrStr4;
254 attrList2.toOutputStream( attrStr4 );
255 ATH_MSG_DEBUG(
"ChanNum " << chanNum <<
" Attribute list " << attrStr4.str() );
256 attrListColl->
add(chanNum, attrList2);
260 coral::AttributeList attrList3(*attrSpec);
261 attrList3[
"xPosition"].setValue((
float)65.0);
262 attrList3[
"id"].setValue((
int)47);
263 attrList3[
"name"].setValue(std::string(
"TestAttrList"));
266 std::ostringstream attrStr5;
267 attrList3.toOutputStream( attrStr5 );
268 ATH_MSG_DEBUG(
"ChanNum " << chanNum <<
" Attribute list " << attrStr5.str() );
269 attrListColl->
add(chanNum, attrList3);
273 attrListColl->
add(chanNum, range);
274 ATH_MSG_DEBUG(
"Add min : since " << range.start().run() <<
" " << range.start().event()
275 <<
" till " << range.stop().run() <<
" " << range.stop().event() );
277 coral::AttributeList attrList4(*attrSpec);
278 attrList4[
"xPosition"].setValue((
float)75.0);
279 attrList4[
"id"].setValue((
int)57);
280 attrList4[
"name"].setValue(std::string(
"TestAttrList"));
283 std::ostringstream attrStr6;
284 attrList4.toOutputStream( attrStr6 );
285 ATH_MSG_DEBUG(
"ChanNum " << chanNum <<
" Attribute list " << attrStr6.str() );
286 attrListColl->
add(chanNum, attrList4);
290 attrListColl->
add(chanNum, range1);
297 citr!=attrListColl->
end();++citr) {
299 std::ostringstream name;
300 name <<
"Name_" << chan;
301 attrListColl->
add(chan,name.str());
305 ATH_CHECK(
detStore()->record(attrListColl,
"/IOVDbTest/IOVDbTestAttrListColl") );
307 return StatusCode::SUCCESS;
329 ATH_CHECK(
detStore()->retrieve(amdbCorr,
"/IOVDbTest/IOVDbTestAMDBCorrection") );
330 ATH_MSG_INFO (
"Retrieved /IOVDbTest/IOVDbTestAMDBCorrection" );
333 HepGeom::Point3D<double> rot = amdbCorr->
getRotation();
336 <<
" trans " << trans.x() <<
" " << trans.y() <<
" " << trans.z()
337 <<
" rot " << rot.x() <<
" " << rot.y() <<
" " << rot.z() );
343 ATH_CHECK(
detStore()->retrieve(amdbCorr,
"/IOVDbTest/IOVDbTestAMDBCorrection-NEWTAG") );
344 ATH_MSG_INFO(
"Retrieved /IOVDbTest/IOVDbTestAMDBCorrection-NEWTAG" );
347 HepGeom::Point3D<double> rot = amdbCorr->
getRotation();
350 <<
" trans " << trans.x() <<
" " << trans.y() <<
" " << trans.z()
351 <<
" rot " << rot.x() <<
" " << rot.y() <<
" " << rot.z() );
363 std::ostringstream attrStr1;
364 attrList->
print( attrStr1 );
369 ATH_CHECK(
detStore()->retrieve(attrList,
"/IOVDbTest/IOVDbTestAttrList-NEWTAG") );
372 std::ostringstream attrStr1;
373 attrList->
print( attrStr1 );
374 ATH_MSG_DEBUG(
"Attribute list NEWTAG: " << attrStr1.str() );
381 std::ostringstream fanstr;
382 attrList->
print( fanstr );
385 const coral::Blob& blob=(*attrList)[
"FanBlob"].data<coral::Blob>();
386 const unsigned char* p=
static_cast<const unsigned char*
>
387 (blob.startingAddress());
389 for (
int i=0;i<blob.size();++i,++p)
if (*p!=(i % 256)) ++nerr;
391 " data mismatches!" );
395 ATH_CHECK(
detStore()->retrieve(attrListColl,
"/IOVDbTest/IOVDbTestAttrListColl") );
399 std::ostringstream attrStr2;
404 for (; first != last; ++first) {
406 if (
msgLvl (MSG::DEBUG)) {
407 std::ostringstream attrStr1;
408 (*first).second.toOutputStream( attrStr1 );
409 msg() << MSG::DEBUG <<
"ChanNum " << (*first).first;
415 msg() << MSG::DEBUG <<
" name " << nitr->second;
417 msg() << MSG::DEBUG <<
418 " Attribute list " << attrStr1.str() <<
endmsg;
424 if (iovIt != attrListColl->
iov_end()) {
425 const IOVRange& range = (*iovIt).second;
426 if(range.start().isTimestamp()) {
427 ATH_MSG_DEBUG(
"Range timestamp : since " << range.start().timestamp()
428 <<
" till " << range.stop().timestamp() );
431 ATH_MSG_DEBUG(
"Range R/E : since " << range.start().run() <<
" "
432 << range.start().event()
433 <<
" till " << range.stop().run() <<
" "
434 << range.stop().event() );
444 if (
detStore()->retrieve(attrList,
"/Simulation/Parameters").isFailure() ) {
450 std::ostringstream attrStr;
451 attrList->
print( attrStr );
455 if (
detStore()->retrieve(attrList,
"/Digitization/Parameters").isFailure()) {
461 std::ostringstream attrStr;
462 attrList->
print( attrStr );
473 ATH_CHECK(
detStore()->retrieve(elemMapColl,
"/IOVDbTest/IOVDbTestMDTEleMapColl") );
478 ATH_MSG_ERROR(
"Must fill in channel numbers! Number of objects: " << elemMapColl->
size()
479 <<
" Number of channels: " << elemMapColl->
chan_size() );
480 return(StatusCode::FAILURE);
483 bool hasIOVs = (elemMapColl->
iov_size() == elemMapColl->
size());
486 for (
unsigned int i = 0; i < elemMapColl->
size(); ++i, ++itChan) {
488 msg() << MSG::INFO <<
"Found " << elemMap->
name()
492 <<
" channel " << (*itChan);
494 msg() << MSG::INFO <<
" iov " << (*itIOV);
500 return StatusCode::SUCCESS;
531 if (
msgLvl (MSG::DEBUG)) {
532 msg() << MSG::DEBUG <<
"Event (run,ev,lb:time): [" << ctx.eventID().run_number() <<
"," << ctx.eventID().event_number();
533 if (
m_printLB)
msg() <<
"," << ctx.eventID().lumi_block();
534 msg() <<
":" << ctx.eventID().time_stamp() <<
"]" <<
endmsg;
540 if (2 != ctx.eventID().run_number() || 5 != ctx.eventID().event_number()) {
541 ATH_MSG_DEBUG(
"Event NOT selected for creating conditions objects " );
542 return StatusCode::SUCCESS;
555 ATH_MSG_DEBUG(
"Calling printCondObjects" <<
m_online<<
"\t"<<ctx.eventID().run_number()<<
"\t"<<ctx.eventID().event_number() );
558 if (
m_online && 2 == ctx.eventID().run_number() && 9 == ctx.eventID().event_number())
563 return StatusCode::SUCCESS;
582 return StatusCode::SUCCESS;
596 typeKeys.emplace_back(
"IOVDbTestMDTEleMap",
"");
597 typeKeys.emplace_back(
"IOVDbTestAmdbCorrection",
"");
598 typeKeys.emplace_back(
"IOVDbTestMDTEleMapColl",
"");
603 for (
unsigned int i = 0; i < typeKeys.size(); ++i) {
604 ATH_MSG_DEBUG( typeKeys[i].first <<
" " << typeKeys[i].second <<
" " );
610 return StatusCode::SUCCESS;
621 std::string tag =
"no tag";
623 tag =
"tag MDTEleMap_" +
m_tagID;
628 ATH_MSG_DEBUG(
"registered IOVDbTestMDTEleMap with " << tag );
631 uint64_t start=
static_cast<long long>(
m_regTime)*1000000000LL;
635 tag =
"tag AmdbCorrection_" +
m_tagID;
640 ATH_MSG_DEBUG(
"registered IOVDbTestAmdbCorrection with " << tag );
649 tag =
"tag AttrList_" +
m_tagID;
652 ATH_CHECK(
m_regSvc->registerIOV(
"AthenaAttributeList",
"/IOVDbTest/IOVDbTestAttrList",
"") );
654 ATH_MSG_DEBUG(
"registered AthenaAttributeList with " << tag );
659 tag =
"tag FancyList_" +
m_tagID;
662 ATH_CHECK(
m_regSvc->registerIOV(
"AthenaAttributeList",
"/IOVDbTest/IOVDbTestFancyList",
"") );
664 ATH_MSG_DEBUG (
"registered Fancy AthenaAttributeList with " << tag );
669 tag =
"tag AttrListColl_" +
m_tagID;
674 ATH_MSG_DEBUG(
"registered CondAttrListCollection with " << tag );
680 tag =
"tag MDTEleMapColl_" +
m_tagID;
685 ATH_MSG_DEBUG(
"registered IOVDbTestMDTEleMapColl with " << tag );
688 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) ...
CondMultChanCollection< IOVDbTestMDTEleMap > IOVDbTestMDTEleMapColl
This typedef represents a collection of IOVDbTestMDTEleMap objects.
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.
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
virtual StatusCode initialize() override
BooleanProperty m_fancylist
BooleanProperty m_noStream
BooleanProperty m_createExtraChans
BooleanProperty m_writeCondObjs
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
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
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