REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestMetadataPlot.h
1/*************************************************************************
2 * This file is part of the REST software framework. *
3 * *
4 * Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) *
5 * For more information see http://gifna.unizar.es/trex *
6 * *
7 * REST is free software: you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation, either version 3 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * REST is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have a copy of the GNU General Public License along with *
18 * REST in $REST_PATH/LICENSE. *
19 * If not, see http://www.gnu.org/licenses/. *
20 * For the list of contributors see $REST_PATH/CREDITS. *
21 *************************************************************************/
22
23#ifndef RestCore_TRestMetadataPlot
24#define RestCore_TRestMetadataPlot
25
26#include <TCanvas.h>
27#include <TLatex.h>
28
29#include "TRestRun.h"
30
33 public:
37 std::string name;
39 std::string title;
41 std::string yVariable;
43 std::string metadataRule;
45 std::string drawOption;
47 Int_t lineColor;
49 Int_t lineWidth;
51 Int_t lineStyle;
53 Int_t fillColor;
55 Int_t fillStyle;
62 };
63
67 std::string name;
69 std::string title;
71 std::string xVariable;
73 Bool_t logX;
75 Bool_t logY;
77 Bool_t legendOn;
81 std::string labelX;
83 std::string labelY;
85 std::string save;
87 TVector2 xRange;
89 TVector2 yRange;
91 std::vector<Graph_Info_Set> graphs;
92 };
93
95 struct Panel_Info {
97 Float_t font_size;
99 std::vector<Float_t> posX;
101 std::vector<Float_t> posY;
103 std::vector<std::string> label;
104 };
105
106 private:
107 void InitFromConfigFile() override;
109
111 Int_t fNFiles;
112
114 TVector2 fCanvasSize;
115
118
120 TString fCanvasSave;
121
124
126 Double_t fLabelOffsetX = 1.1;
128 Double_t fLabelOffsetY = 1.3;
129
131 Double_t fLabelScaleX = 1.2;
133 Double_t fLabelScaleY = 1.3;
134
136 Double_t fTicksScaleX = 1.5;
138 Double_t fTicksScaleY = 1.5;
139
141 Double_t fLegendX1 = 0.7;
143 Double_t fLegendY1 = 0.75;
145 Double_t fLegendX2 = 0.88;
147 Double_t fLegendY2 = 0.88;
148
150 TString fLegendOption = "lp";
151
153 std::vector<Plot_Info_Set> fPlots;
154
156 std::vector<Panel_Info> fPanels;
157
159 std::vector<std::string> fPlotNamesCheck;
160
163
165 std::vector<std::string> fRunInputFileName;
166
169
170 void AddFile(TString fileName);
172 void AddFileFromEnv();
173
174 protected:
175 public:
176 void Initialize() override;
177
178 void PrintMetadata() override {}
179
180 void SaveCanvasToPDF(TString fileName);
181 void SavePlotToPDF(TString fileName, Int_t n = 0);
182 void SaveGraphToPDF(TString fileName, Int_t nPlot = 0, Int_t nGraph = 0);
183
185 void SetOutputPlotsFilename(TString fname) { fCanvasSave = fname; }
186
187 Int_t GetPlotIndex(TString plotName);
188
190 inline TVector2 GetCanvasSize() const { return fCanvasSize; }
191
193 inline TVector2 GetCanvasDivisions() const { return fCanvasDivisions; }
194
195 void GenerateCanvas();
196
198 TRestMetadataPlot(const char* configFilename, const char* name = "");
199
200 virtual ~TRestMetadataPlot();
201
202 ClassDefOverride(TRestMetadataPlot, 3);
203};
204#endif
A helper class to draw the evolution or correlation of metadata information from a set of REST files.
Double_t fLabelOffsetX
A label offset to be applied in the x-label (not tested)
Double_t fTicksScaleY
A label ticks scale to be applied in the y-label (not tested)
TCanvas * fCombinedCanvas
Output canvas.
TString fCanvasSave
A std::string to define the output filename where to store the canvas.
std::vector< Plot_Info_Set > fPlots
A std::vector with the defined plots.
Double_t fLabelScaleX
A label title scale to be applied in the x-label (not tested)
void SaveCanvasToPDF(TString fileName)
A method to execute the generation of an output file with the contents of the TCanvas as it is....
void InitFromConfigFile() override
Initialization of TRestMetadataPlot members through a RML file.
void SaveGraphToPDF(TString fileName, Int_t nPlot=0, Int_t nGraph=0)
A method to execute the generation of a particular graph from a plot inside the canvas using the inde...
TString fLegendOption
The legend drawing option.
void AddFileFromEnv()
We can add input file from parameter "inputFile".
std::vector< Panel_Info > fPanels
A std::vector with the defined panels.
TRestRun * fRun
TRestRun to handle output file.
Double_t fLegendY1
The Y1 legend position.
void SavePlotToPDF(TString fileName, Int_t n=0)
A method to execute the generation of a plot inside the canvas using the index of the plot....
Int_t fNFiles
The total number of files for plotting added to this class.
void AddFile(TString fileName)
It creates a new TRestRun object extracted from the fileName, and it adds it to the list of input fil...
Graph_Info_Set SetupGraphFromConfigFile(TiXmlElement *ele, Plot_Info_Set info)
It fills the components of a Graph_Info_set object using the definition inside a <graph element.
void AddFileFromExternalRun()
We can add input file from process's output file.
Int_t fLabelFont
The font label size.
void Initialize() override
Initialization of TRestMetadataPlot data members.
Double_t fLegendY2
The Y2 legend position.
void SetOutputPlotsFilename(TString fname)
It will set the filename of the plots output file to be generated when GenerateCanvas is called.
Double_t fLegendX1
The X1 legend position.
void PrintMetadata() override
Implemented it in the derived metadata class to print out specific metadata information.
void GenerateCanvas()
The main method of this class, collecting the input files, producing the TGraphs and generating the p...
std::vector< std::string > fPlotNamesCheck
A std::vector to double check that there are no repeated graph names.
TVector2 GetCanvasSize() const
It will return the canvas size in pixel units.
TRestMetadataPlot()
Default constructor.
Double_t fLabelScaleY
A label title scale to be applied in the y-label (not tested)
Double_t fTicksScaleX
A label ticks scale to be applied in the x-label (not tested)
TVector2 fCanvasSize
The size of the canvas window in pixels.
std::vector< std::string > fRunInputFileName
To keep a list of files used.
Double_t fLabelOffsetY
A label offset to be applied in the y-label (not tested)
TVector2 fCanvasDivisions
The number of canvas divisions on X and Y.
Double_t fLegendX2
The X2 legend position.
virtual ~TRestMetadataPlot()
Default destructor.
Int_t GetPlotIndex(TString plotName)
It returns the index of the array correspoding to the plot with the given plotName.
TVector2 GetCanvasDivisions() const
It will return the number of divisions inside the canvas.
A base class for any REST metadata class.
Definition: TRestMetadata.h:74
Data provider and manager in REST.
Definition: TRestRun.h:18
This structure is used to register the values from a <graph definition inside the RML.
Int_t lineStyle
The line style to be assigned to the corresponding TGraph.
Int_t markerSize
The marker size to be assigned to the corresponding TGraph.
Int_t markerColor
The marker color to be assigned to the corresponding TGraph.
Int_t lineWidth
The line width to be assigned to the corresponding TGraph.
Int_t markerStyle
The marker style to be assigned to the corresponding TGraph.
std::string name
The name to be used for the corresponding ROOT TGraph object.
Int_t fillColor
The fill color to be assigned to the corresponding TGraph.
std::string drawOption
The option to be passed to the Draw method.
Int_t lineColor
The line color to be assigned to the corresponding TGraph.
std::string title
The title to be used inside TLegend object.
Int_t fillStyle
The fill style to be assigned to the corresponding TGraph.
std::string yVariable
The metadata class and data member definition to be plotted.
std::string metadataRule
An optional rule to be used for run selection.
This structure is used to register the values from a <panel definition inside the RML.
Float_t font_size
The font size to be used in the panel labels.
std::vector< std::string > label
The std::string containing the text to be drawn in the panel.
std::vector< Float_t > posY
The y-position of labels used inside the panel.
std::vector< Float_t > posX
The x-position of labels used inside the panel.
This structure is used to register the values from a <plot definition inside the RML.
std::string xVariable
The corresponding metadata variable to be used in the X-axis.
std::string name
The name that will be used for the TGraph object.
std::string labelY
The label or title to be given to the y-axis.
std::string labelX
The label or title to be given to the x-axis.
TVector2 xRange
The user defined range in the x-axis.
std::string title
A title that will be visible in top of the plot.
Bool_t timeDisplay
It true a time/date calendar format will be used on the x-axis.
Bool_t legendOn
It true a legend will be shown on the corresponding plot.
std::vector< Graph_Info_Set > graphs
A std::vector containing the properties of the graphs inside the plot.
std::string save
The filename where the file will be saved.
Bool_t logX
It true a logarithmic scale will be used on the x-axis.
Bool_t logY
It true a logarithmic scale will be used on the y-axis.
TVector2 yRange
The user defined range in the y-axis.