16 Design.cpp
Renata Kopecná edited this page 2022-01-27 09:43:07 +01:00

In this file, the functions used to make pretty plots (creating and defining canvases, histograms, graphs, ....) are defined. Please refer to Selection code page for more details how to include the file into ROOT.

Table of Contents

Functions and their parameters:

General helper function

void design_markers()

Takes an existing histogram/TEfficiency, defines marker style. The histogram markers and lines are set to have selected color. Sets it's x-axis title to xaxis_name and y-axis name to yaxis_name. Sets the title and label offsets of the axes.

  • Parameters
    • TH1F *histogram OR TH1D *histogram OR TEfficiency *histogram
    • string xaxis_name
    • string yaxis_name
    • Color_t color

void design_lines()

Takes an existing histogram, defines line style. The histogram lines are set to have selected color. Sets it's x-axis title to xaxis_name and y-axis name to yaxis_name. Sets the title and label offsets of the axes.

  • Parameters
    • TH1F *histogram OR TH1D *histogram OR TH1 *histogram
    • string xaxis_name
    • string yaxis_name
    • Color_t color

void design_filled_plot()

Takes an existing histogram, defines line width and the fill style. The histogram lines and fill are set to have selected color. Sets it's x-axis title to xaxis_name and y-axis name to yaxis_name. Sets the title and label offsets of the axes.

  • Parameters
    • TH1F *histogram OR TH1D *histogram
    • string xaxis_name
    • string yaxis_name
    • Color_t fill_color
    • int fill_style

void design_filled_plot()

Calls design_filled_plot() and sets the line color.

  • Parameters
    • TH1F *histogram OR TH1D *histogram
    • string xaxis_name
    • string yaxis_name
    • Color_t fill_color
    • int fill_style
    • Color_t line_color

void design_canvas()

Takes an existing canvas and sets the margins.

  • Parameters
    • TCanvas *canvas

void design_canvas()

Takes an existing canvas, sets the margins and the title.

  • Parameters
    • TCanvas *canvas
    • string title

void design_canvas_Bmass()

Takes an existing canvas and sets the margins. Used for B mass plots.

  • Parameters
    • TCanvas *canvas

void design_canvas_Bmass()

Takes an existing canvas, sets the margins and the title. Used for B mass plots.

  • Parameters
    • TCanvas *canvas
    • string title

TCanvas *c_TH2F()

Creates a 750x700 canvas, sets the margins, returns the canvas.

  • Parameters
    • string c_name
  • Return
    • Returns a 750x700 TCanvas.

void design_canvas_TH2F()

Takes an existing canvas and sets the margins. Used for 2D plots.

  • Parameters
    • TCanvas *canvas

void design_canvas_fancy()

Takes an existing canvas and sets the margins. Used for fancier plots.

  • Parameters
    • TCanvas *canvas

void design_TH2F()

Takes an existing 2D histogram. The histogram markers and lines are set to have selected color. Sets it's x-axis title to xaxis_name, y-axis name to yaxis_name and z-axis name to zaxis_name. Sets the title and label offsets of the axes, the histogram title is set to be empty.

  • Parameters
    • TH2F *histogram OR TH2D *histogram
    • string xaxis_name
    • string yaxis_name
    • string zaxis_name

void design_TH2F()

Executes design_TH2F() and sets the palette of the histogram.

  • Parameters
    • TH2F *histogram OR TH2D *histogram
    • string xaxis_name
    • string yaxis_name
    • string zaxis_name
    • int palette

void design_TH2F_ratio()

Takes an existing 2D histogram. The histogram markers and lines are set to have selected color. Sets it's x-axis title to xaxis_name, y-axis name to yaxis_name and z-axis name to zaxis_name. Sets the title and label offsets of the axes. The palette is set.

  • Parameters
    • TH2F *histogram OR TH2D *histogram
    • string xaxis_name
    • string yaxis_name
    • string zaxis_name
    • int palette

void design_function()

Takes an existing graph, sets the width and the color of lines.

  • Parameters
    • TF1 *graph
    • Color_t color

void design_function()

Executes design_function() and sets the line style.

  • Parameters
    • TF1 *graph
    • Color_t color
    • int style
  • Return

void design_TH1F(), design_TH1D()

