REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestDataSetPlot.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 https://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 https://www.gnu.org/licenses/. *
20 * For the list of contributors see $REST_PATH/CREDITS. *
21 *************************************************************************/
22
23#ifndef REST_TRestDataSetPlot
24#define REST_TRestDataSetPlot
25
26#include "THStack.h"
27#include "TLatex.h"
28#include "TLegend.h"
29#include "TRestDataSet.h"
30#include "TRestMetadata.h"
31
35 public:
37 struct HistoInfo {
38 std::string name = "";
39 std::string drawOption = "";
40 std::vector<std::string> variable;
41 std::vector<TVector2> range;
42 std::vector<Int_t> nBins;
43 Int_t lineColor;
44 Int_t lineWidth;
45 Int_t lineStyle;
46 Int_t fillColor;
47 Int_t fillStyle;
48 Bool_t statistics = false;
49 TRestCut* histoCut = nullptr;
50 TH1* histo = nullptr;
51 };
52
54 struct PlotInfo {
55 std::string name = "";
56 std::string title = "";
57
58 std::string save = "";
59
60 std::string stackDrawOption = "nostack";
61
62 Double_t normalize;
63 std::string scale = "";
64 Bool_t logX = false;
65 Bool_t logY = false;
66 Bool_t logZ = false;
67 Bool_t gridX = false;
68 Bool_t gridY = false;
69 Bool_t legendOn = false;
70
71 Double_t xOffset;
72 Double_t yOffset;
73
74 Double_t marginLeft;
75 Double_t marginRight;
76 Double_t marginTop;
77 Double_t marginBottom;
78
79 Bool_t timeDisplay;
80
81 std::string labelX;
82 std::string labelY;
83
84 std::vector<HistoInfo> histos;
85
86 THStack* hs = nullptr;
87 TLegend* legend = nullptr;
88 };
89
91 struct PanelInfo {
92 Float_t font_size;
93 Int_t precision;
94
95 std::vector<std::pair<std::array<std::string, 3>, TVector2>> variablePos;
96 std::vector<std::pair<std::array<std::string, 3>, TVector2>> metadataPos;
97 std::vector<std::pair<std::array<std::string, 3>, TVector2>> obsPos;
98
99 TRestCut* panelCut = nullptr;
100
101 std::vector<TLatex*> text;
102 };
103
105 private:
107 const std::map<std::string, int> ColorIdMap{{"white", kWhite}, {"black", kBlack}, {"gray", kGray},
108 {"red", kRed}, {"green", kGreen}, {"blue", kBlue},
109 {"yellow", kYellow}, {"magenta", kMagenta}, {"cyan", kCyan},
110 {"orange", kOrange}, {"spring", kSpring}, {"teal", kTeal},
111 {"azure", kAzure}, {"violet", kViolet}, {"pink", kPink}};
112
114 const std::map<std::string, int> LineStyleMap{
115 {"solid", kSolid}, {"dashed", kDashed}, {"dotted", kDotted}, {"dashDotted", kDashDotted}};
116
118 const std::map<std::string, int> FillStyleMap{
119 {"dotted", kFDotted1}, {"dashed", kFDashed1}, {"dotted1", kFDotted1},
120 {"dotted2", kFDotted2}, {"dotted3", kFDotted3}, {"hatched1", kFHatched1},
121 {"hatched2", kHatched2}, {"hatched3", kFHatched3}, {"hatched4", kFHatched4},
122 {"wicker", kFWicker}, {"scales", kFScales}, {"bricks", kFBricks},
123 {"snowflakes", kFSnowflakes}, {"circles", kFCircles}, {"tiles", kFTiles},
124 {"mondrian", kFMondrian}, {"diamonds", kFDiamonds}, {"waves1", kFWaves1},
125 {"dashed1", kFDashed1}, {"dashed2", kFDashed2}, {"alhambra", kFAlhambra},
126 {"waves2", kFWaves2}, {"stars1", kFStars1}, {"stars2", kFStars2},
127 {"pyramids", kFPyramids}, {"frieze", kFFrieze}, {"metopes", kFMetopes},
128 {"empty", kFEmpty}, {"solid", kFSolid}};
129
130 private:
132 std::string fDataSetName = "";
133
135 std::string fOutputFileName = "";
136
138 TRestCut* fCut = nullptr;
139
141 Int_t fPaletteStyle = 57;
142
144 Bool_t fPreviewPlot = true;
145
147 Double_t fLegendX1 = 0.7;
148 Double_t fLegendY1 = 0.75;
149 Double_t fLegendX2 = 0.88;
150 Double_t fLegendY2 = 0.88;
151
153 TVector2 fCanvasSize = TVector2(800, 600);
154 TVector2 fCanvasDivisions = TVector2(2, 2);
155 TVector2 fCanvasDivisionMargins = TVector2(0.01, 0.01);
156
158 std::vector<PlotInfo> fPlots;
159
161 std::vector<PanelInfo> fPanels;
162
163 void InitFromConfigFile() override;
164
165 public:
166 void Initialize() override;
167 void PrintMetadata() override;
168
170
171 void PlotCombinedCanvas();
172
173 void ReadPlotInfo();
174 void ReadPanelInfo();
175
176 void CleanUp();
177
178 TRestCut* ReadCut(TRestCut* cut, TiXmlElement* ele = nullptr);
179 Int_t GetIDFromMapString(const std::map<std::string, int>& mapStr, const std::string& in);
180
182 TRestDataSetPlot(const char* configFilename, std::string name = "");
184
185 ClassDefOverride(TRestDataSetPlot, 1);
186};
187#endif
A class to help on cuts definitions. To be used with TRestAnalysisTree.
Definition: TRestCut.h:31
Perform the plot over datasets.
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 col...
std::vector< PanelInfo > fPanels
Vector with panels/label options.
TRestCut * ReadCut(TRestCut *cut, TiXmlElement *ele=nullptr)
this function is used to add the different cuts provided in different metadata sections,...
void Initialize() override
Function to initialize input/output event members and define the section name.
void PlotCombinedCanvas()
This functions performs the plot of the combined canvas with the different panels and plots.
const std::map< std::string, int > LineStyleMap
LineStyleMap as enum "ELineStyle" defined in TAttLine.h.
std::string fDataSetName
Name of the dataset to be imported.
void ReadPlotInfo()
This function reads the config file plot info and stores it in a vector of PlotInfo.
void ReadPanelInfo()
This function reads the config file panel info and stores it in a vector of PanelInfo.
void GenerateDataSetFromFilePattern(TRestDataSet &dataSet)
This functions generates a dataSet based on the information of the rml file. A TRestDataSet is pased ...
Int_t fPaletteStyle
Palette style.
const std::map< std::string, int > FillStyleMap
FillStyleMap as enum "EFillStyle" defined in TAttFill.h.
TRestDataSetPlot()
Default constructor.
TRestCut * fCut
Global cut for the entire dataSet.
Bool_t fPreviewPlot
Preview plot.
const std::map< std::string, int > ColorIdMap
Maps for internal use only.
void PrintMetadata() override
Prints on screen the information about the metadata members of TRestDataSetPlot.
TVector2 fCanvasSize
Canvas options, size, divisions and margins.
std::string fOutputFileName
OutputFileName.
~TRestDataSetPlot()
Default destructor.
Double_t fLegendX1
Legend position and size.
std::vector< PlotInfo > fPlots
Vector with plots/pads options.
void InitFromConfigFile() override
Initialization of specific TRestDataSetPlot members through an RML file.
void CleanUp()
Clean up histos and text but note that the metadata is unchanged.
It allows to group a number of runs that satisfy given metadata conditions.
Definition: TRestDataSet.h:34
A base class for any REST metadata class.
Definition: TRestMetadata.h:70
Nested classes for internal use only.
Auxiliary class for panels/labels.
Auxiliary struct for plots/pads.