ROOTTools
 
Loading...
Searching...
No Matches
GUIDistrCutter2D.hpp
Go to the documentation of this file.
1
9#ifndef ROOT_TOOLS_GUI_DISTR_CUTTER_2D_HPP
10#define ROOT_TOOLS_GUI_DISTR_CUTTER_2D_HPP
11
12#include <iostream>
13#include <string>
14#include <vector>
15#include <array>
16#include <fstream>
17
18#include "TBox.h"
19#include "TFrame.h"
20#include "TPad.h"
21#include "TH2.h"
22#include "TLine.h"
23#include "Buttons.h"
24
28namespace GUIDistrCutter2D
29{
34 void AddHistogram(TH2D *hist);
41 void ReadCutAreas(const std::string& fileName);
49 void SetOutputFile(const std::string& fileName, const bool rewrite = false);
51 void Exec();
53 inline void SetLine(TLine& line, const double x1, const double y1,
54 const double x2, const double y2, const Color_t color=kRed);
56 void Draw(const bool isRangeFixed = false);
58 void ApplyCuts(TH2D* hist);
60 void MouseMotionAction(const double x, const double y);
62 void Button1DownAction(const double x, const double y);
64 void KeyPressAction(const int button);
66 bool IsBinCut(const int binX, const int binY);
68 inline double Pol1(const double x, const double par0, const double par1);
70 std::vector<TH2D *> hists;
72 std::vector<TH2D *> histsWithCuts;
74 std::vector<unsigned long> histsOrigIntegral;
76 unsigned short currentHist = 0;
78 std::vector<std::vector<bool>> inputFileCutAreas;
80 short currentCutMode = -1;
82 std::vector<double> rectXMin;
84 std::vector<double> rectXMax;
86 std::vector<double> rectYMin;
88 std::vector<double> rectYMax;
90 std::vector<double> lineXMin;
92 std::vector<double> lineXMax;
94 std::vector<double> lineYMin;
96 std::vector<double> lineYMax;
98 std::vector<double> invRectXMin;
100 std::vector<double> invRectXMax;
102 std::vector<double> invRectYMin;
104 std::vector<double> invRectYMax;
106 std::vector<double> angledLine1X1;
108 std::vector<double> angledLine1X2;
110 std::vector<double> angledLine1Y1;
112 std::vector<double> angledLine1Y2;
114 std::vector<double> angledLine2X1;
116 std::vector<double> angledLine2X2;
118 std::vector<double> angledLine2Y1;
120 std::vector<double> angledLine2Y2;
122 std::vector<double> tanAlpha1;
124 std::vector<double> tanAlpha2;
126 std::vector<double> shiftY1;
128 std::vector<double> shiftY2;
130 std::vector<double> singleBinXCut;
132 std::vector<double> singleBinYCut;
134 std::array<bool, 5> isMin = {true, true, true, true, true};
136 std::string outputFileName;
138 bool isOutputFileSet = false;
140 bool isHistogramAdded = false;
142 bool isFirstDraw = true;
143};
144
145#endif /* ROOT_TOOLS_GUI_DISTR_CUTTER_2D_HPP */
Stores various useful data and functions for functionality of GUI cutter. The only useful funtions fo...
bool isOutputFileSet
shows whether the output file was set
Definition GUIDistrCutter2D.hpp:138
std::vector< double > angledLine2X2
stores x2 values of the 2nd line of angled line cuts
Definition GUIDistrCutter2D.hpp:116
void Draw(const bool isRangeFixed=false)
Draws histogram with cuts applied. This function is called automaticaly when needed.
Definition GUIDistrCutter2D.cpp:177
std::vector< double > rectXMin
stores minimum x values of the rectangular cut mode
Definition GUIDistrCutter2D.hpp:82
std::vector< TH2D * > histsWithCuts
stores added distributions to which cuts will be applied
Definition GUIDistrCutter2D.hpp:72
std::vector< double > angledLine2Y2
stores y2 values of the 2nd line of angled line cuts
Definition GUIDistrCutter2D.hpp:120
void KeyPressAction(const int button)
Applies actions to kKeyPress event. This function is called automaticaly when needed.
Definition GUIDistrCutter2D.cpp:579
void ReadCutAreas(const std::string &fileName)
Reads cut areas from the file.
Definition GUIDistrCutter2D.cpp:71
void SetOutputFile(const std::string &fileName, const bool rewrite=false)
Set the file in which cut areas will be written.
Definition GUIDistrCutter2D.cpp:151
double Pol1(const double x, const double par0, const double par1)
Needed for angular cut mode. This function is called automaticaly when needed.
Definition GUIDistrCutter2D.cpp:912
bool isHistogramAdded
shows whether at least one histogram was added
Definition GUIDistrCutter2D.hpp:140
std::vector< double > invRectYMax
stores maximum y values of inverse rectangular cut mode
Definition GUIDistrCutter2D.hpp:104
std::vector< double > singleBinYCut
stores y values of the single pixel cut mode
Definition GUIDistrCutter2D.hpp:132
std::string outputFileName
name of the file in which cuts will be written
Definition GUIDistrCutter2D.hpp:136
bool isFirstDraw
checks if the histogram was drawn the first time
Definition GUIDistrCutter2D.hpp:142
std::vector< double > lineYMin
stores minimum y values of y linear cut mode
Definition GUIDistrCutter2D.hpp:94
std::vector< double > lineYMax
stores maximum y values of y linear cut mode
Definition GUIDistrCutter2D.hpp:96
bool IsBinCut(const int binX, const int binY)
Checks whether the bin is cut or not.
Definition GUIDistrCutter2D.cpp:840
std::vector< double > angledLine1Y2
stores y2 values of the 1st line of angled line cuts
Definition GUIDistrCutter2D.hpp:112
std::vector< double > invRectYMin
stores minimum y values of inverse rectangular cut mode
Definition GUIDistrCutter2D.hpp:102
std::vector< unsigned long > histsOrigIntegral
stores integrals of added uncut hists
Definition GUIDistrCutter2D.hpp:74
std::vector< double > shiftY2
stores y shifts of the 2nd line of angled line cuts
Definition GUIDistrCutter2D.hpp:128
std::vector< double > shiftY1
stores y shifts of the 1st line of angled line cuts
Definition GUIDistrCutter2D.hpp:126
std::vector< double > tanAlpha1
stores tangent of alpha of the 1st line of angled line cuts
Definition GUIDistrCutter2D.hpp:122
std::vector< double > rectYMax
stores maximum y values of the rectangular cut mode
Definition GUIDistrCutter2D.hpp:88
std::vector< double > angledLine1X2
stores x2 values of the 1st line of angled line cuts
Definition GUIDistrCutter2D.hpp:108
void MouseMotionAction(const double x, const double y)
Applies actions to kMouseMotion event. This function is called automaticaly when needed.
Definition GUIDistrCutter2D.cpp:220
unsigned short currentHist
stores information about the index of the currently displayed histogram
Definition GUIDistrCutter2D.hpp:76
void SetLine(TLine &line, const double x1, const double y1, const double x2, const double y2, const Color_t color=kRed)
Sets style to the provided TLine. This function is called automaticaly when needed.
Definition GUIDistrCutter2D.cpp:165
void ApplyCuts(TH2D *hist)
Applies cuts to the passed distribution. This function is called automaticaly when needed.
std::vector< double > angledLine1Y1
stores y1 values of the 1st line of angled line cuts
Definition GUIDistrCutter2D.hpp:110
short currentCutMode
stores information about the current cut mode
Definition GUIDistrCutter2D.hpp:80
std::vector< double > singleBinXCut
stores x values of the single pixel cut mode
Definition GUIDistrCutter2D.hpp:130
std::vector< double > lineXMin
stores minimum x values of x linear cut mode
Definition GUIDistrCutter2D.hpp:90
void AddHistogram(TH2D *hist)
Add histogram.
Definition GUIDistrCutter2D.cpp:14
std::vector< double > invRectXMin
stores minimum x values of inverse rectangular cut mode
Definition GUIDistrCutter2D.hpp:98
std::vector< double > angledLine2X1
stores x1 values of the 2nd line of angled line cuts
Definition GUIDistrCutter2D.hpp:114
std::vector< double > rectXMax
stores maximum x values of the rectangular cut mode
Definition GUIDistrCutter2D.hpp:84
std::vector< double > rectYMin
stores minimum y values of the rectangular cut mode
Definition GUIDistrCutter2D.hpp:86
void Exec()
Executable to pass to TPad::AddExec(name, command) to start GUI session.
Definition GUIDistrCutter2D.cpp:917
std::vector< double > lineXMax
stores maximum x values of x linear cut mode
Definition GUIDistrCutter2D.hpp:92
std::vector< double > invRectXMax
stores maximum x values of inverse rectangular cut mode
Definition GUIDistrCutter2D.hpp:100
std::vector< double > angledLine2Y1
stores y1 values of the 2nd line of angled line cuts
Definition GUIDistrCutter2D.hpp:118
std::vector< TH2D * > hists
stores added distributions
Definition GUIDistrCutter2D.hpp:70
std::vector< std::vector< bool > > inputFileCutAreas
stores information about cut areas that were read from the input file
Definition GUIDistrCutter2D.hpp:78
std::vector< double > angledLine1X1
stores x1 values of the 1st line of angled line cuts
Definition GUIDistrCutter2D.hpp:106
std::vector< double > tanAlpha2
stores tangent of alpha of the 2nd line of angled line cuts
Definition GUIDistrCutter2D.hpp:124
void Button1DownAction(const double x, const double y)
Applies actions to kButton1Down event. This function is called automaticaly when needed.
Definition GUIDistrCutter2D.cpp:339
std::array< bool, 5 > isMin
stores information that shows whether the first point was chosen for the given cut mode
Definition GUIDistrCutter2D.hpp:134