1#ifndef TSOURCECALIBRATION_H
2#define TSOURCECALIBRATION_H
23#include "TGFSComboBox.h"
24#include "TGStatusBar.h"
25#include "TGButtonGroup.h"
27#include "TGNumberEntry.h"
29#include "TGProgressBar.h"
30#include "TRootEmbeddedCanvas.h"
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);
52bool FilledBin(TH2* matrix,
const int& bin);
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);
77 void ReplacePeak(const
size_t& index, const
double& channel);
81 void Status(
const char* status,
int position);
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);
147 void Write(TFile* output);
154 TGraphErrors*
Data(
int channelId)
const {
return fSources[channelId]->Data(); }
216 void SetSource(Int_t windowId, Int_t entryId);
229 using TObject::RecursiveRemove;
259 using TGWindow::HandleTimer;
397 std::vector<std::vector<std::tuple<double, double, double, double>>>
fSourceEnergy;
401 std::queue<std::pair<int, std::future<TChannelTab*>>>
fFutures;
void FindCalibratedPeaks()
TSourceCalibration * fSourceCalibration
the parent of this tab
std::vector< GH1D * > fProjections
vector of all projections
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
TGTab * fSourceTab
tab for sources
void SelectCanvas(Event_t *event)
void Write(TFile *output)
void FindAllCalibratedPeaks()
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)
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
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
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
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 ¢roid) override
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
void SelectedTab(Int_t id)
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()
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)
static int MaxIterations()
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.
TGLabel * fThresholdLabel
static int fMaxIterations
Maximum iterations over combinations in Match and SmartMatch.
static void MaxIterations(int val)
TGTextButton * fFindAllPeaksButton
TGHProgressBar * fProgressBar
TSourceCalibration(const TSourceCalibration &)=delete
void PrintCanvases() const
TGHButtonGroup * fNavigationGroup
TGNumberEntry * fThresholdEntry
void SetSource(Int_t windowId, Int_t entryId)
static int StatusbarHeight()
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)
TGLabel * fMaxResidualLabel
static bool fFast
Do we use the fast peak finding method on startup or not.
bool WriteNonlinearities()
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.
static void ResetBadBins()
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)
void BuildFirstInterface()
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
void MakeSecondConnections()
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)
void MakeFirstConnections()
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.
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
void BuildSecondInterface()
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)
TGraphErrors * Fwhm() const
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
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
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)