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

This class provides the core BLOB infrastructure. More...

#include <TileCalibDrawerBase.h>

Inheritance diagram for TileCalibDrawerBase:
Collaboration diagram for TileCalibDrawerBase:

Public Member Functions

virtual ~TileCalibDrawerBase ()
 Dtor.
 TileCalibDrawerBase (const TileCalibDrawerBase &other)
 Copy Ctor.
TileCalibDrawerBaseoperator= (const TileCalibDrawerBase &other)
 Assignment operator.
virtual void clone (const TileCalibDrawerBase &other)
 Initialzes Blob with content of other Blob.
virtual uint16_t getType () const
 Returns TileCalibDrawer::BASE.
virtual void dump () const
 Prints the BLOB header summary information to std::cout.
virtual void dump (std::ostream &stm) const
 Prints the BLOB header summary information.
long getBlobSize () const
 Returns the BLOB size in units of bytes.
long getBlobSize32 () const
 Returns the BLOB size in units of uint32_t.
uint16_t getObjType () const
 Returns the BLOB object type.
uint16_t getObjVersion () const
 Returns the BLOB object version.
uint32_t getObjSizeUint32 () const
 Returns the size of a data object in units of uint32_t.
uint32_t getObjSizeByte () const
 Returns the size of a data object in units of bytes.
uint32_t getNObjs () const
 Returns the number of data objects stored int the BLOB.
uint16_t getNChans () const
 Returns the number of channels stored in the BLOB.
uint16_t getNGains () const
 Returns the number of gains stored for each channel.
uint32_t getCommentSizeUint32 () const
 Returns the space occupied by the comment fields in units of uint32_t.
uint32_t getCommentSizeChar () const
 Returns the space occupied by the comment fields in units of chars.
std::string getAuthor () const
 Returns the comment author.
std::string getComment () const
 Returns the actual comment.
uint64_t getTimeStamp () const
 Returns the unix timestamp of the comment (seconds since 1.1.1970)
std::string getDate () const
 Returns the date of the comment as string (derived from timestamp)
std::string getFullComment () const
 Returns a formated string build from all comment fields.
const void * getAddress (unsigned int iEle) const
 Returns start address of iEle-th basic unit.
void * getAddress (unsigned int iEle)

Static Public Attributes

static const unsigned int m_hdrSize32 = 5
 The header size in units of uint32_t.

Protected Member Functions

 TileCalibDrawerBase (const coral::Blob &blob)
 Ctor for const blob.
 TileCalibDrawerBase (coral::Blob &blob)
 Ctor for non-const blob.
uint32_t createBlob (uint16_t objType, uint16_t objVersion, uint32_t objSizeUint32, uint32_t nObjs, uint16_t nChans, uint16_t nGains, const std::string &author="", const std::string &comment="", uint64_t timeStamp=0)
 (re-)creation of the referenced BLOB object.
void dumpHeader (std::ostream &stm) const
 Prints the BLOB header summary information.

Private Attributes

coral::Blob * m_blob_nc
 Non-const reference to the BLOB.
const coral::Blob * m_blob
 Const reference to the BLOB (always there)
const uint32_t * m_blobStart32
 Cache blob starting address as uint_32t*.
const uint16_t * m_blobStart16
 Cache blob starting address as uint_16t*.
uint64_t m_blobSize32
 Cache blob size in units of uint32_t.
bool m_isBlobOwner
 Is this TileCalibDrawer owner of the BLOB.

Detailed Description

This class provides the core BLOB infrastructure.

Author
Nils Gollub nils..nosp@m.goll.nosp@m.ub@ce.nosp@m.rn.c.nosp@m.h

All data storage classes inherit from this class. It provides the infrastructure to store and retrieve units of conditions data associated with one channel or ADC ("data object") by implementing a common BLOB header. This header holds the following information:

  • The type of the object stored in the BLOB (see TileCalibType class for known types)
  • The version of the type, allows for schema evolution
  • The size of a data object in units of uint32_t (4 bytes)
  • The total number of data objects
  • The number of channels stored in the blob
  • The number of gains stored for each channel
  • The number of uint32_t used to store comment information (after the actual blob data)

A data object contains all conditions data related to one channel or ADC (depending on data stored on channel or adc level), for example 5 floats. The conditions data units themselves must be build from objects of 32 bit length, i.e. available types are float, uint32_t and int32_t.

