40using std::cout, std::endl, std::string;
72 coutW(Plotting) <<
"Empty sampling distribution given to plot. Skipping." << endl;
92 coutW(Plotting) <<
"Could not determine xmin and xmax of sampling distribution that was given to plot." << endl;
101 double xlow =
xmin - 1.5*binWidth;
102 double xup =
xmax + 1.5*binWidth;
114 for (
int w_idx = 0; valuesIt !=
fSamplingDistr.end(); ++valuesIt, ++w_idx) {
121 double weightSum = 1.0;
153 coutW(Plotting) <<
"Empty sampling distribution given to plot. Skipping." << endl;
163 for (
int i=0; i<shaded->
GetNbinsX(); ++i) {
197 TH1 * hcopy =
static_cast<TH1*
>(
h->Clone());
231 std::cerr <<
fName <<
"::addObject: called with a null pointer" << std::endl;
249 coutE(InputArguments) <<
fName <<
"::addOtherObject: called with a null pointer" << std::endl;
268 double theYMin(std::numeric_limits<float>::quiet_NaN());
287 coutE(InputArguments) <<
"invalid variable to plot" << std::endl;
300 for(
auto * obj : static_range_cast<TH1F*>(
fItems)) {
303 TH1 * cloneObj =
static_cast<TH1*
>(obj->Clone());
325 if(!
fApplyStyle)
coutW(Plotting) <<
"gStyle will be changed to adjust SetOptLogx(...)" << endl;
329 if(!
fApplyStyle)
coutW(Plotting) <<
"gStyle will be changed to adjust SetOptLogy(...)" << endl;
375 for(
auto * obj : static_range_cast<TH1F*>(
fItems)) {
376 if(obj->GetXaxis()->GetXmin() < tmpmin) tmpmin = obj->GetXaxis()->GetXmin();
377 if(obj->GetXaxis()->GetXmax() > tmpmax) tmpmax = obj->GetXaxis()->GetXmax();
378 if(obj->GetMaximum() > tmpYmax) tmpYmax = obj->GetMaximum() + 0.1*obj->GetMaximum();
393 if (samplDist ==
nullptr) {
397 shadedName +=
"_shaded";
399 for(
auto * obj : static_range_cast<TH1F*>(
fItems)) {
400 if (!strcmp(obj->GetName(), shadedName.
Data())) {
401 obj->SetLineColor(color);
402 obj->SetFillColor(color);
409 shadedName +=
"_shaded";
411 for(
auto * obj : static_range_cast<TH1F*>(
fItems)) {
412 if (!strcmp(obj->GetName(), samplDist->
GetName())) {
413 obj->SetLineColor(color);
416 if (!strcmp(obj->GetName(), shadedName.
Data())) {
417 obj->SetLineColor(color);
418 obj->SetFillColor(color);
431 if(samplDist ==
nullptr){
435 for(
auto * obj : static_range_cast<TH1F*>(
fItems)) {
436 if(!strcmp(obj->GetName(),samplDist->
GetName())){
437 obj->SetLineWidth(lwidth);
450 if(samplDist ==
nullptr){
454 for(
auto * obj : static_range_cast<TH1F*>(
fItems)) {
455 if(!strcmp(obj->GetName(),samplDist->
GetName())){
456 obj->SetLineStyle(
style);
469 if(samplDist ==
nullptr){
473 for(
auto * obj : static_range_cast<TH1F*>(
fItems)) {
474 if(!strcmp(obj->GetName(),samplDist->
GetName())){
475 obj->SetMarkerStyle(
style);
488 if(samplDist ==
nullptr){
492 for(
auto * obj : static_range_cast<TH1F*>(
fItems)) {
493 if(!strcmp(obj->GetName(),samplDist->
GetName())){
494 obj->SetMarkerColor(color);
507 if(samplDist ==
nullptr){
511 for(
auto * obj : static_range_cast<TH1F*>(
fItems)) {
512 if(!strcmp(obj->GetName(),samplDist->
GetName())){
513 obj->SetMarkerSize(
size);
526 if(samplDist ==
nullptr){
529 for(
auto * obj : static_range_cast<TH1F*>(
fItems)) {
530 if(!strcmp(obj->GetName(),samplDist->
GetName())){
543 if(samplDist ==
nullptr){
547 for(
auto * obj : static_range_cast<TH1F*>(
fItems)) {
548 if(!strcmp(obj->GetName(),samplDist->
GetName())){
549 obj->
Rebin(rebinFactor);
565 cout <<
"Plot was not drawn yet. Dump can only be saved after it was drawn with Draw()." << endl;
569 TFile ofile(RootFileName,
option, ftitle, compress);
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char y1
R__EXTERN TStyle * gStyle
RooPlot * frame(const RooCmdArg &arg1, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}, const RooCmdArg &arg6={}, const RooCmdArg &arg7={}, const RooCmdArg &arg8={}) const
Create a new RooPlot on the heap with a drawing frame initialized for this object,...
void SetTitle(const char *name) override
Set the title of the RooPlot to 'title'.
void addObject(TObject *obj, Option_t *drawOptions="", bool invisible=false)
Add a generic object to this plot.
void addTH1(TH1 *hist, Option_t *drawOptions="", bool invisible=false)
Add a TH1 histogram object to this plot.
virtual void SetMinimum(double minimum=-1111)
Set minimum value of Y axis.
static bool addDirectoryStatus()
Query whether new instances of RooPlot will add themselves to gDirectory.
virtual void SetMaximum(double maximum=-1111)
Set maximum value of Y axis.
void Draw(Option_t *options=nullptr) override
Draw this plot and all of the elements it contains.
static bool setAddDirectoryStatus(bool flag)
Configure whether new instances of RooPlot will add themselves to gDirectory.
Variable that can be changed from the outside.
This class provides simple and straightforward utilities to plot SamplingDistribution objects.
void SetSampleWeights(const SamplingDistribution *samplingDist)
Determine if the sampling distribution has weights and store them.
TList fItems
holds TH1Fs only
void DumpToFile(const char *RootFileName, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault)
write to Root file
void RebinDistribution(Int_t rebinFactor, const SamplingDistribution *samplDist=nullptr)
~SamplingDistPlot() override
Destructor of SamplingDistribution.
void Draw(Option_t *options=nullptr) override
Draw this plot and all of the elements it contains.
void GetAbsoluteInterval(double &theMin, double &theMax, double &theYMax) const
void SetLineWidth(Width_t lwidth, const SamplingDistribution *samplDist=nullptr)
void SetLineStyle(Style_t style, const SamplingDistribution *samplDist=nullptr)
double AddSamplingDistributionShaded(const SamplingDistribution *samplingDist, double minShaded, double maxShaded, Option_t *drawOptions="NORMALIZE HIST")
Like AddSamplingDistribution, but also sets a shaded area in the minShaded and maxShaded boundaries.
void SetMarkerColor(Color_t color, const SamplingDistribution *samplDist=nullptr)
std::vector< double > fSampleWeights
void AddLine(double x1, double y1, double x2, double y2, const char *title=nullptr)
add a line
void SetLineColor(Color_t color, const SamplingDistribution *samplDist=nullptr)
Sets line color for given sampling distribution and fill color for the associated shaded TH1F.
void ApplyDefaultStyle(void)
Applies a predefined style if fApplyStyle is true (default).
void AddTH1(TH1 *h, Option_t *drawOptions="")
add a TH1
std::vector< double > fSamplingDistr
void AddTF1(TF1 *f, const char *title=nullptr, Option_t *drawOptions="SAME")
add a TF1
double AddSamplingDistribution(const SamplingDistribution *samplingDist, Option_t *drawOptions="NORMALIZE HIST")
adds the sampling distribution and returns the scale factor
void addOtherObject(TObject *obj, Option_t *drawOptions=nullptr)
Add a generic object to this plot.
void addObject(TObject *obj, Option_t *drawOptions=nullptr)
Add a generic object to this plot.
void SetMarkerSize(Size_t size, const SamplingDistribution *samplDist=nullptr)
TH1F * GetTH1F(const SamplingDistribution *samplDist=nullptr)
Returns the TH1F associated with the give SamplingDistribution.
SamplingDistPlot(Int_t nbins=100)
Constructors for SamplingDistribution.
void SetXRange(double mi, double ma)
change x range
void SetMarkerStyle(Style_t style, const SamplingDistribution *samplDist=nullptr)
TList fOtherItems
other objects to be drawn like TLine etc.
This class simply holds a sampling distribution of some test statistic.
const std::vector< double > & GetSampleWeights() const
Get the sampling weights.
const TString GetVarName() const
const std::vector< double > & GetSamplingDistribution() const
Get test statistics values.
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
Bool_t cd() override
Change current directory to "this" directory.
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
void Close(Option_t *option="") override
Close a file.
1-D histogram with a float per channel (see TH1 documentation)
TH1 is the base class of all histogram classes in ROOT.
virtual void SetDirectory(TDirectory *dir)
By default, when a histogram is created, it is added to the list of histogram objects in the current ...
virtual Double_t GetBinCenter(Int_t bin) const
Return bin center for 1D histogram.
Option_t * GetOption() const override
virtual Int_t GetNbinsX() const
virtual void SetMaximum(Double_t maximum=-1111)
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
virtual void SetMinimum(Double_t minimum=-1111)
virtual Double_t Integral(Option_t *option="") const
Return integral of bin contents.
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content see convention for numbering bins in TH1::GetBin In case the bin number is greater th...
virtual TH1 * Rebin(Int_t ngroup=2, const char *newname="", const Double_t *xbins=nullptr)
Rebin this histogram.
virtual void Scale(Double_t c1=1, Option_t *option="")
Multiply this histogram by a constant c1.
TObject * Clone(const char *newname="") const override
Make a complete copy of the underlying object.
virtual void Sumw2(Bool_t flag=kTRUE)
Create structure to store sum of squares of weights.
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
TLegendEntry * AddEntry(const TObject *obj, const char *label="", Option_t *option="lpf")
Add a new entry to this legend.
Use the TLine constructor to create a simple line.
void Add(TObject *obj) override
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
Mother of all ROOT objects.
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
virtual Option_t * GetOption() const
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
virtual const char * GetTitle() const
Returns title of object.
virtual void SetBorderSize(Int_t bordersize=4)
Sets the border size of the TPave box and shadow.
TSubString Strip(EStripType s=kTrailing, char c=' ') const
Return a substring of self stripped at beginning and/or end.
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
void ToUpper()
Change string to upper case.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
void SetPadBorderMode(Int_t mode=1)
void SetOptLogx(Int_t logx=1)
void SetCanvasColor(Color_t color=19)
void SetCanvasBorderMode(Int_t mode=1)
void SetFrameFillStyle(Style_t styl=0)
void SetFrameBorderMode(Int_t mode=1)
void SetOptLogy(Int_t logy=1)
void SetPaperSize(EPaperSize size)
Set paper size for PostScript output.
void SetStatColor(Color_t color=19)
void SetPadColor(Color_t color=19)
Namespace for the RooStats classes.
Double_t Infinity()
Returns an infinity as defined by the IEEE standard.