Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
91 changes: 45 additions & 46 deletions graf2d/gpad/inc/TRatioPlot.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,22 @@
// //
//////////////////////////////////////////////////////////////////////////

#include "TH1.h"
#include "TPad.h"
#include "TGraphAsymmErrors.h"
#include "TGraphErrors.h"
#include "TGraph.h"
#include "TAxis.h"
#include "TGaxis.h"
#include "TH1F.h"
#include "TFitResultPtr.h"
#include "THStack.h"

class TObject;
class TH1;
class TPad;
class TGraphAsymmErrors;
class TGraphErrors;
class TGraph;
class TAxis;
class TGaxis;
class TLine;
class TFitResultPtr;
class TFitResult;
class THStack;
class TBrowser;
class TFileMergeInfo;

class TRatioPlot : public TPad {
class TRatioPlot : public TObject {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you inherit from TObject (and you should) then we need to #include TObject.h. If you source file starts with #include "TRatioPlot.h" then it should have told you - which is why that should be the first #include :-)


private:
TRatioPlot& operator=(const TRatioPlot&); // Not implemented
Expand Down Expand Up @@ -135,59 +136,60 @@ class TRatioPlot : public TPad {
virtual void SetupPads();
virtual void CreateVisualAxes();
virtual Bool_t SyncPadMargins();
virtual void SetPadMargins();
virtual void CreateGridline();
void SetPadMargins();
void CreateGridline();

virtual void ImportAxisAttributes(TGaxis* gaxis, TAxis* axis);
void ImportAxisAttributes(TGaxis* gaxis, TAxis* axis);

virtual Bool_t IsDrawn();
Bool_t IsDrawn();

virtual void Init(TH1* h1, TH1* h2, Option_t *option = "", Option_t *h1DrawOpt = "hist", Option_t *h2DrawOpt = "E", Option_t *graphDrawOpt = "AP");
virtual void Init(TH1* h1, TH1* h2, Option_t *option = "");

public:

TRatioPlot();
virtual ~TRatioPlot();
TRatioPlot(TH1* h1, TH1* h2, Option_t *option = "pois", Option_t *h1DrawOpt = "hist", Option_t *h2DrawOpt = "E", Option_t *graphDrawOpt = "AP", const char *name = "RatioPlot", const char *title = "RatioPlot", Double_t xlow = 0, Double_t ylow = 0, Double_t xup = 1, Double_t yup = 1);

TRatioPlot(THStack* st, TH1* h2, Option_t *option = "pois", Option_t *h1DrawOpt = "hist", Option_t *h2DrawOpt = "E", Option_t *graphDrawOpt = "AP", const char *name = "RatioPlot", const char *title = "RatioPlot", Double_t xlow = 0, Double_t ylow = 0, Double_t xup = 1, Double_t yup = 1);
TRatioPlot(TH1* h1, TH1* h2, Option_t *option = "pois");

TRatioPlot(TH1* h1, Option_t *option = "", Option_t *h1DrawOpt = "", Option_t *graphDrawOpt = "LX", TFitResult *fitres = 0, const char *name = "RatioPlot", const char *title = "RatioPlot", Double_t xlow = 0, Double_t ylow = 0, Double_t xup = 1, Double_t yup = 1);
TRatioPlot(THStack* st, TH1* h2, Option_t *option = "pois");

TRatioPlot(TH1* h1, Option_t *option = "", TFitResult *fitres = 0);

void SetH1DrawOpt(Option_t *opt);
void SetH2DrawOpt(Option_t *opt);
void SetGraphDrawOpt(Option_t *opt);

virtual void Draw(Option_t *chopt="");
virtual void Browse(TBrowser *b);

virtual void BuildLowerPlot();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Is this a function that users should be able to call?
  2. It's marked virtual, so I should be able to re-implement it in a derived class. But that derived class cannot access the private data members - so how can that derived class's reimplementation do anything useful? Maybe mark non-virtual; or make this return a TGraph* (or a TObject*?), or make the data members protected.


virtual void Paint(Option_t *opt = "");
virtual void PaintModified();

// Slots for signal receiving
virtual void UnZoomed();
virtual void RangeAxisChanged();
virtual void SubPadResized();
void UnZoomed();
void RangeAxisChanged();
void SubPadResized();

// Getters
virtual TAxis *GetXaxis() { return fSharedXAxis; }
virtual TAxis *GetUpYaxis() { return fUpYaxis; }
virtual TAxis *GetLowYaxis() { return fLowYaxis; }
TAxis *GetXaxis() { return fSharedXAxis; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These functions should be const - please check the other functions, too...

TAxis *GetUpYaxis() { return fUpYaxis; }
TAxis *GetLowYaxis() { return fLowYaxis; }

virtual TGraph *GetLowerRefGraph();
virtual TAxis *GetLowerRefXaxis();
virtual TAxis *GetLowerRefYaxis();
TAxis *GetLowerRefXaxis();
TAxis *GetLowerRefYaxis();

virtual TObject *GetUpperRefObject();
virtual TAxis *GetUpperRefXaxis();
virtual TAxis *GetUpperRefYaxis();
TAxis *GetUpperRefXaxis();
TAxis *GetUpperRefYaxis();

virtual TPad * GetUpperPad() { return fUpperPad; }
virtual TPad * GetLowerPad() { return fLowerPad; }
TPad * GetUpperPad() { return fUpperPad; }
TPad * GetLowerPad() { return fLowerPad; }

// Setters
virtual void SetFitResult(TFitResultPtr fitres);
virtual void SetFitResult(TFitResult *fitres);
void SetFitResult(TFitResultPtr fitres);
void SetFitResult(TFitResult *fitres);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can already construct an TFileResultPtr from a TFitResult*, do we really need this overload?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found it unintuitive to use TFitResultPtr, and I cannot just use TFitResult* since TFitResultPtr does not convert to TFitResult* automatically.


// Setters for margins
void SetUpTopMargin(Float_t margin);
Expand All @@ -197,21 +199,18 @@ class TRatioPlot : public TPad {
void SetLeftMargin(Float_t margin);
void SetRightMargin(Float_t margin);

virtual void SetSeparationMargin(Float_t);
virtual Float_t GetSeparationMargin();
virtual void SetSplitFraction(Float_t sf);
virtual void SetConfidenceLevels(Double_t cl1, Double_t cl2);

virtual void SetLogx(Int_t value = 1); // *TOGGLE*
virtual void SetLogy(Int_t value = 1); // *TOGGLE*
void SetSeparationMargin(Float_t);
Float_t GetSeparationMargin();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be const?

void SetSplitFraction(Float_t sf);
void SetConfidenceLevels(Double_t cl1, Double_t cl2);

virtual void SetGridlines(Double_t *gridlines, Int_t numGridlines);
virtual void SetGridlines(std::vector<double> gridlines);

virtual void SetConfidenceIntervalColors(Color_t ci1 = kGreen, Color_t ci2 = kYellow);
void SetConfidenceIntervalColors(Color_t ci1 = kGreen, Color_t ci2 = kYellow);

virtual void SetC1(Double_t c1) { fC1 = c1; }
virtual void SetC2(Double_t c2) { fC2 = c2; }
void SetC1(Double_t c1) { fC1 = c1; }
void SetC2(Double_t c2) { fC2 = c2; }

ClassDef(TRatioPlot, 1) //A ratio of histograms
};
Expand Down
Loading