The TileCalibDrawerBase class holds a reference to a coral::Blob containing conditions data for one TileCal drawer. A total number of 277 TileCalibDrawer objects are stored in each COOL folder to hold data for the whole detector. Each TileCalibDrawer is stored in its own COOL channel, numbered from 0 to 276. Data related to the 4*64 TileCal modules (LBA01, LBA02, ... , LBC01, ... , EBA01, ... , EBC63, EBC64) are stored in the channel range [20,275]. The channel range [0,19] holds default drawers: [0-3] are global detector defaults, [4-7] for LBA, [8-11] for LBC, [12-15] for EBA and [16-19] for EBC.

Channel number 1000 contains TileCalibDrawerCmt comment classes, common for all TileCalibDrawers of the same IOV which do not have their own comment fields initialized. Comment fields are not initialized if both the author and the comment field are empty in initialization.

Definition at line 59 of file TileCalibDrawerBase.h.

Constructor & Destructor Documentation

◆ ~TileCalibDrawerBase()

TileCalibDrawerBase::~TileCalibDrawerBase ( )
virtual

Dtor.

Definition at line 36 of file TileCalibDrawerBase.cxx.

37{
38 //=== delete the coral::Blob if owner
39 if(m_isBlobOwner) {delete m_blob;}
40}
const coral::Blob * m_blob
Const reference to the BLOB (always there)
bool m_isBlobOwner
Is this TileCalibDrawer owner of the BLOB.

◆ TileCalibDrawerBase() [1/3]

TileCalibDrawerBase::TileCalibDrawerBase ( const TileCalibDrawerBase & other)

Copy Ctor.

In case the copy constructor is called, the underlying coral::Blob is copied and the new TileCalibDrawer is the owner of the new coral::Blob. I.e. it will be deleted when the TileCalibDrawer Dtor is called.

Parameters
otherThe TileCalibDrawer to copy

Definition at line 44 of file TileCalibDrawerBase.cxx.

44 :
45 m_blob_nc(new coral::Blob(*other.m_blob)),
47 m_blobStart32(static_cast<const uint32_t*>(m_blob->startingAddress())),
48 m_blobStart16(static_cast<const uint16_t*>(m_blob->startingAddress())),
49 m_blobSize32(m_blob->size()/sizeof(uint32_t)),
50 m_isBlobOwner(true)
51{
52}
uint64_t m_blobSize32
Cache blob size in units of uint32_t.
const uint32_t * m_blobStart32
Cache blob starting address as uint_32t*.
const uint16_t * m_blobStart16
Cache blob starting address as uint_16t*.
coral::Blob * m_blob_nc
Non-const reference to the BLOB.
setWord1 uint16_t
setEventNumber uint32_t

◆ TileCalibDrawerBase() [2/3]

TileCalibDrawerBase::TileCalibDrawerBase ( const coral::Blob & blob)
protected

Ctor for const blob.

Definition at line 12 of file TileCalibDrawerBase.cxx.

12 :
13 m_blob_nc(nullptr),
14 m_blob(&blob),
15 m_blobStart32(static_cast<const uint32_t*>(m_blob->startingAddress())),
16 m_blobStart16(static_cast<const uint16_t*>(m_blob->startingAddress())),
17 m_blobSize32(m_blob->size()/sizeof(uint32_t)),
18 m_isBlobOwner(false)
19{
20}

◆ TileCalibDrawerBase() [3/3]

TileCalibDrawerBase::TileCalibDrawerBase ( coral::Blob & blob)
protected

Ctor for non-const blob.

Definition at line 24 of file TileCalibDrawerBase.cxx.

24 :
25 m_blob_nc(&blob),
26 m_blob(&blob),
27 m_blobStart32(static_cast<const uint32_t*>(m_blob->startingAddress())),
28 m_blobStart16(static_cast<const uint16_t*>(m_blob->startingAddress())),
29 m_blobSize32(m_blob->size()/sizeof(uint32_t)),
30 m_isBlobOwner(false)
31{
32}

Member Function Documentation

◆ clone()

void TileCalibDrawerBase::clone ( const TileCalibDrawerBase & other)
virtual

Initialzes Blob with content of other Blob.

Parameters
otherTileCalibDrawer used for initialization

Definition at line 74 of file TileCalibDrawerBase.cxx.

75{
76 //=== copy content of other blob
77 *m_blob_nc = *other.m_blob;
78 //=== and reset cached attributes
79 m_blobStart32 = static_cast<const uint32_t*>(m_blob->startingAddress());
80 m_blobStart16 = static_cast<const uint16_t*>(m_blob->startingAddress());
81 m_blobSize32 = m_blob->size()/sizeof(uint32_t);
82}

◆ createBlob()

