MaCh3  2.6.0
Reference Guide
Functions | Variables
PlotLLH.cpp File Reference
#include <algorithm>
#include <iomanip>
#include "PlottingUtils/PlottingManager.h"
Include dependency graph for PlotLLH.cpp:

Go to the source code of this file.

Functions

void SetTPads (TPad *&LLHPad, TPad *&ratioPad)
 TPad is SUPER FRAGILE, it is safer to just make raw pointer, while ROOT behave weirdly with smart pointers. More...
 
void getSplitSampleStack (int fileIdx, const std::string &parameterName, const TH1D &LLH_allSams, std::vector< float > &cumSums, std::vector< bool > &drawLabel, THStack *sampleStack, TLegend *splitSamplesLegend, float baselineLLH_main=0.00001)
 
void drawRatioStack (THStack *ratioCompStack)
 
void makeLLHScanComparisons (const std::string &paramName, const std::string &LLHType, const std::string &outputFileName, const std::unique_ptr< TCanvas > &canv)
 
void makeSplitSampleLLHScanComparisons (const std::string &paramName, const std::string &outputFileName, const std::unique_ptr< TCanvas > &canv)
 
int PlotLLH ()
 
int main (int argc, char **argv)
 

Variables

M3::Plotting::PlottingManager * PlotMan
 

Detailed Description

Author
Ewan Miller

Definition in file PlotLLH.cpp.

Function Documentation

◆ drawRatioStack()

void drawRatioStack ( THStack *  ratioCompStack)

Definition at line 108 of file PlotLLH.cpp.

108  {
109  // do this so 1.0 is in the middle of the plot vertically
110  double stackMax = ratioCompStack->GetMaximum("NOSTACK");
111  double stackMin = ratioCompStack->GetMinimum("NOSTACK");
112 
113  double stackLim = std::max(std::abs(1.0 - stackMax), std::abs(1.0 - stackMin));
114  auto yTitleOffset = PlotMan->getOption<double>("yTitleOffset");
115  auto ratioPlotSplit = PlotMan->getOption<double>("ratioPlotSplit");
116  // scale the ratio plot labels by this much to make them same size as the normal plot
117  auto ratioLabelScaling = (1.0 / ratioPlotSplit - 1.0);
118 
119  ratioCompStack->SetMinimum(1.0 - 1.05 * stackLim);
120  ratioCompStack->SetMaximum(1.0 + 1.05 * stackLim);
121 
122  // draw it
123  ratioCompStack->Draw(Form("NOSTACK%s", PlotMan->getDrawOptions().c_str()));
124 
125  // make it look a bit nicer
126  ratioCompStack->GetXaxis()->SetLabelSize(ratioLabelScaling *
127  ratioCompStack->GetXaxis()->GetLabelSize());
128  ratioCompStack->GetXaxis()->SetTitleSize(ratioLabelScaling *
129  ratioCompStack->GetXaxis()->GetLabelSize());
130  ratioCompStack->GetXaxis()->SetTitle("Parameter Variation");
131 
132  ratioCompStack->GetYaxis()->SetLabelSize(ratioLabelScaling *
133  ratioCompStack->GetYaxis()->GetLabelSize());
134  ratioCompStack->GetYaxis()->SetTitleSize(ratioLabelScaling *
135  ratioCompStack->GetYaxis()->GetLabelSize());
136  ratioCompStack->GetYaxis()->SetTitleOffset(yTitleOffset);
137  ratioCompStack->GetYaxis()->SetNdivisions(5, 2, 0);
138 }
M3::Plotting::PlottingManager * PlotMan
Definition: PlotLLH.cpp:17

◆ getSplitSampleStack()

void getSplitSampleStack ( int  fileIdx,
const std::string &  parameterName,
const TH1D &  LLH_allSams,
std::vector< float > &  cumSums,
std::vector< bool > &  drawLabel,
THStack *  sampleStack,
TLegend *  splitSamplesLegend,
float  baselineLLH_main = 0.00001 
)

Definition at line 41 of file PlotLLH.cpp.

