GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
TSourceCalibration.h
Go to the documentation of this file.
1#ifndef TSOURCECALIBRATION_H
2#define TSOURCECALIBRATION_H
3
4/** \addtogroup Calibration
5 * @{
6 */
7
8#include <cstdarg>
9#include <vector>
10#include <string>
11#include <mutex>
12#include <future>
13#include <queue>
14
15#include "TFile.h"
16#include "TPad.h"
17#include "TLegend.h"
18#include "TGFrame.h"
19#include "TGTab.h"
20#include "TGStatusBar.h"
21#include "TGButtonGroup.h"
22#include "TGButton.h"
23#include "TGNumberEntry.h"
24#include "TGLabel.h"
25#include "TGProgressBar.h"
26#include "TGComboBox.h"
27#include "TRootEmbeddedCanvas.h"
28#include "TH2.h"
29#include "TPaveText.h"
30
31#include "TPeakFitter.h"
32#include "TGauss.h"
33#include "TSinglePeak.h"
34#include "TNucleus.h"
35#include "TCalibrationGraph.h"
36#include "GH1D.h"
37#include "Globals.h"
38#include "TRedirect.h"
39
40class TSourceTab;
41
42std::map<double, std::tuple<double, double, double, double>> RoughCal(std::vector<double> peaks, std::vector<std::tuple<double, double, double, double>> sources, TSourceTab* sourceTab);
43std::map<TGauss*, std::tuple<double, double, double, double>> Match(std::vector<TGauss*> peaks, std::vector<std::tuple<double, double, double, double>> sources, TSourceTab* sourceTab);
44std::map<TGauss*, std::tuple<double, double, double, double>> SmartMatch(std::vector<TGauss*> peaks, std::vector<std::tuple<double, double, double, double>> sources, TSourceTab* sourceTab);
45
46double Polynomial(double* x, double* par);
47
48bool FilledBin(TH2* matrix, const int& bin);
49
51
52class TChannelTab;
53
55public:
56 TSourceTab(TSourceCalibration* sourceCal, TChannelTab* channel, TGCompositeFrame* frame, GH1D* projection, const char* sourceName, std::vector<std::tuple<double, double, double, double>> sourceEnergy);
57 TSourceTab(const TSourceTab& rhs);
58 TSourceTab(TSourceTab&&) noexcept = default;
59 TSourceTab& operator=(const TSourceTab&) = default;
60 TSourceTab& operator=(TSourceTab&&) noexcept = default;
61 ~TSourceTab();
62
63 void MakeConnections();
64 void Disconnect();
65
66 void ProjectionStatus(Event_t* event);
67 void ProjectionStatus(Int_t event, Int_t px, Int_t py, TObject* selected);
68
69 void InitialCalibration(const bool& force);
70 void Add(std::map<double, std::tuple<double, double, double, double>> map);
71 void Add(std::map<TGauss*, std::tuple<double, double, double, double>> map);
72 void FindCalibratedPeaks(const TF1* calibration);
73 void ReplacePeak(const size_t& index, const double& channel);
74
75 void SourceEnergy(std::vector<std::tuple<double, double, double, double>> val) { fSourceEnergy = std::move(val); }
76
77 void Status(const char* status, int position);
78
79 TGraphErrors* Data() const { return fData; }
80 TGraphErrors* Fwhm() const { return fFwhm; }
81 TRootEmbeddedCanvas* ProjectionCanvas() const { return fProjectionCanvas; }
82 const char* SourceName() const { return fSourceName; }
83
84 void RemovePoint(Int_t oldPoint);
85
86 void Print() const;
87 void PrintLayout() const;
88
89 void PrintCanvases() const;
90
91 void Draw();
92
93private:
94 void BuildInterface();
95 void UpdateRegions();
96 bool Good(TGauss* peak);
97 bool Good(TGauss* peak, double lowRange, double highRange) { return Good(peak) && lowRange < peak->Centroid() && peak->Centroid() < highRange; }
98 void UpdateFits();
99 void SetLineColors();
100
101 // parents
104
105 // graphic elements
106 TGCompositeFrame* fSourceFrame{nullptr};
107 TRootEmbeddedCanvas* fProjectionCanvas{nullptr};
108 TGStatusBar* fSourceStatusBar{nullptr};
109
110 // storage elements
111 GH1D* fProjection{nullptr};
112 const char* fSourceName;
113 TGraphErrors* fData{nullptr};
114 TGraphErrors* fFwhm{nullptr};
115 std::vector<TPeakFitter*> fFits; ///< all good fits
116 std::vector<TPeakFitter*> fBadFits; ///< all bad fits (centroid err > 10%, area err > 100%, or either of them not a number at all)
117 std::vector<TGauss*> fPeaks; ///< all peaks that have been fitted and are good
118 std::vector<std::tuple<double, double, double, double>> fSourceEnergy; ///< gamma rays from the source, with their energies, uncertainties in the energies, intensities, and uncertainties in the intesities
119 std::vector<std::pair<double, double>> fRegions;
120};
121
123public:
124 TChannelTab(TSourceCalibration* sourceCal, std::vector<TNucleus*> nuclei, std::vector<GH1D*> projections, std::string name, TGCompositeFrame* frame, std::vector<std::vector<std::tuple<double, double, double, double>>> sourceEnergies, TGHProgressBar* progressBar);
125 TChannelTab(const TChannelTab&) = default;
126 TChannelTab(TChannelTab&&) noexcept = default;
127 TChannelTab& operator=(const TChannelTab&) = default;
128 TChannelTab& operator=(TChannelTab&&) noexcept = default;
129 ~TChannelTab();
130
131 void MakeConnections();
132 void Disconnect();
133 void Initialize(const bool& force);
134
135 void CalibrationStatus(Int_t event, Int_t px, Int_t py, TObject* selected);
136 void SelectCanvas(Event_t* event);
137 void RemovePoint(Int_t oldGraph, Int_t oldPoint);
138
139 void UpdateData();
140 void UpdateFwhm();
141 void UpdateChannel();
142 void SelectedTab(Int_t id);
143 void Write(TFile* output);
144 void Calibrate();
145 void Calibrate(int degree);
146 void RecursiveRemove(const double& maxResidual);
147 void FindCalibratedPeaks();
149 TGTab* SourceTab() const { return fSourceTab; }
150 TGraphErrors* Data(int channelId) const { return fSources[channelId]->Data(); }
151 size_t NumberOfSources() const { return fSources.size(); }
152 std::string Name() const { return fName; }
153 int ActiveSourceTab() const { return fActiveSourceTab; }
155
156 //TSourceCalibration* SourceCalibration() const { return fSourceCalibration; }
157
158 static void ZoomX();
159 static void ZoomY();
160
161 void PrintLayout() const;
162
163 void PrintCanvases() const;
164
165 void Draw();
166
167private:
168 void BuildInterface();
169 void CreateSourceTab(size_t source);
170
171 // graphic elements
172 TGCompositeFrame* fChannelFrame{nullptr}; ///< main frame of this tab
173 TGTab* fSourceTab{nullptr}; ///< tab for sources
174 std::vector<TSourceTab*> fSources; ///< tabs for all sources
175 TGTab* fCanvasTab{nullptr}; ///< tab for canvases (calibration with residuals, and FWHM)
176 TGCompositeFrame* fCalibrationFrame{nullptr}; ///< frame of tab with calibration
177 TRootEmbeddedCanvas* fCalibrationCanvas{nullptr};
178 TPad* fResidualPad{nullptr};
179 TPad* fCalibrationPad{nullptr};
180 TGStatusBar* fChannelStatusBar{nullptr};
181 TLegend* fLegend{nullptr};
182 TPaveText* fChi2Label{nullptr};
183 TPaveText* fCalLabel{nullptr};
184 TPaveText* fInfoLabel{nullptr};
185 TGCompositeFrame* fFwhmFrame{nullptr}; ///< frame of tab with fwhm
186 TRootEmbeddedCanvas* fFwhmCanvas{nullptr};
187 TGCompositeFrame* fInitFrame{nullptr}; ///< frame of tab with initial calibration
188 TRootEmbeddedCanvas* fInitCanvas{nullptr};
189 TGHProgressBar* fProgressBar{nullptr};
190
191 // storage elements
192 TSourceCalibration* fSourceCalibration; ///< the parent of this tab
193 std::vector<TNucleus*> fNuclei; ///< the source nucleus
194 std::vector<GH1D*> fProjections; ///< vector of all projections
195 std::string fName; ///< name of this tab
196 std::vector<std::vector<std::tuple<double, double, double, double>>> fSourceEnergies; ///< vector with source energies and uncertainties
197 TCalibrationGraphSet* fData{nullptr}; ///< combined data from all sources
198 TCalibrationGraphSet* fFwhm{nullptr}; ///< combined fwhm from all sources
199 TCalibrationGraphSet* fInit{nullptr}; ///< combined initial data from all sources
200 int fActiveSourceTab{0}; ///< id of the currently active source tab
201};
202
203class TSourceCalibration : public TGMainFrame {
204public:
205 TSourceCalibration(double sigma, double threshold, int degree, int count...);
208 TSourceCalibration& operator=(const TSourceCalibration&) = delete;
209 TSourceCalibration& operator=(TSourceCalibration&&) noexcept = delete;
211
212 void SetSource(Int_t windowId, Int_t entryId);
213 void Start();
214
215 void LineHeight(const unsigned int& val)
216 {
217 fLineHeight = val;
218 Resize(GetSize());
219 }
220
221 void Navigate(Int_t id);
222 void Fitting(Int_t id);
223 void Calibrate();
224 void Remove();
225 using TObject::RecursiveRemove;
226 void RecursiveRemove();
227 void FindSourcePeaks();
228 void FindChannelPeaks();
229 void FindAllPeaks();
230 void SelectedTab(Int_t id);
231
232 void NavigateFinal(Int_t id);
233 void FitFinal(const int& channelId);
234 void SelectedFinalTab(Int_t id);
235 void SelectedFinalMainTab(Int_t id);
236 void UpdateChannel(const int& channelId);
237 void WriteCalibration();
238
239 double Sigma() { return fSigmaEntry->GetNumber(); }
240 double Threshold() { return fThresholdEntry->GetNumber(); }
241 int Degree()
242 {
243 if(fDegreeEntry != nullptr) { fDefaultDegree = static_cast<int>(fDegreeEntry->GetNumber()); }
244 return fDefaultDegree;
245 }
246 double MaxResidual()
247 {
248 if(fMaxResidualEntry != nullptr) { fDefaultMaxResidual = fMaxResidualEntry->GetNumber(); }
249 return fDefaultMaxResidual;
250 }
251 bool WriteNonlinearities() { return fWriteNonlinearities->IsDown(); }
252 std::vector<std::tuple<double, double, double, double>> SourceEnergy(const size_t& i) { return fSourceEnergy.at(i); }
253 void CalibrationStatus(Int_t event, Int_t px, Int_t py, TObject* selected);
254
255 using TGWindow::HandleTimer;
256 void HandleTimer();
257 void SecondWindow();
259
260 std::mutex& GraphicsMutex() { return fGraphicsMutex; }
261
262 static void PanelWidth(int val) { fPanelWidth = val; }
263 static void PanelHeight(int val) { fPanelHeight = val; }
264 static void StatusbarHeight(int val) { fStatusbarHeight = val; }
265
266 static int PanelWidth() { return fPanelWidth; }
267 static int PanelHeight() { return fPanelHeight; }
268 static int StatusbarHeight() { return fStatusbarHeight; }
269
270 // no getters for these as they are only used in this class
271 static void ParameterHeight(int val) { fParameterHeight = val; }
272 static void SourceboxWidth(int val) { fSourceboxWidth = val; }
273 static void DigitWidth(int val) { fDigitWidth = val; }
274 static void NumberOfThreads(size_t val) { fNumberOfThreads = val; }
275
276 static void VerboseLevel(EVerbosity val) { fVerboseLevel = val; }
278
279 static void LogFile(std::string val) { fLogFile = std::move(val); }
280 static std::string LogFile() { return fLogFile; }
281
282 static void MaxIterations(int val) { fMaxIterations = val; }
283 static int MaxIterations() { return fMaxIterations; }
284
285 static void FitRange(int val) { fFitRange = val; }
286 static double FitRange() { return fFitRange; }
287
288 static void AcceptBadFits(bool val) { fAcceptBadFits = val; }
289 static bool AcceptBadFits() { return fAcceptBadFits; }
290
291 static void Fast(bool val) { fFast = val; }
292 static bool Fast() { return fFast; }
293
294 static void UseCalibratedPeaks(bool val) { fUseCalibratedPeaks = val; }
295 static bool UseCalibratedPeaks() { return fUseCalibratedPeaks; }
296
297 static void MinIntensity(double val) { fMinIntensity = val; }
298 static double MinIntensity() { return fMinIntensity; }
299
300 static void BadBins(const std::vector<int>& val) { fBadBins = val; }
301 static void BadBin(const int& val) { fBadBins.push_back(val); }
302 static void ResetBadBins() { fBadBins.clear(); }
303
304 static void ZoomX();
305
306 void PrintLayout() const;
307
308 void PrintCanvases() const;
309
310private:
321 // the numbering of these two enums needs to match the order in which the buttons are created
322 enum ENavigate : std::uint8_t {
328 kNext = 6
329 };
337
338 void BuildFirstInterface();
340 void DisconnectFirst();
341 void DeleteFirst();
344 void AcceptChannel(const int& channelId = -1);
345 void DisconnectSecond();
349 void AcceptFinalChannel(const int& channelId = -1);
351 void DeleteElement(TGFrame* element);
352 TGTransientFrame* CreateProgressbar(const char* format);
353
354 //TGHorizontalFrame* fTopFrame{nullptr};
355 TGHorizontalFrame* fBottomFrame{nullptr};
356 TGVerticalFrame* fLeftFrame{nullptr};
357 TGVerticalFrame* fRightFrame{nullptr};
358 TGTextButton* fStartButton{nullptr};
359 TGTab* fTab{nullptr};
360 std::vector<TChannelTab*> fChannelTab;
361
362 TGTextButton* fEmitter{nullptr};
363 TGHButtonGroup* fNavigationGroup{nullptr};
364 TGTextButton* fPreviousButton{nullptr};
365 TGTextButton* fDiscardButton{nullptr};
366 TGTextButton* fAcceptButton{nullptr};
367 TGTextButton* fAcceptAllButton{nullptr};
368 TGTextButton* fWriteButton{nullptr};
369 TGTextButton* fNextButton{nullptr};
370 TGHButtonGroup* fFittingGroup{nullptr};
371 TGTextButton* fCalibrateButton{nullptr};
372 TGTextButton* fFindAllPeaksButton{nullptr};
373 TGTextButton* fFindChannelPeaksButton{nullptr};
374 TGTextButton* fFindSourcePeaksButton{nullptr};
375 TGTextButton* fRecursiveRemoveButton{nullptr};
376 TGGroupFrame* fParameterFrame{nullptr};
377 TGLabel* fSigmaLabel{nullptr};
378 TGNumberEntry* fSigmaEntry{nullptr};
379 TGLabel* fThresholdLabel{nullptr};
380 TGNumberEntry* fThresholdEntry{nullptr};
381 TGLabel* fDegreeLabel{nullptr};
382 TGNumberEntry* fDegreeEntry{nullptr};
383 TGLabel* fMaxResidualLabel{nullptr};
384 TGNumberEntry* fMaxResidualEntry{nullptr};
385 TGGroupFrame* fSettingsFrame{nullptr};
386 TGCheckButton* fApplyToAll{nullptr};
387 TGCheckButton* fWriteNonlinearities{nullptr};
388 TGHProgressBar* fProgressBar{nullptr};
389
390 std::vector<TGLabel*> fMatrixNames;
391 std::vector<TGComboBox*> fSourceBox;
392 std::vector<TNucleus*> fSource;
393 std::vector<std::vector<std::tuple<double, double, double, double>>> fSourceEnergy; ///< vector to hold source energy, energy uncertainty, intensity, and intensity uncertainty
394 std::vector<int> fActiveBins;
395 std::vector<int> fActualChannelId;
396 std::vector<const char*> fChannelLabel;
397 std::queue<std::pair<int, std::future<TChannelTab*>>> fFutures;
398
399 std::vector<TH2*> fMatrices;
400 int fNofBins{0}; ///< Number of filled bins in first matrix
401
402 static std::string fLogFile; ///< name of log file, if empty no log file is written
403 TRedirect* fRedirect{nullptr}; ///< redirect, created in constructor and destroyed in destructor if a log file name has been provided
404
405 // graphic settings
406 unsigned int fLineHeight{20}; ///< Height of text boxes and progress bar
407 static int fPanelWidth; ///< Width of one panel
408 static int fPanelHeight; ///< Height of one panel
409 static int fStatusbarHeight; ///< Height of status bar (also extra height needed for tabs)
410 static int fParameterHeight; ///< Height of the frame for the parameters
411 static int fSourceboxWidth; ///< Width of the box to select which source each histogram is from
412 static int fDigitWidth; ///< Number of digits used for parameter entries (if they are floating point)
413
414 int fWaitMs{100}; ///< How many milliseconds we wait before we process the navigation input (to avoid double triggers?)
415
416 int fOldErrorLevel; ///< Used to store old value of gErrorIgnoreLevel (set to kError for the scope of the class)
417
418 double fDefaultSigma{2.}; ///< The default sigma used for the peak finding algorithm, can be changed later.
419 double fDefaultThreshold{0.05}; ///< The default threshold used for the peak finding algorithm, can be changed later. Co-56 source needs a much lower threshold, 0.01 or 0.02, but that makes it much slower too.
420 int fDefaultDegree{1}; ///< The default degree of the polynomial used for calibrating, can be changed later.
421 double fDefaultMaxResidual{2.}; ///< The default maximum residual accepted when trying to iteratively find peaks
422 static int fMaxIterations; ///< Maximum iterations over combinations in Match and SmartMatch
423 static int fFitRange; ///< range in sigma used for fitting peaks (peak position - range to peas position + range)
424 static bool fAcceptBadFits; ///< Do we accept peaks where the fit was bad (position or area uncertainties too large or not numbers)
425 static bool fFast; ///< Do we use the fast peak finding method on startup or not.
426 static bool fUseCalibratedPeaks; ///< Do we use the initial calibration to find more peaks in the source spectra?
427 static double fMinIntensity; ///< Minimum intensity of source peaks to be considered when trying to find them in the spectrum.
428 static size_t fNumberOfThreads; ///< Maximum number of threads to run while creating the channel tabs
429 static std::vector<int> fBadBins; ///< Bins of the 2D matrix to be ignored even if there are enough counts in them
430
431 std::mutex fGraphicsMutex; ///< mutex to lock changes to graphics
432
433 TFile* fOutput{nullptr};
434
435 static EVerbosity fVerboseLevel; ///< Changes verbosity from kQuiet to kAll
436
437 /// \cond CLASSIMP
438 ClassDefOverride(TSourceCalibration, 1) // NOLINT(readability-else-after-return)
439 /// \endcond
440};
441/*! @} */
442#endif
EVerbosity
Definition Globals.h:143
Definition GH1D.h:19
TSourceCalibration * fSourceCalibration
the parent of this tab
std::vector< GH1D * > fProjections
vector of all projections
void PrintLayout() const
TGCompositeFrame * fChannelFrame
main frame of this tab
std::vector< TSourceTab * > fSources
tabs for all sources
TCalibrationGraphSet * fFwhm
combined fwhm from all sources
TGraphErrors * Data(int channelId) const
TPaveText * fChi2Label
TGTab * fSourceTab
tab for sources
void SelectCanvas(Event_t *event)
void Write(TFile *output)
TRootEmbeddedCanvas * fInitCanvas
TChannelTab(TSourceCalibration *sourceCal, std::vector< TNucleus * > nuclei, std::vector< GH1D * > projections, std::string name, TGCompositeFrame *frame, std::vector< std::vector< std::tuple< double, double, double, double > > > sourceEnergies, TGHProgressBar *progressBar)
void CalibrationStatus(Int_t event, Int_t px, Int_t py, TObject *selected)
TSourceTab * SelectedSourceTab() const
void Initialize(const bool &force)
static void ZoomY()
void RemovePoint(Int_t oldGraph, Int_t oldPoint)
TGCompositeFrame * fCalibrationFrame
frame of tab with calibration
std::vector< std::vector< std::tuple< double, double, double, double > > > fSourceEnergies
vector with source energies and uncertainties
int ActiveSourceTab() const
std::string Name() const
void CreateSourceTab(size_t source)
TGCompositeFrame * fFwhmFrame
frame of tab with fwhm
TCalibrationGraphSet * fInit
combined initial data from all sources
TRootEmbeddedCanvas * fFwhmCanvas
int fActiveSourceTab
id of the currently active source tab
std::string fName
name of this tab
TPaveText * fInfoLabel
static void ZoomX()
std::vector< TNucleus * > fNuclei
the source nucleus
void SelectedTab(Int_t id)
TGStatusBar * fChannelStatusBar
size_t NumberOfSources() const
TGTab * SourceTab() const
void RecursiveRemove(const double &maxResidual)
TGTab * fCanvasTab
tab for canvases (calibration with residuals, and FWHM)
TChannelTab(const TChannelTab &)=default
TPaveText * fCalLabel
TGCompositeFrame * fInitFrame
frame of tab with initial calibration
void PrintCanvases() const
TChannelTab(TChannelTab &&) noexcept=default
TGHProgressBar * fProgressBar
TRootEmbeddedCanvas * fCalibrationCanvas
TCalibrationGraphSet * fData
combined data from all sources
void Centroid(const Double_t &centroid) override
Definition TGauss.cxx:13
unsigned int fLineHeight
Height of text boxes and progress bar.
int fWaitMs
How many milliseconds we wait before we process the navigation input (to avoid double triggers?...
TGTextButton * fPreviousButton
TRedirect * fRedirect
redirect, created in constructor and destroyed in destructor if a log file name has been provided
static std::string LogFile()
static int fStatusbarHeight
Height of status bar (also extra height needed for tabs)
TGVerticalFrame * fRightFrame
TGTransientFrame * CreateProgressbar(const char *format)
static std::string fLogFile
name of log file, if empty no log file is written
static void UseCalibratedPeaks(bool val)
static void FitRange(int val)
static void SourceboxWidth(int val)
TSourceCalibration(double sigma, double threshold, int degree, int count...)
TGCheckButton * fWriteNonlinearities
TGNumberEntry * fMaxResidualEntry
std::mutex fGraphicsMutex
mutex to lock changes to graphics
int fDefaultDegree
The default degree of the polynomial used for calibrating, can be changed later.
void NavigateFinal(Int_t id)
static EVerbosity VerboseLevel()
static void ZoomX()
TGGroupFrame * fParameterFrame
std::vector< TGLabel * > fMatrixNames
static void VerboseLevel(EVerbosity val)
static void AcceptBadFits(bool val)
TGTextButton * fFindSourcePeaksButton
TGTextButton * fCalibrateButton
static double MinIntensity()
TGTextButton * fAcceptAllButton
void AcceptChannel(const int &channelId=-1)
TGNumberEntry * fSigmaEntry
static void ParameterHeight(int val)
std::vector< std::tuple< double, double, double, double > > SourceEnergy(const size_t &i)
double fDefaultSigma
The default sigma used for the peak finding algorithm, can be changed later.
static int fMaxIterations
Maximum iterations over combinations in Match and SmartMatch.
static void MaxIterations(int val)
TGTextButton * fFindAllPeaksButton
TGHProgressBar * fProgressBar
TSourceCalibration(const TSourceCalibration &)=delete
TGHButtonGroup * fNavigationGroup
TGNumberEntry * fThresholdEntry
void SetSource(Int_t windowId, Int_t entryId)
void SelectedFinalMainTab(Int_t id)
void SelectedFinalTab(Int_t id)
std::vector< int > fActiveBins
TGTextButton * fDiscardButton
std::vector< TNucleus * > fSource
std::queue< std::pair< int, std::future< TChannelTab * > > > fFutures
static void Fast(bool val)
void CalibrationStatus(Int_t event, Int_t px, Int_t py, TObject *selected)
static bool fFast
Do we use the fast peak finding method on startup or not.
std::vector< const char * > fChannelLabel
static void BadBins(const std::vector< int > &val)
std::vector< TChannelTab * > fChannelTab
static bool fAcceptBadFits
Do we accept peaks where the fit was bad (position or area uncertainties too large or not numbers)
static void LogFile(std::string val)
TGTextButton * fAcceptButton
static int fPanelWidth
Width of one panel.
static size_t fNumberOfThreads
Maximum number of threads to run while creating the channel tabs.
double fDefaultMaxResidual
The default maximum residual accepted when trying to iteratively find peaks.
void BuildThirdInterface()
void UpdateChannel(const int &channelId)
static int fPanelHeight
Height of one panel.
TGTextButton * fRecursiveRemoveButton
void AcceptFinalChannel(const int &channelId=-1)
TSourceCalibration(TSourceCalibration &&) noexcept=delete
static void MinIntensity(double val)
std::vector< TH2 * > fMatrices
void LineHeight(const unsigned int &val)
static bool fUseCalibratedPeaks
Do we use the initial calibration to find more peaks in the source spectra?
static void NumberOfThreads(size_t val)
int fOldErrorLevel
Used to store old value of gErrorIgnoreLevel (set to kError for the scope of the class)
static int fDigitWidth
Number of digits used for parameter entries (if they are floating point)
TGHButtonGroup * fFittingGroup
TGTextButton * fWriteButton
std::vector< TGComboBox * > fSourceBox
std::vector< int > fActualChannelId
int fNofBins
Number of filled bins in first matrix.
TGTextButton * fFindChannelPeaksButton
void FitFinal(const int &channelId)
TGNumberEntry * fDegreeEntry
static double fMinIntensity
Minimum intensity of source peaks to be considered when trying to find them in the spectrum.
void DeleteElement(TGFrame *element)
static int fParameterHeight
Height of the frame for the parameters.
static void PanelWidth(int val)
static void BadBin(const int &val)
std::vector< std::vector< std::tuple< double, double, double, double > > > fSourceEnergy
vector to hold source energy, energy uncertainty, intensity, and intensity uncertainty
static void StatusbarHeight(int val)
static bool AcceptBadFits()
static std::vector< int > fBadBins
Bins of the 2D matrix to be ignored even if there are enough counts in them.
static int fSourceboxWidth
Width of the box to select which source each histogram is from.
static double FitRange()
TGTextButton * fStartButton
double fDefaultThreshold
The default threshold used for the peak finding algorithm, can be changed later. Co-56 source needs a...
void MakeThirdConnections()
TGCheckButton * fApplyToAll
std::mutex & GraphicsMutex()
TGTextButton * fNextButton
TGVerticalFrame * fLeftFrame
static void DigitWidth(int val)
static EVerbosity fVerboseLevel
Changes verbosity from kQuiet to kAll.
TGGroupFrame * fSettingsFrame
TGHorizontalFrame * fBottomFrame
static void PanelHeight(int val)
static bool UseCalibratedPeaks()
static int fFitRange
range in sigma used for fitting peaks (peak position - range to peas position + range)
void SourceEnergy(std::vector< std::tuple< double, double, double, double > > val)
TSourceTab(TSourceTab &&) noexcept=default
void InitialCalibration(const bool &force)
void Status(const char *status, int position)
void ReplacePeak(const size_t &index, const double &channel)
const char * fSourceName
TGraphErrors * fFwhm
TGraphErrors * Fwhm() const
bool Good(TGauss *peak)
TRootEmbeddedCanvas * fProjectionCanvas
bool Good(TGauss *peak, double lowRange, double highRange)
std::vector< std::pair< double, double > > fRegions
void RemovePoint(Int_t oldPoint)
TChannelTab * fChannelTab
void ProjectionStatus(Event_t *event)
const char * SourceName() const
TSourceTab(TSourceCalibration *sourceCal, TChannelTab *channel, TGCompositeFrame *frame, GH1D *projection, const char *sourceName, std::vector< std::tuple< double, double, double, double > > sourceEnergy)
TGCompositeFrame * fSourceFrame
TRootEmbeddedCanvas * ProjectionCanvas() const
TGraphErrors * Data() const
TGraphErrors * fData
std::vector< TPeakFitter * > fBadFits
all bad fits (centroid err > 10%, area err > 100%, or either of them not a number at all)
std::vector< std::tuple< double, double, double, double > > fSourceEnergy
gamma rays from the source, with their energies, uncertainties in the energies, intensities,...
std::vector< TPeakFitter * > fFits
all good fits
void Add(std::map< double, std::tuple< double, double, double, double > > map)
TSourceCalibration * fSourceCalibration
void PrintLayout() const
std::vector< TGauss * > fPeaks
all peaks that have been fitted and are good
void FindCalibratedPeaks(const TF1 *calibration)
TGStatusBar * fSourceStatusBar
void PrintCanvases() const
std::map< TGauss *, std::tuple< double, double, double, double > > SmartMatch(std::vector< TGauss * > peaks, std::vector< std::tuple< double, double, double, double > > sources, TSourceTab *sourceTab)
std::map< TGauss *, std::tuple< double, double, double, double > > Match(std::vector< TGauss * > peaks, std::vector< std::tuple< double, double, double, double > > sources, TSourceTab *sourceTab)
bool FilledBin(TH2 *matrix, const int &bin)
std::map< double, std::tuple< double, double, double, double > > RoughCal(std::vector< double > peaks, std::vector< std::tuple< double, double, double, double > > sources, TSourceTab *sourceTab)
double Polynomial(double *x, double *par)