ATLAS Offline Software
Classes | Macros | Functions
TileCalibDrawerOfc.h File Reference
#include "TileCalibBlobObjs/TileCalibDrawerBase.h"
#include "TileCalibBlobObjs/TileCalibType.h"
#include "TileCalibBlobObjs/TileCalibUtils.h"
#include "CoralBase/Blob.h"
#include <stdint.h>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <cmath>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  TileCalibDrawerOfc
 

Macros

#define PHASE_PRECISION   0.1
 Class for storing Optimal Filtering Coefficients (OFCs) in a coral::Blob. More...
 

Functions

 __attribute__ ((always_inline)) inline uint32_t TileCalibDrawerOfc
 

Macro Definition Documentation

◆ PHASE_PRECISION

#define PHASE_PRECISION   0.1

Class for storing Optimal Filtering Coefficients (OFCs) in a coral::Blob.

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

This class extends the header defined in TileCalibDrawerBase by two additional 32 bit words:

  • nSamples: The number of samples used in OFC computation
  • nPhases: The number of phases stored in the BLOB.

Directly after these two extra header words a list of phases is stored. The phases are encoded as integers so that exact comparisons are possible. Since phases are only needed with a resolution of 0.1ns, a good convention is to store int(10*phase).

If the nPhases is set to a negative value in initialization with init(...), only one list of phases common for all ADCs is stored.

Definition at line 39 of file TileCalibDrawerOfc.h.

Function Documentation

◆ __attribute__()

__attribute__ ( (always_inline)  )

Definition at line 203 of file TileCalibDrawerOfc.h.