45 {
46  auto sampNames = PlotMan->input().getTaggedSamples(PlotMan->getOption<std::vector<std::string>>("sampleTags"));
47  size_t nSamples = sampNames.size();
48 
49  cumSums.resize(nSamples);
50  drawLabel.resize(nSamples);
51 
52  float LLH_main_integ = LLH_allSams.Integral();
53  float cumSum = 0.0;
54  int nBins = LLH_allSams.GetNbinsX();
55 
56  MACH3LOG_DEBUG("getting split sample THStack for {} known samples", nSamples);
57  for (uint i = 0; i < nSamples; i++)
58  {
59  std::string sampName = sampNames[i];
60 
61  MACH3LOG_DEBUG(" on sample {}/{}: {}", i, nSamples, sampName);
62 
63  TH1D *LLH_indivSam =
64  new TH1D(PlotMan->input().getSampleSpecificLLHScan_TH1D(fileIdx, parameterName, sampName));
65  LLH_indivSam->SetName(Form("%i_%s_%s", fileIdx, parameterName.c_str(), sampName.c_str()));
66  LLH_indivSam->SetBit(kCanDelete);
67 
68  // the hist for this sample didn't exist so move on
69  if (LLH_indivSam->GetNbinsX() == 1)
70  {
71  MACH3LOG_DEBUG(" sample hist had only 1 bin - assuming it doesn't exist");
72  delete LLH_indivSam;
73  drawLabel[i] = false;
74  cumSums[i] = -999.9;
75  continue;
76  }
77 
78  LLH_indivSam->SetStats(0);
79  LLH_indivSam->SetLineColor(TColor::GetColorPalette(
80  floor(static_cast<float>(i) * TColor::GetNumberOfColors() / static_cast<float>(nSamples))));
81  LLH_indivSam->SetFillColor(TColor::GetColorPalette(
82  floor(static_cast<float>(i) * TColor::GetNumberOfColors() / static_cast<float>(nSamples))));
83  sampleStack->Add(LLH_indivSam);
84  splitSamplesLegend->AddEntry(LLH_indivSam, PlotMan->style().prettifySampleName(sampName).c_str(), "lf");
85 
86  float lastBinLLH = LLH_indivSam->GetBinContent(nBins);
87  cumSum += lastBinLLH;
88 
89  MACH3LOG_DEBUG(" Last bin LLH = {} :: cumulative LLH = {}", lastBinLLH, cumSum);
90  MACH3LOG_DEBUG(" LLH fraction = {} / {} = {}", LLH_indivSam->Integral(), LLH_main_integ, LLH_indivSam->Integral() / LLH_main_integ);
91 
92  cumSums[i] = cumSum;
93  auto sampleLabelThreshold = PlotMan->getOption<double>("sampleLabelThreshold");
94  // dont draw a label if the likelihood contribution is less than threshold%
95  if ((LLH_indivSam->Integral() / LLH_main_integ > sampleLabelThreshold) &&
96  (LLH_indivSam->Integral() / baselineLLH_main > sampleLabelThreshold))
97  {
98  drawLabel[i] = true;
99  } else {
100  drawLabel[i] = false;
101  }
102  MACH3LOG_DEBUG(" drawLabel = {}", drawLabel.back());
103  MACH3LOG_DEBUG("");
104  }
105 }
#define MACH3LOG_DEBUG
Definition: MaCh3Logger.h:34

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 471 of file PlotLLH.cpp.

471  {
474 
475  PlotMan = new M3::Plotting::PlottingManager();
476  PlotMan->parseInputs(argc, argv);
477  PlotMan->setExec("PlotLLH");
478 
479  if(PlotMan->getPlotRatios() && PlotMan->input().getNInputFiles() == 1){
480  MACH3LOG_ERROR("Can't plot ratio with single file...");
481  throw MaCh3Exception(__FILE__, __LINE__);
482  }
483 
484  return PlotLLH();
485 }
#define MACH3LOG_ERROR
Definition: MaCh3Logger.h:37
void SetMaCh3LoggerFormat()
Set messaging format of the logger.
Definition: MaCh3Logger.h:60
int PlotLLH()
Definition: PlotLLH.cpp:420
Custom exception class used throughout MaCh3.
void MaCh3Welcome()
KS: Prints welcome message with MaCh3 logo.
Definition: Monitor.cpp:13

