Functions | Variables
tools.h File Reference

Go to the source code of this file.

Functions

void SetColors ()
 
void Simulation ()
 
void Preliminary ()
 
void NumuOnly ()
 
void JointAnalysis ()
 
TGraph * graphAsymmError (TH1 *hDataScaled, TH1 *hData)
 
TH1 * PlotSystShifts (const SystShifts &shifts)
 
void drawLabel (int quantId=0)
 
void drawLabelUnosc (int quantId=0)
 
void drawLabelRatio (int quantId=0)
 
void DrawLeftArrow (int color, float x, float dx, float ymin, float ymax)
 
void DrawRightArrow (int color, float x, float dx, float ymin, float ymax)
 
void DrawLegendBF (double bfSin, double bfDm, Color_t color, Style_t style)
 
void DrawLegendBF2 (double bfSin, double bfDm, Color_t color, Style_t style, double bfSin2, double bfDm2, Color_t color2, Style_t style2)
 
void drawBFMirror (double bfSin, double bfDm, Color_t color, Style_t style=kFullCircle)
 

Variables

int colors [6]
 

Function Documentation

void drawBFMirror ( double  bfSin,
double  bfDm,
Color_t  color,
Style_t  style = kFullCircle 
)

Definition at line 342 of file tools.h.

Referenced by plotContProf().

343 {
344 
345  double mirror = bfSin;
346  TMarker* manMarker = new TMarker(bfSin, bfDm, style);
347  manMarker->SetMarkerSize(1.5);
348  manMarker->SetMarkerColor(color);
349  manMarker->Draw();
350 
351  // uncomment to draw two best fits
352  /*
353  if(bfSin > 0.514) mirror = 0.514 - (bfSin - 0.514);
354  if(bfSin < 0.514) mirror = 0.514 + (0.514 - bfSin );
355  TMarker* mirrorMarker = new TMarker(mirror, bfDm, style);
356  mirrorMarker->SetMarkerSize(1.5);
357  mirrorMarker->SetMarkerColor(color);
358  mirrorMarker->Draw();
359  */
360 }
void drawLabel ( int  quantId = 0)

Definition at line 132 of file tools.h.

References genie::utils::style::Format().

Referenced by plotDataPred().

132  {
133 
134  TPaveText *pText = new TPaveText(0.12, 0.58, 0.42, 0.85, "NDC");
135  pText->SetBorderSize(0);
136  pText->SetFillStyle(0);
137 
138  TText *text1 = pText->AddText("#splitline{NOvA Normal Hierarchy}{8.85#times10^{20} POT-equiv.}");
139  TText *text2 = pText->AddText(" ");
140  TText *text3 = pText->AddText(" ");
141  text1->SetTextAlign(11);
142  text1->SetTextSize(0.04);
143 
144  if(quantId == 0){
145  TText *text4 = pText->AddText("All Quantiles");
146  text4->SetTextAlign(11);
147  text4->SetTextSize(0.05);
148  }
149  else if(quantId == 1){
150  TText *text4 = pText->AddText(TString::Format("Quantile %d", quantId));
151  text4->SetTextAlign(11);
152  text4->SetTextSize(0.05);
153  TText *text5 = pText->AddText("best resolution");
154  text5->SetTextAlign(11);
155  text5->SetTextSize(0.04);
156  }
157  else if(quantId == 4){
158  TText *text4 = pText->AddText(TString::Format("Quantile %d", quantId));
159  text4->SetTextAlign(11);
160  text4->SetTextSize(0.05);
161  TText *text5 = pText->AddText("worst resolution");
162  text5->SetTextAlign(11);
163  text5->SetTextSize(0.04);
164  }
165  else{
166  TText *text4 = pText->AddText(TString::Format("Quantile %d", quantId));
167  text4->SetTextAlign(11);
168  text4->SetTextSize(0.05);
169  }
170 
171  pText->Draw();
172 
173 
174 }
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
void drawLabelRatio ( int  quantId = 0)

Definition at line 223 of file tools.h.

References genie::utils::style::Format(), and MakeMiniprodValidationCuts::text.

Referenced by plotDataPred().

