Pottu
Classes | Public Member Functions | List of all members
pottu::Calibrator Class Reference

Pipeline stage which applies second order calibration. More...

#include <Calibrator.hpp>

Inheritance diagram for pottu::Calibrator:
Inheritance graph
[legend]
Collaboration diagram for pottu::Calibrator:
Collaboration graph
[legend]

Classes

struct  item_t
 Struct holding the calibration coefficients. More...
 

Public Member Functions

 Calibrator ()
 Constructor. More...
 
void readFromGainsFile (const std::string &filename)
 Reads grain-compatible gains file. More...
 
double getCalibratedValue (unsigned int ch, int data) noexcept
 Returns a calibrated value for a ch and adc value. More...
 
void fillCalibratedEnergy (DetectorEvent &event) noexcept
 Returns a calibrated value for a detector event. More...
 
virtual void process (std::vector< DetectorEvent > &data) noexcept
 Assigns calibrated energies to all events. More...
 
void setCoefficients (unsigned int ch, float c0, float c1, float c2) noexcept
 Sets the coefficient for the channel. More...
 
- Public Member Functions inherited from pottu::StageDetectorEvent
virtual ~StageDetectorEvent ()
 Virtual desctructor.
 

Detailed Description

Pipeline stage which applies second order calibration.

The stage reads the adc value of each DetectorEvent, calculates the calibrated energy with the model

 e = a + b*x + c*x*x

where a, b and c are constants set by user or read from a file. The default values are a=0; b=1; c=0.

The maximum number of daq channels supported is 4096.

Constructor & Destructor Documentation

◆ Calibrator()

pottu::Calibrator::Calibrator ( )
inline

Constructor.

Creates the Calibrator object. All coefficients for daq channels 0–4095 are set to have a=0; b=1; c=0.

Member Function Documentation

◆ fillCalibratedEnergy()

void pottu::Calibrator::fillCalibratedEnergy ( DetectorEvent event)
inlinenoexcept

Returns a calibrated value for a detector event.

Parameters
eventDetector event which is used to read the channel number and adc value. Ch number of the event must be in range [0,4095]. Bigger number will read random memory location.
Returns
Calibrated value.

An uniformly distributed random number with range [-0.5,0.5] is summed to the adc value before applying the model.

◆ getCalibratedValue()

double pottu::Calibrator::getCalibratedValue ( unsigned int  ch,
int  data 
)
inlinenoexcept

Returns a calibrated value for a ch and adc value.

Parameters
chData acquisition channel number. Must be in range [0,4095]. Bigger number will read random memory location.
dataADC value to be used.
Returns
Calibrated value.

An uniformly distributed random number with range [-0.5,0.5] is summed to the adc value before applying the model.

◆ process()

virtual void pottu::Calibrator::process ( std::vector< DetectorEvent > &  data)
inlinevirtualnoexcept

Assigns calibrated energies to all events.

Parameters
dataDetector events to be calibrated.

Maximimum channel number is 4095 in DetectorEvent. Bigger number will lead to undefined behavior!

An uniformly distributed random number with range [-0.5,0.5] is summed to the adc value before applying the model.

Implements pottu::StageDetectorEvent.

◆ readFromGainsFile()

void pottu::Calibrator::readFromGainsFile ( const std::string &  filename)
inline

Reads grain-compatible gains file.

Parameters
filenameFilenmame of the gains file to be read.

File is read with scanf function with the format %d = %lf %lf %lf %d. I.e. the file should have rows like

32 = -23.4 0.456 0 0
921 = -1.4 0.1233 2.231124e-8 0

Channels which are not set in the file will remain unchanged.

◆ setCoefficients()

void pottu::Calibrator::setCoefficients ( unsigned int  ch,
float  c0,
float  c1,
float  c2 
)
inlinenoexcept

Sets the coefficient for the channel.

Parameters
chData-acquisition channel. Bigger values than 4095 causes exit(EXIT_FAILURE) to be called.
c0Offset value.
c1First order coefficient.
c2Second order coefficient.

The documentation for this class was generated from the following file: