Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated TBGSubtraction's class description #1488

Merged
merged 4 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 55 additions & 48 deletions include/GH1D.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class GH1D : public TH1D {
void SetParent(TObject* obj) { fParent = obj; }

TVirtualPad* GetPad() const { return fPad; }
void SetPad(TVirtualPad* pad);
void SetPad(TVirtualPad* pad);

int GetProjectionAxis() const { return fProjectionAxis; }
void SetProjectionAxis(int axis) { fProjectionAxis = axis; }
Expand All @@ -63,73 +63,80 @@ class GH1D : public TH1D {
GH1D* Project_Background(double value_low, double value_high, double bg_value_low, double bg_value_high,
EBackgroundSubtraction mode = EBackgroundSubtraction::kRegionBackground) const;

TVirtualPad* Pad() const { return fPad; }
TList* ListOfRegions() { return &fRegions; }
TVirtualPad* Pad() const { return fPad; }
TList* ListOfRegions() { return &fRegions; }

void HandleMovement(Int_t eventType, Int_t eventX, Int_t eventY, TObject* selected);
void HandleEvent(Event_t* event, Window_t window);
void HandleMovement(Int_t eventType, Int_t eventX, Int_t eventY, TObject* selected);
void HandleEvent(Event_t* event, Window_t window);

void RemoveRegion(TRegion* region);
void RemoveRegion(TRegion* region);

void UpdatePad() { fPad->Modified(); fPad->Update(); }
void UpdateRegions();
void PrintRegions();
void DrawRegions(Option_t* opt = "");
void UpdatePad()
{
fPad->Modified();
fPad->Update();
}
void UpdateRegions();
void PrintRegions();
void DrawRegions(Option_t* opt = "");

static void VerboseLevel(int level) { fVerboseLevel = level; }
static int VerboseLevel() { return fVerboseLevel; }
static void VerboseLevel(int level) { fVerboseLevel = level; }
static int VerboseLevel() { return fVerboseLevel; }

private:
void RemoveCurrentRegion();

TRef fParent;
int fProjectionAxis;
TVirtualPad* fPad{nullptr}; //!<!
// variables for regions
double fStartX{0.}; //!<! initial x-position of new region
double fStartY{0.}; //!<! initial y-position of new region
bool fGate{false}; //< flag to indicate that next region will be a gate region
bool fBackground{false}; //< flag to indicate that next region will be a background region
bool fRegion{false}; //< flag to indicate that next region will be a default region
TBox* fCurrentRegion{nullptr}; //!<! box for the current region
std::array<int, 3> fRegionColor{kOrange+2, kGreen+2, kCyan+2}; // could be made static?
size_t fNofRegions{0}; //!<! counts number of regions in this histogram, only used to set the color of the region
TList fRegions;

static int fVerboseLevel; //!<! level of verbosity
void RemoveCurrentRegion();

TRef fParent;
int fProjectionAxis;
TVirtualPad* fPad{nullptr}; //!<!
// variables for regions
double fStartX{0.}; //!<! initial x-position of new region
double fStartY{0.}; //!<! initial y-position of new region
bool fGate{false}; //< flag to indicate that next region will be a gate region
bool fBackground{false}; //< flag to indicate that next region will be a background region
bool fRegion{false}; //< flag to indicate that next region will be a default region
TBox* fCurrentRegion{nullptr}; //!<! box for the current region
std::array<int, 3> fRegionColor{kOrange + 2, kGreen + 2, kCyan + 2}; // could be made static?
size_t fNofRegions{0}; //!<! counts number of regions in this histogram, only used to set the color of the region
TList fRegions;

static int fVerboseLevel; //!<! level of verbosity

/// /cond CLASSIMP
ClassDefOverride(GH1D, 1) // NOLINT(readability-else-after-return)
/// /endcond
/// /endcond
};

enum class ERegionType{kDefault, kGate, kBackground, kRegion};
enum class ERegionType { kDefault,
kGate,
kBackground,
kRegion };

class TRegion : public TBox {
public:
TRegion() = default;
TRegion(TBox* box, ERegionType type, GH1D* parent);
TRegion(const TRegion&) = default;
TRegion(TRegion&&) = default;
TRegion& operator=(const TRegion&) = default;
TRegion& operator=(TRegion&&) = default;
~TRegion() = default;

bool Update();
void Hide();
void Draw(Option_t* opt = "") override;
TRegion() = default;
TRegion(TBox* box, ERegionType type, GH1D* parent);
TRegion(const TRegion&) = default;
TRegion(TRegion&&) = default;
TRegion& operator=(const TRegion&) = default;
TRegion& operator=(TRegion&&) = default;
~TRegion() = default;

bool Update();
void Hide();
void Draw(Option_t* opt = "") override;

void Update(double startX, double stopX);
void Update(double startX, double stopX);

private:
GH1D* fParent{nullptr};
ERegionType fType{ERegionType::kDefault};
double fLowX{0.};
double fHighX{0.};
GH1D* fParent{nullptr};
ERegionType fType{ERegionType::kDefault};
double fLowX{0.};
double fHighX{0.};

/// /cond CLASSIMP
ClassDefOverride(TRegion, 1) // NOLINT(readability-else-after-return)
/// /endcond
/// /endcond
};

#endif /* GH1D_H */
11 changes: 11 additions & 0 deletions include/TBGSubtraction.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@
///
/// This class implements a GUI to perform projections of a 2D-Matrix
/// with proper background subtraction.
///
/// There is a known issue that clicking on the close button of the
/// window will cause a segmentation violation. If the class was
/// created on the heap (using `new`), this will make it impossible
/// to kill grsisort from within the terminal or sending it to the
/// background. If the class was however created on the stack, this
/// will simply crash grsisort. Because of this the recommended way
/// to start it is using a line like `TBGSubtraction bg(<matrix-name>)`
/// where bg is the variable name (can be any other valid c++ variable
/// name), and <matrix-name> is the name of the 2D histogram (without
/// any quotation marks).
///
/////////////////////////////////////////////////////////////////

Expand Down
4 changes: 2 additions & 2 deletions include/TCalibrationGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ class TCalibrationGraphSet : public TNamed, public TQObject {
fGraphs.erase(fGraphs.begin() + index);
ResetTotalGraph();
}
Int_t RemovePoint(const Int_t& px, const Int_t& py); //*SIGNAL*
Int_t RemoveResidualPoint(const Int_t& px, const Int_t& py); //*SIGNAL*
Int_t RemovePoint(const Int_t& px, const Int_t& py); //*SIGNAL*
Int_t RemoveResidualPoint(const Int_t& px, const Int_t& py); //*SIGNAL*

void XAxisLabel(const std::string& xAxisLabel) { fXAxisLabel = xAxisLabel; }
void YAxisLabel(const std::string& yAxisLabel) { fYAxisLabel = yAxisLabel; }
Expand Down
53 changes: 27 additions & 26 deletions include/TSourceCalibration.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

class TSourceTab;

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);
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);
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);

