ATLAS Offline Software
Loading...
Searching...
No Matches
Blob2ToolConstants Class Reference

#include <Blob2ToolConstants.h>

Inheritance diagram for Blob2ToolConstants:
Collaboration diagram for Blob2ToolConstants:

Public Member Functions

 Blob2ToolConstants (const std::string &type, const std::string &name, const IInterface *parent)
virtual StatusCode initialize ()
coral::AttributeList * ToolConstantsToAttrList (const CaloRec::ToolConstants *tc) const
 Method convert ToolConstants -> AttributeList (writing)
StatusCode AttrListToToolConstants (const coral::AttributeList &attrList, CaloRec::ToolConstants &tc) const
 Method convert AttributeList->ToolConstants (reading)
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Static Public Member Functions

static const InterfaceID & interfaceID ()
static unsigned nameToChannelNumber (const std::string &name)
 Method to create a channel number (hash)

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 22 of file Blob2ToolConstants.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ Blob2ToolConstants()

Blob2ToolConstants::Blob2ToolConstants ( const std::string & type,
const std::string & name,
const IInterface * parent )

Definition at line 19 of file Blob2ToolConstants.cxx.

21 :
22 AthAlgTool(type,name,parent)
23{
24 declareInterface<Blob2ToolConstants>(this);
25}
AthAlgTool()
Default constructor:

Member Function Documentation

◆ AttrListToToolConstants()

StatusCode Blob2ToolConstants::AttrListToToolConstants ( const coral::AttributeList & attrList,
CaloRec::ToolConstants & tc ) const

Method convert AttributeList->ToolConstants (reading)

Parameters
attrListReference to coral::AttributeList (source)
[out]tcReference to ToolConstants object (destination)
mLogMessageStream for logging
Returns
True if successful, False otherwise

Uses a ROOT streamer to serialize the underlying Array class

Definition at line 78 of file Blob2ToolConstants.cxx.

78 {
79
81 std::unique_ptr<T> map;
82
83 try {
84 tc.clsname(attrList["clsname"].data<std::string>());
85 tc.version(attrList["version"].data<unsigned int>());
86 const unsigned blobVersion=attrList["blobVersion"].data<unsigned int>();
87 const coral::Blob& blob = attrList["Constants"].data<coral::Blob>();
88
89 if (blobVersion!=0) {
90 msg(MSG::ERROR) << "Can't interpret BLOB version " << blobVersion << endmsg;
91 return StatusCode::FAILURE;
92 }
93
94 TClass* klass = TClass::GetClass ("std::map<std::string, CaloRec::Arrayrep>");
95 if (klass==nullptr) {
96 msg(MSG::ERROR) << "Can't find TClass std::map<std::string, CaloRec::Arrayrep>" << endmsg;
97 return StatusCode::FAILURE;
98 }
99 else
100 msg(MSG::DEBUG) << "Got TClass std::map<std::string, CaloRec::Arrayrep>" << endmsg;
101
102 // TBufferFile needs a void* even in read-only mode:
103 void* blob_start ATLAS_THREAD_SAFE = const_cast<void*>(blob.startingAddress());
104 TBufferFile buf (TBuffer::kRead, blob.size(), blob_start, false);
105 map.reset( (T*)buf.ReadObjectAny (klass) );
106 }catch (coral::AttributeListException &e) {
107 msg(MSG::ERROR) << e.what() << endmsg;
108 return StatusCode::FAILURE;
109 }
110
111 T::const_iterator it=map->begin();
112 T::const_iterator it_e=map->end();
113 for (;it!=it_e;++it) {
114 tc.setrep(it->first,it->second);
115 }
116 return StatusCode::SUCCESS;
117}
#define endmsg
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
static Double_t tc
#define ATLAS_THREAD_SAFE
MsgStream & msg() const
std::map< std::string, CxxUtils::Arrayrep > Maptype
Type of the map from keys to values.
unsigned long long T

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ initialize()

StatusCode Blob2ToolConstants::initialize ( )
virtual

