REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
Public Member Functions | Data Fields | Protected Attributes | Private Member Functions
TRestRawSignal Class Reference

Detailed Description

It defines a Short_t array with a physical parameter that evolves in time using a fixed time bin.

TRestRawSignal is ... a longer description comes here

DOCUMENTATION TO BE WRITTEN (main description, figures, ...)


Warning
⚠ REST is under continous development. This documentation is offered to you by the REST community. Your HELP is needed to keep this code up to date. Your feedback will be worth to support this software, please report any problems/suggestions you may find will using it at The REST Framework forum. You are welcome to contribute fixing typos, updating information or adding/proposing new contributions. See also our Contribution Guide.

RESTsoft - Software for Rare Event Searches with TPCs

History of developments:

2017-February: First concept and implementation of TRestRawSignal class.

Author
Javier Galan

2022-January: Added robust baseline calculation methods

Author
Konrad Altenmüller

Definition at line 36 of file TRestRawSignal.h.

#include <TRestRawSignal.h>

Public Member Functions

void AddOffset (Short_t offset)
 This method adds an offset to the signal data.
 
void AddPoint (Double_t)
 Adds a new point to the end of the signal data array.
 
void AddPoint (Short_t)
 Adds a new point to the end of the signal data array.
 
void CalculateBaseLine (Int_t startBin, Int_t endBin, const std::string &option="")
 This method calculates the average and fluctuation of the baseline in the specified range and writes the values to fBaseLine and fBaseLineSigma respectively. Without further option, this method calculates the average as arithmetic mean, and the fluctuation as standard deviation. More...
 
void CalculateBaseLineMean (Int_t startBin, Int_t endBin)
 This method is called by CalculateBaseLine and is used to determine the value of the baseline as average (arithmetic mean) of the data points found in the range defined between startBin and endBin.
 
void CalculateBaseLineMedian (Int_t startBin, Int_t endBin)
 This method is called by CalculateBaseLine with the "ROBUST"-option and is used to determine the value of the baseline as the median of the data points found in the range defined between startBin and endBin.
 
Double_t GetAverageInRange (Int_t startBin, Int_t endBin)
 It returns the average of the points found in the range (startBin, endBin)
 
Double_t GetBaseLine () const
 
void GetBaseLineCorrected (TRestRawSignal *smoothedSignal, Int_t averagingPoints)
 It applies the moving average filter (GetSignalSmoothed) to the signal, which is then subtracted from the raw data, resulting in a corrected baseline. The returned signal is placed at the signal pointer given by the argument. More...
 
Double_t GetBaseLineSigma () const
 
Double_t GetData (Int_t n) const
 It returns the data value of point n including baseline correction. More...
 
void GetDifferentialSignal (TRestRawSignal *diffSignal, Int_t smearPoints)
 It calculates the differential signal of the existing signal and it will place at the signal pointer given by argument. More...
 
TGraph * GetGraph (Int_t color=1)
 It builds a TGraph object that can be used for drawing.
 
Int_t GetHeadPoints () const
 Returns the number of head points used on points over threshold definition.
 
Int_t GetID () const
 Returns the value of signal ID.
 
Double_t GetIntegral ()
 It returns the integral of points found in the region defined by fRange. If fRange was not defined the integral is calculated in the full range.
 
Double_t GetIntegralInRange (Int_t startBin, Int_t endBin)
 It returns the integral of points found in the specific range given by (startBin,endBin).
 
Int_t GetMaxPeakBin ()
 It returns the bin at which the maximum peak amplitude happens.
 
Double_t GetMaxPeakValue ()
 It returns the amplitude of the signal maximum, baseline will be corrected if CalculateBaseLine was called first.
 
Int_t GetMaxPeakWidth ()
 It returns the temporal width of the peak with maximum amplitude inside the signal.
 
Double_t GetMaxValue ()
 Returns the maximum value found in the data points. It includes baseline correction.
 
Int_t GetMinPeakBin ()
 It returns the bin at which the minimum peak amplitude happens.
 
Double_t GetMinPeakValue ()
 It returns the amplitude of the signal minimum, baseline will be corrected if CalculateBaseLine was called first.
 
Double_t GetMinValue ()
 Returns the lowest value found in the data points. It includes baseline correction.
 