double Polynomial(double* x, double* par);
Expand Down Expand Up @@ -65,14 +65,14 @@ class TSourceTab {

void SourceEnergy(std::vector<std::tuple<double, double, double, double>> val) { fSourceEnergy = std::move(val); }

void Status(const char* status, int position);
void Status(const char* status, int position);

TGraphErrors* Data() const { return fData; }
TGraphErrors* Fwhm() const { return fFwhm; }
TGraphErrors* Data() const { return fData; }
TGraphErrors* Fwhm() const { return fFwhm; }
TRootEmbeddedCanvas* ProjectionCanvas() const { return fProjectionCanvas; }

void RemovePoint(Int_t px, Int_t py);
void RemoveResidualPoint(Int_t px, Int_t py);
void RemovePoint(Int_t px, Int_t py);
void RemoveResidualPoint(Int_t px, Int_t py);

void PrintLayout() const;

Expand All @@ -94,7 +94,7 @@ class TSourceTab {
TGraphErrors* fFwhm{nullptr};
double fSigma{2.};
double fThreshold{0.05};
double fPeakRatio{2.};
double fPeakRatio{2.};
std::vector<GPeak*> fPeaks;
std::vector<std::tuple<double, double, double, double>> fSourceEnergy;
std::vector<std::pair<double, double>> fRegions;
Expand All @@ -115,7 +115,7 @@ class TChannelTab {
void Disconnect();

void CalibrationStatus(Int_t event, Int_t px, Int_t py, TObject* selected);
void SelectCanvas(Event_t* event);
void SelectCanvas(Event_t* event);

void UpdateData();
void UpdateFwhm();
Expand All @@ -130,7 +130,7 @@ class TChannelTab {
size_t NumberOfSources() const { return fSources.size(); }
std::string Name() const { return fName; }
int ActiveSourceTab() const { return fActiveSourceTab; }
TSourceTab* SelectedSourceTab() const { return fSources[fActiveSourceTab]; };
TSourceTab* SelectedSourceTab() const { return fSources[fActiveSourceTab]; };

static void ZoomX();
static void ZoomY();
Expand All @@ -139,18 +139,18 @@ class TChannelTab {

private:
// graphic elements
TGCompositeFrame* fChannelFrame{nullptr}; ///< main frame of this tab
TGTab* fSourceTab{nullptr}; ///< tab for sources
std::vector<TSourceTab*> fSources; ///< tabs for all sources
TGTab* fCanvasTab{nullptr}; ///< tab for canvases (calibration with residuals, and FWHM)
TGCompositeFrame* fCalibrationFrame{nullptr}; ///< frame of tab with calibration
TGCompositeFrame* fChannelFrame{nullptr}; ///< main frame of this tab
TGTab* fSourceTab{nullptr}; ///< tab for sources
std::vector<TSourceTab*> fSources; ///< tabs for all sources
TGTab* fCanvasTab{nullptr}; ///< tab for canvases (calibration with residuals, and FWHM)
TGCompositeFrame* fCalibrationFrame{nullptr}; ///< frame of tab with calibration
TRootEmbeddedCanvas* fCalibrationCanvas{nullptr};
TPad* fResidualPad{nullptr};
TPad* fCalibrationPad{nullptr};
TGStatusBar* fChannelStatusBar{nullptr};
TLegend* fLegend{nullptr};
TPaveText* fChi2Label{nullptr};
TGCompositeFrame* fFwhmFrame{nullptr}; ///< frame of tab with fwhm
TGCompositeFrame* fFwhmFrame{nullptr}; ///< frame of tab with fwhm
TRootEmbeddedCanvas* fFwhmCanvas{nullptr};
TGHProgressBar* fProgressBar{nullptr};

Expand All @@ -172,12 +172,12 @@ class TSourceCalibration : public TGMainFrame {
public:
enum EEntry : int {
kStartButton,
kSourceBox = 100,
kSigmaEntry = 200,
kThresholdEntry = 300,
kDegreeEntry = 400,
kPeakRatioEntry = 500,
kWriteNonlinearities = 600
kSourceBox = 100,
kSigmaEntry = 200,
kThresholdEntry = 300,
kDegreeEntry = 400,
kPeakRatioEntry = 500,
kWriteNonlinearities = 600
};

TSourceCalibration(double sigma, double threshold, int degree, double peakRatio, int count...);
Expand Down Expand Up @@ -216,11 +216,12 @@ class TSourceCalibration : public TGMainFrame {
if(fDegreeEntry != nullptr) { fDefaultDegree = static_cast<int>(fDegreeEntry->GetNumber()); }
return fDefaultDegree;
}
double PeakRatio() {
if(fPeakRatioEntry != nullptr) { fDefaultPeakRatio = fPeakRatioEntry->GetNumber(); }
return fDefaultPeakRatio;
}
bool WriteNonlinearities() { return fWriteNonlinearities->IsDown(); }
double PeakRatio()
{
if(fPeakRatioEntry != nullptr) { fDefaultPeakRatio = fPeakRatioEntry->GetNumber(); }
return fDefaultPeakRatio;
}
bool WriteNonlinearities() { return fWriteNonlinearities->IsDown(); }
std::vector<std::tuple<double, double, double, double>> SourceEnergy(const size_t& i) { return fSourceEnergy.at(i); }
void CalibrationStatus(Int_t event, Int_t px, Int_t py, TObject* selected);

Expand Down
Loading
Loading