C++ API
Note
This project is under active development.
-
namespace analysis
Functions
-
void createDataset1D(ROOT::RDF::RInterface<ROOT::Detail::RDF::RJittedFilter, void> frame, RooWorkspace *w, std::string name, std::string title, std::string helicity, std::string fitvarx, double xmin, double xmax, std::string massvar, double mmin, double mmax, std::vector<std::string> binvars, std::vector<std::vector<double>> binvarlims, std::vector<std::string> depolvars, std::vector<std::vector<double>> depolvarlims)
Create a dataset for a 1D fit.
Create a RooFit dataset for use with an invariant mass signal fit and an asymmetry fit, adding helicity, fit, mass, binning, and depolarization variables.
- Parameters:
frame – ROOT RDataframe from which to create a RooDataSet
w – RooWorkspace in which to work
name – Dataset name
title – Dataset title
helicity – Name of helicity variable
fitvarx – Name of fit variable
xmin – Minimum bound for fit variable
xmax – Maximum bound for fit variable
massvar – Invariant mass variable name
mmin – Minimum bound for invariant mass variable
mmax – Maximum bound for invariant mass variable
binvars – List of kinematic binning variables (up to 4)
binvarlims – List of minimum and maximum bounds for each kinematic binning variable
depolvars – List of depolarization variables (up to 5)
depolvarlims – List of minimum and maximum bounds for each depolarization variable
-
void applyLambdaMassFit(RooWorkspace *w, std::string massvar, std::string dataset_name, std::string sgYield_name, std::string bgYield_name, std::string model_name)
Apply a \(\Lambda\) baryon mass fit.
Apply a \(\Lambda\) baryon mass fit with crystal ball signal and Chebychev polynomial background and save model and yield variables to workspace.
- Parameters:
w – RooWorkspace in which to work
massvar – Invariant mass variable name
dataset_name – Dataset name
sgYield_name – Signal yield variable name
bgYield_name – Background yield variable name
model_name – Full PDF name
-
std::vector<double> applyLambdaMassFit(RooWorkspace *w, std::string massvar, std::string dataset_name, std::string sgYield_name, std::string bgYield_name, ROOT::RDF::RInterface<ROOT::Detail::RDF::RJittedFilter, void> frame, int mass_nbins_hist, double mass_min, double mass_max, int mass_nbins_conv, std::string model_name, std::string sig_pdf_name, double sg_region_min, double sg_region_max, std::string ws_unique_id, int use_poly4_bg)
Apply a \(\Lambda\) baryon mass fit.
Apply a \(\Lambda\) baryon mass fit with signal function chosen from (
"gauss","landau","cb","landau_X_gauss","cb_X_gauss") and Chebychev polynomial background function and save model and yield variables to workspace for use with sPlot method from arXiv:physics/0402083. This will also return \(\varepsilon\) which is the fraction of events in the signal region (sig_region_min,sig_region_max) which are background based on the difference between the observed distribution and the histogrammed background function.- Parameters:
w – RooWorkspace in which to work
massvar – Invariant mass variable name
dataset_name – Dataset name
sgYield_name – Signal yield variable name
bgYield_name – Background yield variable name
frame – ROOT RDataframe from which to create a histogram of invariant mass
mass_nbins_hist – Number of bins for the invariant mass histogram
mass_min – Minimum bound for invariant mass variable
mass_max – Maximum bound for invariant mass variable
mass_nbins_conv – Number of invariant mass bins for convolution of PDFs
model_name – Full PDF name
sig_pdf_name – Signal PDF name
sg_region_min – Invariant mass signal region lower bound
sg_region_max – Invariant mass signal region upper bound
ws_unique_id – Identifier string to ensure PDFs uniqueness in workspace
use_poly4_bg – Use a 4th order Chebychev polynomial background instead 2nd order
- Returns:
List containing background fraction epsilon and its statistical error
-
void applySPlot(RooWorkspace *w, std::string dataset_name, std::string sgYield_name, std::string bgYield_name, std::string model_name, std::string dataset_sg_name, std::string dataset_bg_name)
Apply the sPlot method from arXiv:physics/0402083.
Apply sPlot method from arXiv:physics/0402083 given a dataset, yield variables, and a model and add the sWeighted datasets to the workspace.
- Parameters:
w – RooWorkspace in which to work
dataset_name – Dataset name
sgYield_name – Signal yield variable name
bgYield_name – Background yield variable name
model_name – Full PDF name
dataset_sg_name – Name of dataset with signal sweights
dataset_bg_name – Name of dataset with background sweights
-
TArrayF *getKinBinAsymUBML1D(std::string outdir, TFile *outroot, ROOT::RDF::RInterface<ROOT::Detail::RDF::RJittedFilter, void> frame, RooWorkspace *w, std::string dataset_name, std::vector<std::string> binvars, std::vector<std::vector<double>> binvarlims, std::string bincut, std::string bintitle, double pol, std::vector<std::string> depolvars, std::vector<std::vector<double>> depolvarlims, std::string helicity = "heli", std::string fitformula = "[0]*sin(x)+[1]*sin(2*x)", int nparams = 2, std::vector<double> params = std::vector<double>(5), std::string fitvarx = "phi_h", std::string fitvarxtitle = "#phi_{h p#pi^{-}}", double xmin = 0.0, double xmax = 2 * TMath::Pi(), bool use_sumW2Error = true, std::ostream &out = std::cout)
Compute an asymmetry using an unbinned maximum likelihood fit with 1 fit variable.
Compute the bin count, bin variable values and errors, depolarization variable values and errors, and fit parameter values and errors using an unbinned maximum likelihood fit to the asymmetry. Note that the given asymmetry formula \( A(x, a_0, a_1, a_2, ...) \) will be converted internally to a PDF of the form
\[ PDF(h, x, a_0, a_1, a_2,...) = 1 + h \cdot P \cdot A(x, a_0, a_1, a_2, ...) \]The variable names should be replaced in the fit formula by
helicity\(\rightarrow\)[0],x\(\rightarrow\)[1],a_0\(\rightarrow\)[2], etc.- Parameters:
outdir – Name of output directory
outroot – Name of output ROOT file
frame – ROOT RDataframe from which to get bin count
w – RooWorkspace in which to work
dataset_name – Dataset name
binvars – List of kinematic binning variables
binvarlims – List of minimum and maximum bounds for each kinematic binning variable
bincut – Kinematic variable cut for bin
bintitle – Bin title
pol – Luminosity averaged beam polarization
depolvars – List of depolarization variables
depolvarlims – List of minimum and maximum bounds for each depolarization variable
helicity – Name of helicity variable
fitformula – The asymmetry formula
nparams – Number of parameters in the asymmetry formula (up to 5)
params – List of initial values for asymmetry parameters
fitvarx – Name of fit variable
fitvarxtitle – Title of fit variable
xmin – Minimum bound for fit variable
xmax – Maximum bound for fit variable
use_sumW2Error – Option to use RooFit::SumW2Error(true) option when fitting to dataset which is necessary if using a weighted dataset
out – Output stream
- Returns:
List of bin count, bin variable means and errors, depolarization variable means and errors, fit parameters and errors
-
void getKinBinnedAsymUBML1D(std::string outdir, TFile *outroot, ROOT::RDF::RInterface<ROOT::Detail::RDF::RJittedFilter, void> frame, std::string method, std::string binvar, int nbins, double *bins, double pol, std::vector<std::string> depolvars, std::string workspace_name = "w", std::string workspace_title = "workspace", std::string dataset_name = "dataset", std::string dataset_title = "dataset", std::string helicity = "heli", std::string fitvarx = "x", double xmin = 0.0, double xmax = 1.0, std::string massvar = "mass_ppim", double mmin = 1.08, double mmax = 1.24, std::string sgYield_name = "sgYield", std::string bgYield_name = "bgYield", std::string model_name = "model", std::string fitformula = "[0]*sin(x)+[1]*sin(2*x)", int nparams = 2, std::vector<double> params = std::vector<double>(5), std::string fitvarxtitle = "#phi_{h p#pi^{-}}", bool use_sumW2Error = true, bool use_splot = true, std::string graph_title = "BSA A_{LU} vs. #Delta#phi", int marker_color = 4, int marker_style = 20, std::ostream &out = std::cout)
Loop kinematic bins and fit a 1D asymmetry.
Loop bins and compute an asymmetry using an unbinned maximum likelihood fit. Optionally apply an invariant mass fit and background correction using the sPlot method from arXiv:physics/0402083. Note that the asymmetry fit formula \( A(x, a_0, a_1, a_2, ...) \) will be converted internally to a PDF of the form
\[ PDF(h, x, a_0, a_1, a_2,...) = 1 + h \cdot P \cdot A(x, a_0, a_1, a_2, ...) \]The variable names should be replaced in the fit formula by
helicity\(\rightarrow\)[0],x\(\rightarrow\)[1],a_0\(\rightarrow\)[2], etc.- Parameters:
outdir – Name of output directory
outroot – Name of output ROOT file
frame – ROOT RDataFrame
method – Asymmetry fit method
binvar – Kinematic binning variable
nbins – Number of kinematic variable bins
bins – List of bin limits, which must have dimension nbins+1
pol – Luminosity averaged beam polarization
depolvars – List of depolarization variables (up to 5)
workspace_name – Name of workspace in which to work
workspace_title – Title of workspace in which to work
dataset_name – Dataset name
dataset_title – Dataset title
helicity – Name of helicity variable
fitvarx – Name of fit variable
xmin – Minimum bound for fit variable
xmax – Maximum bound for fit variable
massvar – Invariant mass variable name
mmin – Minimum bound for invariant mass variable
mmax – Maximum bound for invariant mass variable
sgYield_name – Signal yield variable name
bgYield_name – Background yield variable name
model_name – Full PDF name
fitformula – The asymmetry formula
nparams – Number of parameters in the asymmetry formula (up to 5)
params – List of initial values for asymmetry parameters
fitvarxtitle – Title of fit variable
use_sumW2Error – Option to use RooFit::SumW2Error(true) option when fitting to dataset which is necessary if using a weighted dataset
use_splot – Option to use sPlot method and perform fit with sWeighted dataset
graph_title – Title of kinematically binned graph of asymmetry parameters
marker_color – Graph ROOT marker color
marker_style – Graph ROOT marker style
out – Output stream
-
void getKinBinnedAsym1D(std::string outdir, TFile *outroot, ROOT::RDF::RInterface<ROOT::Detail::RDF::RJittedFilter, void> frame, std::string method, std::string binvar, int nbins, double *bins, double pol, std::vector<std::string> depolvars, std::string workspace_name = "w", std::string workspace_title = "workspace", std::string dataset_name = "dataset", std::string dataset_title = "dataset", std::string helicity = "heli", std::string fitvarx = "x", double xmin = 0.0, double xmax = 1.0, std::string massvar = "mass_ppim", double mass_min = 1.08, double mass_max = 1.24, std::string sgYield_name = "sgYield", std::string bgYield_name = "bgYield", std::string model_name = "model", std::string fitformula = "[0]*sin(x)+[1]*sin(2*x)", int nparams = 2, std::vector<double> params = std::vector<double>(5), std::string fitvarxtitle = "#phi_{h p#pi^{-}}", bool use_sumW2Error = true, bool use_splot = true, std::string graph_title = "BSA A_{LU} vs. #Delta#phi", int marker_color = 4, int marker_style = 20, std::ostream &out = std::cout, std::string sgcut = "Q2>1", std::string bgcut = "Q2>1", int mass_nbins_hist = 100, int mass_nbins_conv = 1000, std::string sig_pdf_name = "cb", double sg_region_min = 1.11, double sg_region_max = 1.13, bool use_sb_subtraction = false)
Loop kinematic bins and fit a 1D asymmetry, correcting for background with sideband subtraction or sPlots.
Loop bins and compute an asymmetry using an unbinned maximum likelihood fit. Optionally apply an invariant mass fit and background correction using the sPlot method from arXiv:physics/0402083. or the sideband subtraction method.Note that the asymmetry fit formula \( A(x, a_0, a_1, a_2, ...) \) will be converted internally to a PDF of the form
\[ PDF(h, x, a_0, a_1, a_2,...) = 1 + h \cdot P \cdot A(x, a_0, a_1, a_2, ...) \]The variable names should be replaced in the fit formula by
h\(\rightarrow\)[0],x\(\rightarrow\)[1],a_0\(\rightarrow\)[2], etc.- Parameters:
outdir – Name of output directory
outroot – Name of output ROOT file
frame – ROOT RDataframe from which to create RooFit datasets
method – Asymmetry fit method
binvar – Kinematic binning variable
nbins – Number of kinematic variable bins
bins – List of bin limits, which must have dimension nbins+1
pol – Luminosity averaged beam polarization
depolvars – List of depolarization variables (up to 5)
workspace_name – Name of workspace in which to work
workspace_title – Title of workspace in which to work
dataset_name – Dataset name
dataset_title – Dataset title
helicity – Name of helicity variable
fitvarx – Name of fit variable
xmin – Minimum bound for fit variable
xmax – Maximum bound for fit variable
massvar – Invariant mass variable name
mass_min – Minimum bound for invariant mass variable
mass_max – Maximum bound for invariant mass variable
sgYield_name – Signal yield variable name
bgYield_name – Background yield variable name
model_name – Full PDF name
fitformula – The asymmetry formula
nparams – Number of parameters in the asymmetry formula (up to 5)
params – List of initial values for asymmetry parameters
fitvarxtitle – Title of fit variable
use_sumW2Error – Option to use RooFit::SumW2Error() option when fitting to dataset which is necessary if using a weighted dataset
use_splot – Option to use sPlot method and perform fit with sWeighted dataset
graph_title – Title of kinematically binned graph of asymmetry parameters
marker_color – Graph ROOT marker color
marker_style – Graph ROOT style color
out – Output stream
sgcut – Signal region cut for sideband subtraction background correction
bgcut – Signal region cut for sideband subtraction background correction
mass_nbins_hist – Number of bins for the invariant mass histogram
mass_nbins_conv – Number of invariant mass bins for convolution of PDFs
sig_pdf_name – Signal PDF name
sg_region_min – Invariant mass signal region lower bound
sg_region_max – Invariant mass signal region upper bound
use_sb_subtraction – Option to use sideband subtraction for background correction
-
void createDataset2D(ROOT::RDF::RInterface<ROOT::Detail::RDF::RJittedFilter, void> frame, RooWorkspace *w, std::string name, std::string title, std::string helicity, std::string fitvarx, double xmin, double xmax, std::string fitvary, double ymin, double ymax, std::string massvar, double mmin, double mmax, std::vector<std::string> binvars, std::vector<std::vector<double>> binvarlims, std::vector<std::string> depolvars, std::vector<std::vector<double>> depolvarlims)
Create a dataset for a 2D fit.
Create a RooFit dataset for use with an invariant mass signal fit and an asymmetry fit, adding helicity, fit, mass, binning, and depolarization variables.
- Parameters:
frame – ROOT RDataframe from which to create a RooDataSet
w – RooWorkspace in which to work
name – Dataset name
title – Dataset title
helicity – Name of helicity variable
fitvarx – Name of fit variable
xmin – Minimum bound for fit variable 1
xmax – Maximum bound for fit variable 1
fitvary – Name of fit variable 2
ymin – Minimum bound for fit variable 2
ymax – Maximum bound for fit variable 2
massvar – Invariant mass variable name
mmin – Minimum bound for invariant mass variable
mmax – Maximum bound for invariant mass variable
binvars – List of kinematic binning variables (up to 4)
binvarlims – List of minimum and maximum bounds for each kinematic binning variable
depolvars – List of depolarization variables (up to 5)
depolvarlims – List of minimum and maximum bounds for each depolarization variable
-
TArrayF *getKinBinAsymUBML2D(std::string outdir, TFile *outroot, ROOT::RDF::RInterface<ROOT::Detail::RDF::RJittedFilter, void> frame, RooWorkspace *w, std::string dataset_name, std::vector<std::string> binvars, std::vector<std::vector<double>> binvarlims, std::string bincut, std::string bintitle, double pol, std::vector<std::string> depolvars, std::vector<std::vector<double>> depolvarlims, std::string helicity = "heli", std::string fitformula = "[0]*sin(x)+[1]*sin(2*x)", int nparams = 2, std::vector<double> params = std::vector<double>(5), std::string fitvarx = "phi_h", std::string fitvarxtitle = "#phi_{h p#pi^{-}}", double xmin = 0.0, double xmax = 2 * TMath::Pi(), std::string fitvary = "phi_h", std::string fitvarytitle = "#phi_{h p#pi^{-}}", double ymin = 0.0, double ymax = 2 * TMath::Pi(), bool use_sumW2Error = true, std::ostream &out = std::cout)
Compute an asymmetry using an unbinned maximum likelihood fit with 2 fit variables.
Compute the bin count, bin variable values and errors, depolarization variable values and errors, and fit parameter values and errors using an unbinned maximum likelihood fit and an asymmetry fit. Note that the given asymmetry formula \( A(x, y, a_0, a_1, a_2, ...) \) will be converted internally to a PDF of the form
\[ PDF(h, x, y, a_0, a_1, a_2,...) = 1 + h \cdot P \cdot A(x, y, a_0, a_1, a_2, ...) \]The variable names should be replaced in the fit formula by
helicity\(\rightarrow\)[0],x\(\rightarrow\)[1],y\(\rightarrow\)[2],a_0\(\rightarrow\)[3], etc.- Parameters:
outdir – Name of output directory
outroot – Name of output ROOT file
frame – ROOT RDataframe from which to create a RooDataSet
w – RooWorkspace in which to work
dataset_name – Dataset name
binvars – List of kinematic binning variables
binvarlims – List of minimum and maximum bounds for each kinematic binning variable
bincut – Kinematic variable cut for bin
bintitle – Bin title
pol – Luminosity averaged beam polarization
depolvars – List of depolarization variables (up to 5)
depolvarlims – List of minimum and maximum bounds for each depolarization variable
helicity – Name of helicity variable
fitformula – The asymmetry formula
nparams – Number of parameters in the asymmetry formula (up to 5)
params – List of initial values for asymmetry parameters
fitvarx – Name of fit variable 1
fitvarxtitle – Title of fit variable 1
xmin – Minimum bound for fit variable 1
xmax – Maximum bound for fit variable 1
fitvary – Name of fit variable 2
fitvarytitle – Title of fit variable 2
ymin – Minimum bound for fit variable 2
ymax – Maximum bound for fit variable 2
use_sumW2Error – Option to use RooFit::SumW2Error(true) option when fitting to dataset which is necessary if using a weighted dataset
out – Output stream
- Returns:
List of bin count, bin variable means and errors, depolarization variable means and errors, fit parameters and errors
-
void getKinBinnedAsymUBML2D(std::string outdir, TFile *outroot, ROOT::RDF::RInterface<ROOT::Detail::RDF::RJittedFilter, void> frame, std::string method, std::string binvar, int nbins, double *bins, double pol, std::vector<std::string> depolvars, std::string workspace_name = "w", std::string workspace_title = "workspace", std::string dataset_name = "dataset", std::string dataset_title = "dataset", std::string helicity = "heli", std::string fitvarx = "x", double xmin = 0.0, double xmax = 1.0, std::string fitvary = "y", double ymin = 0.0, double ymax = 1.0, std::string massvar = "mass_ppim", double mmin = 1.08, double mmax = 1.24, std::string sgYield_name = "sgYield", std::string bgYield_name = "bgYield", std::string model_name = "model", std::string fitformula = "[0]*sin(x)+[1]*sin(2*x)", int nparams = 2, std::vector<double> params = std::vector<double>(5), std::string fitvarxtitle = "x", std::string fitvarytitle = "y", bool use_sumW2Error = true, bool use_splot = true, std::string graph_title = "BSA A_{LU} vs. #Delta#phi", int marker_color = 4, int marker_style = 20, std::ostream &out = std::cout)
Loop kinematic bins and fit a 2D asymmetry.
Loop bins and compute an asymmetry using an unbinned maximum likelihood fit. Optionally apply an invariant mass fit and background correction using the sPlot method from arXiv:physics/0402083. Note that the given asymmetry formula \( A(x, y, a_0, a_1, a_2, ...) \) will be converted internally to a PDF of the form
\[ PDF(h, x, y, a_0, a_1, a_2,...) = 1 + h \cdot P \cdot A(x, y, a_0, a_1, a_2, ...) \]The variable names should be replaced in the fit formula by
helicity\(\rightarrow\)[0],x\(\rightarrow\)[1],y\(\rightarrow\)[2],a_0\(\rightarrow\)[3], etc.- Parameters:
outdir – Name of output directory
outroot – Name of output ROOT file
frame – ROOT RDataFrame
method – Asymmetry fit method
binvar – Kinematic binning variable
nbins – Number of kinematic variable bins
bins – List of bin limits, which must have dimension nbins+1
pol – Luminosity averaged beam polarization
depolvars – List of depolarization variables (up to 5)
workspace_name – Name of workspace in which to work
workspace_title – Title of workspace in which to work
dataset_name – Dataset name
dataset_title – Dataset title
helicity – Name of helicity variable
fitvarx – Name of fit variable 1
xmin – Minimum bound for fit variable 1
xmax – Maximum bound for fit variable 1
fitvary – Name of fit variable 2
ymin – Minimum bound for fit variable 2
ymax – Maximum bound for fit variable 2
massvar – Invariant mass variable name
mmin – Minimum bound for invariant mass variable
mmax – Maximum bound for invariant mass variable
sgYield_name – Signal yield variable name
bgYield_name – Background yield variable name
model_name – Full PDF name
fitformula – The asymmetry formula
nparams – Number of parameters in the asymmetry formula (up to 5)
params – List of initial values for asymmetry parameters
fitvarxtitle – Title of fit variable 1
fitvarytitle – Title of fit variable 2
use_sumW2Error – Option to use RooFit::SumW2Error(true) option when fitting to dataset which is necessary if using a weighted dataset
use_splot – Option to use sPlot method and perform fit with sWeighted dataset
graph_title – Title of kinematically binned graph of asymmetry parameters
marker_color – Graph ROOT marker color
marker_style – Graph ROOT marker style
out – Output stream
-
void createDataset1D(ROOT::RDF::RInterface<ROOT::Detail::RDF::RJittedFilter, void> frame, RooWorkspace *w, std::string name, std::string title, std::string helicity, std::string fitvarx, double xmin, double xmax, std::string massvar, double mmin, double mmax, std::vector<std::string> binvars, std::vector<std::vector<double>> binvarlims, std::vector<std::string> depolvars, std::vector<std::vector<double>> depolvarlims)