uint32_t TileCalibDrawerBase::createBlob ( uint16_t objType,
uint16_t objVersion,
uint32_t objSizeUint32,
uint32_t nObjs,
uint16_t nChans,
uint16_t nGains,
const std::string & author = "",
const std::string & comment = "",
uint64_t timeStamp = 0 )
protected

(re-)creation of the referenced BLOB object.

Parameters
objTypeObject type
objVersionObject version
objSizeUint32Size of a data object (in uint32_t)
nObjsTotal number of data objects
nChansnumber of stored channels
nGainsnumber of stored gains
authorcomment author
commentactual comment
timeStampunix time stamp (if 0, current time is used)

Definition at line 87 of file TileCalibDrawerBase.cxx.

96{
97 //=== blob data length including header in bytes
98 uint32_t dataSizeByte = (m_hdrSize32+objSizeUint32*nObjs) * sizeof(uint32_t);
99
100 //=== calculate comment length, including two ASCII NULLs to end text fields
101 uint32_t commentSizeChar(0);
102 if(author.size() || comment.size() || timeStamp){
103 commentSizeChar += author.size()+comment.size()+sizeof(uint64_t) + 2;
104 //=== force comment length to end on 4 byte boundary
105 commentSizeChar += (commentSizeChar % sizeof(uint32_t)) ?
106 (sizeof(uint32_t)-(commentSizeChar % sizeof(uint32_t))) : 0;
107 }
108
109 //=== create blob
110 uint32_t blobSizeInBytes = dataSizeByte+commentSizeChar;
111 m_blob_nc->resize(blobSizeInBytes);
112 uint32_t* blobStart32 = static_cast<uint32_t*>(m_blob_nc->startingAddress());
113 uint16_t* blobStart16 = static_cast<uint16_t*>(m_blob_nc->startingAddress());
114 m_blobSize32 = m_blob_nc->size()/sizeof(uint32_t);
115
116 m_blobStart32 = blobStart32;
117 m_blobStart16 = blobStart16;
118
119 //=== fill header
120 blobStart16[0] = objType;
121 blobStart16[1] = objVersion;
122 blobStart32[1] = objSizeUint32;
123 blobStart32[2] = nObjs;
124 blobStart16[6] = nChans;
125 blobStart16[7] = nGains;
126 blobStart32[4] = commentSizeChar/sizeof(uint32_t);
127
128 //==== fill comment fields
129 if(commentSizeChar){
130 if(!timeStamp) timeStamp = ::time(0);
131 uint64_t* pTimeStamp = reinterpret_cast<uint64_t*>(blobStart32+dataSizeByte/sizeof(uint32_t));
132 pTimeStamp[0] = timeStamp;
133 char* pChar = reinterpret_cast<char*>(++pTimeStamp);
134 std::string::const_iterator iStr = author.begin();
135 for(; iStr!=author.end(); ++iStr){ *pChar = *iStr; ++pChar; }
136 *pChar = 0;
137 for(iStr=comment.begin(); iStr!=comment.end(); ++iStr){ *(++pChar) = *iStr; }
138 *(++pChar) = 0;
139 }
140
141 return (blobSizeInBytes/sizeof(uint32_t));
142}
static const unsigned int m_hdrSize32
The header size in units of uint32_t.
setEventNumber timeStamp

◆ dump() [1/2]

virtual void TileCalibDrawerBase::dump ( ) const
inlinevirtual

Prints the BLOB header summary information to std::cout.

Reimplemented in TileCalibDrawerCmt, TileCalibDrawerDat< T >, TileCalibDrawerDat< float >, TileCalibDrawerDat< uint32_t >, and TileCalibDrawerOfc.

Definition at line 83 of file TileCalibDrawerBase.h.

83{ dumpHeader(std::cout); }
void dumpHeader(std::ostream &stm) const
Prints the BLOB header summary information.

◆ dump() [2/2]

virtual void TileCalibDrawerBase::dump ( std::ostream & stm) const
inlinevirtual

Prints the BLOB header summary information.

Parameters
stmThe output stream to use

Reimplemented in TileCalibDrawerCmt, TileCalibDrawerDat< T >, and TileCalibDrawerOfc.

Definition at line 86 of file TileCalibDrawerBase.h.

86{dumpHeader(stm);}

◆ dumpHeader()

void TileCalibDrawerBase::dumpHeader ( std::ostream & stm) const
protected

Prints the BLOB header summary information.

Parameters
stmoutput stream to use

Definition at line 200 of file TileCalibDrawerBase.cxx.