Definition at line 28 of file Blob2ToolConstants.cxx.

28 {
29 msg(MSG::DEBUG) << "Initializing..." << endmsg;
30 return StatusCode::SUCCESS;
31}

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

const InterfaceID & Blob2ToolConstants::interfaceID ( )
static

Definition at line 130 of file Blob2ToolConstants.cxx.

130 {
132}
static const InterfaceID IID_Blob2ToolConstants("Blob2ToolConstants", 1, 0)

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ nameToChannelNumber()

uint32_t Blob2ToolConstants::nameToChannelNumber ( const std::string & name)
static

Method to create a channel number (hash)

Parameters
nameof the channel (usually the Tool name)
Returns
channel number

Uses SG::crc64 method as hash-function (only lower 32bits uses)

Definition at line 119 of file Blob2ToolConstants.cxx.

119 {
120 const uint64_t hash64=CxxUtils::crc64(name);
121 const uint32_t hash32=(uint32_t)(hash64 & 0xFFFFFFFF);
122 //std::cout << "HASH: 64bit:" << std::hex << hash64 << " 32bit:" << hash32 << std::endl;
123 return hash32;
124 }
uint64_t crc64(const CRCTable &table, const char *data, size_t data_len)
Find the CRC-64 of a string,.
Definition crc64.cxx:696
setEventNumber uint32_t
std::uint64_t hash64(const void *data, std::size_t size)
Passthrough to XXH3_64bits.
Definition XXH.cxx:9

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ ToolConstantsToAttrList()

coral::AttributeList * Blob2ToolConstants::ToolConstantsToAttrList ( const CaloRec::ToolConstants * tc) const

Method convert ToolConstants -> AttributeList (writing)

Parameters
tcPointer to ToolConstants object
mLogMessageStream for logging
Returns
Pointer to AttributeList (owned by client)

Uses a ROOT streamer to serialize the underlying Array class

Definition at line 34 of file Blob2ToolConstants.cxx.

34 {
35
36 coral::AttributeListSpecification* spec = new coral::AttributeListSpecification();
37
38 spec->extend("clsname","string"); //Data member of CaloRec::ToolConstants
39 spec->extend("version","unsigned int"); //Data member of CaloRec::ToolConstants
40 spec->extend("blobVersion","unsigned int"); //Should allow schema evolution if needed
41 spec->extend("Constants","blob"); //Holds the map<string,Arrayrep>
42
43
44 auto attrList = std::make_unique<coral::AttributeList>(*spec);
45
46 spec->release();
47 // cppcheck-suppress memleak
48 spec = nullptr;
49
50 (*attrList)["clsname"].data<std::string>()=tc->clsname();
51 (*attrList)["version"].data<unsigned int>()=(unsigned int)tc->version();
52 (*attrList)["blobVersion"].data<unsigned int>()=(unsigned int)0;
53
54 coral::Blob& blob=(*attrList)["Constants"].data<coral::Blob>();
55
56 //typedef std::map<std::string, CaloRec::Arrayrep> T;
57 TClass* klass = TClass::GetClass ("std::map<std::string, CaloRec::Arrayrep>");
58 if (klass==nullptr) {
59 msg( MSG::ERROR) << "Can't find TClass std::map<std::string, CaloRec::Arrayrep>" << endmsg;
60 return nullptr;
61 }
62 else
63 msg(MSG::DEBUG) << "Got TClass std::map<std::string, CaloRec::Arrayrep>" << endmsg;
64
65 TBufferFile buf (TBuffer::kWrite);
66
67 if (buf.WriteObjectAny (&tc->map(), klass) != 1) {
68 msg(MSG::ERROR) << "Failed to stream CaloRec::ToolConstants::Maptype " << endmsg;
69 return nullptr;
70 }
71
72 blob.resize(buf.Length());
73 void* adr = blob.startingAddress();
74 memcpy(adr,buf.Buffer(),buf.Length());
75 return attrList.release();
76 }

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: