ATLAS Offline Software
CaloCondBlobBase.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef CALOCONDBLOBOBJS_CALOCONDBLOBBASE_H
6 #define CALOCONDBLOBOBJS_CALOCONDBLOBBASE_H
7 
33 #include <stdint.h>
34 #include <vector>
35 #include <string>
36 #include <ostream>
37 #include <iostream>
38 #include "CoralBase/Blob.h"
41 
43  public:
45  virtual ~CaloCondBlobBase();
50 
52  virtual uint16_t getType() const {return CaloCondType::BASE;}
53 
55  virtual void dump() const { dumpHeader(std::cout); }
58  virtual void dump(std::ostream& stm) const {dumpHeader(stm);}
59 
60 
61  //==================================================================
62  //== Accessor methods for the header
63  //==================================================================
65  long getBlobSize() const {return m_blob->size(); }
67  uint16_t getObjType() const;
69  uint16_t getObjVersion() const;
71  uint32_t getObjSizeUint32() const;
73  uint32_t getObjSizeByte() const {return getObjSizeUint32()*sizeof(uint32_t);}
75  uint32_t getNObjs() const;
77  uint32_t getNChans() const;
79  uint32_t getNGains() const;
85  unsigned int getHdrSize() const {return 5;}
86 
87  //==================================================================
88  //== Accessor methods for the comment fields
89  //==================================================================
91  std::string getAuthor() const;
93  std::string getComment() const;
95  uint64_t getTimeStamp() const;
97  std::string getDate() const;
99  std::string getFullComment() const;
100 
101 
102  //==================================================================
103  //== Blob field access
104  //==================================================================
107  const void* getAddress(unsigned int iEle) const;
108  void* getAddress(unsigned int iEle);
109 
110 
111  protected:
114 
117 
128  uint32_t createBlob(uint16_t objType,
130  uint32_t objSizeUint32,
131  uint32_t nObjs,
132  uint32_t nChans,
133  uint16_t nGains,
134  const std::string& author="",
135  const std::string& comment="",
136  uint64_t timeStamp=0);
137 
140  void dumpHeader(std::ostream& stm) const;
141 
142  private:
144  CaloCondBlobBase(coral::Blob* blob_nc, const coral::Blob* blob);
145 
146  static uint32_t packGainAndNchans(const uint32_t gain, const uint32_t nChans);
147  static uint32_t unpacknGains(const uint32_t gainAndnChans);
148  static uint32_t unpacknChans(const uint32_t gainAndnChans);
149 
151  const uint32_t* getBlobStart() const;
154 
158 
161 
164 
166  unsigned m_sizeOfObj;
167  unsigned m_nChans;
168  unsigned m_nGains;
169 protected:
170  const void* m_pDataStart;
171 };
172 
173 
174 //
175 //_________________________________________________________
176 inline const uint32_t*
178 {
179  return static_cast<const uint32_t*>(m_blob->startingAddress());
180 }
181 
182 //
183 //_________________________________________________________
184 inline uint32_t*
186 {
187  return static_cast<uint32_t*>(m_blob_nc->startingAddress());
188 }
189 
190 //
191 //_________________________________________________________
192 inline uint16_t
194 {
195  if(uint64_t(m_blob->size())<getHdrSize()*sizeof(uint32_t))
196  throw CaloCond::InvalidBlob("CaloCondBlobBase::getObjType");
197  return static_cast<const uint16_t*>(m_blob->startingAddress())[0];
198 }
199 
200 //
201 //_________________________________________________________
202 inline uint16_t
204 {
205  if(uint64_t(m_blob->size())<getHdrSize()*sizeof(uint32_t))
206  throw CaloCond::InvalidBlob("CaloCondBlobBase::getObjVersion");
207  return static_cast<const uint16_t*>(m_blob->startingAddress())[1];
208 }
209 
210 //
211 //_________________________________________________________
212 inline uint32_t
214 {
215  return m_sizeOfObj;
216 }
217 
218 //
219 //_________________________________________________________
220 inline uint32_t
222 {
223  if(uint64_t(m_blob->size())<getHdrSize()*sizeof(uint32_t))
224  throw CaloCond::InvalidBlob("CaloCondBlobBase::getNObjs");
225  return static_cast<const uint32_t*>(m_blob->startingAddress())[2];
226 }
227 
228 //
229 //_________________________________________________________
230 inline uint32_t
232 {
233  return m_nChans;
234 }
235 
236 //
237 //_________________________________________________________
238 inline uint32_t
240 {
241  return m_nGains;
242 
243 
244 }
245 
246 //
247 //_________________________________________________________
248 inline uint32_t
250 {
251  if(uint64_t(m_blob->size())<getHdrSize()*sizeof(uint32_t))
252  throw CaloCond::InvalidBlob("CaloCondBlobBase::getCommentSizeUint32");
253  return static_cast<const uint32_t*>(m_blob->startingAddress())[4];
254 }
255 
256 //
257 //_________________________________________________________
258 inline const void*
259 CaloCondBlobBase::getAddress(unsigned int iEle) const
260 {
261  if(iEle>=getNObjs()){
262  throw CaloCond::IndexOutOfRange("CaloCondBlobBase::getAddress", iEle, getNObjs());
263  }
264  return static_cast<const void*>
265  ( getBlobStart() + getHdrSize() + getObjSizeUint32()*iEle );
266 }
267 
268 //
269 //_________________________________________________________
270 inline void*
271 CaloCondBlobBase::getAddress(unsigned int iEle)
272 {
273  if(iEle>=getNObjs()){
274  throw CaloCond::IndexOutOfRange("CaloCondBlobBase::getAddress", iEle, getNObjs());
275  }
276  return static_cast<void*>
277  ( getBlobStart() + getHdrSize() + getObjSizeUint32()*iEle );
278 }
279 
280 //
281 //_________________________________________________________
282 inline uint64_t
284 {
285  if(!getCommentSizeUint32()) return 0;
286  return *(reinterpret_cast<const uint64_t*>(getBlobStart()+getHdrSize() +
288 }
289 
290 #endif
CaloCondBlobBase::getCommentSizeUint32
uint32_t getCommentSizeUint32() const
Returns the space occupied by the comment fields in units of uint32_t.
Definition: CaloCondBlobBase.h:249
checkFileSG.nObjs
nObjs
Definition: checkFileSG.py:90
CaloCondBlobBase::m_isBlobOwner
bool m_isBlobOwner
Do I own the BLOB?
Definition: CaloCondBlobBase.h:163
CaloCondBlobBase::packGainAndNchans
static uint32_t packGainAndNchans(const uint32_t gain, const uint32_t nChans)
Definition: CaloCondBlobBase.cxx:139
CaloCondBlobBase::getObjSizeUint32
uint32_t getObjSizeUint32() const
Returns the size of a data object in units of uint32_t.
Definition: CaloCondBlobBase.h:213
CaloCondBlobBase::getAuthor
std::string getAuthor() const
Returns the comment author.
Definition: CaloCondBlobBase.cxx:176
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
CaloCondBlobBase::dump
virtual void dump(std::ostream &stm) const
Prints the BLOB header summary information.
Definition: CaloCondBlobBase.h:58
CaloCondBlobBase::m_nGains
unsigned m_nGains
Definition: CaloCondBlobBase.h:168
CaloCondBlobBase::m_blob_nc
coral::Blob * m_blob_nc
Non-const reference to the BLOB.
Definition: CaloCondBlobBase.h:157
CaloCondBlobBase::getAddress
const void * getAddress(unsigned int iEle) const
Returns start address of iEle-th basic unit.
Definition: CaloCondBlobBase.h:259
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
python.subdetectors.tile.Blob
Blob
Definition: tile.py:17
CaloCondBlobBase::getBlobSize
long getBlobSize() const
Returns the BLOB size.
Definition: CaloCondBlobBase.h:65
CaloCondBlobBase::m_pDataStart
const void * m_pDataStart
Definition: CaloCondBlobBase.h:170
CaloCondBlobBase::getType
virtual uint16_t getType() const
Returns CaloCondDrawer::BASE.
Definition: CaloCondBlobBase.h:52
CaloCondBlobBase::createBlob
uint32_t createBlob(uint16_t objType, uint16_t objVersion, uint32_t objSizeUint32, uint32_t nObjs, uint32_t nChans, uint16_t nGains, const std::string &author="", const std::string &comment="", uint64_t timeStamp=0)
(re-)creation of the referenced BLOB object.
Definition: CaloCondBlobBase.cxx:83
CaloCondBlobBase::getObjType
uint16_t getObjType() const
Returns the BLOB object type.
Definition: CaloCondBlobBase.h:193
CaloCondBlobBase::getDate
std::string getDate() const
Returns the date of the comment as string (derived from timestamp)
Definition: CaloCondBlobBase.cxx:205
TileCalibBlobPython_writeOfc.objVersion
objVersion
Definition: TileCalibBlobPython_writeOfc.py:71
CaloCondBlobBase::operator=
CaloCondBlobBase & operator=(const CaloCondBlobBase &other)
Assignment operator.
Definition: CaloCondBlobBase.cxx:64
CaloCondBlobBase::CaloCondBlobBase
CaloCondBlobBase(const CaloCondBlobBase &other)
Copy Ctor.
Definition: CaloCondBlobBase.cxx:50
CaloCondBlobBase::getHdrSize
unsigned int getHdrSize() const
Returns the size of the header in units of uint32_t.
Definition: CaloCondBlobBase.h:85
CaloCondBlobBase::getCommentSizeChar
uint32_t getCommentSizeChar() const
Returns the space occupied by the comment fields in units of chars.
Definition: CaloCondBlobBase.h:83
Exception.h
CaloCondBlobBase::getBlobStart
const uint32_t * getBlobStart() const
Returns the BLOB start address as uint32_t pointer.
Definition: CaloCondBlobBase.h:177
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:93
CaloCondBlobBase::getObjVersion
uint16_t getObjVersion() const
Returns the BLOB object version.
Definition: CaloCondBlobBase.h:203
CaloCondType::BASE
@ BASE
Enum for CaloCondBlobBase class.
Definition: CaloCondType.h:28
CaloCondBlobBase::getComment
std::string getComment() const
Returns the actual comment.
Definition: CaloCondBlobBase.cxx:190
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
CaloCondBlobBase::m_nChans
unsigned m_nChans
Definition: CaloCondBlobBase.h:167
CaloCondBlobBase::dumpHeader
void dumpHeader(std::ostream &stm) const
Prints the BLOB header summary information.
Definition: CaloCondBlobBase.cxx:229
CaloCondType.h
CaloCondBlobBase::unpacknChans
static uint32_t unpacknChans(const uint32_t gainAndnChans)
Definition: CaloCondBlobBase.cxx:160
CaloCond::InvalidBlob
Thrown if coral::Blob does not conform with expected structure.
Definition: Calorimeter/CaloCondBlobObjs/CaloCondBlobObjs/Exception.h:50
CaloCondBlobAlgs_fillNoiseFromASCII.comment
string comment
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:27
CaloCond::IndexOutOfRange
Thrown if an index is out of range.
Definition: Calorimeter/CaloCondBlobObjs/CaloCondBlobObjs/Exception.h:124
CaloCondBlobBase::getNObjs
uint32_t getNObjs() const
Returns the number of data objects stored int the BLOB.
Definition: CaloCondBlobBase.h:221
CaloCondBlobBase::getNGains
uint32_t getNGains() const
Returns the number of gains stored for each channel.
Definition: CaloCondBlobBase.h:239
xAOD::timeStamp
setEventNumber timeStamp
Definition: EventInfo_v1.cxx:128
CaloCondBlobBase::m_blob
const coral::Blob * m_blob
Const reference to the BLOB (always there)
Definition: CaloCondBlobBase.h:160
CaloCondBlobBase::getFullComment
std::string getFullComment() const
Returns a formated string build from all comment fields.
Definition: CaloCondBlobBase.cxx:219
CaloCondBlobBase::getObjSizeByte
uint32_t getObjSizeByte() const
Returns the size of a data object in units of bytes.
Definition: CaloCondBlobBase.h:73
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
CaloCondBlobBase
This class provides the core BLOB infrastructure.
Definition: CaloCondBlobBase.h:42
CaloCondBlobBase::m_sizeOfObj
unsigned m_sizeOfObj
Chache of some frequently-used numbers.
Definition: CaloCondBlobBase.h:166
CaloCondBlobAlgs_fillNoiseFromASCII.author
string author
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:26
CaloCondBlobBase::~CaloCondBlobBase
virtual ~CaloCondBlobBase()
Dtor.
Definition: CaloCondBlobBase.cxx:42
CaloCondBlobBase::getTimeStamp
uint64_t getTimeStamp() const
Returns the unix timestamp of the comment (seconds since 1.1.1970)
Definition: CaloCondBlobBase.h:283
CaloCondBlobBase::dump
virtual void dump() const
Prints the BLOB header summary information to std::cout.
Definition: CaloCondBlobBase.h:55
CaloCondBlobBase::unpacknGains
static uint32_t unpacknGains(const uint32_t gainAndnChans)
Definition: CaloCondBlobBase.cxx:150
CaloCondBlobAlgs_fillNoiseFromASCII.blob
blob
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:96
CaloCondBlobBase::getNChans
uint32_t getNChans() const
Returns the number of channels stored in the BLOB.
Definition: CaloCondBlobBase.h:231