201{
202 stm << "This is a " << TileCalibType::getClassName(getObjType()) << std::endl;
203 stm << "ObjType : " << getObjType() << std::endl;
204 stm << "ObjVersion : " << getObjVersion() << std::endl;
205 stm << "ObjSize [bytes]: " << getObjSizeByte() << std::endl;
206 stm << "NObjs : " << getNObjs() << std::endl;
207 stm << "NChannels : " << getNChans() << std::endl;
208 stm << "NGains : " << getNGains() << std::endl;
210 stm << "=== No comment available ===" << std::endl;
211 }
212 else{
213 stm << "Author : " << getAuthor() << std::endl;
214 stm << "Date : " << getDate() << " ("<< getTimeStamp() << ")" << std::endl;
215 stm << "Comment: : " << getComment() << std::endl;
216 }
217}
uint32_t getCommentSizeUint32() const
Returns the space occupied by the comment fields in units of uint32_t.
uint16_t getNChans() const
Returns the number of channels stored in the BLOB.
std::string getComment() const
Returns the actual comment.
uint16_t getObjType() const
Returns the BLOB object type.
uint16_t getNGains() const
Returns the number of gains stored for each channel.
uint64_t getTimeStamp() const
Returns the unix timestamp of the comment (seconds since 1.1.1970)
std::string getDate() const
Returns the date of the comment as string (derived from timestamp)
uint32_t getNObjs() const
Returns the number of data objects stored int the BLOB.
std::string getAuthor() const
Returns the comment author.
uint16_t getObjVersion() const
Returns the BLOB object version.
uint32_t getObjSizeByte() const
Returns the size of a data object in units of bytes.
static std::string getClassName(TileCalibType::TYPE type)
Returns the class name.

◆ getAddress() [1/2]

void * TileCalibDrawerBase::getAddress ( unsigned int iEle)

◆ getAddress() [2/2]

const void * TileCalibDrawerBase::getAddress ( unsigned int iEle) const

Returns start address of iEle-th basic unit.

Parameters
iElesequential basic unit number

◆ getAuthor()

std::string TileCalibDrawerBase::getAuthor ( ) const

Returns the comment author.

Definition at line 147 of file TileCalibDrawerBase.cxx.

148{
149 if(!getCommentSizeUint32()) return std::string("");
150 const char* iBeg =
151 reinterpret_cast<const char*>(m_blobStart32 + m_hdrSize32 +
153 sizeof(uint64_t)/sizeof(uint32_t));
154 return std::string(iBeg);
155}
uint32_t getObjSizeUint32() const
Returns the size of a data object in units of uint32_t.

◆ getBlobSize()

long TileCalibDrawerBase::getBlobSize ( ) const
inline

Returns the BLOB size in units of bytes.

Definition at line 92 of file TileCalibDrawerBase.h.

92{ return m_blobSize32 * sizeof(uint32_t); }

◆ getBlobSize32()

long TileCalibDrawerBase::getBlobSize32 ( ) const
inline

Returns the BLOB size in units of uint32_t.

Definition at line 94 of file TileCalibDrawerBase.h.

94{ return m_blobSize32; }

◆ getComment()

std::string TileCalibDrawerBase::getComment ( ) const

Returns the actual comment.

Definition at line 161 of file TileCalibDrawerBase.cxx.

162{
163 if(!getCommentSizeUint32()) return std::string("");
164 const char* iBeg =
165 reinterpret_cast<const char*>(m_blobStart32 + m_hdrSize32 +
167 sizeof(uint64_t)/sizeof(uint32_t));
168 const char* iEnd = iBeg + getCommentSizeChar();
169 iBeg = std::find(iBeg,iEnd,0);
170 return std::string(++iBeg);
171}
uint32_t getCommentSizeChar() const
Returns the space occupied by the comment fields in units of chars.

◆ getCommentSizeChar()

uint32_t TileCalibDrawerBase::getCommentSizeChar ( ) const
inline

Returns the space occupied by the comment fields in units of chars.

Definition at line 112 of file TileCalibDrawerBase.h.

112{return getCommentSizeUint32()*sizeof(uint32_t);}

◆ getCommentSizeUint32()

uint32_t TileCalibDrawerBase::getCommentSizeUint32 ( ) const

Returns the space occupied by the comment fields in units of uint32_t.

◆ getDate()

std::string TileCalibDrawerBase::getDate ( ) const

Returns the date of the comment as string (derived from timestamp)

Definition at line 176 of file TileCalibDrawerBase.cxx.

