1#ifndef TEFFICIENCYCALIBRATOR_H
2#define TEFFICIENCYCALIBRATOR_H
4#if __cplusplus >= 201703L
19#include "TGFSComboBox.h"
20#include "TGStatusBar.h"
21#include "TGButtonGroup.h"
23#include "TGNumberEntry.h"
25#include "TGProgressBar.h"
26#include "TRootEmbeddedCanvas.h"
42class TEfficiencyCalibrator;
43class TEfficiencyDatatypeTab;
60 enum EPeakType { kRWPeak = 0,
65 TEfficiencyTab(TEfficiencyDatatypeTab* parent,
TNucleus* nucleus, std::tuple<TH1*, TH2*, TH2*> hists, TGCompositeFrame* frame);
66 TEfficiencyTab(
const TEfficiencyTab&) =
default;
67 TEfficiencyTab(TEfficiencyTab&&) noexcept = default;
68 TEfficiencyTab& operator=(const TEfficiencyTab&) = default;
69 TEfficiencyTab& operator=(TEfficiencyTab&&) noexcept = default;
70 ~TEfficiencyTab() = default;
75 void MakeConnections();
77 void Status(Int_t event, Int_t px, Int_t py, TObject* selected);
80 std::vector<std::tuple<
TTransition*,
double,
double,
double,
double,
double,
double,
double,
double>> Peaks()
const {
return fPeaks; }
81 const char* GetName()
const {
return fNucleus->GetName(); }
84 void BuildInterface();
87 TGCompositeFrame* fFrame{
nullptr};
88 TGHorizontalFrame* fTopFrame{
nullptr};
89 TRootEmbeddedCanvas* fProjectionCanvas{
nullptr};
90 TGStatusBar* fStatusBar{
nullptr};
94 TEfficiencyDatatypeTab* fParent;
95 TH1* fSingles{
nullptr};
96 TH2* fSummingOut{
nullptr};
97 TH2* fSummingIn{
nullptr};
99 std::vector<TH1*> fSummingInProj;
100 std::vector<TH1*> fSummingInProjBg;
101 std::vector<TH1*> fSummingOutProj;
102 TH1* fSummingOutTotalProj;
103 TH1* fSummingOutTotalProjBg;
104 std::vector<std::tuple<TTransition*, double, double, double, double, double, double, double, double>> fPeaks;
105 std::vector<TObject*> fFitFunctions;
106 std::vector<TObject*> fRemovedFitFunctions;
109class TEfficiencyDatatypeTab {
120 enum EEntry { kRangeEntry,
123 kCalibrationUncertaintyEntry,
126 kPlotEfficiencyCheck,
127 kPlotUncorrEfficiencyCheck,
130 kPlotSummingOutCheck };
132 TEfficiencyDatatypeTab(TEfficiencyCalibrator* parent, std::vector<TNucleus*> nucleus, std::vector<std::tuple<TH1*, TH2*, TH2*>> hists, TGCompositeFrame* frame,
const std::string& dataType, TGHProgressBar* progressBar);
133 TEfficiencyDatatypeTab(
const TEfficiencyDatatypeTab&) =
default;
134 TEfficiencyDatatypeTab(TEfficiencyDatatypeTab&&) noexcept = default;
135 TEfficiencyDatatypeTab& operator=(const TEfficiencyDatatypeTab&) = default;
136 TEfficiencyDatatypeTab& operator=(TEfficiencyDatatypeTab&&) noexcept = default;
137 ~TEfficiencyDatatypeTab();
140 void MakeConnections();
143 void Status(Int_t event, Int_t px, Int_t py, TObject* selected);
145 void UpdateEfficiencyGraph();
146 void UpdatePeakType();
147 void FitEfficiency();
148 void FittingControl(Int_t
id);
154 static double EfficiencyDebertin(
double* x,
double* par);
155 static double EfficiencyRadware(
double* x,
double* par);
156 static double EfficiencyPolynomial(
double* x,
double* par);
162 TGCompositeFrame* fFrame{
nullptr};
163 TGVerticalFrame* fLeftFrame{
nullptr};
164 TGTab* fDataTab{
nullptr};
165 std::vector<TEfficiencyTab*> fEfficiencyTab;
166 TGGroupFrame* fFittingParameterFrame{
nullptr};
167 TGLabel* fRangeLabel{
nullptr};
168 TGNumberEntry* fRangeEntry{
nullptr};
169 TGLabel* fBgParamLabel{
nullptr};
170 TGNumberEntry* fBgParamEntry{
nullptr};
171 TGLabel* fThresholdLabel{
nullptr};
172 TGNumberEntry* fThresholdEntry{
nullptr};
173 TGComboBox* fPeakTypeBox{
nullptr};
174 TGHButtonGroup* fFittingControlGroup{
nullptr};
175 TGTextButton* fRefitButton{
nullptr};
176 TGTextButton* fRefitAllButton{
nullptr};
177 TGVerticalFrame* fRightFrame{
nullptr};
178 TRootEmbeddedCanvas* fEfficiencyCanvas{
nullptr};
179 TLegend* fLegend{
nullptr};
180 TGStatusBar* fStatusBar{
nullptr};
181 TGGroupFrame* fGraphParameterFrame{
nullptr};
182 TGLabel* fDegreeLabel{
nullptr};
183 TGNumberEntry* fDegreeEntry{
nullptr};
184 TGLabel* fCalibrationUncertaintyLabel{
nullptr};
185 TGNumberEntry* fCalibrationUncertaintyEntry{
nullptr};
186 TGGroupFrame* fPlotOptionFrame{
nullptr};
187 TGCheckButton* fPlotEfficiencyCheck{
nullptr};
188 TGCheckButton* fPlotUncorrEfficiencyCheck{
nullptr};
189 TGCheckButton* fPlotPeakAreaCheck{
nullptr};
190 TGCheckButton* fPlotSummingInCheck{
nullptr};
191 TGCheckButton* fPlotSummingOutCheck{
nullptr};
192 TGTextButton* fRecalculateButton{
nullptr};
195 std::vector<TNucleus*> fNucleus;
196 TEfficiencyCalibrator* fParent;
197 std::string fDataType;
203 TF1* fEfficiency{
nullptr};
204 TDirectory* fMainDirectory{
nullptr};
205 TDirectory* fSubDirectory{
nullptr};
208class TEfficiencyCalibrator :
public TGMainFrame {
235 enum ESources { k22Na,
241 enum EEntry { kStartButton,
244 kThresholdEntry = 300 };
246 explicit TEfficiencyCalibrator(
int n...);
247 TEfficiencyCalibrator(
const TEfficiencyCalibrator&) =
delete;
248 TEfficiencyCalibrator(TEfficiencyCalibrator&&) noexcept = delete;
249 TEfficiencyCalibrator& operator=(const TEfficiencyCalibrator&) = delete;
250 TEfficiencyCalibrator& operator=(TEfficiencyCalibrator&&) noexcept = delete;
251 ~TEfficiencyCalibrator();
253 void SetSource(Int_t windowId, Int_t entryId);
256 void LineHeight(const
unsigned int& val)
262 using TGWindow::HandleTimer;
266 static void Range(
const double& val) { fRange = val; }
267 static void Threshold(
const double& val) { fThreshold = val; }
268 static void BgParam(
const int& val) { fBgParam = val; }
269 static void PeakType(
const TEfficiencyTab::EPeakType& val) { fPeakType = val; }
270 static void Degree(
const int& val) { fDegree = val; }
271 static void CalibrationUncertainty(
const double& val) { fCalibrationUncertainty = val; }
272 static void ShowRemovedFits(
const bool& val) { fShowRemovedFits = val; }
274 static double Range() {
return fRange; }
275 static double Threshold() {
return fThreshold; }
276 static int BgParam() {
return fBgParam; }
277 static TEfficiencyTab::EPeakType PeakType() {
return fPeakType; }
278 static int Degree() {
return fDegree; }
279 static double CalibrationUncertainty() {
return fCalibrationUncertainty; }
280 static bool ShowRemovedFits() {
return fShowRemovedFits; }
282 static int LineHeight() {
return fLineHeight; }
283 static int WindowWidth() {
return fWindowWidth; }
285 static EVerbosity VerboseLevel() {
return fVerboseLevel; }
286 static void VerboseLevel(
EVerbosity val) { fVerboseLevel = val; }
288 std::vector<TCalibrationGraphSet*> EfficiencyGraphs() {
return fEfficiencyGraph; }
289 size_t NumberOfEfficiencyGraphs() {
return fEfficiencyGraph.size(); }
293 void DeleteElement(TGFrame* element);
294 void BuildFirstInterface();
295 void MakeFirstConnections();
296 void DisconnectFirst();
298 void BuildSecondInterface();
299 void MakeSecondConnections();
300 void DisconnectSecond();
303 static double fRange;
304 static double fThreshold;
306 static TEfficiencyTab::EPeakType fPeakType;
308 static double fCalibrationUncertainty;
309 static bool fShowRemovedFits;
310 std::vector<TFile*> fFiles;
311 std::vector<TNucleus*> fSources;
312 std::vector<std::string> fDataType;
313 std::vector<std::vector<std::tuple<TH1*, TH2*, TH2*>>> fHistograms;
314 std::vector<TEfficiencyDatatypeTab*> fEfficiencyDatatypeTab;
315 std::vector<TCalibrationGraphSet*> fEfficiencyGraph;
316 TFile* fOutput{
nullptr};
318 TGTextButton* fEmitter{
nullptr};
320 static unsigned int fLineHeight;
321 static unsigned int fWindowWidth;
324 std::vector<TGLabel*> fSourceLabel;
325 std::vector<TGComboBox*> fSourceBox;
326 TGTab* fDatatypeTab{
nullptr};
327 TGHProgressBar* fProgressBar{
nullptr};
328 TGTextButton* fStartButton{
nullptr};
331 ClassDefOverride(TEfficiencyCalibrator, 1)