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

Detailed Description

Metadata class to calculate,store and apply the gain corrected calibration of a group of detectors.

TRestDataSetGainMap calculates and stores the calibration parameters for a given detector with multiple (or just one) modules. The modules are defined using the Module class (defined internally). It performs a gain correction based on a spatial segmentation of the detector module. This is useful forbig modules such as the ones used in TREX-DM experiment. The input data files for this methods are TRestDataSet for both calculating the calibration parameters and performing the calibration of the desired events.

To correct the gain inhomogeneities, the module is divided in fNumberOfSegmentsX*fNumberOfSegmentsY segments. The energy peaks provided are fitted in each segment. The events are associated to each segment based on the observables fSpatialObservableX and fSpatialObservablesY. This results in the following plot that can be obtain with the function TRestDataSetGainMap::Module::DrawSpectrum()

TRestDataSetGainMap::Module::DrawSpectrum()" TRestDataSetGainMap::Module::DrawSpectrum()" TRestDataSetGainMap::Module::DrawSpectrum()" TRestDataSetGainMap::Module::DrawSpectrum()"

Also, the peak position provides a gain map that can be plotted with the function TRestDataSetGainMap::Module::DrawGainMap(peakNumber)

The result is a better energy resolution with the gain corrected calibration (red) than the plain calibration (blue).

Parameters

Examples

A example of RML definition of this class can be found inside the file REST_PATH/examples/calibrationCorrection.rml. This have the following structure:

<TRestDataSetGainMap name="calib">
...
<module>
...
</module>
<module>
...
</module>
Metadata class to calculate,store and apply the gain corrected calibration of a group of detectors.

Example to calculate the calibration parameters over a calibration dataSet using restRoot:

TRestDataSetGainMap gm ("calibrationCorrection.rml");
gm.SetCalibrationFileName("myDataSet.root"); //if not already defined in rml file
gm.SetOutputFileName("myCalibration.root"); //if not already defined in rml file
gm.GenerateGainMap();
gm.Export(); // gm.Export("anyOtherFileName.root")

Example to calibrate a dataSet with the previously calculated calibration parameters and draw the result (using restRoot):

gm.Import("myCalibration.root");
gm.CalibrateDataSet("dataSetToCalibrate.root", "calibratedDataSet.root");
ds.Import("calibratedDataSet.root");
auto h = ds.GetDataFrame().Histo1D({"hname", "",100,-1,40.}, "calib_ThresholdIntegral");
h->Draw();
void CalibrateDataSet(const std::string &dataSetFileName, std::string outputFileName="", std::vector< std::string > excludeColumns={})
Function to calibrate a dataset with this gain map.
void Import(const std::string &fileName)
Function to import the calibration parameters from the root file fileName.
It allows to group a number of runs that satisfy given metadata conditions.
Definition: TRestDataSet.h:34
void Import(const std::string &fileName)
This function imports metadata from a root file it import metadata info from the previous dataSet whi...
ROOT::RDF::RNode GetDataFrame() const
Gives access to the RDataFrame.
Definition: TRestDataSet.h:129

Example to refit manually the peaks of the gain map if any of them is not well fitted (using restRoot):

gm.Import("myCalibration.root");
// Draw all segmented spectra and check if any need a refit
for (auto pID : gm.GetPlaneIDs())
for (auto mID : gm.GetModuleIDs(pID))
gm.GetModule(pID,mID)->DrawSpectrum();
// Draw only the desired spectrum (segment 0,0 in this case)
gm.GetModule(0,0)->DrawSpectrum(0, 0);
// Refit the desired peak (peak with energy 22.5 in this case) with a new range
TVector2 range(100000, 200000); // Define here the new range for the fit as you wish
gm.GetModule(0,0)->Refit(TVector2(0,0), 22.5, range);
// Check the result
gm.GetModule(0,0)->DrawSpectrum(TVector2(0.0,0.0)); // using x,y physical coord is possible
// Export the new calibration
gm.Export(); // gm.Export("anyOtherFileName.root")
void DrawSpectrum(const bool drawFits=true, const int color=-1, TCanvas *c=nullptr)
Function to draw the spectrum for each segment of the module on the same canvas. The canvas is divide...
void Refit(const TVector2 &position, const double energy, const TVector2 &range)
Function to fit again manually a peak for a given segment of the module.
std::set< int > GetModuleIDs(const int planeId) const
Function to get a list (set) of the module IDs of the plane with planeID.
void Export(const std::string &fileName="")
Function to export the calibration to the file fileName.
std::set< int > GetPlaneIDs() const
Function to get a list (set) of the plane IDs.
Module * GetModule(const size_t index=0)
Function to retrieve the module calibration by index. Default is 0.

REST-for-Physics - Software for Rare Event Searches Toolkit

History of developments:

2023-September: First implementation of TRestDataSetGainMap Álvaro Ezquerro

Author
: Álvaro Ezquerro aezqu.nosp@m.erro.nosp@m.@uniz.nosp@m.ar.e.nosp@m.s

Definition at line 41 of file TRestDataSetGainMap.h.

#include <TRestDataSetGainMap.h>

Inheritance diagram for TRestDataSetGainMap:
TRestMetadata

Data Structures

class  Module
 

Public Member Functions

void CalibrateDataSet (const std::string &dataSetFileName, std::string outputFileName="", std::vector< std::string > excludeColumns={})
 Function to calibrate a dataset with this gain map. More...
 
 ClassDefOverride (TRestDataSetGainMap, 2)
 