204  {
205  return *(static_cast<const uint32_t*>(getAddress(0)));
206 }
207 
208 //
209 //______________________________________________________________
210 __attribute__((always_inline))
211 inline int32_t TileCalibDrawerOfc::getNPhases() const {
212  return *(static_cast<const int32_t*>(getAddress(1)));
213 }
214 
215 //
216 //______________________________________________________________
217 __attribute__((always_inline))
218 inline unsigned int TileCalibDrawerOfc::getPhaseNumber(unsigned int channel, unsigned int adc, float& phase) const {
219 
220  if (std::abs(phase) > 1e6F) {
221  // Bad phase is requested (probably, bad value is in the DB)
222  phase = 0.0F;
223  }
224  int db_phase = (int) std::round(phase * (1 / PHASE_PRECISION)); // Phases are stored as int(10*phase) in DB
225  const int32_t* beg = getPhaseStartAddress(channel, adc, 0);
226  const int32_t* end = beg + std::abs(getNPhases());
227  const int32_t* pos = std::lower_bound(beg, end, db_phase);
228 
229  if (pos == end || (*pos != db_phase && pos != beg && (*pos - db_phase) > (db_phase - *(pos - 1)))) {
230  --pos;
231  }
232 
234  return (pos - beg);
235 }
236 
237 //
238 //______________________________________________________________
239 __attribute__((always_inline))
240 inline float TileCalibDrawerOfc::getPhase(unsigned int channel, unsigned int adc, unsigned int phaseIdx) const {
241  return *(getPhaseStartAddress(channel, adc, phaseIdx)) * PHASE_PRECISION; // Phases are stored as int(10*phase) in DB
242 }
243 
244 //
245 //______________________________________________________________
246 __attribute__((always_inline))
248  //=== determine objVersion from Blob if default is passed
250 
251  if( objVersion == 3){ return 5; }
252  else if(objVersion == 2){ return 4; }
253  else if(objVersion == 1){ return 3; }
254  else{
255  throw TileCalib::VersionConflict("TileCalibDrawerOfc::getNFields", objVersion);
256  }
257 }
258 
259 //
260 //______________________________________________________________
261 inline float TileCalibDrawerOfc::getOfc(unsigned int field, unsigned int channel, unsigned int adc
262  , float phase, unsigned int sample) const {
263  if(sample >= getNSamples())
264  throw TileCalib::IndexOutOfRange("TileCalibDrawerOfc::getA", sample, getNSamples());
266 }
267 
268 inline void TileCalibDrawerOfc::fillOfc (unsigned int channel,unsigned int adc, float& phase
269  , float* w_a, float* w_b, float* w_c, float* g, float* dg) const {
270 
271 
272  const float* startAddress = getOfcStartAddress(TileCalibDrawerOfc::FieldA, channel, adc, phase);
273  size_t allSamplesSize = getNSamples() * sizeof(float);
274  size_t fieldSize = getObjSizeUint32() * getNSamples();
275 
276  memcpy(w_a, startAddress, allSamplesSize);
277  startAddress += fieldSize;
278  memcpy(w_b, startAddress, allSamplesSize);
279  startAddress += fieldSize;
280  memcpy(g, startAddress, allSamplesSize);
281  startAddress += fieldSize;
282  memcpy(w_c, startAddress, allSamplesSize);
283  if (getNFields() > 4) {
284  startAddress += fieldSize;
285  memcpy(dg, startAddress, allSamplesSize);
286  } else {
287  memset(dg, 0, allSamplesSize);
288  }
289 }
290 
291 
292 //
293 //______________________________________________________________
294 inline void TileCalibDrawerOfc::setOfc(unsigned int field,unsigned int channel, unsigned int adc
295  , float phase, unsigned int sample, float value) {
296  if(sample >= getNSamples())
297  throw TileCalib::IndexOutOfRange("TileCalibDrawerOfc::setOfc", sample, getNSamples());
299 }
ReadOfcFromCool.phase
phase
Definition: ReadOfcFromCool.py:127
TileCalibDrawerOfc::getOfc
float getOfc(unsigned int field, unsigned int channel, unsigned int adc, float phase, unsigned int sample) const
Returns OFC data.
checkCoolLatestUpdate.dg
dg
Definition: checkCoolLatestUpdate.py:9
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:28
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
__attribute__
__attribute__((always_inline)) inline uint32_t TileCalibDrawerOfc
Definition: TileCalibDrawerOfc.h:203
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
PHASE_PRECISION
#define PHASE_PRECISION
Class for storing Optimal Filtering Coefficients (OFCs) in a coral::Blob.
Definition: TileCalibDrawerOfc.h:38
MuonGM::round
float round(const float toRound, const unsigned int decimals)
Definition: Mdt.cxx:27
TileCalibDrawerOfc::setOfc
void setOfc(unsigned int field, unsigned int channel, unsigned int adc, float phase, unsigned int sample, float value)
Sets OFC data.
TileCalibDrawerOfc::fillOfc
void fillOfc(unsigned int channel, unsigned int adc, float &phase, float *w_a, float *w_b, float *w_c, float *g, float *dg) const
Fill all OFC for optimazation.
TileCalibDrawerOfc::getNPhases
int32_t getNPhases() const
Returns the number of phases (WARNING: Can be negative!)
athena.value
value
Definition: athena.py:122
ReadOfcFromCool.field
field
Definition: ReadOfcFromCool.py:48
TileCalibBlobPython_writeOfc.objVersion
objVersion
Definition: TileCalibBlobPython_writeOfc.py:71
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
TileCalibDrawerBase::getObjVersion
uint16_t getObjVersion() const
Returns the BLOB object version.
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:88
FullCPAlgorithmsTest_eljob.sample
sample
Definition: FullCPAlgorithmsTest_eljob.py:100
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
TileCalib::VersionConflict
Thrown if object version in BLOB does not agree with class.
Definition: TileCalorimeter/TileCalib/TileCalibBlobObjs/TileCalibBlobObjs/Exception.h:78
TileCalibDrawerOfc::getPhaseNumber
unsigned int getPhaseNumber(unsigned int channel, unsigned int adc, float &phase) const
Returns the index for a given phase.
TileCalibDrawerOfc::getPhase
float getPhase(unsigned int channel, unsigned int adc, unsigned int phaseIdx) const
Returns the stored phase.
WriteBchToCool.beg
beg
Definition: WriteBchToCool.py:69
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
ReadFloatFromCool.adc
adc
Definition: ReadFloatFromCool.py:48
TileCalibDrawerOfc::getOfcStartAddress
const float * getOfcStartAddress(unsigned int field, unsigned int channel, unsigned int adc, float &phase) const
Returns pointer to first data OFC for a given field, ADC & phase.
TileCalibDrawerOfc::getNSamples
uint32_t getNSamples() const
Returns the number of sample stored.
TileCalibDrawerOfc::getPhaseStartAddress
const int32_t * getPhaseStartAddress(unsigned int channel, unsigned int adc, unsigned int phaseIdx) const
Returns pointer to the requested phase value.
TileCalibDrawerOfc::FieldA
@ FieldA
Definition: TileCalibDrawerOfc.h:45
TileCalibDrawerOfc::getNFields
uint32_t getNFields(uint16_t objVersion=0) const
Returns the number of fields.
TileCalibDrawerBase::getObjSizeUint32
uint32_t getObjSizeUint32() const
Returns the size of a data object in units of uint32_t.
readCCLHist.float
float
Definition: readCCLHist.py:83
TileCalibDrawerBase::getAddress
const void * getAddress(unsigned int iEle) const
Returns start address of iEle-th basic unit.