◆ makeLLHScanComparisons()

void makeLLHScanComparisons ( const std::string &  paramName,
const std::string &  LLHType,
const std::string &  outputFileName,
const std::unique_ptr< TCanvas > &  canv 
)

Definition at line 140 of file PlotLLH.cpp.

143  {
144  // will use these to make comparisons of likelihoods
145  auto compStack = std::make_unique<THStack>("LLH_Stack", "");
146  auto ratioCompStack = std::make_unique<THStack>("LLH_Ratio_Stack", "");
147  auto legend = std::make_unique<TLegend>(0.3, 0.6, 0.7, 0.8);
148 
149  TPad* LLHPad = nullptr;
150  TPad* ratioPad = nullptr;
151  SetTPads(LLHPad, ratioPad);
152 
153  // get the sample reweight hist from the main file
154  TH1D LLH_main = PlotMan->input().getLLHScan_TH1D(0, paramName, LLHType);
155  LLH_main.SetStats(0);
156 
157  LLH_main.SetLineColor(kBlack);
158  compStack->Add(&LLH_main);
159  legend->AddEntry(&LLH_main, PlotMan->getFileLabel(0).c_str(), "l");
160 
161  int nBins = LLH_main.GetNbinsX();
162  int lineWidth = PlotMan->getOption<int>("lineWidth");
163  // go through the other files
164  for (unsigned int extraFileIdx = 1; extraFileIdx < PlotMan->input().getNInputFiles(); extraFileIdx++)
165  {
166  int originalErrorLevel = gErrorIgnoreLevel;
167  gErrorIgnoreLevel = kFatal;
168 
169  TH1D *compHist = new TH1D(PlotMan->input().getLLHScan_TH1D(extraFileIdx, paramName, LLHType));
170  compHist->SetName(Form("LLHScan_%s_%s_%d", paramName.c_str(), LLHType.c_str(), extraFileIdx));
171  compHist->SetBit(kCanDelete); // <- will allow this to be deleted by root once done plotting
172  gErrorIgnoreLevel = originalErrorLevel;
173  if (compHist->GetNbinsX() == 0)
174  continue;
175 
176  // make them look different to each other
177  compHist->SetLineColor(
178  TColor::GetColorPalette(floor(static_cast<float>(extraFileIdx) * TColor::GetNumberOfColors() /
179  static_cast<float>(PlotMan->input().getNInputFiles()))));
180  compHist->SetLineStyle(2 + extraFileIdx % 9);
181  compHist->SetLineWidth(lineWidth);
182 
183  TH1D *divHist = static_cast<TH1D*>(compHist->Clone(Form("RatioHist_%i", extraFileIdx)));
184  divHist->SetBit(kCanDelete);
185 
186  if (PlotMan->getPlotRatios())
187  {
188  // get the ratio hist
189  divHist->Divide(compHist, &LLH_main);
190  ratioCompStack->Add(divHist);
191  }
192 
193  // add it to the comparison stack and legend
194  compStack->Add(compHist);
195  legend->AddEntry(compHist, PlotMan->getFileLabel(extraFileIdx).c_str(), "l");
196  }
197  auto yTitleOffset = PlotMan->getOption<double>("yTitleOffset");
198  // draw the log likelihoods
199  canv->cd();
200  canv->Draw();
201  LLHPad->Draw();
202  LLHPad->cd();
203  if (PlotMan->getDrawGrid())
204  LLHPad->SetGrid();
205  compStack->Draw(Form("NOSTACK%s", PlotMan->getDrawOptions().c_str()));
206  if (!PlotMan->getPlotRatios())
207  compStack->GetXaxis()->SetTitle("Parameter Variation");
208  compStack->GetYaxis()->SetTitle(Form("-2LLH_{%s}", LLHType.c_str()));
209  compStack->SetTitle(PlotMan->style().prettifyParamName(paramName).c_str());
210  compStack->GetYaxis()->SetTitleOffset(yTitleOffset);
211  legend->Draw();
212 
213  // add the ratio plot if specified
214  if (PlotMan->getPlotRatios())
215  {
216  canv->cd();
217  ratioPad->Draw();
218  ratioPad->cd();
219  if (PlotMan->getDrawGrid())
220  ratioPad->SetGrid();
221 
222  drawRatioStack(ratioCompStack.get());
223 
224  // add horizontal line at 1 for reference
225  TLine line = TLine();
226  line.SetLineColor(kBlack);
227  line.SetLineWidth(lineWidth);
228  line.DrawLine(LLH_main.GetBinLowEdge(1), 1.0, LLH_main.GetBinLowEdge(nBins + 1), 1.0);
229  }
230 
231  // save to the output file
232  canv->SaveAs(outputFileName.c_str());
233  delete LLHPad;
234  delete ratioPad;
235 }
void drawRatioStack(THStack *ratioCompStack)
Definition: PlotLLH.cpp:108
void SetTPads(TPad *&LLHPad, TPad *&ratioPad)
TPad is SUPER FRAGILE, it is safer to just make raw pointer, while ROOT behave weirdly with smart poi...
Definition: PlotLLH.cpp:20

