Public Member Functions | Private Member Functions | Private Attributes | List of all members
ana::NuePlotStyle Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-12-01/3FlavorAna/Plotting/NuePlotStyle.h"

Public Member Functions

 NuePlotStyle (TString pid, bool third=false)
 
 ~NuePlotStyle ()
 
TCanvas * MakeSACanvas (std::vector< TH1 * > hists)
 
TCanvas * MakeSACanvas (TH1 *hist)
 

Private Member Functions

void CenterTitles (TH1 *hist)
 
void PIDTag ()
 
void PIDDivisions (bool shortaxis)
 
void PIDBinLabels (bool shortaxis)
 
void POTLabel (bool shortaxis)
 
void PID2DAxis (TH1 *hist, bool shortaxis)
 

Private Attributes

TString fPID
 
bool fThird
 

Detailed Description

Definition at line 13 of file NuePlotStyle.h.

Constructor & Destructor Documentation

ana::NuePlotStyle::NuePlotStyle ( TString  pid,
bool  third = false 
)

Definition at line 23 of file NuePlotStyle.cxx.

24  : fPID(pid), fThird(third)
25  {}
ana::NuePlotStyle::~NuePlotStyle ( )

Definition at line 28 of file NuePlotStyle.cxx.

29  {}

Member Function Documentation

void ana::NuePlotStyle::CenterTitles ( TH1 *  hist)
private

Definition at line 73 of file NuePlotStyle.cxx.

Referenced by MakeSACanvas(), ana::Nue2017FourBinAxis(), and ana::Nue2018ThreeBinAxis().

74  {
75  hist->GetXaxis()->CenterTitle();
76  hist->GetYaxis()->CenterTitle();
77  hist->GetZaxis()->CenterTitle();
78  }
TCanvas * ana::NuePlotStyle::MakeSACanvas ( std::vector< TH1 * >  hists)

Definition at line 32 of file NuePlotStyle.cxx.

References ana::assert(), allTimeWatchdog::can, CenterTitles(), PID2DAxis(), PIDBinLabels(), PIDDivisions(), and PIDTag().

Referenced by MakeSACanvas().

33  {
34  assert(hists.size() > 0 && "You must provide at least one histogram");
35  TCanvas* can = new TCanvas();
36  CenterTitles(hists[0]);
37  // for (int i = 0; i < (int)hists.size(); i++)
38  // hists[i]->Draw("same");
39  hists[0]->Draw("axis");
40  PIDTag();
41  PIDDivisions(false);
42  PIDBinLabels(false);
43  PID2DAxis(hists[0],false);
44  return can;
45  }
void PIDBinLabels(bool shortaxis)
TString hists[nhists]
Definition: bdt_com.C:3
void CenterTitles(TH1 *hist)
assert(nhit_max >=nhit_nbins)
void PID2DAxis(TH1 *hist, bool shortaxis)
void PIDDivisions(bool shortaxis)
TCanvas * ana::NuePlotStyle::MakeSACanvas ( TH1 *  hist)

Definition at line 48 of file NuePlotStyle.cxx.

References hists, and MakeSACanvas().

49  {
50  std::vector<TH1*> hists = {hist};
51  return MakeSACanvas(hists);
52  }
TString hists[nhists]
Definition: bdt_com.C:3
TCanvas * MakeSACanvas(std::vector< TH1 * > hists)
void ana::NuePlotStyle::PID2DAxis ( TH1 *  hist,
bool  shortaxis 
)
private

Definition at line 153 of file NuePlotStyle.cxx.

References visualisationForPaperMasterPlot::ax, fThird, gen_flatrecord::size, and ymin.

Referenced by MakeSACanvas(), and ana::PlotDataMC().

154  {
155  int xmax1 = (shortaxis) ? 5 : 8;
156  int xmax2 = (shortaxis) ? 11 : 18;
157  int xmax3 = (shortaxis) ? 17 : 30;
158  int xmin1 = (shortaxis) ? 1 : 0;
159  int xmin2 = (shortaxis) ? 7 : 10;
160  int xmin3 = (shortaxis) ? 13 : 20;
161  int gmin1 = (shortaxis) ? 1 : 0;
162  int gmax1 = (shortaxis) ? 3 : 4;
163  int gmax2 = (shortaxis) ? 3 : 5;
164 
165  double ymin = hist->GetMinimum();
166  // Paint our own x-axis fragments
167  TGaxis* gax1 = new TGaxis(xmin1, ymin, xmax1, ymin, gmin1, gmax1, gmax1, "");
168  TGaxis* gax2 = new TGaxis(xmin2, ymin, xmax2, ymin, gmin1, gmax1, gmax1, "");
169  TGaxis* gax3 = new TGaxis(xmin3, ymin, xmax3, ymin, gmin1, gmax2, gmax2, "");
170 
171  float size = 0.05;
172  float offs = hist->GetXaxis()->GetLabelOffset();
173  int font = hist->GetXaxis()->GetLabelFont();
174  // And then hide its title
175  hist->GetXaxis()->SetLabelSize(0);
176  hist->GetYaxis()->SetLabelSize(0.05);
177  // and make all the tick marks the same size
178  hist->GetXaxis()->SetNdivisions(1800);
179  hist->GetXaxis()->SetTitle("Reconstructed energy (GeV)");
180  hist->GetYaxis()->SetTitle("Events / 0.5 GeV");
181  hist->GetXaxis()->CenterTitle();
182  hist->GetYaxis()->CenterTitle();
183  hist->SetTitle("");
184 
185  if ( fThird ){
186  gax1->SetLabelSize(size);
187  gax1->SetLabelOffset(offs);
188  gax1->SetLabelFont(font);
189  gax1->Draw();
190  }
191  else
192  for(TGaxis* ax: {gax1, gax2, gax3}){
193  // Copy settings from pre-existing axis
194  ax->SetLabelSize(size);
195  ax->SetLabelOffset(offs);
196  ax->SetLabelFont(font);
197  ax->Draw();
198  }
199 
200  }
Double_t ymin
Definition: plot.C:24
void ana::NuePlotStyle::PIDBinLabels ( bool  shortaxis)
private

