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