1#ifndef TEFFICIENCYCALIBRATOR_H
2#define TEFFICIENCYCALIBRATOR_H
4#if __cplusplus >= 201703L
15#include "TGStatusBar.h"
16#include "TGButtonGroup.h"
18#include "TGNumberEntry.h"
20#include "TGProgressBar.h"
21#include "TGComboBox.h"
22#include "TRootEmbeddedCanvas.h"
36class TEfficiencyCalibrator;
37class TEfficiencyDatatypeTab;
54 enum EPeakType : std::uint8_t { kRWPeak = 0,
59 TEfficiencyTab(TEfficiencyDatatypeTab* parent,
TNucleus* nucleus, std::tuple<TH1*, TH1*, TH2*> hists, TGCompositeFrame* frame);
60 TEfficiencyTab(
const TEfficiencyTab&) =
default;
61 TEfficiencyTab(TEfficiencyTab&&) noexcept = default;
62 TEfficiencyTab& operator=(const TEfficiencyTab&) = default;
63 TEfficiencyTab& operator=(TEfficiencyTab&&) noexcept = default;
64 ~TEfficiencyTab() = default;
70 void MakeConnections();
72 void Status(Int_t event, Int_t px, Int_t py, TObject* selected);
75 std::vector<std::tuple<
TTransition*,
double,
double,
double,
double,
double,
double,
double,
double>> Peaks()
const {
return fPeaks; }
76 const char* GetName()
const {
return fNucleus->GetName(); }
79 void BuildInterface();
82 TGCompositeFrame* fFrame{
nullptr};
83 TGHorizontalFrame* fTopFrame{
nullptr};
84 TRootEmbeddedCanvas* fProjectionCanvas{
nullptr};
85 TGStatusBar* fStatusBar{
nullptr};
89 TEfficiencyDatatypeTab* fParent;
90 TH1* fSingles{
nullptr};
91 TH1* fSummingOut{
nullptr};
92 TH2* fSummingIn{
nullptr};
95 std::vector<TH1*> fSummingInProj;
96 std::vector<TH1*> fSummingInProjBg;
97 std::vector<std::tuple<TTransition*, double, double, double, double, double, double, double, double>> fPeaks;
98 std::vector<TObject*> fFitFunctions;
99 std::vector<TObject*> fRemovedFitFunctions;
102class TEfficiencyDatatypeTab {
113 enum EEntry : std::uint8_t { kRangeEntry,
116 kCalibrationUncertaintyEntry,
119 kPlotEfficiencyCheck,
120 kPlotUncorrEfficiencyCheck,
123 kPlotSummingOutCheck };
125 TEfficiencyDatatypeTab(TEfficiencyCalibrator* parent, std::vector<TNucleus*> nucleus, std::vector<std::tuple<TH1*, TH1*, TH2*>> hists, TGCompositeFrame* frame,
const std::string& dataType, TGHProgressBar* progressBar);
126 TEfficiencyDatatypeTab(
const TEfficiencyDatatypeTab&) =
default;
127 TEfficiencyDatatypeTab(TEfficiencyDatatypeTab&&) noexcept = default;
128 TEfficiencyDatatypeTab& operator=(const TEfficiencyDatatypeTab&) = default;
129 TEfficiencyDatatypeTab& operator=(TEfficiencyDatatypeTab&&) noexcept = default;
130 ~TEfficiencyDatatypeTab();
133 void MakeConnections();
136 void Status(Int_t event, Int_t px, Int_t py, TObject* selected);
138 void UpdateEfficiencyGraph();
139 void UpdatePeakType();
140 void FitEfficiency();
141 void FittingControl(Int_t
id);
147 static double EfficiencyDebertin(
double* x,
double* par);
148 static double EfficiencyRadware(
double* x,
double* par);
149 static double EfficiencyPolynomial(
double* x,
double* par);
155 TGCompositeFrame* fFrame{
nullptr};
156 TGVerticalFrame* fLeftFrame{
nullptr};
157 TGTab* fDataTab{
nullptr};
158 std::vector<TEfficiencyTab*> fEfficiencyTab;
159 TGGroupFrame* fFittingParameterFrame{
nullptr};
160 TGLabel* fRangeLabel{
nullptr};
161 TGNumberEntry* fRangeEntry{
nullptr};
162 TGLabel* fBgParamLabel{
nullptr};
163 TGNumberEntry* fBgParamEntry{
nullptr};
164 TGLabel* fThresholdLabel{
nullptr};
165 TGNumberEntry* fThresholdEntry{
nullptr};
166 TGComboBox* fPeakTypeBox{
nullptr};
167 TGHButtonGroup* fFittingControlGroup{
nullptr};
168 TGTextButton* fRefitButton{
nullptr};
169 TGTextButton* fRefitAllButton{
nullptr};
170 TGVerticalFrame* fRightFrame{
nullptr};
171 TRootEmbeddedCanvas* fEfficiencyCanvas{
nullptr};
172 TLegend* fLegend{
nullptr};
173 TGStatusBar* fStatusBar{
nullptr};
174 TGGroupFrame* fGraphParameterFrame{
nullptr};
175 TGLabel* fDegreeLabel{
nullptr};
176 TGNumberEntry* fDegreeEntry{
nullptr};
177 TGLabel* fCalibrationUncertaintyLabel{
nullptr};
178 TGNumberEntry* fCalibrationUncertaintyEntry{
nullptr};
179 TGGroupFrame* fPlotOptionFrame{
nullptr};
180 TGCheckButton* fPlotEfficiencyCheck{
nullptr};
181 TGCheckButton* fPlotUncorrEfficiencyCheck{
nullptr};
182 TGCheckButton* fPlotPeakAreaCheck{
nullptr};
183 TGCheckButton* fPlotSummingInCheck{
nullptr};
184 TGCheckButton* fPlotSummingOutCheck{
nullptr};
185 TGTextButton* fRecalculateButton{
nullptr};
188 std::vector<TNucleus*> fNucleus;
189 TEfficiencyCalibrator* fParent;
190 std::string fDataType;
196 TF1* fEfficiency{
nullptr};
197 TDirectory* fMainDirectory{
nullptr};
198 TDirectory* fSubDirectory{
nullptr};
201class TEfficiencyCalibrator :
public TGMainFrame {
230 enum ESources : std::uint8_t { k22Na,
236 enum EEntry : std::uint16_t { kStartButton = 0,
239 kThresholdEntry = 300 };
241 explicit TEfficiencyCalibrator(
int n...);
242 TEfficiencyCalibrator(
const TEfficiencyCalibrator&) =
delete;
243 TEfficiencyCalibrator(TEfficiencyCalibrator&&) noexcept = delete;
244 TEfficiencyCalibrator& operator=(const TEfficiencyCalibrator&) = delete;
245 TEfficiencyCalibrator& operator=(TEfficiencyCalibrator&&) noexcept = delete;
246 ~TEfficiencyCalibrator();
248 void SetSource(Int_t windowId, Int_t entryId);
251 void LineHeight(const
unsigned int& val)
257 using TGWindow::HandleTimer;
261 static void Range(
const double& val) { fRange = val; }
262 static void Threshold(
const double& val) { fThreshold = val; }
263 static void BgParam(
const int& val) { fBgParam = val; }
264 static void PeakType(
const TEfficiencyTab::EPeakType& val) { fPeakType = val; }
265 static void Degree(
const int& val) { fDegree = val; }
266 static void CalibrationUncertainty(
const double& val) { fCalibrationUncertainty = val; }
267 static void ShowRemovedFits(
const bool& val) { fShowRemovedFits = val; }
269 static double Range() {
return fRange; }
270 static double Threshold() {
return fThreshold; }
271 static int BgParam() {
return fBgParam; }
272 static TEfficiencyTab::EPeakType PeakType() {
return fPeakType; }
273 static int Degree() {
return fDegree; }
274 static double CalibrationUncertainty() {
return fCalibrationUncertainty; }
275 static bool ShowRemovedFits() {
return fShowRemovedFits; }
277 static int LineHeight() {
return fLineHeight; }
278 static int WindowWidth() {
return fWindowWidth; }
280 static EVerbosity VerboseLevel() {
return fVerboseLevel; }
281 static void VerboseLevel(
EVerbosity val) { fVerboseLevel = val; }
283 std::vector<TCalibrationGraphSet*> EfficiencyGraphs() {
return fEfficiencyGraph; }
284 size_t NumberOfEfficiencyGraphs() {
return fEfficiencyGraph.size(); }
288 void DeleteElement(TGFrame* element);
289 void BuildFirstInterface();
290 void MakeFirstConnections();
291 void DisconnectFirst();
293 void BuildSecondInterface();
294 void MakeSecondConnections();
295 void DisconnectSecond();
298 static double fRange;
299 static double fThreshold;
301 static TEfficiencyTab::EPeakType fPeakType;
303 static double fCalibrationUncertainty;
304 static bool fShowRemovedFits;
305 std::vector<TFile*> fFiles;
306 std::vector<TNucleus*> fSources;
307 std::vector<std::string> fDataType;
308 std::vector<std::vector<std::tuple<TH1*, TH1*, TH2*>>> fHistograms;
309 std::vector<TEfficiencyDatatypeTab*> fEfficiencyDatatypeTab;
310 std::vector<TCalibrationGraphSet*> fEfficiencyGraph;
311 TFile* fOutput{
nullptr};
313 TGTextButton* fEmitter{
nullptr};
315 static unsigned int fLineHeight;
316 static unsigned int fWindowWidth;
319 std::vector<TGLabel*> fSourceLabel;
320 std::vector<TGComboBox*> fSourceBox;
321 TGTab* fDatatypeTab{
nullptr};
322 TGHProgressBar* fProgressBar{
nullptr};
323 TGTextButton* fStartButton{
nullptr};
326 ClassDefOverride(TEfficiencyCalibrator, 1)