ATLAS Offline Software
CaloCondBlobDat.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef CALOCONDBLOBOBJS_CALOCONDBLOBDAT_H
6 #define CALOCONDBLOBOBJS_CALOCONDBLOBDAT_H
7 
23 #include <stdint.h>
24 #include <vector>
25 #include <ostream>
26 #include <iostream>
27 #include "CoralBase/Blob.h"
28 
29 template<class T>
31 {
32  public:
37  typedef std::vector<std::vector<T> > DefType;
38 
40  virtual ~CaloCondBlobDat(){}
41 
42  //==================================================================
43  //== Data getter and setter methods
44  //==================================================================
49  T getData(const unsigned int channel, const unsigned int adc, const unsigned int idx) const;
50 
51  //==================================================================
52  //== Optimized data getter for calibrations independent of gain and ADC
53  //==================================================================
57  T getData(const unsigned int channel) const;
58 
67  void init(const DefType& def,
68  uint32_t nChans,
69  uint16_t objVers,
70  const std::string& author="",
71  const std::string& comment="",
73 
79  void setData(unsigned int channel, unsigned int adc, unsigned int idx, T data);
80 
85  void setData(unsigned int channel, unsigned int adc, const std::vector<T>& data);
86 
87 
89  virtual void dump() const { dump(std::cout); }
92  virtual void dump(std::ostream& stm) const;
93 
94  protected:
99 
100 
104  const T* getAddress(const unsigned int channel, const unsigned int adc) const;
105  T* getAddress(const unsigned int channel, const unsigned int adc);
106 };
107 
108 //
109 //_______________________________________________________________
110 template<class T> void
112  uint32_t nChans,
113  uint16_t objVers,
114  const std::string& author,
115  const std::string& comment,
117 {
118  uint32_t objSize = def.begin()->size() * sizeof(T)/sizeof(uint32_t);
119  uint16_t nGains = def.size();
120  uint32_t nObjs = nChans*nGains;
121  createBlob(getType(), objVers, objSize, nObjs, nChans, nGains, author, comment, timeStamp);
122 
123  //=== fill the blob with default
124  for(unsigned int channel=0; channel<nChans; ++channel){
125  for(unsigned int adc=0; adc<nGains; ++adc){
126  setData(channel, adc, def[adc]);
127  }
128  }
129 }
130 
131 //
132 //______________________________________________________________
133 template<class T> T
134 CaloCondBlobDat<T>::getData(const unsigned int channel, const unsigned int adc, const unsigned int idx) const
135 {
136  if(idx<getObjSizeUint32()){return getAddress(channel,adc)[idx];}
137  else{throw CaloCond::IndexOutOfRange("CaloCondBlobDat::getData",idx,getObjVersion());}
138 }
139 
140 
141 template<class T> T
142 CaloCondBlobDat<T>::getData(const unsigned int channel) const {
143 return (static_cast<const T*>(m_pDataStart))[channel];
144 }
145 
146 
147 //
148 //______________________________________________________________
149 template<class T> void
150 CaloCondBlobDat<T>::setData(unsigned int channel, unsigned int adc, unsigned int idx, T data)
151 {
152  if(idx<getObjSizeUint32()){ getAddress(channel,adc)[idx] = data;}
153  else{throw CaloCond::IndexOutOfRange("CaloCondBlobDat::setData",idx,getObjVersion());}
154 }
155 
156 //
157 //______________________________________________________________
158 template<class T> void
159 CaloCondBlobDat<T>::setData(unsigned int channel, unsigned int adc, const std::vector<T>& data)
160 {
161  for(typename std::vector<T>::const_iterator i=data.begin(); i!=data.end(); ++i){
162  setData(channel,adc,i-data.begin(),*i);
163  }
164 }
165 
166 //
167 //______________________________________________________________
168 template<class T> const T*
169 CaloCondBlobDat<T>::getAddress(const unsigned int channel, const unsigned int adc) const
170 {
171  //=== check for out of bounds
172  if(channel >= getNChans()){
173  throw CaloCond::IndexOutOfRange("CaloCondBlobDat::getAddress(channel)",channel,getNChans());
174  }
175  if(adc>=getNGains()){
176  throw CaloCond::IndexOutOfRange("CaloCondBlobDat::getAddress(gain)",adc,getNGains());
177  }
178 
179  const unsigned int idx = channel*getNGains() + adc;
180  return static_cast<const T*>(CaloCondBlobBase::getAddress(idx));
181 }
182 
183 //
184 //______________________________________________________________
185 template<class T> T*
186 CaloCondBlobDat<T>::getAddress(const unsigned int channel, const unsigned int adc)
187 {
188  //=== check for out of bounds
189  if(channel >= getNChans()){
190  throw CaloCond::IndexOutOfRange("CaloCondBlobDat::getAddress(channel)",channel,getNChans());
191  }
192  if(adc>=getNGains()){
193  throw CaloCond::IndexOutOfRange("CaloCondBlobDat::getAddress(gain)",adc,getNGains());
194  }
195 
196  const unsigned int idx = channel*getNGains() + adc;
197  return static_cast<T*>(CaloCondBlobBase::getAddress(idx));
198 }
199 
200 //
201 //______________________________________________________________
202 template<class T> void
203 CaloCondBlobDat<T>::dump(std::ostream& stm) const
204 {
206  for(unsigned int channel=0; channel<getNChans(); ++channel){
207  for(unsigned int adc=0; adc<getNGains(); ++adc){
208  stm << channel<<"/"<<adc<<":\t";
209  for(unsigned int idx=0; idx<getObjSizeUint32(); ++idx){
210  stm << getData(channel,adc,idx) << "\t";
211  }
212  stm << std::endl;
213  }
214  }
215 }
216 
217 
218 #endif
checkFileSG.nObjs
nObjs
Definition: checkFileSG.py:90
CaloCondBlobDat::setData
void setData(unsigned int channel, unsigned int adc, unsigned int idx, T data)
Sets a single T belonging to a channel/gain.
Definition: CaloCondBlobDat.h:150
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
CaloCondBlobDat
Generic template class for storing a number of "T"s for each channel/gain.
Definition: CaloCondBlobDat.h:31
CaloCondBlobDat::getData
T getData(const unsigned int channel, const unsigned int adc, const unsigned int idx) const
Returns a single T belonging to a channel/gain.
Definition: CaloCondBlobDat.h:134
InDetSimDataHelpers::getData
const InDetSimData * getData(const InDetSimDataCollection &coll, const Identifier &id)
Definition: InDetSimDataDict.h:24
CaloCondBlobDat::DefType
std::vector< std::vector< T > > DefType
Object to hold default data used for initialization.
Definition: CaloCondBlobDat.h:37
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:28
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
CaloCondBlobDat::getAddress
T * getAddress(const unsigned int channel, const unsigned int adc)
Definition: CaloCondBlobDat.h:186
CaloCondBlobBase::getAddress
const void * getAddress(unsigned int iEle) const
Returns start address of iEle-th basic unit.
Definition: CaloCondBlobBase.h:259
CaloCondBlobDat::getAddress
const T * getAddress(const unsigned int channel, const unsigned int adc) const
Returns a pointer to the first value for the specified channel/gain.
Definition: CaloCondBlobDat.h:169
python.subdetectors.tile.Blob
Blob
Definition: tile.py:17
CaloCondBlobDat::getData
T getData(const unsigned int channel) const
Returns a single T belonging to a channel/gain.
Definition: CaloCondBlobDat.h:142
CaloCondBlobDat::init
void init(const DefType &def, uint32_t nChans, uint16_t objVers, const std::string &author="", const std::string &comment="", uint64_t timeStamp=0)
Initializing function.
Definition: CaloCondBlobDat.h:111
CaloCondBlobDat::CaloCondBlobDat
CaloCondBlobDat(const coral::Blob &blob)
Ctor.
Definition: CaloCondBlobDat.h:96
CaloCondBlobBase.h
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:88
lumiFormat.i
int i
Definition: lumiFormat.py:92
CaloCondBlobDat::~CaloCondBlobDat
virtual ~CaloCondBlobDat()
Dtor.
Definition: CaloCondBlobDat.h:40
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
CaloCondBlobBase::dumpHeader
void dumpHeader(std::ostream &stm) const
Prints the BLOB header summary information.
Definition: CaloCondBlobBase.cxx:229
CaloCondType.h
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
xAOD::timeStamp
setEventNumber timeStamp
Definition: EventInfo_v1.cxx:128
CaloCondBlobDat::setData
void setData(unsigned int channel, unsigned int adc, const std::vector< T > &data)
Sets a number of Ts stored in the input vector.
Definition: CaloCondBlobDat.h:159
ReadFloatFromCool.adc
adc
Definition: ReadFloatFromCool.py:48
CaloCondBlobBase
This class provides the core BLOB infrastructure.
Definition: CaloCondBlobBase.h:42
CaloCondBlobDat::dump
virtual void dump() const
Prints out the content of the blob to std::out.
Definition: CaloCondBlobDat.h:89
CaloCondBlobAlgs_fillNoiseFromASCII.author
string author
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:26
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
CaloCondBlobDat::dump
virtual void dump(std::ostream &stm) const
Prints out the content of the blob.
Definition: CaloCondBlobDat.h:203
Ringer::getType
T getType(const char *cStr)
Return Ringer enumeration of type T identifying string type:
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
CaloCondBlobAlgs_fillNoiseFromASCII.blob
blob
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:96
CaloCondBlobDat::CaloCondBlobDat
CaloCondBlobDat(coral::Blob &blob)
Ctor.
Definition: CaloCondBlobDat.h:98