ATLAS Offline Software
Loading...
Searching...
No Matches
TileCalibDrawerOfc.h File Reference
#include "TileCalibBlobObjs/TileCalibDrawerBase.h"
#include "TileCalibBlobObjs/TileCalibType.h"
#include "TileCalibBlobObjs/TileCalibUtils.h"
#include "CoralBase/Blob.h"
#include <iosfwd>
#include <vector>
#include <cstdint>
#include <cmath>
#include <string>
#include <cstring>
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.

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 37 of file TileCalibDrawerOfc.h.

Function Documentation

◆ __attribute__()

__attribute__ ( (always_inline) )

Definition at line 202 of file TileCalibDrawerOfc.h.

203 {
204 return *(static_cast<const uint32_t*>(getAddress(0)));
205}
206
207//
208//______________________________________________________________
209__attribute__((always_inline))
210inline int32_t TileCalibDrawerOfc::getNPhases() const {
211 return *(static_cast<const int32_t*>(getAddress(1)));
212}
213
214//
215//______________________________________________________________
216__attribute__((always_inline))
217inline unsigned int TileCalibDrawerOfc::getPhaseNumber(unsigned int channel, unsigned int adc, float& phase) const {
218
219 if (std::abs(phase) > 1e6F) {
220 // Bad phase is requested (probably, bad value is in the DB)
221 phase = 0.0F;
222 }
223 int db_phase = (int) std::round(phase * (1 / PHASE_PRECISION)); // Phases are stored as int(10*phase) in DB
224 const int32_t* beg = getPhaseStartAddress(channel, adc, 0);
225 const int32_t* end = beg + std::abs(getNPhases());
226 const int32_t* pos = std::lower_bound(beg, end, db_phase);
227
228 if (pos == end || (*pos != db_phase && pos != beg && (*pos - db_phase) > (db_phase - *(pos - 1)))) {
229 --pos;
230 }
231
233 return (pos - beg);
234}
235
236//
237//______________________________________________________________
238__attribute__((always_inline))
239inline float TileCalibDrawerOfc::getPhase(unsigned int channel, unsigned int adc, unsigned int phaseIdx) const {
240 return *(getPhaseStartAddress(channel, adc, phaseIdx)) * PHASE_PRECISION; // Phases are stored as int(10*phase) in DB
241}
242
243//
244//______________________________________________________________
245__attribute__((always_inline))
246inline uint32_t TileCalibDrawerOfc::getNFields(uint16_t objVersion) const {
247 //=== determine objVersion from Blob if default is passed
248 if(objVersion==0) objVersion = getObjVersion();
249
250 if( objVersion == 3){ return 5; }
251 else if(objVersion == 2){ return 4; }
252 else if(objVersion == 1){ return 3; }
253 else{
254 throw TileCalib::VersionConflict("TileCalibDrawerOfc::getNFields", objVersion);
255 }
256}
257
258//
259//______________________________________________________________
260inline float TileCalibDrawerOfc::getOfc(unsigned int field, unsigned int channel, unsigned int adc
261 , float phase, unsigned int sample) const {
262 if(sample >= getNSamples())
263 throw TileCalib::IndexOutOfRange("TileCalibDrawerOfc::getA", sample, getNSamples());
264 return getOfcStartAddress(field, channel, adc, phase)[sample];
265}
266
267inline void TileCalibDrawerOfc::fillOfc (unsigned int channel,unsigned int adc, float& phase
268 , float* w_a, float* w_b, float* w_c, float* g, float* dg) const {
269
270
271 const float* startAddress = getOfcStartAddress(TileCalibDrawerOfc::FieldA, channel, adc, phase);
272 size_t allSamplesSize = getNSamples() * sizeof(float);
273 size_t fieldSize = getObjSizeUint32() * getNSamples();
274
275 std::memcpy(w_a, startAddress, allSamplesSize);
276 startAddress += fieldSize;
277 std::memcpy(w_b, startAddress, allSamplesSize);
278 startAddress += fieldSize;
279 std::memcpy(g, startAddress, allSamplesSize);
280 startAddress += fieldSize;
281 std::memcpy(w_c, startAddress, allSamplesSize);
282 if (getNFields() > 4) {
283 startAddress += fieldSize;
284 std::memcpy(dg, startAddress, allSamplesSize);
285 } else {
286 std::memset(dg, 0, allSamplesSize);
287 }
288}
289
290
291//
292//______________________________________________________________
293inline void TileCalibDrawerOfc::setOfc(unsigned int field,unsigned int channel, unsigned int adc
294 , float phase, unsigned int sample, float value) {
295 if(sample >= getNSamples())
296 throw TileCalib::IndexOutOfRange("TileCalibDrawerOfc::setOfc", sample, getNSamples());
297 getOfcStartAddress(field, channel, adc, phase)[sample] = value;
298}
__attribute__((always_inline)) inline uint32_t TileCalibDrawerOfc
#define PHASE_PRECISION
Class for storing Optimal Filtering Coefficients (OFCs) in a coral::Blob.
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.
const void * getAddress(unsigned int iEle) const
Returns start address of iEle-th basic unit.
unsigned int getPhaseNumber(unsigned int channel, unsigned int adc, float &phase) const
Returns the index for a given phase.
int32_t getNPhases() const
Returns the number of phases (WARNING: Can be negative!).
void setOfc(unsigned int field, unsigned int channel, unsigned int adc, float phase, unsigned int sample, float value)
Sets OFC data.
float getPhase(unsigned int channel, unsigned int adc, unsigned int phaseIdx) const
Returns the stored phase.
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.
uint32_t getNSamples() const
Returns the number of sample stored.
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.
float getOfc(unsigned int field, unsigned int channel, unsigned int adc, float phase, unsigned int sample) const
Returns OFC data.
const int32_t * getPhaseStartAddress(unsigned int channel, unsigned int adc, unsigned int phaseIdx) const
Returns pointer to the requested phase value.
uint32_t getNFields(uint16_t objVersion=0) const
Returns the number of fields.
setEventNumber uint32_t