Int_t GetNumberOfPoints () const
 Returns the actual number of points, or size of the signal.
 
std::vector< std::pair< UShort_t, double > > GetPeaks (double threshold, UShort_t distance=5) const
 
std::vector< Int_t > GetPointsOverThreshold () const
 Returns a std::vector containing the indexes of data points over threshold.
 
TVector2 GetRange () const
 Returns the range defined by user.
 
Double_t GetRawData (Int_t n) const
 It returns the original data value of point n without baseline correction.
 
Double_t GetRiseSlope ()
 It returns the rate of change or slope from the points that have been identified over threshlold on the first positive rise of the signal. InitializePointsOverThreshold should have been called first.
 
Int_t GetRiseTime ()
 It returns the time required from the signal to reach the maximum. InitializePointsOverThreshold should have been called first.
 
UInt_t GetSeed () const
 
Int_t GetSignalID () const
 Returns the value of signal ID.
 
std::vector< Float_t > GetSignalSmoothed (Int_t averagingPoints, std::string option="")
 It smoothes the existing signal and returns it in a vector of Float_t values. More...
 
void GetSignalSmoothed (TRestRawSignal *smoothedSignal, Int_t averagingPoints)
 It smoothes the existing signal and places it at the signal pointer given by argument. More...
 
Double_t GetSlopeIntegral ()
 It returns the integral of points identified over threshold found in the first positive rise of the signal. InitializePointsOverThreshold should have been called first.
 
Int_t GetTailPoints () const
 Returns the number of tail points used on points over threshold definition.
 
Double_t GetThresholdIntegral ()
 It returns the integral of points identified over threshold. InitializePointsOverThreshold should have been called first.
 
Double_t GetTripleMaxIntegral ()
 It returns the integral calculated using the maximum signal amplitude and its neightbour points.
 
void GetWhiteNoiseSignal (TRestRawSignal *noiseSignal, Double_t noiseLevel=1.)
 It calculates an arbitrary Gaussian noise placing it at the signal pointer given by argument. The number of points defined will be the same as the existing signal. More...
 
void IncreaseBinBy (Int_t bin, Double_t data)
 It adds the content of data to fSignalData[bin].
 
void Initialize ()
 Initialization of TRestRawSignal members.
 
void InitializePointsOverThreshold (const TVector2 &thrPar, Int_t nPointsOver, Int_t nPointsFlat=512)
 It initializes the fPointsOverThreshold array with the indexes of data points that are found over threshold. The parameters provided to this method are used to identify those points. More...
 
Bool_t IsADCSaturation (int Nflat=3)
 It returns whether the signal has ADC saturation.
 
Bool_t isBaseLineInitialized () const
 Returns false if the baseline and its baseline fluctuation was not initialized.
 
Short_t operator[] (Int_t n)
 It overloads the operator [] so that we can retrieve a particular point n in the form rawSignal[n].
 
void Print () const
 It prints the signal data on screen.
 
void Reset ()
 Initializes the existing signal data and sets it to zero while keeping the array size.
 
void Scale (Double_t value)
 This method scales the signal by a given value.
 
void SetHeadPoints (Int_t p)
 It sets the number of head points.
 
void SetID (Int_t sID)
 It sets the id number of the signal.
 
void SetRange (const TVector2 &range)
 It sets/constrains the range for any calculation.
 
void SetRange (Int_t from, Int_t to)
 It sets/constrains the range for any calculation.
 
void SetRangeToMax ()
 
void SetSeed (UInt_t seed)
 
void SetSignalID (Int_t sID)
 It sets the id number of the signal.
 
void SetTailPoints (Int_t p)
 It sets the number of tail points.
 
void SignalAddition (const TRestRawSignal &signal)
 This method adds the signal provided by argument to the existing signal.
 
 TRestRawSignal ()
 Default constructor.
 
 TRestRawSignal (Int_t nBins)
 Default constructor initializing fSignalData with a number of points equal to nBins.
 
void WriteSignalToTextFile (const TString &filename)
 This method dumps to a text file the data inside fSignalData.
 
 ~TRestRawSignal ()
 Default destructor.
 

Data Fields

Double_t fBaseLine = 0
 This baseline value will be subtracted from GetData for any raw signal observable calculation.
 
