1#ifndef TSOURCECALIBRATION_H
2#define TSOURCECALIBRATION_H
17#include "TGFSComboBox.h"
18#include "TGStatusBar.h"
19#include "TGButtonGroup.h"
21#include "TGNumberEntry.h"
23#include "TGProgressBar.h"
24#include "TRootEmbeddedCanvas.h"
39std::map<GPeak*, std::tuple<double, double, double, double>>
Match(std::vector<GPeak*> peaks, std::vector<std::tuple<double, double, double, double>> sources,
TSourceTab* sourceTab);
40std::map<GPeak*, std::tuple<double, double, double, double>>
SmartMatch(std::vector<GPeak*> peaks, std::vector<std::tuple<double, double, double, double>> sources,
TSourceTab* sourceTab);
44bool FilledBin(TH2* matrix,
const int& bin);
52 TSourceTab(
TChannelTab* parent, TGCompositeFrame* frame,
GH1D* projection,
const double& sigma,
const double& threshold,
const double& peakRatio, std::vector<std::tuple<double, double, double, double>> sourceEnergy);
65 void Add(std::map<
GPeak*, std::tuple<
double,
double,
double,
double>> map);
66 void FindPeaks(const
double& sigma, const
double& threshold, const
double& peakRatio, const
bool& force = false, const
bool& fast = true);
70 void Status(
const char* status,
int position);
107 TChannelTab(
TSourceCalibration* parent, std::vector<TNucleus*> nuclei, std::vector<GH1D*> projections, std::string name, TGCompositeFrame* frame,
double sigma,
double threshold,
int degree, std::vector<std::vector<std::tuple<double, double, double, double>>> sourceEnergies, TGHProgressBar* progressBar);
126 void Write(TFile* output);
128 void Calibrate(const
int& degree, const
bool& force = false);
129 void FindPeaks(const
double& sigma, const
double& threshold, const
double& peakRatio, const
bool& force = false, const
bool& fast = true);
131 TGraphErrors*
Data(
int channelId)
const {
return fSources[channelId]->Data(); }
175 TSourceCalibration(
double sigma,
double threshold,
int degree,
double peakRatio,
int count...);
182 void SetSource(Int_t windowId, Int_t entryId);
220 using TGWindow::HandleTimer;
320 std::vector<std::vector<std::tuple<double, double, double, double>>>
fSourceEnergy;
bool FilledBin(TH2 *matrix, const int &bin)
std::map< GPeak *, std::tuple< double, double, double, double > > Match(std::vector< GPeak * > peaks, std::vector< std::tuple< double, double, double, double > > sources, TSourceTab *sourceTab)
double Polynomial(double *x, double *par)
std::map< GPeak *, std::tuple< double, double, double, double > > SmartMatch(std::vector< GPeak * > peaks, std::vector< std::tuple< double, double, double, double > > sources, TSourceTab *sourceTab)
std::vector< GH1D * > fProjections
vector of all projections
double fThreshold
the threshold (relative to the largest peak) used in the peak finder
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
TChannelTab(TSourceCalibration *parent, std::vector< TNucleus * > nuclei, std::vector< GH1D * > projections, std::string name, TGCompositeFrame *frame, double sigma, double threshold, int degree, std::vector< std::vector< std::tuple< double, double, double, double > > > sourceEnergies, TGHProgressBar *progressBar)
TGTab * fSourceTab
tab for sources
void SelectCanvas(Event_t *event)
void Write(TFile *output)
void CalibrationStatus(Int_t event, Int_t px, Int_t py, TObject *selected)
TSourceTab * SelectedSourceTab() const
TGCompositeFrame * fCalibrationFrame
frame of tab with calibration
TSourceCalibration * fParent
the parent of this tab
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
TRootEmbeddedCanvas * fFwhmCanvas
int fActiveSourceTab
id of the currently active source tab
std::string fName
name of this tab
void FindPeaks(const double &sigma, const double &threshold, const double &peakRatio, const bool &force=false, const bool &fast=true)
int fDegree
degree of polynomial function used to calibrate
std::vector< TNucleus * > fNuclei
the source nucleus
void SelectedTab(Int_t id)
TGStatusBar * fChannelStatusBar
size_t NumberOfSources() const
TGTab * SourceTab() const
TGTab * fCanvasTab
tab for canvases (calibration with residuals, and FWHM)
TChannelTab(const TChannelTab &)=default
double fSigma
the sigma used in the peak finder
TChannelTab(TChannelTab &&) noexcept=default
TGHProgressBar * fProgressBar
TRootEmbeddedCanvas * fCalibrationCanvas
TCalibrationGraphSet * fData
combined data from all sources
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
static std::string LogFile()
static int fStatusbarHeight
Height of status bar (also extra height needed for tabs)
TGVerticalFrame * fRightFrame
static std::string fLogFile
name of log file, if empty no log file is written
TGNumberEntry * fPeakRatioEntry
static void SourceboxWidth(int val)
TGCheckButton * fWriteNonlinearities
void SelectedTab(Int_t id)
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)
TGTextButton * fCalibrateButton
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.
TGTextButton * fFindPeaksFastButton
static void MaxIterations(int val)
double fDefaultPeakRatio
The default ratio between found peaks and peaks in the source (per region).
TGHProgressBar * fProgressBar
TSourceCalibration(const TSourceCalibration &)=delete
TGHButtonGroup * fNavigationGroup
TGNumberEntry * fThresholdEntry
void SetSource(Int_t windowId, Int_t entryId)
TGTextButton * fFindPeaksButton
static int StatusbarHeight()
void SelectedFinalMainTab(Int_t id)
void SelectedFinalTab(Int_t id)
std::vector< int > fActiveBins
TGTextButton * fDiscardButton
std::vector< TNucleus * > fSource
void CalibrationStatus(Int_t event, Int_t px, Int_t py, TObject *selected)
bool WriteNonlinearities()
std::vector< const char * > fChannelLabel
std::vector< TChannelTab * > fChannelTab
static void LogFile(std::string val)
TGTextButton * fAcceptButton
TSourceCalibration(double sigma, double threshold, int degree, double peakRatio, int count...)
static int fPanelWidth
Width of one panel.
void BuildThirdInterface()
void UpdateChannel(const int &channelId)
static int fPanelHeight
Height of one panel.
void AcceptFinalChannel(const int &channelId=-1)
TSourceCalibration(TSourceCalibration &&) noexcept=delete
std::vector< TH2 * > fMatrices
void LineHeight(const unsigned int &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)
std::vector< TGComboBox * > fSourceBox
TGLabel * fPeakRatioLabel
std::vector< int > fActualChannelId
int fNofBins
Number of filled bins in first matrix.
void FitFinal(const int &channelId)
TGNumberEntry * fDegreeEntry
void MakeSecondConnections()
void DeleteElement(TGFrame *element)
static int fParameterHeight
Height of the frame for the parameters.
static void PanelWidth(int val)
void MakeFirstConnections()
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 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()
TGTextButton * fNextButton
TGVerticalFrame * fLeftFrame
static void DigitWidth(int val)
static EVerbosity fVerboseLevel
Changes verbosity from 0 (quiet) to 4 (very verbose)
TGHorizontalFrame * fBottomFrame
void BuildSecondInterface()
static void PanelHeight(int val)
void RemovePoint(Int_t px, Int_t py)
void SourceEnergy(std::vector< std::tuple< double, double, double, double > > val)
TSourceTab(TSourceTab &&) noexcept=default
std::vector< GPeak * > fPeaks
void Status(const char *status, int position)
TGraphErrors * Fwhm() const
TRootEmbeddedCanvas * fProjectionCanvas
TSourceTab(TChannelTab *parent, TGCompositeFrame *frame, GH1D *projection, const double &sigma, const double &threshold, const double &peakRatio, std::vector< std::tuple< double, double, double, double > > sourceEnergy)
void FindPeaks(const double &sigma, const double &threshold, const double &peakRatio, const bool &force=false, const bool &fast=true)
std::vector< std::pair< double, double > > fRegions
void Add(std::map< GPeak *, std::tuple< double, double, double, double > > map)
void ProjectionStatus(Event_t *event)
TGCompositeFrame * fSourceFrame
TRootEmbeddedCanvas * ProjectionCanvas() const
TGraphErrors * Data() const
void RemoveResidualPoint(Int_t px, Int_t py)
std::vector< std::tuple< double, double, double, double > > fSourceEnergy
TGStatusBar * fSourceStatusBar