BAT
0.9.4
The Bayesian analysis toolkit
|
A class for fitting several templates to a data set. More...
#include <BCMTF.h>
Public Member Functions | |
Constructors and destructors | |
BCMTF () | |
BCMTF (const char *name) | |
~BCMTF () | |
Member functions (get) | |
int | GetNChannels () |
int | GetNProcesses () |
int | GetNSystematics () |
int | GetChannelIndex (const char *name) |
int | GetProcessIndex (const char *name) |
int | GetSystematicIndex (const char *name) |
int | GetParIndexProcess (int index) |
int | GetParIndexSystematic (int index) |
BCMTFChannel * | GetChannel (int index) |
BCMTFProcess * | GetProcess (int index) |
BCMTFSystematic * | GetSystematic (int index) |
Member functions (set) | |
int | SetData (const char *channelname, TH1D hist, double minimum=-1, double maximum=-1) |
int | SetTemplate (const char *channelname, const char *processname, TH1D hist, double efficiency=1., double norm=1.) |
int | SetTemplate (const char *channelname, const char *processname, std::vector< TF1 * > *funccont, int nbins, double efficiency=1.) |
void | SetExpectationFunction (int parindex, TF1 *func) |
int | SetSystematicVariation (const char *channelname, const char *processname, const char *systematicname, double variation_up, double variation_down) |
int | SetSystematicVariation (const char *channelname, const char *processname, const char *systematicname, TH1D hist_up, TH1D hist_down) |
int | SetSystematicVariation (const char *channelname, const char *processname, const char *systematicname, TH1D hist, TH1D hist_up, TH1D hist_down) |
void | SetFlagEfficiencyConstraint (bool flag) |
Member functions (miscellaneous methods) | |
int | AddChannel (const char *name) |
int | AddProcess (const char *name, double nmin=0., double nmax=1., int color=-1, int fillstyle=-1, int linestyle=-1) |
int | AddSystematic (const char *name, double min=-5., double max=5.) |
double | Expectation (int channelindex, int binindex, const std::vector< double > ¶meters) |
double | ExpectationFunction (int parindex, int channelindex, int processindex, const std::vector< double > ¶meters) |
double | Efficiency (int channelindex, int processindex, int binindex, const std::vector< double > ¶meters) |
double | Probability (int channelindex, int processindex, int binindex, const std::vector< double > ¶meters) |
double | CalculateChi2 (int channelindex, const std::vector< double > ¶meters) |
double | CalculateChi2 (const std::vector< double > ¶meters) |
double | CalculateCash (int channelindex, const std::vector< double > ¶meters) |
double | CalculateCash (const std::vector< double > ¶meters) |
double | CalculatePValue (int channelindex, const std::vector< double > ¶meters) |
double | CalculatePValue (const std::vector< double > ¶meters) |
Member functions (output methods) | |
int | PrintSummary (const char *filename="summary.txt") |
int | PrintStack (int channelindex, const std::vector< double > ¶meters, const char *filename="stack.pdf", const char *options="e1b0stack") |
int | PrintStack (const char *channelname, const std::vector< double > ¶meters, const char *filename="stack.pdf", const char *options="e1b0stack") |
Member functions (overloaded from BCModel) | |
double | LogLikelihood (const std::vector< double > ¶meters) |
void | MCMCUserIterationInterface () |
![]() | |
BCModel (const char *name="model") | |
BCModel (const BCModel &bcmodel) | |
virtual | ~BCModel () |
BCModel & | operator= (const BCModel &bcmodel) |
const std::string & | GetName () const |
double | GetModelAPrioriProbability () const |
double | GetModelAPosterioriProbability () const |
BCDataSet * | GetDataSet () const |
BCDataPoint * | GetDataPointLowerBoundaries () const |
BCDataPoint * | GetDataPointUpperBoundaries () const |
double | GetDataPointLowerBoundary (unsigned int index) const |
double | GetDataPointUpperBoundary (unsigned int index) const |
bool | GetFlagBoundaries () const |
unsigned | GetNDataPoints () const |
BCDataPoint * | GetDataPoint (unsigned int index) const |
void | SetName (const char *name) |
void | SetModelAPrioriProbability (double probability) |
void | SetModelAPosterioriProbability (double probability) |
virtual int | AddParameter (BCParameter *parameter) |
void | SetDataSet (BCDataSet *dataset) |
void | SetSingleDataPoint (BCDataPoint *datapoint) |
void | SetSingleDataPoint (BCDataSet *dataset, unsigned int index) |
void | SetDataBoundaries (unsigned int index, double lowerboundary, double upperboundary, bool fixed=false) |
void | SetDataPointLowerBoundaries (BCDataPoint *datasetlowerboundaries) |
void | SetDataPointUpperBoundaries (BCDataPoint *datasetupperboundaries) |
void | SetDataPointLowerBoundary (int index, double lowerboundary) |
void | SetDataPointUpperBoundary (int index, double upperboundary) |
int | SetPrior (int index, TF1 *f) |
int | SetPrior (const char *name, TF1 *f) |
int | SetPriorDelta (int index, double value) |
int | SetPriorDelta (const char *name, double value) |
int | SetPriorGauss (int index, double mean, double sigma) |
int | SetPriorGauss (const char *name, double mean, double sigma) |
int | SetPriorGauss (int index, double mean, double sigmadown, double sigmaup) |
int | SetPriorGauss (const char *name, double mean, double sigmadown, double sigmaup) |
int | SetPrior (int index, TH1 *h, bool flag=false) |
int | SetPrior (const char *name, TH1 *h, bool flag=false) |
int | SetPriorConstant (int index) |
int | SetPriorConstant (const char *name) |
int | SetPriorConstantAll () |
void | Copy (const BCModel &bcmodel) |
double | APrioriProbability (const std::vector< double > ¶meters) |
virtual double | LogAPrioriProbability (const std::vector< double > ¶meters) |
virtual double | Likelihood (const std::vector< double > ¶ms) |
double | ProbabilityNN (const std::vector< double > ¶ms) |
double | LogProbabilityNN (const std::vector< double > ¶meters) |
double | Probability (const std::vector< double > ¶meter) |
double | LogProbability (const std::vector< double > ¶meter) |
virtual double | SamplingFunction (const std::vector< double > ¶meters) |
double | Eval (const std::vector< double > ¶meters) |
virtual double | LogEval (const std::vector< double > ¶meters) |
virtual void | CorrelateDataPointValues (std::vector< double > &x) |
double | GetPvalueFromChi2 (const std::vector< double > &par, int sigma_index) |
double | GetPvalueFromKolmogorov (const std::vector< double > &par, int index) |
double | GetPvalueFromChi2NDoF (std::vector< double > par, int sigma_index) |
BCH1D * | CalculatePValue (std::vector< double > par, bool flag_histogram=false) |
double | GetPValue () |
double | GetPValueNDoF () |
double | GetChi2NDoF () |
std::vector< double > | GetChi2Runs (int dataIndex, int sigmaIndex) |
void | SetGoFNIterationsMax (int n) |
void | SetGoFNIterationsRun (int n) |
void | SetGoFNChains (int n) |
double | HessianMatrixElement (const BCParameter *parameter1, const BCParameter *parameter2, std::vector< double > point) |
void | PrintSummary () |
void | PrintResults (const char *file) |
void | PrintShortFitSummary (int chi2flag=0) |
void | PrintHessianMatrix (std::vector< double > parameters) |
virtual double | CDF (const std::vector< double > &, int, bool) |
Additional Inherited Members | |
![]() | |
std::string | fName |
double | fModelAPriori |
double | fModelAPosteriori |
BCDataSet * | fDataSet |
BCDataPoint * | fDataPointLowerBoundaries |
BCDataPoint * | fDataPointUpperBoundaries |
std::vector< bool > | fDataFixedValues |
double | fPValue |
double | fChi2NDoF |
double | fPValueNDoF |
bool | flag_discrete |
int | fGoFNIterationsMax |
int | fGoFNIterationsRun |
int | fGoFNChains |
std::vector< TNamed * > | fPriorContainer |
bool | fPriorConstantAll |
std::vector< bool > | fPriorContainerConstant |
std::vector< bool > | fPriorContainerInterpolate |
A class for fitting several templates to a data set.
BCMTF::BCMTF | ( | const char * | name | ) |
int BCMTF::AddChannel | ( | const char * | name | ) |
int BCMTF::AddProcess | ( | const char * | name, |
double | nmin = 0. , |
||
double | nmax = 1. , |
||
int | color = -1 , |
||
int | fillstyle = -1 , |
||
int | linestyle = -1 |
||
) |
Add a process and the associated BAT parameter.
name | The process name |
nmin | The minimum number of expected events (lower limit on the BAT parameter values). |
nmax | The maximum number of expected events (upper limit on the BAT parameter values). |
color | The histogram color |
fillstyle | The histogram fill style |
linestyle | The histogram line style |
int BCMTF::AddSystematic | ( | const char * | name, |
double | min = -5. , |
||
double | max = 5. |
||
) |
Add a source of systematic uncertainty and the associated BAT (nuisance) parameter.
name | The systematic uncertainty name. |
min | The lower limit on the BAT parameter values, typically -5 sigma if Gaussian constraint is used. |
max | The upper limit on the BAT parameter values, typically +5 sigma if Gaussian constraint is used. |
double BCMTF::CalculateCash | ( | int | channelindex, |
const std::vector< double > & | parameters | ||
) |
Calculate the Cash statistic for a single channel
channelindex | The channel index. |
parameters | A reference to the parameters used to calculate the Cash statistic. |
double BCMTF::CalculateCash | ( | const std::vector< double > & | parameters | ) |
Calculate the Cash statistic for all channels
parameters | A reference to the parameters used to calculate the Cash statistic. |
double BCMTF::CalculateChi2 | ( | int | channelindex, |
const std::vector< double > & | parameters | ||
) |
Calculate a chi2 for a single channel given a set of parameters.
channelindex | The channel index. |
parameters | A reference to the parameters used to calculate the chi2. |
double BCMTF::CalculateChi2 | ( | const std::vector< double > & | parameters | ) |
Calculate a chi2 for all channels together given a set of parameters.
parameters | A reference to the parameters used to calculate the chi2. |
double BCMTF::CalculatePValue | ( | int | channelindex, |
const std::vector< double > & | parameters | ||
) |
Calculates and returns the fast p-value for the total likelihood as test statistic.
channelindex | The channel index. |
parameters | A reference to the parameters for which the model expectations are computed. |
double BCMTF::CalculatePValue | ( | const std::vector< double > & | parameters | ) |
Calculates and returns the fast p-value for the total likelihood as test statistic.
parameters | A reference to the parameters for which the model expectations are computed. |
double BCMTF::Efficiency | ( | int | channelindex, |
int | processindex, | ||
int | binindex, | ||
const std::vector< double > & | parameters | ||
) |
Return the efficiency for a process in a channel and for a particular bin.
channelindex | The channel index. |
processindex | The process index. |
binindex | The bin index. |
parameters | A reference to the parameters used to calculate the efficiency. |
double BCMTF::Expectation | ( | int | channelindex, |
int | binindex, | ||
const std::vector< double > & | parameters | ||
) |
double BCMTF::ExpectationFunction | ( | int | parindex, |
int | channelindex, | ||
int | processindex, | ||
const std::vector< double > & | parameters | ||
) |
Return the function value of the expectation function for a parameter, channel and process.
parindex | The parameter index. |
channelindex | The channel index. |
processindex | The process index. |
A | reference to the parameters used to calculate the expectation. |
|
inline |
int BCMTF::GetChannelIndex | ( | const char * | name | ) |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
int BCMTF::GetProcessIndex | ( | const char * | name | ) |
|
inline |
int BCMTF::GetSystematicIndex | ( | const char * | name | ) |
|
virtual |
void BCMTF::MCMCUserIterationInterface | ( | ) |
int BCMTF::PrintStack | ( | int | channelindex, |
const std::vector< double > & | parameters, | ||
const char * | filename = "stack.pdf" , |
||
const char * | options = "e1b0stack" |
||
) |
Print the stack of templates together with the data in a particular channel. Several plot options are available:
"logx" : plot the x-axis on a log scale
"logy" : plot the y-axis on a log scale
"bw" : plot in black and white
"sum" : draw a line corresponding to the sum of all templates
"stack" : draw the templates as a stack
"e0" : do not draw error bars
"e1" : draw error bars corresponding to sqrt(n)
"b0" : draw an error band on the expectation corresponding to the central 68% probability
"b1" : draw bands showing the probability to observe a certain number of events given the expectation. The green (yellow, red) bands correspond to the central 68% (95%, 99.8%) probability
channelindex | The channel index. |
parameters | A reference to the parameters used to scale the templates. |
options | The plotting options. |
int BCMTF::PrintStack | ( | const char * | channelname, |
const std::vector< double > & | parameters, | ||
const char * | filename = "stack.pdf" , |
||
const char * | options = "e1b0stack" |
||
) |
Print the stack of templates together with the data in a particular channel.
channelname | The name of the channel. |
parameters | A reference to the parameters used to scale the templates. |
options | The plotting options. |
int BCMTF::PrintSummary | ( | const char * | filename = "summary.txt" | ) |
double BCMTF::Probability | ( | int | channelindex, |
int | processindex, | ||
int | binindex, | ||
const std::vector< double > & | parameters | ||
) |
Return the probability for a process in a channel and for a particular bin. This corresponds to the (normalized) bin content of the template.
channelindex | The channel index. |
processindex | The process index. |
binindex | The bin index. |
parameters | A reference to the parameters used to calculate the probability. |
int BCMTF::SetData | ( | const char * | channelname, |
TH1D | hist, | ||
double | minimum = -1 , |
||
double | maximum = -1 |
||
) |
Set the data histogram in a particular channel.
channelname | The name of the channel. |
hist | The TH1D histogram. |
minimum | The minimum number of expected events (used for calculation of uncertainty bands). |
maximum | The maximum number of expected events (used for calculation of uncertainty bands). |
|
inline |
Set an expectation function.
parindex | The index of the parameter |
func | The pointer to a TF1 function. |
|
inline |
int BCMTF::SetSystematicVariation | ( | const char * | channelname, |
const char * | processname, | ||
const char * | systematicname, | ||
double | variation_up, | ||
double | variation_down | ||
) |
Set the impact of a source of systematic uncertainty for a particular source of systematic uncertainty and process in a given channel. The impact is the relative deviation between the varied and the nominal template, i.e., if the variation is set to 0.05 then the efficiency is multiplied by (1+0.05*eps), where eps is the corresponding nuisance parameter.
channelname | The name of the channel. |
processname | The name of the process. |
systematicname | The name of the source of systematic uncertainty. |
variation_up | The relative shift between the up-variation and the nominal template: (up-nom)/nom. |
variation_down | The relative shift between the down-variation and the nominal template: (nom-down)/nom. |
int BCMTF::SetSystematicVariation | ( | const char * | channelname, |
const char * | processname, | ||
const char * | systematicname, | ||
TH1D | hist_up, | ||
TH1D | hist_down | ||
) |
Set the impact of a source of systematic uncertainty for a particular source of systematic uncertainty and process in a given channel. The variation depends on x and is given as a histogram.
channelname | The name of the channel. |
processname | The name of the process. |
systematicname | The name of the source of systematic uncertainty. |
hist_up | The TH1D histogram defining the relative shift between the up-variation and the nominal template: (up-nom)/nom. |
hist_down | The TH1D histogram defining the relative shift between the down-variation and the nominal template: (nom-down)/nom. |
int BCMTF::SetSystematicVariation | ( | const char * | channelname, |
const char * | processname, | ||
const char * | systematicname, | ||
TH1D | hist, | ||
TH1D | hist_up, | ||
TH1D | hist_down | ||
) |
Set the impact of a source of systematic uncertainty for a particular source of systematic uncertainty and process in a given channel. The variation depends on x. The histograms are the raw histograms after the shift and the variation wrt the nominal template will be calculated automatically.
channelname | The name of the channel. |
processname | The name of the process. |
systematicname | The name of the source of systematic uncertainty. |
hist | The histogram with the nominal template |
hist_up | The TH1D histogram after up-scaling of the systematic uncertainty. |
hist_down | The TH1D histogram after down-scaling of the systematic uncertainty. |
int BCMTF::SetTemplate | ( | const char * | channelname, |
const char * | processname, | ||
TH1D | hist, | ||
double | efficiency = 1. , |
||
double | norm = 1. |
||
) |
int BCMTF::SetTemplate | ( | const char * | channelname, |
const char * | processname, | ||
std::vector< TF1 * > * | funccont, | ||
int | nbins, | ||
double | efficiency = 1. |
||
) |
Set the template for a specific process in a particular channel. This is an alternative way to describe the number of expected events. It is used in the rare case that processes cannot be summed directly, but interference effects have to be taken into account. The expected number of events is then parametrized as a function for each bin.
channelname | The name of the channel. |
processname | The name of the process. |
funccont | A vector of pointers of TF1 functions. |
nbins | The number of bins used for the histogram. |
efficiency | The efficiency of this process in this channel. |