Double_t fBaseLineSigma = 0
 The baseline fluctuation calculated as the standard deviation of the baseline.
 
TGraph * fGraph
 A TGraph pointer used to store the TRestRawSignal drawing.
 
Int_t fHeadPoints
 It defines the number of points to include before point over threshold definition. NOT implemented.
 
std::vector< Int_t > fPointsOverThreshold
 A std::vector containing the index of points that are identified over threshold.
 
TVector2 fRange = TVector2(0, 0)
 Any signal calculation will be restricted to the following range definition.
 
Int_t fTailPoints
 It defines the number of points to include after point over threshold definition. NOT implemented.
 
Double_t fThresholdIntegral = -1
 It stores the integral value obtained from the points identified over threshold.
 

Protected Attributes

UInt_t fSeed = gRandom->GetSeed()
 Seed used for random number generation.
 
Bool_t fShowWarnings = true
 
std::vector< Short_t > fSignalData
 Vector with the data of the signal.
 
Int_t fSignalID
 An integer value used to attribute a unique identification number to the signal.
 

Private Member Functions

void CalculateBaseLineSigmaIQR (Int_t startBin, Int_t endBin)
 This method is called by CalculateBaseLine with the "ROBUST"-option to determine the value of the baseline fluctuation as its interquartile range (IQR) in the baseline range provided. The IQR is more robust towards outliers than the standard deviation.
 
void CalculateBaseLineSigmaSD (Int_t startBin, Int_t endBin)
 This method is called by CalculateBaseLine to determine the value of the baseline fluctuation as its standard deviation in the baseline range provided.
 
void CalculateThresholdIntegral ()
 This method will be called each time InitializePointsOverThreshold is called to re-define the value of fThresholdIntegral. This method is only used internally.
 
std::vector< Float_t > GetSignalSmoothed_ExcludeOutliers (Int_t averagingPoints)
 It smooths the existing signal and returns it in a vector of Float_t values. This method excludes points which are far off from the BaseLine IQR (e.g. signals). In case the baseline parameters were not calculated yet, this method calls CalculateBaseLine with the "ROBUST" option on the entire signal range minus 5 bins on the edges. More...
 

Member Function Documentation

◆ CalculateBaseLine()

void TRestRawSignal::CalculateBaseLine ( Int_t  startBin,
Int_t  endBin,
const std::string &  option = "" 
)

This method calculates the average and fluctuation of the baseline in the specified range and writes the values to fBaseLine and fBaseLineSigma respectively. Without further option, this method calculates the average as arithmetic mean, and the fluctuation as standard deviation.

Parameters
optionBy setting this option to "ROBUST", the average is calculated as median, and the fluctuation as interquartile range (IQR), which are less affected by outliers (e.g. a signal pulse).

Definition at line 776 of file src/TRestRawSignal.cxx.

◆ GetBaseLine()

Double_t TRestRawSignal::GetBaseLine ( ) const
inline

Returns the value of baseline that it is initialized after calling CalculateBaseLine.

Definition at line 109 of file TRestRawSignal.h.

◆ GetBaseLineCorrected()

void TRestRawSignal::GetBaseLineCorrected ( TRestRawSignal smoothedSignal,
Int_t  averagingPoints 
)

It applies the moving average filter (GetSignalSmoothed) to the signal, which is then subtracted from the raw data, resulting in a corrected baseline. The returned signal is placed at the signal pointer given by the argument.

Parameters
smoothedSignalThe pointer to the TRestRawSignal which will contain the corrected signal
averagingPointsIt defines the number of neighbour consecutive points used to average the signal

Definition at line 716 of file src/TRestRawSignal.cxx.

◆ GetBaseLineSigma()

Double_t TRestRawSignal::GetBaseLineSigma ( ) const
inline

Returns the value of baseline sigma that it is initialized after calling CalculateBaseLineSigmaSD or CalculateBaseLineSigmaIQR.

Definition at line 113 of file TRestRawSignal.h.

◆ GetData()

Double_t TRestRawSignal::GetData ( Int_t  n) const

It returns the data value of point n including baseline correction.

This method will substract the internal value of fBaseLine that is extracted from the existing data points after calling the method CalculateBaseLine. If CalculateBaseLine has not been called previously, this method will return the raw values inside fSignalData.

