ATLAS Offline Software
TileCalibDrawerDat.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 TILECALIBBLOBOBJS_TILECALIBDRAWERDAT_H
6 #define TILECALIBBLOBOBJS_TILECALIBDRAWERDAT_H
7 
24 #include <stdint.h>
25 #include <vector>
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 ~TileCalibDrawerDat(){}
41 
42  //==================================================================
43  //== Data getter and setter methods
44  //==================================================================
49  T getData(unsigned int channel, unsigned int adc, unsigned int idx) const;
50 
59  void init(const DefType& def,
60  uint16_t nChans,
61  uint16_t objVers,
62  const std::string& author="",
63  const std::string& comment="",
65 
71  void setData(unsigned int channel, unsigned int adc, unsigned int idx, T data);
72 
77  void setData(unsigned int channel, unsigned int adc, const std::vector<T>& data);
78 
79 
81  virtual void dump() const { dump(std::cout); }
84  virtual void dump(std::ostream& stm) const;
85 
86  protected:
93 
100  const T* getAddress(unsigned int channel, unsigned int adc) const;
101  T* getAddress(unsigned int channel, unsigned int adc);
102 };
103 
104 //
105 //_______________________________________________________________
106 template<class T> void
108  uint16_t nChans,
109  uint16_t objVers,
110  const std::string& author,
111  const std::string& comment,
113 {
114  uint16_t nGains = def.size();
115  uint32_t objSize = nGains>0 ? def.begin()->size() * sizeof(T)/sizeof(uint32_t) : 0;
116  uint32_t nObjs = nChans*nGains;
117 
118  //=== ensure all gains have the same object size
119  for(unsigned int iGain=0; iGain<nGains; ++iGain){
120  unsigned int thisSize = def[iGain].size()*sizeof(T)/sizeof(uint32_t);
121  if( thisSize != objSize ){
122  throw TileCalib::SizeConflict("TileCalibDrawerDat<T>::init",thisSize,objSize);
123  }
124  }
125 
126  //=== create blob
127  createBlob(getType(), objVers, objSize, nObjs, nChans, nGains, author, comment, timeStamp);
128 
129  //=== fill the blob with default
130  for(unsigned int channel=0; channel<nChans; ++channel){
131  for(unsigned int adc=0; adc<nGains; ++adc){
132  setData(channel, adc, def[adc]);
133  }
134  }
135 }
136 
137 //
138 //______________________________________________________________
139 template<class T> T
140 TileCalibDrawerDat<T>::getData(unsigned int channel, unsigned int adc, unsigned int idx) const
141 {
142  if(idx>=getObjSizeUint32()){
143  throw TileCalib::IndexOutOfRange("TileCalibDrawerDat::getData",idx,getObjVersion());
144  }
145 
146  //=== Tile Default Policy
147 
148  if(channel >= getNChans()) {
150  channel = 0;
151  } else {
153  if (channel >= getNChans()) channel = 0;
154  }
155  }
156 
157  if(adc >= getNGains()) {adc = 0;}
158 
159  return getAddress(channel,adc)[idx];
160 }
161 
162 //
163 //______________________________________________________________
164 template<class T> void
165 TileCalibDrawerDat<T>::setData(unsigned int channel, unsigned int adc, unsigned int idx, T data)
166 {
167  //=== check for out of bounds
168  if(channel >= getNChans()){
169  throw TileCalib::IndexOutOfRange("TileCalibDrawerDat::getAddress(channel)",channel,getNChans());
170  }
171  if(adc>=getNGains()){
172  throw TileCalib::IndexOutOfRange("CaloCalibDrawerDat::getAddress(gain)",adc,getNGains());
173  }
174  if(idx>=getObjSizeUint32()){
175  throw TileCalib::IndexOutOfRange("TileCalibDrawerDat::getData",idx,getObjVersion());
176  }
177 
178  getAddress(channel,adc)[idx] = data;
179 }
180 
181 //
182 //______________________________________________________________
183 template<class T> void
184 TileCalibDrawerDat<T>::setData(unsigned int channel, unsigned int adc, const std::vector<T>& data)
185 {
186  for(typename std::vector<T>::const_iterator i=data.begin(); i!=data.end(); ++i){
187  setData(channel,adc,i-data.begin(),*i);
188  }
189 }
190 
191 //
192 //______________________________________________________________
193 template<class T> const T*
194 TileCalibDrawerDat<T>::getAddress(unsigned int channel, unsigned int adc) const
195 {
196  unsigned int idx = channel*getNGains() + adc;
197  return static_cast<const T*>(TileCalibDrawerBase::getAddress(idx));
198 }
199 
200 //
201 //______________________________________________________________
202 template<class T> T*
203 TileCalibDrawerDat<T>::getAddress(unsigned int channel, unsigned int adc)
204 {
205  unsigned int idx = channel*getNGains() + adc;
206  return static_cast<T*>(TileCalibDrawerBase::getAddress(idx));
207 }
208 
209 //
210 //______________________________________________________________
211 template<class T> void
212 TileCalibDrawerDat<T>::dump(std::ostream& stm) const
213 {
215  for(unsigned int channel=0; channel<getNChans(); ++channel){
216  for(unsigned int adc=0; adc<getNGains(); ++adc){
217  stm << channel<<"/"<<adc<<":\t";
218  for(unsigned int idx=0; idx<getObjSizeUint32(); ++idx){
219  stm << getData(channel,adc,idx) << "\t";
220  }
221  stm << std::endl;
222  }
223  }
224 }
225 
226 
227 #endif
checkFileSG.nObjs
nObjs
Definition: checkFileSG.py:90
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
InDetSimDataHelpers::getData
const InDetSimData * getData(const InDetSimDataCollection &coll, const Identifier &id)
Definition: InDetSimDataDict.h:24
TileCalib::IndexOutOfRange
Thrown if an index is out of range.
Definition: TileCalorimeter/TileCalib/TileCalibBlobObjs/TileCalibBlobObjs/Exception.h:141
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
TileCalibType.h
python.subdetectors.tile.Blob
Blob
Definition: tile.py:17
TileCalibUtils.h
TileCalibDrawerBase::dumpHeader
void dumpHeader(std::ostream &stm) const
Prints the BLOB header summary information.
Definition: TileCalibDrawerBase.cxx:200
TileCalibDrawerDat
Generic template class for storing a number of "T"s for each channel or ADC.
Definition: TileCalibDrawerDat.h:31
TileCalib::SizeConflict
Thrown if BLOB size is not correct.
Definition: TileCalorimeter/TileCalib/TileCalibBlobObjs/TileCalibBlobObjs/Exception.h:120
TileCalibDrawerDat::TileCalibDrawerDat
TileCalibDrawerDat(coral::Blob &blob)
Ctor (non-const).
Definition: TileCalibDrawerDat.h:92
TileCalibDrawerDat::setData
void setData(unsigned int channel, unsigned int adc, unsigned int idx, T data)
Sets a single T belonging to a channel/ADC.
Definition: TileCalibDrawerDat.h:165
TileCalibDrawerDat::TileCalibDrawerDat
TileCalibDrawerDat(const coral::Blob &blob)
Ctor (const).
Definition: TileCalibDrawerDat.h:89
TileCalibDrawerDat::~TileCalibDrawerDat
virtual ~TileCalibDrawerDat()
Dtor.
Definition: TileCalibDrawerDat.h:40
TileCalibDrawerBase.h
TileCalibDrawerDat::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: TileCalibDrawerDat.h:184
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:88
TileCalibDrawerBase
This class provides the core BLOB infrastructure.
Definition: TileCalibDrawerBase.h:59
lumiFormat.i
int i
Definition: lumiFormat.py:85
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
TileCalibDrawerDat::getAddress
T * getAddress(unsigned int channel, unsigned int adc)
Definition: TileCalibDrawerDat.h:203
CaloCondBlobAlgs_fillNoiseFromASCII.comment
string comment
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:27
TileCalibDrawerDat::init
void init(const DefType &def, uint16_t nChans, uint16_t objVers, const std::string &author="", const std::string &comment="", uint64_t timeStamp=0)
Initializing function.
Definition: TileCalibDrawerDat.h:107
TileCalibDrawerDat::dump
virtual void dump() const
Prints out the content of the blob to std::out.
Definition: TileCalibDrawerDat.h:81
xAOD::timeStamp
setEventNumber timeStamp
Definition: EventInfo_v1.cxx:128
TileCalibDrawerDat::DefType
std::vector< std::vector< T > > DefType
Object to hold default data used for initialization.
Definition: TileCalibDrawerDat.h:37
ReadFloatFromCool.adc
adc
Definition: ReadFloatFromCool.py:48
CaloCondBlobAlgs_fillNoiseFromASCII.author
string author
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:26
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
TileCalibDrawerDat::getAddress
const T * getAddress(unsigned int channel, unsigned int adc) const
Returns a pointer to the first value for the specified channel & ADC.
Definition: TileCalibDrawerDat.h:194
TileCalibDrawerDat::getData
T getData(unsigned int channel, unsigned int adc, unsigned int idx) const
Returns a single T belonging to a channel/ADC.
Definition: TileCalibDrawerDat.h:140
TileCalibUtils::MAX_CHAN
static const unsigned int MAX_CHAN
Number of channels in drawer.
Definition: TileCalibUtils.h:141
TileCalibDrawerDat::dump
virtual void dump(std::ostream &stm) const
Prints out the content of the blob.
Definition: TileCalibDrawerDat.h:212
Ringer::getType
T getType(const char *cStr)
Return Ringer enumeration of type T identifying string type:
TileCalibDrawerBase::getAddress
const void * getAddress(unsigned int iEle) const
Returns start address of iEle-th basic unit.
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
CaloCondBlobAlgs_fillNoiseFromASCII.blob
blob
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:96