◆ makeSplitSampleLLHScanComparisons()

void makeSplitSampleLLHScanComparisons ( const std::string &  paramName,
const std::string &  outputFileName,
const std::unique_ptr< TCanvas > &  canv 
)

Definition at line 237 of file PlotLLH.cpp.

239  {
240  MACH3LOG_DEBUG(" Making split sample LLH comparison");
241  // split the canvas if plotting ratios
242  TPad* LLHPad = nullptr;
243  TPad* ratioPad = nullptr;
244  SetTPads(LLHPad, ratioPad);
245  canv->Clear();
246  canv->Draw();
247 
248  canv->Divide(PlotMan->getNFiles());
249 
250  // get the sample hist from the main file
251  TH1D LLH_main = PlotMan->input().getLLHScan_TH1D(0, paramName, "sample");
252  if (LLH_main.GetNbinsX() == 1)
253  {
254  MACH3LOG_DEBUG(" Main LLH had only 1 bin, assuming it doesn't exist");
255  return;
256  }
257 
258  auto baseSplitSamplesStack = std::make_unique<THStack>(
259  paramName.c_str(), Form("%s - %s", paramName.c_str(), PlotMan->getFileLabel(0).c_str()));
260 
261  auto baseSplitSamplesLegend = std::make_unique<TLegend>(0.37, 0.475, 0.63, 0.9);
262 
263  if (PlotMan->getDrawGrid())
264  canv->cd(1)->SetGrid();
265  else
266  canv->cd(1);
267 
268  canv->cd(1)->SetLeftMargin(0.15);
269  std::vector<float> cumSums;
270  std::vector<bool> drawLabel;
271 
272  getSplitSampleStack(0, paramName, LLH_main, cumSums, drawLabel, baseSplitSamplesStack.get(),
273  baseSplitSamplesLegend.get());
274  baseSplitSamplesStack->Draw(PlotMan->getDrawOptions().c_str());
275  // KS: Not sure why but need to plot after it's drawn otherwise ROOT throws segfault...
276  baseSplitSamplesStack->GetYaxis()->SetTitle("-2LLH_{sam}");
277  if (PlotMan->getPlotRatios() == false) baseSplitSamplesStack->GetXaxis()->SetTitle("Parameter Variation");
278  gPad->Modified();
279  gPad->Update();
280 
281  bool totalOnSplitPlots = PlotMan->getOption<bool>("totalOnSplitPlots");
282  if (totalOnSplitPlots)
283  {
284  LLH_main.SetLineWidth(1); // undo SetLineWidth that was done above
285  LLH_main.Draw(Form("same%s", PlotMan->getDrawOptions().c_str()));
286  baseSplitSamplesLegend->AddEntry(&LLH_main, "All Samples", "l");
287  }
288 
289  baseSplitSamplesLegend->Draw();
290 
291  auto label = std::make_unique<TLatex>();
292  // format the label
293  label->SetTextAlign(11);
294  label->SetTextAngle(-55);
295  label->SetTextSize(0.012);
296  const auto& SampleTags = PlotMan->getOption<std::vector<std::string>>("sampleTags");
297 
298  // need to draw the labels after other stuff or they don't show up
299  for (uint i = 0; i < PlotMan->input().getTaggedSamples(SampleTags).size(); i++)
300  {
301  MACH3LOG_DEBUG(" Will I draw the label for sample {}??", i);
302  std::string sampName = PlotMan->input().getTaggedSamples(SampleTags)[i];
303  if (!drawLabel[i])
304  {
305  MACH3LOG_DEBUG(" - Not drawing label");
306  continue;
307  }
308  MACH3LOG_DEBUG(" - Drawing label");
309 
310  label->DrawLatex(LLH_main.GetBinLowEdge(LLH_main.GetNbinsX() + 1), cumSums[i],
311  Form("#leftarrow%s", PlotMan->style().prettifySampleName(sampName).c_str()));
312  MACH3LOG_DEBUG(" I drew the label!");
313  }
314 
315  // now we plot the comparison file plots
316  for (unsigned int extraFileIdx = 1; extraFileIdx < PlotMan->getNFiles(); extraFileIdx++)
317  {
318  MACH3LOG_DEBUG(" - Adding plot for additional file {}", extraFileIdx);
319  canv->cd(1 + extraFileIdx);
320 
321  std::vector<float> extraCumSums;
322  std::vector<bool> extraDrawLabel;
323 
324  THStack *splitSamplesStack =
325  new THStack(paramName.c_str(),
326  Form("%s - %s", paramName.c_str(), PlotMan->getFileLabel(extraFileIdx).c_str()));
327 
328  auto splitSamplesLegend = std::make_unique<TLegend>(0.37, 0.475, 0.63, 0.9);
329  splitSamplesStack->SetBit(kCanDelete);
330  splitSamplesLegend->SetBit(kCanDelete);
331 
332  int originalErrorLevel = gErrorIgnoreLevel;
333  gErrorIgnoreLevel = kFatal;
334  TH1D compLLH_main = PlotMan->input().getLLHScan_TH1D(extraFileIdx, paramName, "sample");
335  compLLH_main.SetName((compLLH_main.GetName() + std::string("_file_") + extraFileIdx).Data());
336  gErrorIgnoreLevel = originalErrorLevel;
337  if (compLLH_main.GetNbinsX() == 1)
338  {
339  delete splitSamplesStack;
340  continue;
341  }
342  bool sameAxis = PlotMan->getOption<bool>("sameAxis");
343  // if on the same y axis, also check that the contribution of the sample compared to the
344  // baseline LLH integral is above the threshold otherwise the labels might get very crowded if
345  // the comparisson LLH is much smaller than the baseline one
346  if (sameAxis)
347  getSplitSampleStack(extraFileIdx, paramName, compLLH_main, extraCumSums, extraDrawLabel,
348  splitSamplesStack, splitSamplesLegend.get(), LLH_main.Integral());
349  else
350  getSplitSampleStack(extraFileIdx, paramName, compLLH_main, extraCumSums, extraDrawLabel,
351  splitSamplesStack, splitSamplesLegend.get());
352 
353  // go to the pad for the histograms
354  if (PlotMan->getDrawGrid())
355  LLHPad->SetGrid();
356  LLHPad->Draw();
357  LLHPad->cd();
358 
359  splitSamplesStack->Draw(PlotMan->getDrawOptions().c_str());
360  if (sameAxis)
361  splitSamplesStack->SetMaximum(baseSplitSamplesStack->GetMaximum());
362 
363  if (totalOnSplitPlots)
364  {
365  compLLH_main.Draw(Form("same%s", PlotMan->getDrawOptions().c_str()));
366  compLLH_main.SetLineColor(kBlack);
367  splitSamplesLegend->AddEntry(&compLLH_main, "All Samples", "l");
368  }
369  splitSamplesLegend->Draw();
370 
371  // KS: Not sure why but need to plot after it's drawn otherwise ROOT throws segfault...
372  baseSplitSamplesStack->GetYaxis()->SetTitle("-2LLH_{sam}");
373  if (PlotMan->getPlotRatios() == false) baseSplitSamplesStack->GetXaxis()->SetTitle("Parameter Variation");
374  gPad->Modified();
375  gPad->Update();
376 
377  // need to draw the labels after other stuff or they dont show up
378  for (uint i = 0; i < PlotMan->input().getTaggedSamples(PlotMan->getOption<std::vector<std::string>>("sampleTags")).size(); i++)
379  {
380  std::string sampName = PlotMan->input().getTaggedSamples(PlotMan->getOption<std::vector<std::string>>("sampleTags"))[i];
381  if (!drawLabel[i])
382  continue;
383  label->DrawLatex(compLLH_main.GetBinLowEdge(compLLH_main.GetNbinsX() + 1), extraCumSums[i],
384  Form("#leftarrow%s", PlotMan->style().prettifySampleName(sampName).c_str()));
385  }
386 
387  if (PlotMan->getPlotRatios())
388  {
389  THStack *splitSamplesStackRatios = new THStack(paramName.c_str(), "");
390 
391  TList *baselineHistList = baseSplitSamplesStack->GetHists();
392  TList *compHistList = splitSamplesStack->GetHists();
393  for (uint sampleIdx = 0; sampleIdx < PlotMan->input().getTaggedSamples(PlotMan->getOption<std::vector<std::string>>("sampleTags")).size(); sampleIdx++)
394  {
395  TH1D *divHist = new TH1D(
396  Form("%s_%s_splitDiv_%i", paramName.c_str(), PlotMan->getFileLabel(extraFileIdx).c_str(),
397  sampleIdx),
398  Form("%s_%s_splitDiv", paramName.c_str(), PlotMan->getFileLabel(extraFileIdx).c_str()),
399  compLLH_main.GetNbinsX(), compLLH_main.GetBinLowEdge(1),
400  compLLH_main.GetBinLowEdge(compLLH_main.GetNbinsX() + 1));
401  divHist->Divide(static_cast<TH1D*>(compHistList->At(sampleIdx)),
402  static_cast<TH1D*>(baselineHistList->At(sampleIdx)));
403  splitSamplesStackRatios->Add(divHist);
404  divHist->SetLineColor((static_cast<TH1D*>(compHistList->At(sampleIdx))->GetLineColor()));
405  }
406 
407  canv->cd(2 + extraFileIdx);
408  if (PlotMan->getDrawGrid())
409  ratioPad->SetGrid();
410  ratioPad->Draw();
411  ratioPad->cd();
412  drawRatioStack(splitSamplesStackRatios);
413  }
414  }
415  canv->SaveAs(outputFileName.c_str());
416  delete LLHPad;
417  delete ratioPad;
418 }
void getSplitSampleStack(int fileIdx, const std::string &parameterName, const TH1D &LLH_allSams, std::vector< float > &cumSums, std::vector< bool > &drawLabel, THStack *sampleStack, TLegend *splitSamplesLegend, float baselineLLH_main=0.00001)
Definition: PlotLLH.cpp:41

