|
ATLAS Offline Software
|
Go to the documentation of this file.
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_writeCondObjs(false),
40 m_readWriteCool(false),
41 m_twoStepWriteReg(false),
42 m_createExtraChans(false),
44 m_writeOnlyCool(false),
51 m_streamName(
"CondStream1"),
53 m_regSvc(
"IOVRegistrationSvc",
name),
54 m_streamer (
"CondStream1")
97 while((msgqueue_id = msgget(
key, 0660)) == -1) {
98 printf(
"waiting for message here.\n");
101 printf(
"Recieving a message ...\n");
104 msgrcv(msgqueue_id, (
struct msgbuf *)(&qbuf), 80, 123, 0);
106 printf(
"Type: %ld Text: %s\n", qbuf.mtype, qbuf.mtext);
108 msgctl(msgqueue_id, IPC_RMID, 0);
114 msg() << MSG::INFO <<
"IOVDbTestAlg::testCallBack callback invoked for keys: i = " <<
i <<
" ";
115 for (std::list<std::string>::const_iterator itr=
keys.begin(); itr!=
keys.end(); ++itr) {
116 msg() << *itr <<
" ";
119 return StatusCode::SUCCESS;
128 if (m_writeCondObjs) {
129 m_streamer =
"AthenaOutputStreamTool/" + m_streamName;
146 if (!m_online)
return StatusCode::SUCCESS;
150 ATH_MSG_INFO(
"Registered callback for IOVDbTestAlg::testCallBack" );
153 return StatusCode::SUCCESS;
169 incSvc->fireIncident( Incident(
name(), IncidentType::BeginRun, Gaudi::Hive::currentContext()) );
171 return StatusCode::SUCCESS;
182 unsigned long long timestamp = ctx.eventID().time_stamp();
184 elemMap->
set(ctx.eventID().time_stamp(),
"mdt element map");
186 elemMap->
set(ctx.eventID().run_number(), ctx.eventID().event_number(),
"mdt element map");
198 for (
unsigned int i = 0;
i < 10; ++
i) {
201 unsigned long long timestamp = ctx.eventID().time_stamp();
203 elemMap->
set(ctx.eventID().time_stamp() + 10*
i,
"mdt element map");
205 elemMap->
set(ctx.eventID().run_number() +
i, ctx.eventID().event_number(),
"mdt element map");
212 ATH_CHECK(
detStore()->record(elemMapColl,
"/IOVDbTest/IOVDbTestMDTEleMapColl") );
216 HepGeom::Point3D<double>
x(1.0, 2.0, 3.0);
217 HepGeom::Point3D<double>
y(4.0, 5.0, 6.0);
220 x = HepGeom::Point3D<double>(11.0, 22.0, 33.0);
221 y = HepGeom::Point3D<double>(44.0, 55.0, 66.0);
223 amdbCorr->
set(
x,
y,
"amdb correction");
230 coral::AttributeListSpecification* attrSpec =
new coral::AttributeListSpecification();
231 attrSpec->extend(
"xPosition",
"float");
232 attrSpec->extend(
"id",
"int");
233 attrSpec->extend(
"name",
"string");
235 if (!attrSpec->size()) {
237 return(StatusCode::FAILURE);
246 (*attrList)[
"xPosition"].setValue((
float)
m_run);
247 (*attrList)[
"id"].setValue((
int)7);
248 (*attrList)[
"name"].setValue(std::string(
"TestAttrList"));
251 (*attrList)[
"xPosition"].setValue((
float)125.0);
252 (*attrList)[
"id"].setValue((
int)27);
253 (*attrList)[
"name"].setValue(std::string(
"TestAttrListNEWTAG"));
255 std::ostringstream attrStr1;
257 attrList->toOutputStream( attrStr1 );
266 coral::AttributeListSpecification* fanSpec =
new coral::AttributeListSpecification();
267 fanSpec->extend(
"FanBool",
"bool");
268 fanSpec->extend(
"FanInt",
"int");
269 fanSpec->extend(
"FanUInt",
"unsigned int");
270 fanSpec->extend(
"FanI64",
"long long");
271 fanSpec->extend(
"FanU64",
"unsigned long long");
272 fanSpec->extend(
"FanFloat",
"float");
273 fanSpec->extend(
"FanDouble",
"double");
274 fanSpec->extend(
"FanSmallString",
"string");
275 fanSpec->extend(
"FanBigString",
"string");
276 fanSpec->extend(
"FanBlob",
"blob");
279 (*fanList)[
"FanBool"].data<
bool>()=
true;
280 (*fanList)[
"FanInt"].data<
int>()=-12345;
281 (*fanList)[
"FanUInt"].data<
unsigned int>()=12345;
282 (*fanList)[
"FanI64"].data<
long long>()=-98765432100LL;
283 (*fanList)[
"FanU64"].data<
unsigned long long>()=98765432100LL;
284 (*fanList)[
"FanFloat"].data<
float>()=1.2345;
285 (*fanList)[
"FanDouble"].data<
double>()=1.23456789;
286 (*fanList)[
"FanSmallString"].data<std::string>()=
"small string";
287 (*fanList)[
"FanBigString"].data<std::string>()=
"potentially long string";
290 unsigned int blobsize=2000;
291 blob.resize(blobsize);
292 unsigned char*
p=
static_cast<unsigned char*
>(
blob.startingAddress());
293 for (
unsigned int i=0;
i<blobsize;++
i,++
p) *
p=(
i % 256);
295 std::ostringstream fanstr;
296 fanList->toOutputStream(fanstr);
308 attrList0[
"xPosition"].setValue((
float)35.0);
309 attrList0[
"id"].setValue((
int)17);
310 attrList0[
"name"].setValue(std::string(
"TestAttrList"));
313 std::ostringstream attrStr2;
314 attrList0.toOutputStream( attrStr2 );
319 attrList1[
"xPosition"].setValue((
float)45.0);
320 attrList1[
"id"].setValue((
int)27);
321 attrList1[
"name"].setValue(std::string(
"TestAttrList"));
324 std::ostringstream attrStr3;
325 attrList1.toOutputStream( attrStr3 );
330 attrList2[
"xPosition"].setValue((
float)55.0);
331 attrList2[
"id"].setValue((
int)37);
332 attrList2[
"name"].setValue(std::string(
"TestAttrList"));
335 std::ostringstream attrStr4;
336 attrList2.toOutputStream( attrStr4 );
343 attrList3[
"xPosition"].setValue((
float)65.0);
344 attrList3[
"id"].setValue((
int)47);
345 attrList3[
"name"].setValue(std::string(
"TestAttrList"));
348 std::ostringstream attrStr5;
349 attrList3.toOutputStream( attrStr5 );
357 <<
" till " <<
range.stop().run() <<
" " <<
range.stop().event() );
360 attrList4[
"xPosition"].setValue((
float)75.0);
361 attrList4[
"id"].setValue((
int)57);
362 attrList4[
"name"].setValue(std::string(
"TestAttrList"));
365 std::ostringstream attrStr6;
366 attrList4.toOutputStream( attrStr6 );
379 citr!=attrListColl->
end();++citr) {
381 std::ostringstream
name;
387 ATH_CHECK(
detStore()->record(attrListColl,
"/IOVDbTest/IOVDbTestAttrListColl") );
389 return StatusCode::SUCCESS;
412 ATH_MSG_INFO (
"Retrieved /IOVDbTest/IOVDbTestAMDBCorrection" );
415 HepGeom::Point3D<double> rot = amdbCorr->
getRotation();
418 <<
" trans " << trans.x() <<
" " << trans.y() <<
" " << trans.z()
419 <<
" rot " << rot.x() <<
" " << rot.y() <<
" " << rot.z() );
426 ATH_MSG_INFO(
"Retrieved /IOVDbTest/IOVDbTestAMDBCorrection-NEWTAG" );
429 HepGeom::Point3D<double> rot = amdbCorr->
getRotation();
432 <<
" trans " << trans.x() <<
" " << trans.y() <<
" " << trans.z()
433 <<
" rot " << rot.x() <<
" " << rot.y() <<
" " << rot.z() );
445 std::ostringstream attrStr1;
446 attrList->
print( attrStr1 );
454 std::ostringstream attrStr1;
455 attrList->
print( attrStr1 );
456 ATH_MSG_DEBUG(
"Attribute list NEWTAG: " << attrStr1.str() );
463 std::ostringstream fanstr;
464 attrList->
print( fanstr );
468 const unsigned char*
p=
static_cast<const unsigned char*
>
469 (
blob.startingAddress());
471 for (
int i=0;
i<
blob.size();++
i,++
p)
if (*
p!=(
i % 256)) ++nerr;
473 " data mismatches!" );
481 std::ostringstream attrStr2;
489 std::ostringstream attrStr1;
490 (*first).second.toOutputStream( attrStr1 );
500 " Attribute list " << attrStr1.str() <<
endmsg;
506 if (iovIt != attrListColl->
iov_end()) {
508 if(
range.start().isTimestamp()) {
510 <<
" till " <<
range.stop().timestamp() );
514 <<
range.start().event()
515 <<
" till " <<
range.stop().run() <<
" "
516 <<
range.stop().event() );
526 if (
detStore()->
retrieve(attrList,
"/Simulation/Parameters").isFailure() ) {
532 std::ostringstream attrStr;
533 attrList->
print( attrStr );
537 if (
detStore()->
retrieve(attrList,
"/Digitization/Parameters").isFailure()) {
543 std::ostringstream attrStr;
544 attrList->
print( attrStr );
560 ATH_MSG_ERROR(
"Must fill in channel numbers! Number of objects: " << elemMapColl->
size()
561 <<
" Number of channels: " << elemMapColl->
chan_size() );
562 return(StatusCode::FAILURE);
565 bool hasIOVs = (elemMapColl->
iov_size() == elemMapColl->
size());
568 for (
unsigned int i = 0;
i < elemMapColl->
size(); ++
i, ++itChan) {
570 msg() << MSG::INFO <<
"Found " << elemMap->
name()
574 <<
" channel " << (*itChan);
576 msg() << MSG::INFO <<
" iov " << (*itIOV);
582 return StatusCode::SUCCESS;
614 msg() <<
MSG::DEBUG <<
"Event (run,ev,lb:time): [" << ctx.eventID().run_number() <<
"," << ctx.eventID().event_number();
615 if (
m_printLB)
msg() <<
"," << ctx.eventID().lumi_block();
616 msg() <<
":" << ctx.eventID().time_stamp() <<
"]" <<
endmsg;
622 if (2 != ctx.eventID().run_number() || 5 != ctx.eventID().event_number()) {
623 ATH_MSG_DEBUG(
"Event NOT selected for creating conditions objects " );
624 return StatusCode::SUCCESS;
637 ATH_MSG_DEBUG(
"Calling printCondObjects" <<
m_online<<
"\t"<<ctx.eventID().run_number()<<
"\t"<<ctx.eventID().event_number() );
640 if (
m_online && 2 == ctx.eventID().run_number() && 9 == ctx.eventID().event_number())
645 return StatusCode::SUCCESS;
664 return StatusCode::SUCCESS;
681 typeKeys[
index] = mdtPair;
684 typeKeys[
index] = amdbCorr;
687 typeKeys[
index] = mdtCollPair;
692 for (
unsigned int i = 0;
i < typeKeys.size(); ++
i) {
699 return StatusCode::SUCCESS;
710 std::string
tag =
"no tag";
741 ATH_CHECK(
m_regSvc->registerIOV(
"AthenaAttributeList",
"/IOVDbTest/IOVDbTestAttrList",
"") );
751 ATH_CHECK(
m_regSvc->registerIOV(
"AthenaAttributeList",
"/IOVDbTest/IOVDbTestFancyList",
"") );
777 return StatusCode::SUCCESS;
ChanVec::const_iterator chan_const_iterator
def retrieve(aClass, aKey=None)
const_iterator end() const
BooleanProperty m_writeNewTag
Validity Range object. Holds two IOVTimes (start and stop)
void set(int runNumber, int eventNumber, const std::string &name)
iov_const_iterator iov_end() const
static constexpr uint32_t MAXRUN
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
BooleanProperty m_readNewTag
BooleanProperty m_writeOnlyCool
chan_const_iterator chan_begin() const
Access to Channel numbers via iterators.
void print(std::ostream &os) const
print to simulate function provided by old POOL AttributeList
StatusCode IOVDbTestAlg::initialize ATLAS_NOT_THREAD_SAFE()
Install fatal handler with default options.
uint32_t event() const noexcept
CondMultChanCollection< IOVDbTestMDTEleMap > IOVDbTestMDTEleMapColl
This typedef represents a collection of IOVDbTestMDTEleMap objects.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
StatusCode registerCondObjects()
A CondMultChanCollection is a template class which can hold a collection of T* objects which are inte...
const IOVTime & start() const
BooleanProperty m_readWriteCool
bool msgLvl(const MSG::Level lvl) const
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
This is an interface to a tool used to register conditions objects in the Interval of Validity (IOV) ...
chan_size_type chan_size() const
number of channels
#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,...
This class is a collection of AttributeLists where each one is associated with a channel number....
BooleanProperty m_nameChans
const std::string & name() const
ChanIOVMap::const_iterator iov_const_iterator
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
An algorithm that can be simultaneously executed in multiple threads.
StatusCode testCallBack(IOVSVC_CALLBACK_ARGS)
const IOVTime & stop() const
IOVDbTestAlg(const std::string &name, ISvcLocator *pSvcLocator)
void set(const HepGeom::Point3D< double > &trans, const HepGeom::Point3D< double > &rot, const std::string &name)
ChanNameMap::const_iterator name_const_iterator
Basic time unit for IOVSvc. Hold time as a combination of run and event numbers.
StringProperty m_streamName
BooleanProperty m_writeCondObjs
void waitForSecond() const
const std::string & name() const
IntegerProperty m_regTime
ServiceHandle< IIOVRegistrationSvc > m_regSvc
::StatusCode StatusCode
StatusCode definition for legacy code.
ToolHandle< IAthenaOutputStreamTool > m_streamer
StatusCode printCondObjects() const
static constexpr uint64_t MAXTIMESTAMP
HepGeom::Point3D< double > getTranslation() const
An AttributeList represents a logical row of attributes in a metadata table. The name and type of eac...
iov_const_iterator iov_begin() const
Access to IOVs via iterators.
StatusCode readWithBeginRun()
IOVVec::const_iterator iov_const_iterator
BooleanProperty m_fancylist
iov_size_type iov_size() const
number of IOVs
static constexpr uint32_t MAXEVENT
void add(ChanNum chanNum)
Adding in channel numbers.
name_size_type name_size() const
number of Chan/Name pairs
BooleanProperty m_noStream
uint32_t run() const noexcept
value_type push_back(value_type pElem)
Add an element to the end of the collection.
an iterator over instances of a given type in StoreGateSvc. It d-casts and caches locally the pointed...
static constexpr uint32_t MINEVENT
BooleanProperty m_twoStepWriteReg
BooleanProperty m_readInInit
StatusCode streamOutCondObjects()
#define ATH_MSG_WARNING(x)
ChanAttrListMap::const_iterator const_iterator
name_const_iterator chanNamePair(ChanNum chanNum) const
Access to Chan/Name pairs via channel number: returns map iterator.
virtual StatusCode finalize() override
virtual StatusCode execute(const EventContext &ctx) const override
StatusCode createCondObjects(const EventContext &ctx) const
iov_const_iterator chanIOVPair(ChanNum chanNum) const
Access to Chan/IOV pairs via channel number: returns map iterator.
bool add(ChanNum chanNum, const AttributeList &attributeList)
Adding in chan/attrList pairs.
BooleanProperty m_createExtraChans
BooleanProperty m_printLB
HepGeom::Point3D< double > getRotation() const
size_type size() const noexcept
Returns the number of elements in the collection.
name_const_iterator name_end() const