223  {
224 
225  TPaveText *pText = new TPaveText(0.15, 0.58, 0.45, 0.85, "NDC");
226  TText *text = pText->AddText("#splitline{NOvA Normal Hierarchy}{8.85#times10^{20} POT-equiv.}");
227  text->SetTextAlign(11);
228  pText->SetBorderSize(0);
229  pText->SetFillStyle(0);
230  pText->SetTextSize(0.04);
231  if(quantId == 0){
232  TText *text2 = pText->AddText("All Quantiles");
233  text2->SetTextAlign(11);
234  }
235  else if(quantId == 1){
236  TText *text2 = pText->AddText(TString::Format("Quantile %d", quantId));
237  text2->SetTextAlign(11);
238  TText *text3 = pText->AddText("best resolution");
239  text3->SetTextAlign(11);
240  text3->SetTextSize(0.04);
241  }
242  else if(quantId == 4){
243  TText *text2 = pText->AddText(TString::Format("Quantile %d", quantId));
244  text2->SetTextAlign(11);
245  TText *text3 = pText->AddText("worst resolution");
246  text3->SetTextAlign(11);
247  text3->SetTextSize(0.04);
248  }
249  else{
250  TText *text2 = pText->AddText(TString::Format("Quantile %d", quantId));
251  text2->SetTextAlign(11);
252  }
253 
254  pText->Draw();
255 
256 }
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
void drawLabelUnosc ( int  quantId = 0)

Definition at line 180 of file tools.h.

References genie::utils::style::Format().

Referenced by plotDataPred().

180  {
181 
182  TPaveText *pText = new TPaveText(0.53, 0.60, 0.88, 0.85, "NDC");
183  TText *text1 = pText->AddText("#splitline{NOvA Normal Hierarchy}{8.85#times10^{20} POT-equiv.}");
184  TText *text2 = pText->AddText(" ");
185  TText *text3 = pText->AddText(" ");
186  text1->SetTextAlign(31);
187  text1->SetTextSize(0.04);
188  pText->SetBorderSize(0);
189  pText->SetFillStyle(0);
190  if(quantId == 0){
191  TText *text4 = pText->AddText("All Quantiles");
192  text4->SetTextAlign(31);
193  text4->SetTextSize(0.05);
194  }
195  else if(quantId == 1){
196  TText *text4 = pText->AddText(TString::Format("Quantile %d", quantId));
197  text4->SetTextAlign(31);
198  text4->SetTextSize(0.05);
199  TText *text5 = pText->AddText(TString::Format("best resolution", quantId));
200  text5->SetTextAlign(31);
201  text5->SetTextSize(0.04);
202  }
203  else if(quantId == 4){
204  TText *text4 = pText->AddText(TString::Format("Quantile %d", quantId));
205  text4->SetTextAlign(31);
206  text4->SetTextSize(0.05);
207  TText *text5 = pText->AddText("worst resolution");
208  text5->SetTextAlign(31);
209  text5->SetTextSize(0.04);
210  }
211  else{
212  TText *text4 = pText->AddText(TString::Format("Quantile %d", quantId));
213  text4->SetTextAlign(31);
214  text4->SetTextSize(0.05);
215  }
216 
217  pText->Draw();
218 
219 }
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
void DrawLeftArrow ( int  color,
float  x,
float  dx,
float  ymin,
float  ymax 
)

Definition at line 262 of file tools.h.

References make_syst_table_plots::line, and ymin.

262  {
263 
264  TLine line;
265  line.SetLineWidth(3);
266  line.SetLineColor(color);
267  line.DrawLine(x,ymin,x,ymax);
268 
269  TArrow arr;
270  arr.SetLineWidth(3);
271  arr.SetLineColor(color);
272  arr.SetFillColor(color);
273 
274  float ymid = ymin + 0.5*(ymax-ymin);
275  // std::cout << "ymid " << ymid << std::endl;
276  arr.DrawArrow(x - dx, ymid, x, ymid, 0.01, "<");
277 
278 }
Double_t ymax
Definition: plot.C:25
double dx[NP][NC]
Double_t ymin
Definition: plot.C:24
void DrawLegendBF ( double  bfSin,
double  bfDm,
Color_t  color,
Style_t  style 
)

Definition at line 300 of file tools.h.

References genie::utils::style::Format(), and make_mec_shifts_plots::legend.

