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

Detailed Description

Perform the plot over datasets.

This class is meant to perform the plots over a TRestDataSet and it is meant to replace TRestAnalysisPlot. A dataset is should be provided as input file in order to perform de plots, in addition the possibility to provide a file pattern is also supported for backward compatibility although this method will be deprecated. The rml file has been modified with respect to TRestAnalysisPlot, major changes are that now a TRestCut must be defined in advance in order to perform the cuts over the dataset, in addition the panel/label metadata has been changed in order to distinguish between metadata, variables or observable values.

The rml file can be splitted in three main blocks that are detailed below;

Parameters

Example of TRestDataSetPlot basic parameters with a set TRestCuts:

<TRestDataSetPlot name="restplot" title="Basic Plots" previewPlot="true" canvasSize="(1200,1200)"
canvasDivisions="(2,2)" verboseLevel="info">
<addCut name="North"/>
<addCut name="TrackBalance"/>
<TRestCut name="North" verboseLevel="info">
<cut name="c1" variable="alphaTrackAna_originZ" condition="<0"/>
<TRestCut name="TrackBalance" verboseLevel="info">
<cut name="c2" variable="alphaTrackAna_trackBalanceX" condition=">0.9"/>
<cut name="c3" variable="alphaTrackAna_trackBalanceY" condition=">0.9"/>
A class to help on cuts definitions. To be used with TRestAnalysisTree.
Definition: TRestCut.h:31
Perform the plot over datasets.

Example of panel rule:

<panel font_size="0.05" precision="3">
<metadata value="[TRestRun::fRunTag]" label="Run tag" x="0.25" y="0.82" />
<variable value="[[entries]]" label="Entries" x="0.25" y="0.58" />
<observable value="alphaTrackAna_angle" label="Mean Angle" units="rad" x="0.25" y="0.01" />
<expression value="cos(alphaTrackAna_angle)^2" label="Cosine of the mean angle" units="" x="0.25"
y="0.12" />
<expression value="[TRestDetector::fDriftField]*[TRestDetector::fPressure]" label="Drift field"
units="V/cm" x="0.25" y="0.24" />
<addCut name="Fiducial"/>
</panel>

Example of plot rule:

<plot name="TrackOrigin" title="TrackOrigin" xlabel="X [mm]" ylabel="Y [mm]" save="HitMapUpwards.pdf"
value="ON" >
<histo name="HitMapUpwards" >
<variable name="alphaTrackAna_originX" range="(0,250)" nbins="256" />
<variable name="alphaTrackAna_originY" range="(0,250)" nbins="256" />
<addCut name="Upwards"/>
</histo>
</plot>

Examples

Following example creates one panel and three plots including one or two histograms:

<TRestManager name="alphaTrack" title="alphaTrack" verboseLevel="info">
<TRestDataSetPlot name="alphaTrackPlot" title="Basic Plots for alpha tracks" previewPlot="true"
canvasSize="(1200,1200)" canvasDivisions="(2,2)" verboseLevel="info"
outputFileName="Plots_[TRestRun::fRunTag]_plots.root">
<addCut name="North"/>
<addCut name="TrackBalance"/>
<TRestCut name="North" verboseLevel="info">
<cut name="c1" variable="alphaTrackAna_originZ" condition="<0"/>
<TRestCut name="Fiducial" verboseLevel="info">
<cut name="c2" variable="alphaTrackAna_originX" condition=">20"/>
<cut name="c3" variable="alphaTrackAna_originX" condition="<225"/>
<cut name="c4" variable="alphaTrackAna_originY" condition=">20"/>
<cut name="c5" variable="alphaTrackAna_originY" condition="<225"/>
<TRestCut name="Upwards" verboseLevel="info">
<cut name="c6" variable="alphaTrackAna_downwards" condition="==false"/>
<TRestCut name="Downwards" verboseLevel="info">
<cut name="c7" variable="alphaTrackAna_downwards" condition="==true"/>
<TRestCut name="TrackBalance" verboseLevel="info">
<cut name="c8" variable="alphaTrackAna_trackBalanceX" condition=">0.9"/>
<cut name="c9" variable="alphaTrackAna_trackBalanceY" condition=">0.9"/>
<panel font_size="0.05" precision="3">
<variable label="Summary" x="0.25" y="0.9"/>
<metadata value="[TRestRun::fRunTag]" label="Run tag" x="0.25" y="0.82"/>
<variable value="[[startTime]]" label="Data starts" x="0.25" y="0.74"/>
<variable value="[[endTime]]" label="Data ends" x="0.25" y="0.66"/>
<variable value="[[entries]]" label="Entries" x="0.25" y="0.58"/>
<variable value="[[runLength]]" label="Run duration" units="hours" x="0.25" y="0.50"/>
<observable value="alphaTrackAna_angle" label="Mean Angle" units="rad" x="0.25" y="0.42"/>
<addCut name="Fiducial"/>
</panel>
<plot name="TrackOrigin" title="TrackOrigin" xlabel="X [mm]" ylabel="Y [mm]" save="" value="ON"
stats="ON">
<variable name="alphaTrackAna_originX" range="(0,250)" nbins="256"/>
<variable name="alphaTrackAna_originY" range="(0,250)" nbins="256"/>
</plot>
<plot name="Spectra" title="Spectra" xlabel="Amplitude(ADC)" ylabel="Counts" legend="ON" value="ON"
save="Spectra.pdf">
<histo name="SpectraDownwards">
<variable name="alphaTrackAna_totalEnergy" range="(0,1000000)" nbins="200"/>
<addCut name="Fiducial"/>
<addCut name="Downwards"/>
</histo>
<histo name="SpectraUpwards">
<variable name="alphaTrackAna_totalEnergy" range="(0,1000000)" nbins="200"/>
<parameter name="lineColor" value="1"/>
<addCut name="Fiducial"/>
<addCut name="Upwards"/>
</histo>
</plot>
<plot name="Rate" title="Rate" xlabel="Date/time" ylabel="Rate (Hz)" legend="ON" value="ON"
scale="binSize" timeDisplay="ON">
<histo name="RateDownwards">
<variable name="timeStamp" range="" nbins="100"/>
<addCut name="Downwards"/>
</histo>
<histo name="RateUpwards">
<variable name="timeStamp" range="" nbins="100"/>
<parameter name="lineColor" value="1"/>
<addCut name="Upwards"/>
</histo>
</plot>
<addTask command="alphaTrackPlot->PlotCombinedCanvas()" value="ON"/>
Managing applications and executing tasks.
Definition: TRestManager.h:16

Running example

restManager --c thisExample.rml --f FileWithDataSet.root

Figure to be added (a png image should be uploaded to the ./images/ directory)


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

History of developments:

2023-04: First implementation of TRestDataSetPlot, based on TRestAnalysisPlot JuanAn Garcia

2024-05: Extend some functionalities, Álvaro Ezquerro

Author
: JuanAn Garcia e-mail: juana.nosp@m.ngp@.nosp@m.uniza.nosp@m.r.es

Definition at line 33 of file TRestDataSetPlot.h.

#include <TRestDataSetPlot.h>

Inheritance diagram for TRestDataSetPlot:
TRestMetadata

Data Structures

struct  HistoInfo
 Nested classes for internal use only. More...
 
struct  PanelInfo
 Auxiliary class for panels/labels. More...
 
struct  PlotInfo
 Auxiliary struct for plots/pads. More...
 

Public Member Functions

 ClassDefOverride (TRestDataSetPlot, 2)
 
void CleanUp ()
 Clean up histos and text but note that the metadata is unchanged. More...
 
void GenerateDataSetFromFilePattern (TRestDataSet &dataSet)
 This functions generates a dataSet based on the information of the rml file. A TRestDataSet is pased as reference and will be overwritten. More...
 
Int_t GetIDFromMapString (const std::map< std::string, int > &mapStr, const std::string &in)
 This functions gets the ID from a map string that is passed by reference. It is used to translate colors, line styles and fill styles from the string to an integer value. More...
 
void Initialize () override
 Function to initialize input/output event members and define the section name. More...
 
void PlotCombinedCanvas ()
 This functions performs the plot of the combined canvas with the different panels and plots. More...
 
void PrintMetadata () override
 Prints on screen the information about the metadata members of TRestDataSetPlot. More...
 
TRestCutReadCut (TRestCut *cut, TiXmlElement *ele=nullptr)
 this function is used to add the different cuts provided in different metadata sections, it uses as parameter the cut where the cut is meant to be added and returns the added cut. If *cut is a nullptr it just instantiate it More...
 
void ReadPanelInfo ()
 This function reads the config file panel info and stores it in a vector of PanelInfo. More...
 
void ReadPlotInfo ()
 This function reads the config file plot info and stores it in a vector of PlotInfo. More...
 
 TRestDataSetPlot ()
 Default constructor. More...
 
 TRestDataSetPlot (const char *configFilename, std::string name="")
 Constructor loading data from a config file. More...
 
 ~TRestDataSetPlot ()
 Default destructor. More...
 

Private Member Functions

void InitFromConfigFile () override
 Initialization of specific TRestDataSetPlot members through an RML file. More...
 

Private Attributes

const std::map< std::string, int > ColorIdMap
 Maps for internal use only. More...
 
TVector2 fCanvasDivisionMargins = TVector2(0.01, 0.01)
 
TVector2 fCanvasDivisions = TVector2(2, 2)
 
TVector2 fCanvasSize = TVector2(800, 600)
 Canvas options, size, divisions and margins. More...
 
TRestCutfCut = nullptr
 Global cut for the entire dataSet. More...
 
std::string fDataSetName = ""
 Name of the dataset to be imported. More...
 
const std::map< std::string, int > FillStyleMap
 FillStyleMap as enum "EFillStyle" defined in TAttFill.h. More...
 
Double_t fLegendX1 = 0.7
 Legend position and size. More...
 
Double_t fLegendX2 = 0.88
 
Double_t fLegendY1 = 0.75
 
Double_t fLegendY2 = 0.88
 
std::string fOutputFileName = ""
 OutputFileName. More...
 
Int_t fPaletteStyle = 57
 Palette style. More...
 
std::vector< PanelInfofPanels
 Vector with panels/label options. More...
 
std::vector< PlotInfofPlots
 Vector with plots/pads options. More...
 
Bool_t fPreviewPlot = true
 Preview plot. More...
 
const std::map< std::string, int > LineStyleMap
 LineStyleMap as enum "ELineStyle" defined in TAttLine.h. More...
 

Additional Inherited Members

Constructor & Destructor Documentation

◆ TRestDataSetPlot() [1/2]

TRestDataSetPlot::TRestDataSetPlot ( )

Default constructor.

Definition at line 284 of file TRestDataSetPlot.cxx.

◆ TRestDataSetPlot() [2/2]

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

Constructor loading data from a config file.

Definition at line 289 of file TRestDataSetPlot.cxx.

◆ ~TRestDataSetPlot()

TRestDataSetPlot::~TRestDataSetPlot ( )

Default destructor.

Definition at line 299 of file TRestDataSetPlot.cxx.

Member Function Documentation

◆ CleanUp()

void TRestDataSetPlot::CleanUp ( )

Clean up histos and text but note that the metadata is unchanged.

Definition at line 930 of file TRestDataSetPlot.cxx.

◆ GenerateDataSetFromFilePattern()

void TRestDataSetPlot::GenerateDataSetFromFilePattern ( TRestDataSet dataSet)

This functions generates a dataSet based on the information of the rml file. A TRestDataSet is pased as reference and will be overwritten.

Definition at line 505 of file TRestDataSetPlot.cxx.

◆ GetIDFromMapString()

Int_t TRestDataSetPlot::GetIDFromMapString ( const std::map< std::string, int > &  mapStr,
const std::string &  in 
)

This functions gets the ID from a map string that is passed by reference. It is used to translate colors, line styles and fill styles from the string to an integer value.

Definition at line 952 of file TRestDataSetPlot.cxx.

◆ InitFromConfigFile()

void TRestDataSetPlot::InitFromConfigFile ( )
overrideprivatevirtual

Initialization of specific TRestDataSetPlot members through an RML file.

Reimplemented from TRestMetadata.

Definition at line 310 of file TRestDataSetPlot.cxx.

◆ Initialize()

void TRestDataSetPlot::Initialize ( )
overridevirtual

Function to initialize input/output event members and define the section name.

Reimplemented from TRestMetadata.

Definition at line 305 of file TRestDataSetPlot.cxx.

◆ PlotCombinedCanvas()

void TRestDataSetPlot::PlotCombinedCanvas ( )

This functions performs the plot of the combined canvas with the different panels and plots.

Build the histograms and add them to the THStack

Definition at line 604 of file TRestDataSetPlot.cxx.

◆ PrintMetadata()

void TRestDataSetPlot::PrintMetadata ( )
overridevirtual

Prints on screen the information about the metadata members of TRestDataSetPlot.

Reimplemented from TRestMetadata.

Definition at line 968 of file TRestDataSetPlot.cxx.

◆ ReadCut()

TRestCut * TRestDataSetPlot::ReadCut ( TRestCut cut,
TiXmlElement *  ele = nullptr 
)

this function is used to add the different cuts provided in different metadata sections, it uses as parameter the cut where the cut is meant to be added and returns the added cut. If *cut is a nullptr it just instantiate it

Definition at line 328 of file TRestDataSetPlot.cxx.

◆ ReadPanelInfo()

void TRestDataSetPlot::ReadPanelInfo ( )

This function reads the config file panel info and stores it in a vector of PanelInfo.

Definition at line 349 of file TRestDataSetPlot.cxx.

◆ ReadPlotInfo()

void TRestDataSetPlot::ReadPlotInfo ( )

This function reads the config file plot info and stores it in a vector of PlotInfo.

Definition at line 427 of file TRestDataSetPlot.cxx.

Field Documentation

◆ ColorIdMap