Takes an existing histogram, defines marker style. The histogram markers and lines are set to have selected color. Sets it's x-axis title to xaxis_name and y-axis name to yaxis_name. Sets the title and label offsets of the axes.The title is set to be empty.

  • Parameters
    • TH1F *histogram OR TH1D *histogram
    • string xaxis_name
    • string yaxis_name
    • Color_t color

void design_TH1F(), design_TH1D()

Executes design_TH1F() or design_TH1D() and sets the marker style.

  • Parameters
    • TH1F *histogram OR TH1D *histogram
    • string xaxis_name
    • string yaxis_name
    • Color_t color
    • int marker_style

void design_TH1F(), design_TH1D()

Executes design_TH1F() or design_TH1D() and sets range of the x-axis to (x_low,x_up) and y-axis to (y_low,y_up).

  • Parameters
    • TH1F *histogram OR TH1D *histogram
    • string xaxis_name
    • string yaxis_name
    • Color_t color
    • int marker_style
    • double x_low
    • double x_up
    • double y_low
    • double y_up

TLine *design_cut_line()

Creates and returns a TLine going from x1,y1 to x2,y2. Sets the line width to 5 and the color of the line.

  • Parameters
    • float x1
    • float y1
    • float x2
    • float y2
    • Color_t color
  • Return TLine going from x1,y1 to x2,y2.

TLine *design_ratio_line()

Creates and returns a TLine going from x1,1 to x2,1. Sets the line width to 3, line style to 2 and the color of the line.

  • Parameters
    • float x1
    • float x2
    • Color_t color
  • Return TLine going from x1,1 to x2,1.

TLine *design_veto_line()

Creates and returns a TLine going from x1,y1 to x2,y2. Sets the line width to 1 and the color of the line.

  • Parameters
    • float x1
    • float y1
    • float x2
    • float y2
    • Color_t color

TMVA plots

bool DesignCorrelationPlots()

Takes an existing 2D plots and designs a nice correlation plot

  • Parameters
    • TH2F *h_corr
  • Return
    • Always true

TCanvas *c_Correlation()

Creates a canvas for the correlation plots.

  • Parameters
    • string type
  • Return
    • A 800x750 TCanvas

bool designVariablesSignalVsBackground()

Takes histograms of variables assigned as bkg and as signal and sets their properties for a nice plots.

  • Parameters
    • TH1F *h_variableS
    • TH1F *h_variableB
  • Return
    • Always true

bool designResponseSignalVsBackground()

Takes the signal and background response histograms and designs the overtraining plot (test sample). The method can be either "BDT" or "BDTG" or "MLP". Based on the method, the histogram y-axis range is defined.

  • Parameters
    • TH1F *h_responseS
    • TH1F *h_responseB
    • string method
  • Return
    • Always true

bool designOvertraining()

Takes the signal and background response histograms and designs the overtraining plot (training sample).

  • Parameters
    • TH1F *h_responseS
    • TH1F *h_responseB

TCanvas *c_VariablesSignalVsBackground()

Creates a canvas used to save the variable signal-background plots designed by designVariablesSignalVsBackground().

  • Parameters
    • string variable
  • Return
    • A 750x600 TCanvas

TCanvas *c_Efficiency()

Creates a canvas used to save the MVA efficiency.

  • Parameters
    • string c_name
  • Return
    • A 750x525 TCanvas

bool designEfficiency()

Takes the efficiencie in signal, efficiency in background, purity and significance histograms, makes them pretty for the efficiency plots.

  • Parameters
    • TH1F *h_efficiencySignal
    • TH1F *h_efficiencyBackground
    • TH1F *h_purity
    • TH1F *h_significance
    • string method
  • Return
    • Always true

TPaveText *significanceText()

Takes the number of signal nad background events and creates a text. The text is placed at xmin. In the text, the number of used events, the maximal significance and the significance at given MLP cut is listed.

  • Parameters
    • double xmin
    • int nSig
    • int nBkg
    • double maxSignificance
    • double maxSignificanceMLPcut
  • Return
    • TPave text saying how many events were used and what significance is obtained

TPaveText *text_effFromPi0()