300  {
301 
302 
303  TGraph* marker = new TGraph();
304  marker->SetPoint(1,bfSin, bfDm);
305  marker->SetMarkerStyle(style);
306  marker->SetMarkerColor(color);
307  marker->SetMarkerSize(1.5);
308  TLegend *legend = new TLegend(0.13,0.12,0.28,0.25);
309  legend->SetHeader("Best fit");
310  legend->AddEntry(marker,TString::Format("(%.2f, %.2f#times10^{-3}eV^{2})", bfSin, bfDm),"p");
311  legend->SetTextSize(0.04); //no border for legend
312  legend->SetBorderSize(0);
313  legend->SetFillStyle(0);
314  legend->Draw();
315 
316 
317 }
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
void DrawLegendBF2 ( double  bfSin,
double  bfDm,
Color_t  color,
Style_t  style,
double  bfSin2,
double  bfDm2,
Color_t  color2,
Style_t  style2 
)

Definition at line 321 of file tools.h.

References HTMLTools::entry(), genie::utils::style::Format(), and make_mec_shifts_plots::legend.

321  {
322 
323  TLegend *legend = new TLegend(0.13,0.12,0.28,0.30,NULL,"brNDC");
324  legend->SetTextSize(0.04); //no border for legend
325  legend->SetBorderSize(0);
326  legend->SetFillStyle(0);
327  TLegendEntry *entry = legend->AddEntry("NULL","Best fit","h");
328  entry = legend->AddEntry("bestfit",TString::Format("(%.2f, %.2f 10^{-3} eV^{2})", bfSin, bfDm),"P");
329  entry->SetMarkerColor(color);
330  entry->SetMarkerStyle(style);
331  entry->SetTextFont(42);
332  entry = legend->AddEntry("bestfit",TString::Format("(%.2f, %.2f 10^{-3} eV^{2})", bfSin2, bfDm2),"P");
333  entry->SetMarkerColor(color2);
334  entry->SetMarkerStyle(style2);
335  entry->SetTextFont(42);
336  legend->Draw();
337 
338 }
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
def entry(str)
Definition: HTMLTools.py:26
void DrawRightArrow ( int  color,
float  x,
float  dx,
float  ymin,
float  ymax 
)

Definition at line 281 of file tools.h.

References make_syst_table_plots::line, and ymin.

281  {
282 
283  TLine line;
284  line.SetLineWidth(3);
285  line.SetLineColor(color);
286  line.DrawLine(x,ymin,x,ymax);
287 
288  TArrow arr;
289  arr.SetLineWidth(3);
290  arr.SetLineColor(color);
291  arr.SetFillColor(color);
292 
293  float ymid = ymin + 0.5*(ymax-ymin);
294  arr.DrawArrow(x, ymid, x+dx, ymid, 0.01, ">");
295 
296 }
Double_t ymax
Definition: plot.C:25
double dx[NP][NC]
Double_t ymin
Definition: plot.C:24
TGraph * graphAsymmError ( TH1 *  hDataScaled,
TH1 *  hData 
)

Definition at line 59 of file tools.h.

References bin, om::cout, allTimeWatchdog::endl, make_associated_cosmic_defs::fc, and submit_syst::y.

Referenced by plotDataPred(), and plotDataPred_SplitCanvas().

59  {
60 
61  for(int bin = 1; bin <= hData->GetNbinsX(); bin++) {
62  if(hData->GetBinContent(bin)==0){
63  hData->SetBinContent(bin,0.001);
64  hDataScaled->SetBinContent(bin,0.001);
65  }
66  }
67 
68  //TGraph *datapoisson = new TGraphAsymmErrors(hDataScaled);
69  TFeldmanCousins fc(0.6827); // to get correct poisson error bars
70  TGraphAsymmErrors *datapoisson = new TGraphAsymmErrors(hDataScaled);
71  for(int bin = 1; bin <= hData->GetNbinsX(); bin++) {
72  //scale by bin 0.1/width
73  float binWidth = hData->GetBinWidth(bin);
74  float scaleFactor = 0.1/binWidth;
75  float y = hData->GetBinContent(bin);
76  float posup = (fc.CalculateUpperLimit(y,0));
77  float posdn = (fc.CalculateLowerLimit(y,0));
78  float errup0 = (fc.CalculateUpperLimit(y,0)-y);
79  float errdn0 = (y-fc.CalculateLowerLimit(y,0));
80  float errup = scaleFactor * (fc.CalculateUpperLimit(y,0)-y);
81  float errdn = scaleFactor * (y-fc.CalculateLowerLimit(y,0));
82  datapoisson->SetPointEYhigh(bin-1,errup);
83  datapoisson->SetPointEYlow(bin-1,errdn);
84 
85  std::cout << "\nbin " << bin << " has " << y << "events" << std::endl;
86  std::cout << "bin width = " << binWidth << " , scale factor = " << scaleFactor << std::endl;
87  std::cout << "poisson up = " << posup << ", poisson down = " << posdn << std::endl;
88  std::cout << "up error = " << errup0 << ", down error = " << errdn0 << std::endl;
89  std::cout << "up error scaled = " << errup << ", down error scaled = " << errdn << std::endl;
90  }
91 
92  datapoisson->SetMarkerStyle(kFullCircle);
93  datapoisson->SetMarkerColor(1);
94  datapoisson->SetMarkerSize(1);
95  datapoisson->SetLineWidth(2);
96 
97  return datapoisson;
98 
99 }
float bin[41]
Definition: plottest35.C:14
OStream cout
Definition: OStream.cxx:6
void JointAnalysis ( )