Definition at line 112 of file NuePlotStyle.cxx.

References ana::assert(), ana::bins, ana::Binning::Edges(), genie::utils::style::Format(), fPID, MECModelEnuComparisons::i, ana::kCVNNLBinning, ana::kLEMNLBinning, ana::kLIDNLBinning, BlessedPlots::pid, string, and submit_syst::y.

Referenced by MakeSACanvas(), and ana::PlotDataMC().

112  {
113  // Put the labels near the top of the plot
115  gPad->Update();
116  const double y = gPad->GetUymax() * .95;
117 
118  const ana::Binning* bins = 0;
119  if(fPID == "LID") bins = &ana::kLIDNLBinning;
120  if(fPID == "LEM") bins = &ana::kLEMNLBinning;
121  if(fPID == "CVN") bins = &ana::kCVNNLBinning;
122  assert(bins);
123 
124  int v1 = (shortaxis) ? 3 : 5;
125  int v2 = (shortaxis) ? 6 : 10;
126 
127  for(int i = 0; i < 3; ++i){
128  TLatex* ltx = new TLatex(v1+v2*i, y, TString::Format("%g < %s < %g",
129  bins->Edges()[i],
130  pid.c_str(),
131  bins->Edges()[i+1]));
132  ltx->SetTextSize(0.041);
133  ltx->SetTextColor(kBlack);
134  ltx->SetTextAlign(22);
135  ltx->Draw();
136  }
137  }
Represent the binning of a Spectrum&#39;s x-axis.
Definition: Binning.h:16
const Binning kCVNNLBinning
Definition: Binnings.cxx:20
const std::vector< double > & Edges() const
Definition: Binning.h:34
const Binning bins
Definition: NumuCC_CPiBin.h:8
const Binning kLIDNLBinning
Definition: Binnings.cxx:19
const Binning kLEMNLBinning
Definition: Binnings.cxx:18
assert(nhit_max >=nhit_nbins)
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
enum BeamMode string
void ana::NuePlotStyle::PIDDivisions ( bool  shortaxis)
private

Definition at line 93 of file NuePlotStyle.cxx.

References submit_hadd::l, and central_limit::l1.

Referenced by MakeSACanvas(), and ana::PlotDataMC().

93  {
94  // Separators between the different PID ranges
95  // TGraph not TLine because TGraph is properly clipped by frame
96  int div1 = (shortaxis) ? 6 : 10;
97  int div2 = (shortaxis) ? 12 : 20;
98 
99  TGraph* l1 = new TGraph;
100  l1->SetPoint(0, div1, 0);
101  l1->SetPoint(1, div1, 50000);
102  TGraph* l2 = new TGraph;
103  l2->SetPoint(0, div2, 0);
104  l2->SetPoint(1, div2, 50000);
105  for(TGraph* l: {l1, l2}){
106  l->SetLineWidth(1);
107  l->Draw("l same");
108  }
109  }
void ana::NuePlotStyle::PIDTag ( )
private

Definition at line 81 of file NuePlotStyle.cxx.

References fPID, and getGoodRuns4SAM::tag.

Referenced by MakeSACanvas().

82  {
83  TLatex* tag = new TLatex(.83, .92, fPID);
84  tag->SetTextColor(kGray+1);
85  tag->SetNDC();
86  tag->SetTextSize(0.038);
87  tag->SetTextFont(42);
88  tag->SetTextAlign(12);
89  tag->Draw();
90  }
void ana::NuePlotStyle::POTLabel ( bool  shortaxis)
private

Definition at line 140 of file NuePlotStyle.cxx.

References pot, and submit_syst::y.

140  {
141  // to do: pass a double and make label for that pot
142  int v1 = (shortaxis) ? 3 : 5;
143 
144  const double y = gPad->GetUymax() * .84;
145 
146  TLatex* pot = new TLatex(v1/2.5,y,"3.72#times10^{20} POT");
147  pot->SetTextSize(0.04);
148  pot->SetTextAlign(12);
149  pot->Draw();
150  }
#define pot

Member Data Documentation

TString ana::NuePlotStyle::fPID
private

Definition at line 30 of file NuePlotStyle.h.

Referenced by PIDBinLabels(), and PIDTag().

bool ana::NuePlotStyle::fThird
private

Definition at line 31 of file NuePlotStyle.h.

Referenced by PID2DAxis().


The documentation for this class was generated from the following files: