GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
GCanvas Class Reference

Detailed Description

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/u 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/u 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.

Definition at line 238 of file GCanvas.h.

Public Member Functions

 GCanvas (Bool_t build=kTRUE)
 
 GCanvas (const char *name, const char *title, Int_t winw, Int_t winh)
 
 GCanvas (const char *name, const char *title, Int_t wtopx, Int_t wtopy, Int_t winw, Int_t winh, bool gui=false)
 
 GCanvas (const char *name, const char *title="", Int_t form=1)
 
 GCanvas (const char *name, Int_t winw, Int_t winh, Int_t winid)
 
 GCanvas (const GCanvas &)=delete
 
 GCanvas (GCanvas &&) noexcept=delete
 
 ~GCanvas ()
 
void Draw (Option_t *opt="") override
 
Int_t GetNMarkers ()
 
bool HandleArrowKeyPress (Event_t *event, const UInt_t *keysym)
 
void HandleInput (int event, Int_t x, Int_t y)
 
bool HandleKeyboardPress (Event_t *event, const UInt_t *keysym)
 
bool HandleMouseControlPress (Int_t event, Int_t x, Int_t y)
 
bool HandleMousePress (Int_t event, Int_t x, Int_t y)
 
bool HandleMouseShiftPress (Int_t event, Int_t x, Int_t y)
 
bool HandleWheel (Int_t event, Int_t x, Int_t y)
 
GCanvasoperator= (const GCanvas &)=delete
 
GCanvasoperator= (GCanvas &&) noexcept=delete
 
void SetMarkerMode (bool flag=true)
 
bool StorePosition (Int_t event, Int_t x, Int_t y)
 
bool Zoom (Int_t event, Int_t x, Int_t y)
 

Static Public Member Functions

static TF1 * GetLastFit ()
 
static GCanvasMakeDefCanvas ()
 

Private Member Functions

void AddMarker (int, int, TH1 *hist)
 
bool CycleBackgroundSubtraction ()
 
void GCanvasInit ()
 
void OrderMarkers ()
 
bool Process1DArrowKeyPress (Event_t *event, const UInt_t *keysym)
 
bool Process1DKeyboardPress (Event_t *event, const UInt_t *keysym)
 
bool Process1DMousePress (Int_t event, Int_t x, Int_t y)
 
bool Process2DArrowKeyPress (Event_t *event, const UInt_t *keysym)
 
bool Process2DKeyboardPress (Event_t *event, const UInt_t *keysym)
 
bool Process2DMousePress (Int_t event, Int_t x, Int_t y)
 
bool ProcessNonHistKeyboardPress (Event_t *event, const UInt_t *keysym)
 
void RedrawMarkers ()
 
void RemoveMarker (Option_t *opt="")
 
bool SetBackgroundMarkers ()
 
void UpdateStatsInfo (int, int)
 

Static Private Member Functions

static std::vector< TH1 * > FindAllHists ()
 
static std::vector< TH1 * > FindHists (int dim=1)
 

Private Attributes

std::vector< GMarker * > fBackgroundMarkers
 
EBackgroundSubtraction fBackgroundMode = EBackgroundSubtraction::kNoBackground
 
char * fCutName {nullptr}
 
std::vector< TCutG * > fCuts
 
bool fGuiEnabled {false}
 
bool fMarkerMode {false}
 
std::vector< GMarker * > fMarkers
 
TRootCanvas * fRootCanvas {nullptr}
 

Static Private Attributes

static double fLastX = 0
 
static double fLastY = 0
 
+ Inheritance diagram for GCanvas:
+ Collaboration diagram for GCanvas:

Constructor & Destructor Documentation

◆ GCanvas() [1/7]

GCanvas::GCanvas ( Bool_t build = kTRUE)
explicit

Definition at line 86 of file GCanvas.cxx.

References GCanvasInit().

Referenced by HandleMouseShiftPress(), MakeDefCanvas(), and Process2DKeyboardPress().

◆ GCanvas() [2/7]

GCanvas::GCanvas ( const char * name,
const char * title = "",
Int_t form = 1 )
explicit

Definition at line 91 of file GCanvas.cxx.

References GCanvasInit().

◆ GCanvas() [3/7]

GCanvas::GCanvas ( const char * name,
const char * title,
Int_t winw,
Int_t winh )

Definition at line 96 of file GCanvas.cxx.

References GCanvasInit().

◆ GCanvas() [4/7]

GCanvas::GCanvas ( const char * name,
Int_t winw,
Int_t winh,
Int_t winid )

Definition at line 101 of file GCanvas.cxx.

References fGuiEnabled, and GCanvasInit().

◆ GCanvas() [5/7]

GCanvas::GCanvas ( const char * name,
const char * title,
Int_t wtopx,
Int_t wtopy,
Int_t winw,
Int_t winh,
bool gui = false )

Definition at line 109 of file GCanvas.cxx.

References fGuiEnabled, and GCanvasInit().

◆ GCanvas() [6/7]

GCanvas::GCanvas ( const GCanvas & )
delete

◆ GCanvas() [7/7]

GCanvas::GCanvas ( GCanvas && )
deletenoexcept

◆ ~GCanvas()

GCanvas::~GCanvas ( )

Definition at line 116 of file GCanvas.cxx.

References fCutName.

Member Function Documentation

◆ AddMarker()

void GCanvas::AddMarker ( int x,
int y,
TH1 * hist )
private

Definition at line 137 of file GCanvas.cxx.

References fMarkers, and hist.

Referenced by HandleMousePress().

◆ CycleBackgroundSubtraction()

bool GCanvas::CycleBackgroundSubtraction ( )
private

◆ Draw()

void GCanvas::Draw ( Option_t * opt = "")
override

Definition at line 312 of file GCanvas.cxx.

Referenced by Process1DKeyboardPress().

◆ FindAllHists()

std::vector< TH1 * > GCanvas::FindAllHists ( )
staticprivate

Definition at line 336 of file GCanvas.cxx.

Referenced by HandleMousePress().

◆ FindHists()

std::vector< TH1 * > GCanvas::FindHists ( int dim = 1)
staticprivate

Definition at line 321 of file GCanvas.cxx.

References hist.

Referenced by HandleMouseShiftPress(), Process1DKeyboardPress(), and Process2DKeyboardPress().

◆ GCanvasInit()

void GCanvas::GCanvasInit ( )
private

Definition at line 122 of file GCanvas.cxx.

References fBackgroundMode, fCutName, fGuiEnabled, fMarkerMode, and kNoBackground.

Referenced by GCanvas(), GCanvas(), GCanvas(), GCanvas(), and GCanvas().

◆ GetLastFit()

TF1 * GCanvas::GetLastFit ( )
static

Definition at line 549 of file GCanvas.cxx.

References hist.

◆ GetNMarkers()

Int_t GCanvas::GetNMarkers ( )
inline

Definition at line 259 of file GCanvas.h.

References fMarkers.

Referenced by Process1DKeyboardPress(), Process2DKeyboardPress(), and SetBackgroundMarkers().

◆ HandleArrowKeyPress()

bool GCanvas::HandleArrowKeyPress ( Event_t * event,
const UInt_t * keysym )

Definition at line 348 of file GCanvas.cxx.

References Process1DArrowKeyPress(), and Process2DArrowKeyPress().

Referenced by GRootCanvas::HandleContainerKey().

◆ HandleInput()

void GCanvas::HandleInput ( int event,
Int_t x,
Int_t y )

◆ HandleKeyboardPress()

bool GCanvas::HandleKeyboardPress ( Event_t * event,
const UInt_t * keysym )

◆ HandleMouseControlPress()

bool GCanvas::HandleMouseControlPress ( Int_t event,
Int_t x,
Int_t y )

Definition at line 462 of file GCanvas.cxx.

Referenced by HandleInput().

◆ HandleMousePress()

bool GCanvas::HandleMousePress ( Int_t event,
Int_t x,
Int_t y )

Definition at line 382 of file GCanvas.cxx.

References AddMarker(), FindAllHists(), fMarkerMode, and hist.

Referenced by HandleInput().

◆ HandleMouseShiftPress()

bool GCanvas::HandleMouseShiftPress ( Int_t event,
Int_t x,
Int_t y )

Definition at line 422 of file GCanvas.cxx.

References GCanvas(), FindHists(), and hist.

Referenced by HandleInput().

◆ HandleWheel()

bool GCanvas::HandleWheel ( Int_t event,
Int_t x,
Int_t y )

Zoom in (wheel up) and out (wheel down) of level scheme, focused around x, y. Does nothing if the canvas doesn't have the name "LevelScheme".

Definition at line 504 of file GCanvas.cxx.

Referenced by HandleInput().

◆ MakeDefCanvas()

GCanvas * GCanvas::MakeDefCanvas ( )
static

Definition at line 258 of file GCanvas.cxx.

References GCanvas().

◆ operator=() [1/2]

GCanvas & GCanvas::operator= ( const GCanvas & )
delete

◆ operator=() [2/2]

GCanvas & GCanvas::operator= ( GCanvas && )
deletenoexcept

◆ OrderMarkers()

void GCanvas::OrderMarkers ( )
private

Definition at line 172 of file GCanvas.cxx.

References fMarkers.

◆ Process1DArrowKeyPress()

bool GCanvas::Process1DArrowKeyPress ( Event_t * event,
const UInt_t * keysym )
private

Moves displayed 1D histograms by 50% of the visible range left, right, or selects the next (up) or previous (down) GH1D histogram.

Definition at line 568 of file GCanvas.cxx.

References Move1DHistogram(), and RedrawMarkers().

Referenced by HandleArrowKeyPress().

◆ Process1DKeyboardPress()

◆ Process1DMousePress()

bool GCanvas::Process1DMousePress ( Int_t event,
Int_t x,
Int_t y )
private

Definition at line 992 of file GCanvas.cxx.

◆ Process2DArrowKeyPress()

bool GCanvas::Process2DArrowKeyPress ( Event_t * event,
const UInt_t * keysym )
private

Moves displayed 2D histograms by 50% of the visible range left, right, up, or down

Definition at line 998 of file GCanvas.cxx.

References Move2DHistogram().

Referenced by HandleArrowKeyPress().

◆ Process2DKeyboardPress()

◆ Process2DMousePress()

bool GCanvas::Process2DMousePress ( Int_t event,
Int_t x,
Int_t y )
private

Definition at line 1356 of file GCanvas.cxx.

◆ ProcessNonHistKeyboardPress()

bool GCanvas::ProcessNonHistKeyboardPress ( Event_t * event,
const UInt_t * keysym )
private

Definition at line 576 of file GCanvas.cxx.

Referenced by HandleKeyboardPress().

◆ RedrawMarkers()

void GCanvas::RedrawMarkers ( )
private

Definition at line 177 of file GCanvas.cxx.

References fBackgroundMarkers, and fMarkers.

Referenced by Process1DArrowKeyPress().

◆ RemoveMarker()

void GCanvas::RemoveMarker ( Option_t * opt = "")
private

Definition at line 150 of file GCanvas.cxx.

References fBackgroundMarkers, and fMarkers.

Referenced by Process1DKeyboardPress(), and Process2DKeyboardPress().

◆ SetBackgroundMarkers()

bool GCanvas::SetBackgroundMarkers ( )
private

◆ SetMarkerMode()

void GCanvas::SetMarkerMode ( bool flag = true)
inline

Definition at line 260 of file GCanvas.h.

References fMarkerMode.

Referenced by Process1DKeyboardPress().

◆ StorePosition()

bool GCanvas::StorePosition ( Int_t event,
Int_t x,
Int_t y )

Store the position the mouse button was pressed at.

Definition at line 475 of file GCanvas.cxx.

References fLastX, and fLastY.

Referenced by HandleInput().

◆ UpdateStatsInfo()

void GCanvas::UpdateStatsInfo ( int ,
int  )
private

◆ Zoom()

bool GCanvas::Zoom ( Int_t event,
Int_t x,
Int_t y )

Mouse button was released at this point, set the new range.

Definition at line 486 of file GCanvas.cxx.

References fLastX, and fLastY.

Referenced by HandleInput().

Member Data Documentation

◆ fBackgroundMarkers

std::vector<GMarker*> GCanvas::fBackgroundMarkers
private

◆ fBackgroundMode

◆ fCutName

char* GCanvas::fCutName {nullptr}
private

Definition at line 279 of file GCanvas.h.

Referenced by ~GCanvas(), GCanvasInit(), and Process2DKeyboardPress().

◆ fCuts

std::vector<TCutG*> GCanvas::fCuts
private

Definition at line 278 of file GCanvas.h.

Referenced by Process2DKeyboardPress().

◆ fGuiEnabled

bool GCanvas::fGuiEnabled {false}
private

Definition at line 272 of file GCanvas.h.

Referenced by GCanvas(), GCanvas(), and GCanvasInit().

◆ fLastX

double GCanvas::fLastX = 0
staticprivate

Definition at line 269 of file GCanvas.h.

Referenced by StorePosition(), and Zoom().

◆ fLastY

double GCanvas::fLastY = 0
staticprivate

Definition at line 270 of file GCanvas.h.

Referenced by StorePosition(), and Zoom().

◆ fMarkerMode

bool GCanvas::fMarkerMode {false}
private

Definition at line 274 of file GCanvas.h.

Referenced by GCanvasInit(), HandleMousePress(), and SetMarkerMode().

◆ fMarkers

std::vector<GMarker*> GCanvas::fMarkers
private

◆ fRootCanvas

TRootCanvas* GCanvas::fRootCanvas {nullptr}
private

Definition at line 310 of file GCanvas.h.