Definition at line 47 of file tools.h.

Referenced by plotContProf().

47  {
48  TPaveText *pText1 = new TPaveText(0.73, 0.12, 0.88, 0.22, "NDC");
49  TText *text1 = pText1->AddText("Joint analysis");
50  text1->SetTextAlign(31);
51  text1->SetTextSize(0.04);
52  pText1->SetBorderSize(0);
53  pText1->SetFillStyle(0);
54  pText1->Draw();
55 }
void NumuOnly ( )

Definition at line 37 of file tools.h.

Referenced by plotContProf().

37  {
38  TPaveText *pText1 = new TPaveText(0.73, 0.12, 0.88, 0.22, "NDC");
39  TText *text1 = pText1->AddText("#nu_{#mu} only");
40  text1->SetTextAlign(31);
41  text1->SetTextSize(0.04);
42  pText1->SetBorderSize(0);
43  pText1->SetFillStyle(0);
44  pText1->Draw();
45 }
TH1* PlotSystShifts ( const SystShifts &  shifts)

Definition at line 103 of file tools.h.

References demo5::c1, CenterTitles(), make_syst_table_plots::h, make_syst_table_plots::nsysts, and systs.

103  {
104 
105  auto systs = shifts.ActiveSysts();
106  int nsysts = systs.size();
107  auto h = new TH1D ("sh",";; Pull (N#sigma)", nsysts, -0.5, nsysts + 0.5);
108  for (int systIdx = 0; systIdx < nsysts; ++systIdx){
109  h->SetBinContent( systIdx + 1, shifts.GetShift(systs[systIdx]));
110  h->GetXaxis()->SetBinLabel( systIdx + 1, systs[systIdx]->ShortName().c_str());
111  }
112 
113  h->SetMarkerStyle(kFullCircle);
114  CenterTitles(h);
115  h->SetTitleOffset(3.5);
116  h->GetXaxis()->SetNdivisions(nsysts,kFALSE);
117  h->GetXaxis()->SetLabelSize(0.07);
118  h->GetXaxis()->LabelsOption("v");
119  h->GetYaxis()->SetRangeUser(-1,1);
120 
121  auto c1 = new TCanvas ("c1","c1",700,350);
122  c1->SetBottomMargin(0.5);
123  h->Draw("lp hist");
124  c1->SaveAs("pulls.png");
125  return h;
126 
127 }
std::vector< SystGroupDef > systs
Definition: syst_header.h:385
void CenterTitles(TH1 *h)
c1
Definition: demo5.py:24
void Preliminary ( )

Definition at line 26 of file tools.h.

References prelim.

27 {
28  TLatex* prelim = new TLatex(.9, .95, "NOvA Preliminary");
29  prelim->SetTextColor(kBlue);
30  prelim->SetNDC();
31  prelim->SetTextSize(2/30.);
32  prelim->SetTextAlign(32);
33  prelim->Draw();
34 }
TLatex * prelim
Definition: Xsec_final.C:133
void SetColors ( )

Definition at line 3 of file tools.h.

References colors.

3  {
4 
5  colors[0] = kViolet - 5;
6  colors[1] = kAzure - 3;
7  colors[2] = kGreen + 2;
8  colors[3] = kOrange + 1;
9  colors[4] = kMagenta + 1;
10  colors[5] = kBlack;
11 
12 }
int colors[6]
Definition: tools.h:1
void Simulation ( )

Variable Documentation

int colors[6]