Skip to content

Commit

Permalink
Merge pull request #1419 from VinzenzBildstein/main
Browse files Browse the repository at this point in the history
Adding some doxygen documentation
  • Loading branch information
VinzenzBildstein authored May 26, 2024
2 parents 4db19ce + 52d4774 commit 9509cca
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ bin
lib
myAnalysis
Sandbox
*User*
users
.deps
.nfs*
G__auto*
Expand Down
26 changes: 21 additions & 5 deletions include/ArgParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ struct ParseError : public std::runtime_error {
ParseError(const std::string& msg) : std::runtime_error(msg) {}
};

//// Because gcc-4.7 does not fully implement C++11
// struct ParseError : public std::runtime_error{
// using std::runtime_error::runtime_error;
// };

/** Base class used to parse an individual item.
Most methods are implemented in the templated ArgParseConfig<T>
*/
Expand Down Expand Up @@ -294,6 +289,27 @@ class ArgParseConfigT<std::vector<T>> : public ArgParseConfig<std::vector<T>> {
int fNum_arguments_expected;
};

//////////////////////////////////////////////////////////////////////////
///
/// \class ArgParser
///
/// This class is used to parse the command line arguments.
///
/// Example usage:
/// ```
/// ArgParser parser;
/// parser.option("some-option s", &myOption, true).description("my cool option").default_value(42);
/// parser.parse(argc, argv, true);
/// ```
/// to read the flag "--some-option" or "-s" into the integer variable myOption.
///
/// The 3rd argument in ArgParser::option and ArgParser::parse that are set
/// to true here are the "firstPass" arguments which simply means we want
/// to read these options right away instead of reading something from an
/// input file and only then parse the command line arguments.
///
//////////////////////////////////////////////////////////////////////////

class ArgParser {
public:
ArgParser() {}
Expand Down
77 changes: 76 additions & 1 deletion include/GCanvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@

#include "GH2I.h"

/** \addtogroup GROOT
* @{
*/

///////////////////////////////////////////////////////////////////////////
///
/// \class GMarker
///
///////////////////////////////////////////////////////////////////////////

class GMarker : public TObject {
public:
GMarker() : fLineX(nullptr), fLineY(nullptr) {}
Expand Down Expand Up @@ -117,6 +127,71 @@ class GMarker : public TObject {
ClassDefOverride(GMarker, 0)
};

///////////////////////////////////////////////////////////////////////////
///
/// \class GCanvas
///
/// Reimplementation of TCanvas. Adds different actions for mouse clicks:
/// - single click: stores position (only for TLevelScheme).
/// - double click: add GMarker if the last histogram found in the gPad is 1D or 2D.
/// - shift click: draw the parent of GH1D histogram on new canvas or draw all
/// histograms on a new canvas, or (for 2D histograms) create new GH2D from
/// histogram and draw it on a new canvas (using "colz").
/// - control click: doesn't do anything right now, code for TCutG is commented out.
/// For TLevelSchemes we also have:
/// - mouse wheel to change zoom level
/// - mouse drag to zoom in
/// - u unzooms.
/// Also adds keyboard controls for 1D histograms:
/// - left/right arrow moves the range left/right by 50%.
/// - up/down arrow on GH1D histograms selects the next/previous histogram and draws it.
/// - F2 opens editor.
/// - F9 shows crosshairs.
/// - b Set the background, how it is set depends on B.
/// - B Cycle through types of automatic background subtraction used when projecting with p. Current types include: No subtraction, Fraction of the total, subtract gate from the 3rd marker (gate size set to the distance between marker 1 and 2).
/// - d Open popup.
/// - e Expand the x-axis range between the last two markers.
/// - E Bring up dialogue box used to set desired x-axis range.
/// - f If markers have been set, do a GPeak fit between last two markers on the last histogram (skewed gaus for gamma-rays with automatic bg).
/// - F TPeak Fit (skewed gaus for gamma-rays with automatic bg).
/// - g Simple Gaus fit between the last to marks, displays results of the fit RESULTS STILL NEED TO BE VERIFIED
/// - i Raw integral of counts between the two markers
/// - I TODO: Background subtracted integral of counts between the two markers
/// - l/y Toggle y-axis from linear to logarithmic and vice versa.
/// - m Toggle on marker mode; when on, the histogram will remember and display the last four clicks as marks on the histogram.
/// - M Toggle off marker mode.
/// - n Remove all markers / functions drawn on the histogram.
/// - N Remove all markers and the LAST function drawn on the histogram.
/// - o Unzoom the entire histogram.
/// - p If the 1d hist was made using the global ProjectionX/ProjectionY; gating the original 2D matrix this histogram came from is possible by placing markers around the gate and pressing p. The gates spectra is immediately drawn.
/// - P Draws parent histogram???
/// - q If markers have been set, fit a GPeak between the last two markers on the first histogram (skewed gaus for gamma-rays with automatic bg).
/// - r Expand the y-axis range between the last two markers.
/// - R Bring up the dialogue box used to set the desired y-axis range.
/// - s Show peak values.
/// - S Remove peak values.
/// And for 2D histograms these keyboard controls are added:
/// - left/right arrow moves the range left/right by 50%.
/// - up/down arrow moves the range up/down by 50%.
/// - c Add the initialized cut to the list of cuts (see i).
/// - e Expand the x- and y-axis between the last two markers.
/// - E Bring up dialogue box used to set desired x-axis range.
/// - g Create a cut from the last two markers and add it to the histogram.
/// - i Initialize a new cut.
/// - l/z Toggle z-axis from linear to logarithmic and vice versa.
/// - n Remove all markers / functions drawn on the histogram.
/// - o Unzoom the entire histogram.
/// - P Get projections from this histogram and draw the first one if it exists.
/// - r Expand the y-axis between the last two markers.
/// - R Bring up the dialogue box to set the desired y-axis range.
/// - s Save the cuts that have been created.
/// - x Create projection of the histogram onto the x-axis and draw in a new canvas.
/// - X Create "y summary" of the histogram, i.e. a projection of the first y-bin onto the x-axis that yields a non-empty histogram and draw it on a new canvas.
/// - y Create projection of the histogram onto the x-axis and draw in a new canvas.
/// - Y Create "x summary" of the histogram, i.e. a projection of the first x-bin onto the y-axis that yields a non-empty histogram and draw it on a new canvas.
///
///////////////////////////////////////////////////////////////////////////

class GCanvas : public TCanvas {
public:
GCanvas(Bool_t build = kTRUE);
Expand Down Expand Up @@ -190,5 +265,5 @@ class GCanvas : public TCanvas {

ClassDefOverride(GCanvas, 2);
};

/*! @} */
#endif
27 changes: 16 additions & 11 deletions libraries/GROOT/GCanvas.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ bool GCanvas::HandleMouseShiftPress(Int_t, Int_t, Int_t)
(static_cast<GH1D*>(hist))->GetParent()->Draw("colz");
return true;
}
std::vector<TH1*> hists = FindHists();
std::vector<TH1*> hists = FindHists(1);
new GCanvas();
// options.Append("HIST");
hists.at(0)->DrawCopy(options.Data());
Expand Down Expand Up @@ -571,27 +571,31 @@ TF1* GCanvas::GetLastFit()

bool GCanvas::Process1DArrowKeyPress(Event_t*, UInt_t* keysym)
{
/// Moves displayed 1D histograms by 50% of the visible range left, right, or selects the next (up) or previous (down) GH1D histogram.
bool edited = false;
std::vector<TH1*> hists = FindHists();
std::vector<TH1*> hists = FindHists(1);
if(hists.empty()) {
return edited;
}

// get first and last bin in current range
int first = hists.at(0)->GetXaxis()->GetFirst();
int last = hists.at(0)->GetXaxis()->GetLast();

// first is 1 if no range is defined but can be 0, last is fNbins if no range is defined but can be 0
// so min will always be 0, and max will always be fNbins+1
int min = std::min(first, 0);
int max = std::max(last, hists.at(0)->GetXaxis()->GetNbins() + 1);
// int max = std::max(last,axis->GetNbins()+1);

int xdiff = last - first;
int mdiff = max - min - 2;
int mdiff = max - min - 2; // this will always be fNbins-1

switch(*keysym) {
case kMyArrowLeft: {
if(mdiff > xdiff) {
// try and move left by half the current range
if(first == (min + 1)) {
//
// if first is 1 we can't go any further left
} else if((first - (xdiff / 2)) < min) {
first = min + 1;
last = min + (xdiff) + 1;
Expand All @@ -608,8 +612,9 @@ bool GCanvas::Process1DArrowKeyPress(Event_t*, UInt_t* keysym)
} break;
case kMyArrowRight: {
if(mdiff > xdiff) {
// try and move right by half the current range
if(last == (max - 1)) {
//
// last is fNbins so we can't move further right
} else if((last + (xdiff / 2)) > max) {
first = max - 1 - (xdiff);
last = max - 1;
Expand All @@ -635,10 +640,10 @@ bool GCanvas::Process1DArrowKeyPress(Event_t*, UInt_t* keysym)
}

if(ghist != nullptr) {
TH1* prev = ghist->GetNext();
if(prev != nullptr) {
prev->GetXaxis()->SetRange(first, last);
prev->Draw("");
TH1* next = ghist->GetNext();
if(next != nullptr) {
next->GetXaxis()->SetRange(first, last);
next->Draw("");
RedrawMarkers();
edited = true;
}
Expand Down Expand Up @@ -698,7 +703,7 @@ bool GCanvas::ProcessNonHistKeyboardPress(Event_t*, UInt_t* keysym)
bool GCanvas::Process1DKeyboardPress(Event_t*, UInt_t* keysym)
{
bool edited = false;
std::vector<TH1*> hists = FindHists();
std::vector<TH1*> hists = FindHists(1);
if(hists.empty()) {
return edited;
}
Expand Down

0 comments on commit 9509cca

Please sign in to comment.