◆ PlotLLH()

int PlotLLH ( )

Definition at line 420 of file PlotLLH.cpp.

420  {
421  PlotMan->style().setPalette(PlotMan->getOption<std::string>("colorPalette"));
422 
423  // make the canvas and other plotting stuff
424  auto canv = std::make_unique<TCanvas>("canv", "", 1024, 1024);
425  gStyle->SetOptTitle(2);
426  // split up the canvas so can have side by side plots, one for each file
427  auto splitSamplesCanv = std::make_unique<TCanvas>("splitSampCanv", "", 4096 * PlotMan->getNFiles(), 4096);
428 
429  canv->SaveAs((PlotMan->getOutputName("_Sample") + "[").c_str());
430  canv->SaveAs((PlotMan->getOutputName("_Penalty") + "[").c_str());
431  canv->SaveAs((PlotMan->getOutputName("_Total") + "[").c_str());
432 
433  if (PlotMan->getSplitBySample())
434  canv->SaveAs((PlotMan->getOutputName("_bySample") + "[").c_str());
435 
436  std::string params;
437  for (const std::string& par : PlotMan->getOption<std::vector<std::string>>("parameterTags")){
438  params += par + ", ";
439  }
440  MACH3LOG_INFO("Parameters: {}", params);
441  // loop over the spline parameters
442  for (std::string paramName : PlotMan->input().getTaggedParameters(PlotMan->getOption<std::vector<std::string>>("parameterTags")))
443  {
444  MACH3LOG_DEBUG("working on parameter {}", paramName);
445  // ###############################################################
446  // First lets do just the straight up likelihoods from all samples
447  // ###############################################################
448  makeLLHScanComparisons(paramName, "sample", PlotMan->getOutputName("_Sample"), canv);
449  makeLLHScanComparisons(paramName, "penalty", PlotMan->getOutputName("_Penalty"), canv);
450  makeLLHScanComparisons(paramName, "total", PlotMan->getOutputName("_Total"), canv);
451  // #########################################
452  // ## now lets make plots split by sample ##
453  // #########################################
454  if (PlotMan->getSplitBySample())
455  {
456  makeSplitSampleLLHScanComparisons(paramName, PlotMan->getOutputName("_bySample"), splitSamplesCanv);
457  }
458  }
459 
460  canv->SaveAs((PlotMan->getOutputName("_Sample") + "]").c_str());
461  canv->SaveAs((PlotMan->getOutputName("_Penalty") + "]").c_str());
462  canv->SaveAs((PlotMan->getOutputName("_Total") + "]").c_str());
463  if (PlotMan->getSplitBySample())
464  canv->SaveAs((PlotMan->getOutputName("_bySample") + "]").c_str());
465 
466  if(PlotMan != nullptr) delete PlotMan;
467 
468  return 0;
469 }
#define MACH3LOG_INFO
Definition: MaCh3Logger.h:35
void makeSplitSampleLLHScanComparisons(const std::string &paramName, const std::string &outputFileName, const std::unique_ptr< TCanvas > &canv)
Definition: PlotLLH.cpp:237
void makeLLHScanComparisons(const std::string &paramName, const std::string &LLHType, const std::string &outputFileName, const std::unique_ptr< TCanvas > &canv)
Definition: PlotLLH.cpp:140