void Export (const std::string &fileName="")
 Function to export the calibration to the file fileName. More...
 
void GenerateGainMap ()
 Function to calculate the calibration parameters of all modules.
 
std::string GetCalibrationFileName () const
 
TRestCutGetCut () const
 
double GetInterceptParameter (const int planeID, const int moduleID, const double x, const double y)
 Function to get the intercept parameter of the module with planeID and moduleID at physical position (x,y)
 
double GetInterceptParameterFullSpc (const int planeID, const int moduleID)
 Function to get the intercept parameter of the whole module with planeID and moduleID.
 
ModuleGetModule (const int planeID, const int moduleID)
 Function to retrieve the module calibration with planeID and moduleID.
 
ModuleGetModule (const size_t index=0)
 Function to retrieve the module calibration by index. Default is 0.
 
std::map< int, std::set< int > > GetModuleIDs () const
 Function to get the map of the module IDs for each plane ID.
 
std::set< int > GetModuleIDs (const int planeId) const
 Function to get a list (set) of the module IDs of the plane with planeID.
 
Int_t GetNumberOfModules () const
 
Int_t GetNumberOfPlanes () const
 
std::string GetObservable () const
 
std::string GetOutputFileName () const
 
std::set< int > GetPlaneIDs () const
 Function to get a list (set) of the plane IDs.
 
double GetSlopeParameter (const int planeID, const int moduleID, const double x, const double y)
 Function to get the slope parameter of the module with planeID and moduleID at physical position (x,y)
 
double GetSlopeParameterFullSpc (const int planeID, const int moduleID)
 Function to get the slope parameter of the whole module with planeID and moduleID.
 
std::string GetSpatialObservableX () const
 
std::string GetSpatialObservableY () const
 
void Import (const std::string &fileName)
 Function to import the calibration parameters from the root file fileName.
 
TRestDataSetGainMapoperator= (TRestDataSetGainMap &src)
 
void PrintMetadata () override
 Prints on screen the information about the metadata members.
 
void SetCalibrationFileName (const std::string &fileName)
 
void SetCut (TRestCut *cut)
 
void SetModule (const Module &moduleCal)
 Function to set a module calibration. If the module calibration already exists (same planeId and moduleId), it will be replaced.
 
void SetObservable (const std::string &observable)
 
void SetOutputFileName (const std::string &fileName)
 
void SetSpatialObservableX (const std::string &spatialObservableX)
 
void SetSpatialObservableY (const std::string &spatialObservableY)
 
 TRestDataSetGainMap ()
 Default constructor.
 
 TRestDataSetGainMap (const char *configFilename, std::string name="")
 Constructor loading data from a config file. More...
 
 ~TRestDataSetGainMap ()
 Default destructor.
 

Private Member Functions

void InitFromConfigFile () override
 Initialization of TRestDataSetGainMap members through a RML file.
 
void Initialize () override
 Making default settings.
 

Private Attributes

std::string fCalibFileName = ""
 Name of the file that contains the calibration data.
 
TRestCutfCut = nullptr
 Cut to be applied to the calibration data.
 
std::vector< ModulefModulesCal = {}
 List of modules.
 
std::string fObservable = ""
 Observable that will be used to calculate the gain map.
 
std::string fOutputFileName = ""
 Name of the file where the gain map was (or will be) exported.
 
std::string fSpatialObservableX = ""
 Observable that will be used to segmentize the gain map in the x direction.
 
std::string fSpatialObservableY = ""
 Observable that will be used to segmentize the gain map in the y direction.
 

Additional Inherited Members

Constructor & Destructor Documentation

◆ TRestDataSetGainMap()

TRestDataSetGainMap::TRestDataSetGainMap ( const char *  configFilename,
std::string  name = "" 
)

Constructor loading data from a config file.

If no configuration path is defined using TRestMetadata::SetConfigFilePath the path to the config file must be specified using full path, absolute or relative.

The default behaviour is that the config file must be specified with full path, absolute or relative.

Parameters
configFilenameA const char* that defines the RML filename.
nameThe name of the metadata section. It will be used to find the corresponding TRestDataSetGainMap section inside the RML.

Definition at line 160 of file TRestDataSetGainMap.cxx.

Member Function Documentation

◆ CalibrateDataSet()

void TRestDataSetGainMap::CalibrateDataSet ( const std::string &  dataSetFileName,
std::string  outputFileName = "",
std::vector< std::string >  excludeColumns = {} 
)

Function to calibrate a dataset with this gain map.

Parameters
dataSetFileNamethe name of the root file where the TRestDataSet to be calibrated is stored.
outputFileNamethe name of the output (root) file where the calibrated TRestDataSet will be exported. If empty, the output file will be named as the input file plus the name of the TRestDataSetGainMap. E.g. "data/myDataSet.root" -> "data/myDataSet_<gmName>.root".
excludeColumnsa vector of strings with the names of the columns to be excluded from the output file. If empty, all columns will be included. If "all" is in the list, all columns will be excluded except the calibrated observable, the calibrated observable with no segmentation and the plane-module identifier (pmID).

Definition at line 222 of file TRestDataSetGainMap.cxx.

◆ Export()

void TRestDataSetGainMap::Export ( const std::string &  fileName = "")

Function to export the calibration to the file fileName.

Parameters
fileNameThe name of the output file. If empty, the output file will be the fOutputFileName class member.

Definition at line 493 of file TRestDataSetGainMap.cxx.


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