Takes the signal and bkg yields as input. In order to place the TPaveText well, the maximal value on the y-axis is needed.

  • Parameters
    • double yieldSig
    • double yieldBkg
    • double ymax
  • Return
    • TPaveText

TCanvas *c_ROCplot()

Creates and prepares a TCanvas for a ROC plot.

  • Parameters
    • string c_name
  • Return
    • A 650x600 TCanvas

void designROC()

Takes a ROC histograms and sets the color of the histogram depending on the index. Makes the histogram pretty and sets the user ranges.

  • Parameters
    • TH1F* h_ROC
    • int index

Efficiency plots

TCanvas *c_L0MuonEff()

Creates and prepares a canvas for the L0 muon efficiency plots.

  • Parameters
    • string c_name
  • Return
    • A 650x600 TCanvas.

void designL0MuonEffHistos()

Takes as an input efficiency histogramsobtianed from data, MC and their ratio. Sets their axis titles, colors, line width, and marker style.

  • Parameters
    • TH1D *L0MuonEffData
    • TH1D *L0MuonEffMC
    • TH1D *L0MuonEffRatio

TCanvas * designL0MuonEfficiencies()

Creates a TCanvas used to plot the L0 muon efficiency. Extra string uses as a name tag. It takes as an input efficiency histogramsobtianed from data, MC and their ratio. Adds legend to the plot and the LHCb tag. Saves the TCanvas.

  • Parameters
    • string year
    • string magnet
    • TH1D *L0MuonEffData
    • TH1D *L0MuonEffMC
    • TH1D *L0MuonEffRatio
    • string extraString
  • Returns

void designBasicEfficiency()

Takes and efficiency graph with errors, sets the title, x-axis name, the range and the y-axis name based on the effName. Makes the graph pretty.

  • Parameters
    • TGraphErrors *graph
    • string title
    • string xAxisName
    • string effName
    • double lowRange
    • double highRange

void designBasicEfficiency()

Calls TCanvas * designBasicEfficiency() and sets the color.

  • Parameters
    • TGraphErrors *graph
    • string title
    • string xAxisName
    • string effName
    • double lowRange
    • double highRange
    • Color_t color

void designMultiGraphEfficiency()

Takes a multi graph as an input, sets the title, x-axis name, the range and the y-axis name based on the effName. Makes the graph pretty.

  • Parameters
    • TMultiGraph *graph
    • string title
    • string xAxisName
    • string effName
    • double lowRange
    • double highRange

Generic plots

TCanvas *c_canvas()

Create and return a generic canvas.

  • Parameters
    • string name
  • Return
    • A 750x600 TCanvas.

void designTGraph()

Take a graph with errors, set the title, axis names, the color and the marker styles. Sets the offsets and sizes, title is set to be empty.

  • Parameters
    • TGraphErrors *graph
    • string title
    • string xAxisName
    • string yAxisName
    • Color_t color
    • Int_t markerStyle

TH1D *generalHistogram()

Create a histogram with hist_name, title, number of bins nBins ranging from low_edge to high_edge. Ten call void design_TH1D(). Return the histogram.

  • Parameters
    • string hist_name
    • string title
    • int nBins
    • double low_edge
    • double high_edge
    • string xaxis_name
    • string yaxis_name
    • Color_t color
  • Return
    • A TH1D histogram

TH1D *BmassHistogram()

Calls generalHistogram() with 100 bins, y-axis name "Counts a.u.". Sets line width to 2. Returns the histogram.

  • Parameters
    • string hist_name
    • string title
    • string xaxis_name
    • Color_t color
  • Return
    • Returns a histogram with 100 bins.

void TM_canvas()

Creates and saves a canvas with the truth-matched, not truth-matched and both distributions.

  • Parameters
    • string name
    • TH1D *all
    • TH1D *TMed
    • TH1D *notTMed
    • string year
    • bool ReferenceChannel
    • bool PHSP
    • bool B0
    • bool K1
    • bool Inc

void designMultiGraph()

Makes a pretty multigraph.

  • Parameters
    • TMultiGraph *multGraph
    • string name
    • string xaxis_name
    • string yaxis_name

void designMultiGraph()

Calls designMultiGraph() and sets the x- and y-axis ranges.

  • Parameters
    • TMultiGraph *multGraph
    • string name
    • string xaxis_name
    • string yaxis_name
    • double lowx
    • double highx
    • double lowy
    • double highy