Definition at line 169 of file src/TRestRawSignal.cxx.

◆ GetDifferentialSignal()

void TRestRawSignal::GetDifferentialSignal ( TRestRawSignal diffSignal,
Int_t  smearPoints 
)

It calculates the differential signal of the existing signal and it will place at the signal pointer given by argument.

Parameters
smearPointsis a number bigger that 0 that serves to change the time distance of points used to obtain the differential at a given point.

Definition at line 567 of file src/TRestRawSignal.cxx.

◆ GetPeaks()

vector< pair< UShort_t, double > > TRestRawSignal::GetPeaks ( double  threshold,
UShort_t  distance = 5 
) const

Returns the (time, amplitude) of the peaks in the signal. Peaks are defined as the points that are above the threshold and are separated by a minimum distance in time bin units. The threshold must be set in absolute value (regardless of the baseline)

Definition at line 912 of file src/TRestRawSignal.cxx.

◆ GetSignalSmoothed() [1/2]

std::vector< Float_t > TRestRawSignal::GetSignalSmoothed ( Int_t  averagingPoints,
std::string  option = "" 
)

It smoothes the existing signal and returns it in a vector of Float_t values.

Parameters
averagingPointsIt defines the number of neighbour consecutive points used to average the signal
optionIf the option is set to "EXCLUDE OUTLIERS", points that are too far away from the median baseline will be ignored to improve the smoothing result

Definition at line 640 of file src/TRestRawSignal.cxx.

◆ GetSignalSmoothed() [2/2]

void TRestRawSignal::GetSignalSmoothed ( TRestRawSignal smoothedSignal,
Int_t  averagingPoints 
)

It smoothes the existing signal and places it at the signal pointer given by argument.

Parameters
averagingPointsIt defines the number of neighbour consecutive points used to average the signal

Definition at line 612 of file src/TRestRawSignal.cxx.

◆ GetSignalSmoothed_ExcludeOutliers()

std::vector< Float_t > TRestRawSignal::GetSignalSmoothed_ExcludeOutliers ( Int_t  averagingPoints)
private

It smooths the existing signal and returns it in a vector of Float_t values. This method excludes points which are far off from the BaseLine IQR (e.g. signals). In case the baseline parameters were not calculated yet, this method calls CalculateBaseLine with the "ROBUST" option on the entire signal range minus 5 bins on the edges.

Parameters
averagingPointsIt defines the number of neightbour consecutive points used to average the signal

Definition at line 677 of file src/TRestRawSignal.cxx.

◆ GetWhiteNoiseSignal()

void TRestRawSignal::GetWhiteNoiseSignal ( TRestRawSignal noiseSignal,
Double_t  noiseLevel = 1. 
)

It calculates an arbitrary Gaussian noise placing it at the signal pointer given by argument. The number of points defined will be the same as the existing signal.

Parameters
noiseLevelIt defines the amplitude of the signal noise fluctuations as its standard deviation.

Definition at line 594 of file src/TRestRawSignal.cxx.

◆ InitializePointsOverThreshold()

void TRestRawSignal::InitializePointsOverThreshold ( const TVector2 &  thrPar,
Int_t  nPointsOver,
Int_t  nPointsFlat = 512 
)

It initializes the fPointsOverThreshold array with the indexes of data points that are found over threshold. The parameters provided to this method are used to identify those points.

Parameters
thrParA TVector2 defining two parameters: pointThreshold and signalThreshold. Both numbers define the number of sigmas over the baseline fluctuation, stored in fBaseLineSigma. The first parameter, pointThreshold, serves to identify if a single point is over threshold by satisfying the condition that is above the baseline by the number of sigmas given in pointThreshold. Once a certain number of consecutive points have been identified, the parameter signalThreshold will serve to reject the signals (consecutive points over threshold) that their standard deviation is lower that signalThreshold times the baseline fluctuation.
nPointsOverOnly data points with at least nPointsOver consecutive points will be considered.
nPointsFlatIt will serve to terminate the points over threshold identification in signals where we find an overshoot, being the baseline not returning to zero (or its original value) at the signal tail.

Definition at line 222 of file src/TRestRawSignal.cxx.


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