const std::map<std::string, int> TRestDataSetPlot::ColorIdMap
private
Initial value:
{{"white", kWhite}, {"black", kBlack}, {"gray", kGray},
{"red", kRed}, {"green", kGreen}, {"blue", kBlue},
{"yellow", kYellow}, {"magenta", kMagenta}, {"cyan", kCyan},
{"orange", kOrange}, {"spring", kSpring}, {"teal", kTeal},
{"azure", kAzure}, {"violet", kViolet}, {"pink", kPink}}

Maps for internal use only.

ColorIdMap as enum "EColor" defined in Rtypes.h

Definition at line 108 of file TRestDataSetPlot.h.

◆ fCanvasDivisionMargins

TVector2 TRestDataSetPlot::fCanvasDivisionMargins = TVector2(0.01, 0.01)
private

Definition at line 156 of file TRestDataSetPlot.h.

◆ fCanvasDivisions

TVector2 TRestDataSetPlot::fCanvasDivisions = TVector2(2, 2)
private

Definition at line 155 of file TRestDataSetPlot.h.

◆ fCanvasSize

TVector2 TRestDataSetPlot::fCanvasSize = TVector2(800, 600)
private

Canvas options, size, divisions and margins.

Definition at line 154 of file TRestDataSetPlot.h.

◆ fCut

TRestCut* TRestDataSetPlot::fCut = nullptr
private

Global cut for the entire dataSet.

Definition at line 139 of file TRestDataSetPlot.h.

◆ fDataSetName

std::string TRestDataSetPlot::fDataSetName = ""
private

Name of the dataset to be imported.

Definition at line 133 of file TRestDataSetPlot.h.

◆ FillStyleMap

const std::map<std::string, int> TRestDataSetPlot::FillStyleMap
private
Initial value:
{
{"dotted", kFDotted1}, {"dashed", kFDashed1}, {"dotted1", kFDotted1},
{"dotted2", kFDotted2}, {"dotted3", kFDotted3}, {"hatched1", kFHatched1},
{"hatched2", kHatched2}, {"hatched3", kFHatched3}, {"hatched4", kFHatched4},
{"wicker", kFWicker}, {"scales", kFScales}, {"bricks", kFBricks},
{"snowflakes", kFSnowflakes}, {"circles", kFCircles}, {"tiles", kFTiles},
{"mondrian", kFMondrian}, {"diamonds", kFDiamonds}, {"waves1", kFWaves1},
{"dashed1", kFDashed1}, {"dashed2", kFDashed2}, {"alhambra", kFAlhambra},
{"waves2", kFWaves2}, {"stars1", kFStars1}, {"stars2", kFStars2},
{"pyramids", kFPyramids}, {"frieze", kFFrieze}, {"metopes", kFMetopes},
{"empty", kFEmpty}, {"solid", kFSolid}}

FillStyleMap as enum "EFillStyle" defined in TAttFill.h.

Definition at line 119 of file TRestDataSetPlot.h.

◆ fLegendX1

Double_t TRestDataSetPlot::fLegendX1 = 0.7
private

Legend position and size.

Definition at line 148 of file TRestDataSetPlot.h.

◆ fLegendX2

Double_t TRestDataSetPlot::fLegendX2 = 0.88
private

Definition at line 150 of file TRestDataSetPlot.h.

◆ fLegendY1

Double_t TRestDataSetPlot::fLegendY1 = 0.75
private

Definition at line 149 of file TRestDataSetPlot.h.

◆ fLegendY2

Double_t TRestDataSetPlot::fLegendY2 = 0.88
private

Definition at line 151 of file TRestDataSetPlot.h.

◆ fOutputFileName

std::string TRestDataSetPlot::fOutputFileName = ""
private

OutputFileName.

Definition at line 136 of file TRestDataSetPlot.h.

◆ fPaletteStyle

Int_t TRestDataSetPlot::fPaletteStyle = 57
private

Palette style.

Definition at line 142 of file TRestDataSetPlot.h.

◆ fPanels

std::vector<PanelInfo> TRestDataSetPlot::fPanels
private

Vector with panels/label options.

Definition at line 162 of file TRestDataSetPlot.h.

◆ fPlots

std::vector<PlotInfo> TRestDataSetPlot::fPlots
private

Vector with plots/pads options.

Definition at line 159 of file TRestDataSetPlot.h.

◆ fPreviewPlot

Bool_t TRestDataSetPlot::fPreviewPlot = true
private

Preview plot.

Definition at line 145 of file TRestDataSetPlot.h.

◆ LineStyleMap

const std::map<std::string, int> TRestDataSetPlot::LineStyleMap
private
Initial value:
{
{"solid", kSolid}, {"dashed", kDashed}, {"dotted", kDotted}, {"dashDotted", kDashDotted}}

LineStyleMap as enum "ELineStyle" defined in TAttLine.h.

Definition at line 115 of file TRestDataSetPlot.h.


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