void addYearTag()

Draws a TLatex with the Run/Year tag placed at (x,y). Scaling decides the size of the text. For the tag, see Utils.hpp.

  • Parameters
    • Float_t x = 0.6
    • Float_t y = 0.85
    • string year = ""
    • int Run = 0
    • Int_t color = 1
    • Float_t Scaling = 1.0

void addAnyTag()

Draws a TLatex saying text at (x,y).

  • Parameters
    • Float_t x = 0.6
    • Float_t y = 0.85
    • string text = ""
    • Int_t color = 1
    • Float_t Scaling = 1.0

Truth-matching plots

TCanvas *c_for_TH2D()

Creates a canvas used fro 2D truth-matching plots.

  • Parameters
    • string name
  • Return
    • A 800x750 TCanvas.

bool designTH2D()

Prepares a 2D histrogam.

  • Parameters
    • TH2F *hist
  • Return
    • Always true

TH1D *hist_cosThetaK()

Calls generalHistogram(), setting automatically the ranges, 75 bins, axis labels. Boolean cos denothes whether to use a cos(angle) or just (angle).

  • Parameters
    • string hist_name
    • string title
    • Color_t color
    • bool cos
  • Return
    • A histogram of a ctk diostribution

TH1D *hist_cosAngle()

Calls generalHistogram() for given angle. Angle can be either "thetak","thetal" or "phi"

  • Parameters
    • string angle
    • string hist_name
    • string title
    • Color_t color
    • bool cos
    • bool norm
  • Return

Mass fit plots

void designMassFitFrame()

Takes RooPlot fram eas an input and prepares it for the B+ mass plots. Pull heigh specifies what fraction of the canvas will be the pull plot.

  • Parameters
    • RooPlot* frame
    • float pullHeight

void designPullFrame()

Takes RooPlot frame and RooPlot pull frame as input. Prepares them for the B+ mass plots. Pull heigh specifies what fraction of the canvas will be the pull plot.

  • Parameters
    • RooPlot *pullFrame
    • RooPlot *frame_m
    • float pullHeight

TLine *threeSigmaLine ()

Creates and returns a line from cut_B_plus_M_low to cut_B_plus_M_high (see GlobalFunctions.hpp) at either +3 or at -3 depending on the plus boolean.

  • Parameters
    • bool plus
  • Return
    • A TLine showing the (+ or -) 3 sigma line in a B plus mass plot.

Reweighting control plots

void drawKolmogorovTest()

Take the nTracks histogram in data and MC as an input, plot them including the Kolmogorov test and save the plot.

  • Parameters
    • TH1D *hist_nTracks
    • TH1D *hist_nTracks_MC
    • string canvasPath
    • string TMtype

void drawWeightRatio()

Take the weights used for MC reweighting, plot it, save it.

  • Parameters
    • TH1D *hist_w
    • string canvasPath
    • bool is2D
    • string TMtype

void drawWeightCorrelation()

Takes the 2D weights used for MC reweighting, plot them with their correlation coeffiient and save in a given path.

  • Parameters
    • TH2D *hCorrelationCheck
    • double CorrelationCoefficent
    • string canvasPath

MVA scan, yield plots

void designYieldGraph()

Take the graph with errors created by the MVA scan (BDTcutScanner.cpp), make it prety and save it to the basicPath with the given tag.

  • Parameters
    • TGraphErrors *graph
    • int Run
    • string year
    • string tag
    • string basicPath
    • TFile *TGraphOutput
    • bool fineScan

void design_YieldInQ2()

Take the signal, background, significance and CMS yield graphs with errors, make it in a beautiful complicated plot and save it.

  • Parameters
    • int Run
    • TGraphErrors *graphSig
    • TGraphErrors *graphBkg
    • TGraphErrors *graphSignificance
    • TGraphErrors *CMS
    • bool fixRange

void design_SignificanceInQ2()

Take only the significance and CMS yield graphs with errors, make it in a beautiful complicated plot and save it.

  • Parameters
    • int Run
    • TGraphErrors *graphSignificance
    • TGraphErrors *CMS
    • bool fixRange