◆ SetTPads()

void SetTPads ( TPad *&  LLHPad,
TPad *&  ratioPad 
)

TPad is SUPER FRAGILE, it is safer to just make raw pointer, while ROOT behave weirdly with smart pointers.

Definition at line 20 of file PlotLLH.cpp.

21 {
22  int originalErrorLevel = gErrorIgnoreLevel;
23  gErrorIgnoreLevel = kFatal;
24  auto ratioPlotSplit = PlotMan->getOption<double>("ratioPlotSplit");
25  if (PlotMan->getPlotRatios())
26  {
27  LLHPad = new TPad("LLHPad", "LLHPad", 0.0, ratioPlotSplit, 1.0, 1.0);
28  LLHPad->SetBottomMargin(0.0);
29  ratioPad = new TPad("ratioPad", "ratioPad", 0.0, 0.0, 1.0, ratioPlotSplit);
30  ratioPad->SetTopMargin(0.0);
31  ratioPad->SetBottomMargin(0.3);
32  } else {
33  LLHPad = new TPad("AllSampPad", "AllSampPad", 0.0, 0.0, 1.0, 1.0);
34  ratioPad = new TPad("AllSampRatioPad", "AllSampRatioPad", 0.0, 0.0, 0.0, 0.0);
35  }
36  LLHPad->AppendPad();
37  ratioPad->AppendPad();
38  gErrorIgnoreLevel = originalErrorLevel;
39 }

Variable Documentation

◆ PlotMan

M3::Plotting::PlottingManager* PlotMan
Warning
KS: keep raw pointer or ensure manual delete of PlotMan. If spdlog in automatically deleted before PlotMan then destructor has some spdlog and this could cause segfault

Definition at line 17 of file PlotLLH.cpp.