177{
178 if(!getCommentSizeUint32()) return std::string("");
179 ::time_t timeStamp = getTimeStamp();
180 char buf[32];
181 char* iBeg = ::ctime_r(&timeStamp, buf);
182 char* iEnd = iBeg;
183 while(*iEnd!='\n'){++iEnd;}
184 return std::string(iBeg,iEnd-iBeg);
185}

◆ getFullComment()

std::string TileCalibDrawerBase::getFullComment ( ) const

Returns a formated string build from all comment fields.

Definition at line 190 of file TileCalibDrawerBase.cxx.

191{
192 if(!getCommentSizeUint32()) return std::string("");
193 return getAuthor()+" ("+getDate()+"): "+getComment();
194}

◆ getNChans()

uint16_t TileCalibDrawerBase::getNChans ( ) const

Returns the number of channels stored in the BLOB.

◆ getNGains()

uint16_t TileCalibDrawerBase::getNGains ( ) const

Returns the number of gains stored for each channel.

◆ getNObjs()

uint32_t TileCalibDrawerBase::getNObjs ( ) const

Returns the number of data objects stored int the BLOB.

◆ getObjSizeByte()

uint32_t TileCalibDrawerBase::getObjSizeByte ( ) const
inline

Returns the size of a data object in units of bytes.

Definition at line 102 of file TileCalibDrawerBase.h.

102{return getObjSizeUint32()*sizeof(uint32_t);}

◆ getObjSizeUint32()

uint32_t TileCalibDrawerBase::getObjSizeUint32 ( ) const

Returns the size of a data object in units of uint32_t.

◆ getObjType()

uint16_t TileCalibDrawerBase::getObjType ( ) const

Returns the BLOB object type.

◆ getObjVersion()

uint16_t TileCalibDrawerBase::getObjVersion ( ) const

Returns the BLOB object version.

◆ getTimeStamp()

uint64_t TileCalibDrawerBase::getTimeStamp ( ) const

Returns the unix timestamp of the comment (seconds since 1.1.1970)

◆ getType()

virtual uint16_t TileCalibDrawerBase::getType ( ) const
inlinevirtual

Returns TileCalibDrawer::BASE.

Reimplemented in TileCalibDrawerBch, TileCalibDrawerCmt, TileCalibDrawerFlt, TileCalibDrawerInt, and TileCalibDrawerOfc.

Definition at line 80 of file TileCalibDrawerBase.h.

80{return TileCalibType::BASE;}
@ BASE
Enum for TileCalibDrawerBase class.

◆ operator=()

TileCalibDrawerBase & TileCalibDrawerBase::operator= ( const TileCalibDrawerBase & other)

Assignment operator.

Definition at line 57 of file TileCalibDrawerBase.cxx.

58{
59 //=== catch self-assignment
60 if(&other == this) {return *this;}
61 if (m_isBlobOwner) delete m_blob;
62 m_blob_nc = other.m_blob_nc;
63 m_blob = other.m_blob;
64 m_blobStart32 = other.m_blobStart32;
65 m_blobStart16 = other.m_blobStart16;
66 m_blobSize32 = other.m_blobSize32;
67 m_isBlobOwner = other.m_isBlobOwner;
68 return *this;
69}

Member Data Documentation

◆ m_blob

const coral::Blob* TileCalibDrawerBase::m_blob
private

Const reference to the BLOB (always there)

Definition at line 176 of file TileCalibDrawerBase.h.

◆ m_blob_nc

coral::Blob* TileCalibDrawerBase::m_blob_nc
private

Non-const reference to the BLOB.

(Only present if we were created with a non-const blob.)

Definition at line 174 of file TileCalibDrawerBase.h.

◆ m_blobSize32

uint64_t TileCalibDrawerBase::m_blobSize32
private

Cache blob size in units of uint32_t.

Definition at line 182 of file TileCalibDrawerBase.h.

◆ m_blobStart16

const uint16_t* TileCalibDrawerBase::m_blobStart16
private

Cache blob starting address as uint_16t*.

Definition at line 180 of file TileCalibDrawerBase.h.

◆ m_blobStart32

const uint32_t* TileCalibDrawerBase::m_blobStart32
private

Cache blob starting address as uint_32t*.

Definition at line 178 of file TileCalibDrawerBase.h.

◆ m_hdrSize32

const unsigned int TileCalibDrawerBase::m_hdrSize32 = 5
static

The header size in units of uint32_t.

Definition at line 138 of file TileCalibDrawerBase.h.

◆ m_isBlobOwner

bool TileCalibDrawerBase::m_isBlobOwner
private

Is this TileCalibDrawer owner of the BLOB.

Definition at line 184 of file TileCalibDrawerBase.h.


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