BayesianAnalysisToolkit  0.9.3
Private Attributes | List of all members
BCMTF Class Reference

A class for fitting several templates to a data set. More...

#include <BCMTF.h>

Inheritance diagram for BCMTF:
Inheritance graph
[legend]
Collaboration diagram for BCMTF:
Collaboration graph
[legend]

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)
 
BCMTFChannelGetChannel (int index)
 
BCMTFProcessGetProcess (int index)
 
BCMTFSystematicGetSystematic (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 > &parameters)
 
double ExpectationFunction (int parindex, int channelindex, int processindex, const std::vector< double > &parameters)
 
double Efficiency (int channelindex, int processindex, int binindex, const std::vector< double > &parameters)
 
double Probability (int channelindex, int processindex, int binindex, const std::vector< double > &parameters)
 
double CalculateChi2 (int channelindex, const std::vector< double > &parameters)
 
double CalculateChi2 (const std::vector< double > &parameters)
 
double CalculateCash (int channelindex, const std::vector< double > &parameters)
 
double CalculateCash (const std::vector< double > &parameters)
 
double CalculatePValue (int channelindex, const std::vector< double > &parameters)
 
double CalculatePValue (const std::vector< double > &parameters)
 
Member functions (output methods)
int PrintSummary (const char *filename="summary.txt")
 
int PrintStack (int channelindex, const std::vector< double > &parameters, const char *filename="stack.pdf", const char *options="e1b0stack")
 
int PrintStack (const char *channelname, const std::vector< double > &parameters, const char *filename="stack.pdf", const char *options="e1b0stack")
 
Member functions (overloaded from BCModel)
double LogLikelihood (const std::vector< double > &parameters)
 
void MCMCUserIterationInterface ()
 
- Public Member Functions inherited from BCModel
 BCModel (const char *name="model")
 
 BCModel (const BCModel &bcmodel)
 
virtual ~BCModel ()
 
BCModeloperator= (const BCModel &bcmodel)
 
const std::string & GetName () const
 
double GetModelAPrioriProbability () const
 
double GetModelAPosterioriProbability () const
 
BCDataSetGetDataSet () const
 
BCDataPointGetDataPointLowerBoundaries () const
 
BCDataPointGetDataPointUpperBoundaries () const
 
double GetDataPointLowerBoundary (unsigned int index) const
 
double GetDataPointUpperBoundary (unsigned int index) const
 
bool GetFlagBoundaries () const
 
unsigned GetNDataPoints () const
 
BCDataPointGetDataPoint (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 > &parameters)
 
virtual double LogAPrioriProbability (const std::vector< double > &parameters)
 
virtual double Likelihood (const std::vector< double > &params)
 
double ProbabilityNN (const std::vector< double > &params)
 
double LogProbabilityNN (const std::vector< double > &parameters)
 
double Probability (const std::vector< double > &parameter)
 
double LogProbability (const std::vector< double > &parameter)
 
virtual double SamplingFunction (const std::vector< double > &parameters)
 
double Eval (const std::vector< double > &parameters)
 
virtual double LogEval (const std::vector< double > &parameters)
 
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)
 
BCH1DCalculatePValue (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)
 
- Public Member Functions inherited from BCIntegrate
 BCIntegrate ()
 
 BCIntegrate (const BCIntegrate &bcintegrate)
 
virtual ~BCIntegrate ()
 
BCIntegrateoperator= (const BCIntegrate &bcintegrate)
 
int ReadMarginalizedFromFile (const char *file)
 
BCH1DGetMarginalized (const BCParameter *parameter)
 
BCH1DGetMarginalized (const char *name)
 
BCH1DGetMarginalized (unsigned index)
 
BCH2DGetMarginalized (const BCParameter *parameter1, const BCParameter *parameter2)
 
BCH2DGetMarginalized (const char *name1, const char *name2)
 
BCH2DGetMarginalized (unsigned index1, unsigned index2)
 
int PrintAllMarginalized1D (const char *filebase)
 
int PrintAllMarginalized2D (const char *filebase)
 
int PrintAllMarginalized (const char *file, std::string options1d="BTsiB3CS1D0pdf0Lmeanmode", std::string options2d="BTfB3CS1meangmode", unsigned int hdiv=1, unsigned int ndiv=1)
 
double GetIntegral () const
 
BCIntegrate::BCOptimizationMethod GetOptimizationMethod () const
 
BCIntegrate::BCIntegrationMethod GetIntegrationMethod () const
 
BCIntegrate::BCMarginalizationMethod GetMarginalizationMethod () const
 
BCIntegrate::BCSASchedule GetSASchedule () const
 
void GetRandomVectorUnitHypercube (std::vector< double > &x) const
 
void GetRandomVectorInParameterSpace (std::vector< double > &x) const
 
double GetRandomPoint (std::vector< double > &x)
 
int GetNIterationsMin () const
 
int GetNIterationsMax () const
 
int GetNIterationsPrecisionCheck () const
 
int GetNIterationsOutput () const
 
int GetNIterations () const
 
double GetRelativePrecision () const
 
double GetAbsolutePrecision () const
 
BCCubaMethod GetCubaIntegrationMethod () const
 
const BCCubaOptions::VegasGetCubaVegasOptions () const
 
const BCCubaOptions::SuaveGetCubaSuaveOptions () const
 
const BCCubaOptions::DivonneGetCubaDivonneOptions () const
 
const BCCubaOptions::CuhreGetCubaCuhreOptions () const
 
BCH1DGetSlice (const BCParameter *parameter, const std::vector< double > parameters=std::vector< double >(0), int bins=0, bool flag_norm=true)
 
BCH1DGetSlice (const char *name, const std::vector< double > parameters=std::vector< double >(0), int nbins=0, bool flag_norm=true)
 
BCH2DGetSlice (const BCParameter *parameter1, const BCParameter *parameter2, const std::vector< double > parameters=std::vector< double >(0), int bins=0, bool flag_norm=true)
 
BCH2DGetSlice (const char *name1, const char *name2, const std::vector< double > parameters=std::vector< double >(0), int nbins=0, bool flag_norm=true)
 
BCH2DGetSlice (unsigned index1, unsigned index2, const std::vector< double > parameters=std::vector< double >(0), int nbins=0, bool flag_norm=true)
 
double GetError () const
 
TMinuit * GetMinuit ()
 
int GetMinuitErrorFlag () const
 
double GetSAT0 () const
 
double GetSATmin () const
 
double GetBestFitParameter (unsigned index) const
 
double GetBestFitParameterError (unsigned index) const
 
double GetLogMaximum ()
 
const std::vector< double > & GetBestFitParameters () const
 
const std::vector< double > & GetBestFitParameterErrors () const
 
void SetMinuitArlist (double *arglist)
 
void SetFlagIgnorePrevOptimization (bool flag)
 
void SetOptimizationMethod (BCIntegrate::BCOptimizationMethod method)
 
void SetIntegrationMethod (BCIntegrate::BCIntegrationMethod method)
 
void SetMarginalizationMethod (BCIntegrate::BCMarginalizationMethod method)
 
void SetSASchedule (BCIntegrate::BCSASchedule schedule)
 
void SetNIterationsMin (int niterations)
 
void SetNIterationsMax (int niterations)
 
void SetNIterationsPrecisionCheck (int niterations)
 
void SetNIterationsOutput (int niterations)
 
void SetRelativePrecision (double relprecision)
 
void SetAbsolutePrecision (double absprecision)
 
void SetCubaIntegrationMethod (BCCubaMethod type)
 
void SetCubaOptions (const BCCubaOptions::Vegas &options)
 
void SetCubaOptions (const BCCubaOptions::Suave &options)
 
void SetCubaOptions (const BCCubaOptions::Divonne &options)
 
void SetCubaOptions (const BCCubaOptions::Cuhre &options)
 
void SetSAT0 (double T0)
 
void SetSATmin (double Tmin)
 
void SetFlagWriteSAToFile (bool flag)
 
TTree * GetSATree ()
 
void InitializeSATree ()
 
double Normalize ()
 
double Integrate (BCIntegrationMethod intmethod)
 
double Integrate ()
 
double Integrate (BCIntegrationMethod type, tRandomizer randomizer, tEvaluator evaluator, tIntegralUpdater updater, std::vector< double > &sums)
 
double EvaluatorMC (std::vector< double > &sums, const std::vector< double > &point, bool &accepted)
 
int MarginalizeAll ()
 
int MarginalizeAll (BCMarginalizationMethod margmethod)
 
virtual void MarginalizePreprocess ()
 
virtual void MarginalizePostprocess ()
 
void SAInitialize ()
 
std::vector< double > FindMode (std::vector< double > start=std::vector< double >())
 
std::vector< double > FindMode (BCIntegrate::BCOptimizationMethod optmethod, std::vector< double > start=std::vector< double >())
 
double SATemperature (double t)
 
double SATemperatureBoltzmann (double t)
 
double SATemperatureCauchy (double t)
 
virtual double SATemperatureCustom (double t)
 
std::vector< double > GetProposalPointSA (const std::vector< double > &x, int t)
 
std::vector< double > GetProposalPointSABoltzmann (const std::vector< double > &x, int t)
 
std::vector< double > GetProposalPointSACauchy (const std::vector< double > &x, int t)
 
virtual std::vector< double > GetProposalPointSACustom (const std::vector< double > &x, int t)
 
std::vector< double > SAHelperGetRandomPointOnHypersphere ()
 
double SAHelperGetRadialCauchy ()
 
double SAHelperSinusToNIntegral (int dim, double theta)
 
virtual void ResetResults ()
 
std::string DumpIntegrationMethod (BCIntegrationMethod type)
 
std::string DumpCurrentIntegrationMethod ()
 
std::string DumpUsedIntegrationMethod ()
 
std::string DumpMarginalizationMethod (BCMarginalizationMethod type)
 
std::string DumpCurrentMarginalizationMethod ()
 
std::string DumpUsedMarginalizationMethod ()
 
std::string DumpOptimizationMethod (BCOptimizationMethod type)
 
std::string DumpCurrentOptimizationMethod ()
 
std::string DumpUsedOptimizationMethod ()
 
std::string DumpCubaIntegrationMethod (BCCubaMethod type)
 
std::string DumpCubaIntegrationMethod ()
 
void SetBestFitParameters (const std::vector< double > &x)
 
void SetBestFitParameters (const std::vector< double > &x, const double &new_value, double &old_value)
 
unsigned GetNIntegrationVariables ()
 
double CalculateIntegrationVolume ()
 
bool CheckMarginalizationAvailability (BCMarginalizationMethod type)
 
bool CheckMarginalizationIndices (TH1 *hist, const std::vector< unsigned > &index)
 
- Public Member Functions inherited from BCEngineMCMC
void WriteMarkovChain (bool flag)
 
 BCEngineMCMC ()
 
 BCEngineMCMC (const BCEngineMCMC &enginemcmc)
 
virtual ~BCEngineMCMC ()
 
BCEngineMCMCoperator= (const BCEngineMCMC &engineMCMC)
 
unsigned MCMCGetNChains () const
 
unsigned MCMCGetNLag () const
 
const std::vector< unsigned > & MCMCGetNIterations () const
 
unsigned MCMCGetCurrentIteration () const
 
unsigned MCMCGetCurrentChain () const
 
unsigned MCMCGetNIterationsConvergenceGlobal () const
 
bool MCMCGetFlagConvergenceGlobal () const
 
unsigned MCMCGetNIterationsMax () const
 
unsigned MCMCGetNIterationsRun () const
 
unsigned MCMCGetNIterationsPreRunMin () const
 
unsigned MCMCGetNIterationsUpdate () const
 
unsigned MCMCGetNIterationsUpdateMax () const
 
std::vector< int > MCMCGetNTrialsTrue () const
 
int MCMCGetNTrials () const
 
const std::vector< double > & MCMCGetprobMean () const
 
const std::vector< double > & MCMCGetVariance () const
 
const std::vector< double > & MCMCGetTrialFunctionScaleFactor () const
 
std::vector< double > MCMCGetTrialFunctionScaleFactor (unsigned ichain) const
 
double MCMCGetTrialFunctionScaleFactor (unsigned ichain, unsigned ipar)
 
const std::vector< double > & MCMCGetx () const
 
std::vector< double > MCMCGetx (unsigned ichain)
 
double MCMCGetx (unsigned ichain, unsigned ipar) const
 
const std::vector< double > & MCMCGetLogProbx () const
 
double MCMCGetLogProbx (unsigned ichain)
 
int MCMCGetPhase () const
 
const std::vector< double > & MCMCGetMaximumPoints () const
 
std::vector< double > MCMCGetMaximumPoint (unsigned i) const
 
const std::vector< double > & MCMCGetMaximumLogProb () const
 
int MCMCGetFlagInitialPosition () const
 
double MCMCGetRValueCriterion () const
 
double MCMCGetRValueParametersCriterion () const
 
double MCMCGetRValue () const
 
double MCMCGetRValueParameters (unsigned i)
 
bool MCMCGetRValueStrict () const
 
bool MCMCGetFlagRun () const
 
TTree * MCMCGetMarkovChainTree (unsigned i)
 
BCH1DMCMCGetH1Marginalized (unsigned i)
 
BCH2DMCMCGetH2Marginalized (unsigned i, unsigned j)
 
BCParameterGetParameter (int index) const
 
BCParameterGetParameter (const char *name) const
 
unsigned int GetNParameters () const
 
unsigned int GetNFixedParameters ()
 
unsigned int GetNFreeParameters ()
 
const std::vector< double > & GetBestFitParametersMarginalized () const
 
void MCMCSetTrialFunctionScaleFactor (std::vector< double > scale)
 
void MCMCSetNChains (unsigned n)
 
void MCMCSetNLag (unsigned n)
 
void MCMCSetNIterationsMax (unsigned n)
 
void MCMCSetNIterationsRun (unsigned n)
 
void MCMCSetNIterationsPreRunMin (unsigned n)
 
void MCMCSetNIterationsUpdate (unsigned n)
 
void MCMCSetNIterationsUpdateMax (unsigned n)
 
void MCMCSetMinimumEfficiency (double efficiency)
 
void MCMCSetMaximumEfficiency (double efficiency)
 
void MCMCSetRandomSeed (unsigned seed)
 
void MCMCSetWriteChainToFile (bool flag)
 
void MCMCSetWritePreRunToFile (bool flag)
 
void MCMCSetInitialPositions (const std::vector< double > &x0s)
 
void MCMCSetInitialPositions (std::vector< std::vector< double > > x0s)
 
void MCMCSetFlagInitialPosition (int flag)
 
void MCMCSetFlagOrderParameters (bool flag)
 
void MCMCSetFlagFillHistograms (bool flag)
 
void MCMCSetFlagPreRun (bool flag)
 
void MCMCSetRValueCriterion (double r)
 
void MCMCSetRValueParametersCriterion (double r)
 
void MCMCSetRValueStrict (bool strict=true)
 
void MCMCSetMarkovChainTrees (const std::vector< TTree * > &trees)
 
void MCMCInitializeMarkovChainTrees ()
 
int SetMarginalized (unsigned index, TH1D *h)
 
int SetMarginalized (unsigned index1, unsigned index2, TH2D *h)
 
void MCMCSetValuesDefault ()
 
void MCMCSetValuesQuick ()
 
void MCMCSetValuesDetail ()
 
void MCMCSetPrecision (BCEngineMCMC::Precision precision)
 
void SetNbins (unsigned int nbins)
 
void Copy (const BCEngineMCMC &enginemcmc)
 
virtual int AddParameter (const char *name, double min, double max, const char *latexname="")
 
virtual void MCMCTrialFunction (unsigned ichain, std::vector< double > &x)
 
virtual double MCMCTrialFunctionSingle (unsigned ichain, unsigned ipar)
 
bool MCMCGetProposalPointMetropolis (unsigned chain, std::vector< double > &x)
 
bool MCMCGetProposalPointMetropolis (unsigned chain, unsigned parameter, std::vector< double > &x)
 
bool MCMCGetNewPointMetropolis (unsigned chain=0)
 
bool MCMCGetNewPointMetropolis (unsigned chain, unsigned parameter)
 
void MCMCInChainCheckMaximum ()
 
void MCMCInChainUpdateStatistics ()
 
void MCMCInChainFillHistograms ()
 
void MCMCInChainTestConvergenceAllChains ()
 
void MCMCInChainWriteChains ()
 
int MCMCMetropolis ()
 
int MCMCMetropolisPreRun ()
 
void MCMCResetRunStatistics ()
 
void MCMCInitializeMarkovChains ()
 
int MCMCInitialize ()
 
void ClearParameters (bool hard=false)
 
virtual void MCMCIterationInterface ()
 
virtual void MCMCCurrentPointInterface (std::vector< double > &, int, bool)
 

Private Attributes

std::vector< BCMTFChannel * > fChannelContainer
 
std::vector< BCMTFProcess * > fProcessContainer
 
std::vector< BCMTFSystematic * > fSystematicContainer
 
int fNChannels
 
int fNProcesses
 
int fNSystematics
 
std::vector< int > fProcessParIndexContainer
 
std::vector< int > fSystematicParIndexContainer
 
bool fFlagEfficiencyConstraint
 
std::vector< TF1 * > fExpectationFunctionContainer
 

Additional Inherited Members

- Public Types inherited from BCIntegrate
enum  BCOptimizationMethod {
  kOptEmpty, kOptSimAnn, kOptMetropolis, kOptMinuit,
  kOptDefault, NOptMethods
}
 
enum  BCIntegrationMethod {
  kIntEmpty, kIntMonteCarlo, kIntCuba, kIntGrid,
  kIntDefault, NIntMethods
}
 
enum  BCMarginalizationMethod {
  kMargEmpty, kMargMetropolis, kMargMonteCarlo, kMargGrid,
  kMargDefault, NMargMethods
}
 
enum  BCSASchedule { kSACauchy, kSABoltzmann, kSACustom, NSAMethods }
 
enum  BCCubaMethod {
  kCubaVegas, kCubaSuave, kCubaDivonne, kCubaCuhre,
  NCubaMethods
}
 
typedef void(BCIntegrate::* tRandomizer )(std::vector< double > &) const
 
typedef double(BCIntegrate::* tEvaluator )(std::vector< double > &, const std::vector< double > &, bool &)
 
typedef void(* tIntegralUpdater )(const std::vector< double > &, const int &, double &, double &)
 
- Static Public Member Functions inherited from BCIntegrate
static void IntegralUpdaterMC (const std::vector< double > &sums, const int &nIterations, double &integral, double &absprecision)
 
static int CubaIntegrand (const int *ndim, const double xx[], const int *ncomp, double ff[], void *userdata)
 
static void FCNLikelihood (int &npar, double *grad, double &fval, double *par, int flag)
 
- Protected Member Functions inherited from BCIntegrate
unsigned IntegrationOutputFrequency () const
 
void LogOutputAtStartOfIntegration (BCIntegrationMethod type, BCCubaMethod cubatype)
 
void LogOutputAtIntegrationStatusUpdate (BCIntegrationMethod type, double integral, double absprecision, int nIterations)
 
void LogOutputAtEndOfIntegration (double integral, double absprecision, double relprecision, int nIterations)
 
void Copy (const BCIntegrate &bcintegrate)
 
- Protected Attributes inherited from BCModel
std::string fName
 
double fModelAPriori
 
double fModelAPosteriori
 
BCDataSetfDataSet
 
BCDataPointfDataPointLowerBoundaries
 
BCDataPointfDataPointUpperBoundaries
 
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
 

Detailed Description

A class for fitting several templates to a data set.

Author
Daniel Kollar
Kevin Kröninger
Version
1.1
Date
06.2012 This class can be used for fitting several template histograms to a data histogram. The templates are assumed to have no statistical uncertainty whereas the data are assumed to have Poissonian fluctuations in each bin. Several methods to judge the validity of the model are available.

Definition at line 38 of file BCMTF.h.

Constructor & Destructor Documentation

BCMTF::BCMTF ( )

The default constructor.

Definition at line 35 of file BCMTF.cxx.

36  : BCModel("Multi-template Fitter")
37  , fNChannels(0)
38  , fNProcesses(0)
39  , fNSystematics(0)
41 {}
BCMTF::BCMTF ( const char *  name)

A constructor.

Parameters
nameThe name of the model

Definition at line 44 of file BCMTF.cxx.

45  : BCModel(name)
46  , fNChannels(0)
47  , fNProcesses(0)
48  , fNSystematics(0)
50 {}
BCMTF::~BCMTF ( )

The default destructor.

Definition at line 53 of file BCMTF.cxx.

55 {
56  for (int i = 0; i < fNChannels; ++i)
57  delete fChannelContainer.at(i);
58 }

Member Function Documentation

int BCMTF::AddChannel ( const char *  name)

Add a channel

Parameters
nameThe channel name.
Returns
An error code.

Definition at line 282 of file BCMTF.cxx.

283 {
284  // check if channel exists
285  for (int i = 0; i < fNChannels; ++i) {
286  // compare names
287  if (GetChannelIndex(name) >= 0) {
288  BCLog::OutWarning("BCMultitemplateFitter::AddChannel() : Channel with this name exists already.");
289  return -1;
290  }
291  }
292 
293  // create new channel
294  BCMTFChannel * channel = new BCMTFChannel(name);
295 
296  // create new data
297  BCMTFTemplate * bctemplate = new BCMTFTemplate(channel->GetName().c_str(), "data");
298 
299  // add data
300  channel->SetData(bctemplate);
301 
302  // add process templates
303  for (int i = 0; i < fNProcesses; ++i) {
304  // get process
305  BCMTFProcess * process = GetProcess(i);
306 
307  // create new template
308  BCMTFTemplate * bctemplate = new BCMTFTemplate(name, process->GetName().c_str());
309 
310  // add template
311  channel->AddTemplate(bctemplate);
312  }
313 
314  // loop over all systematics
315  for (int i = 0; i < fNSystematics; ++i) {
316  // get systematic
317  BCMTFSystematic * systematic = GetSystematic(i);
318 
319  // create new systematic variation
320  BCMTFSystematicVariation * variation = new BCMTFSystematicVariation(name, systematic->GetName().c_str(), fNProcesses);
321 
322  // add systematic variation
323  channel->AddSystematicVariation(variation);
324  }
325 
326  // add channel
327  fChannelContainer.push_back(channel);
328 
329  // increase number of channels
330  fNChannels++;
331 
332  // no error
333  return 1;
334 }
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.

Parameters
nameThe process name
nminThe minimum number of expected events (lower limit on the BAT parameter values).
nmaxThe maximum number of expected events (upper limit on the BAT parameter values).
colorThe histogram color
fillstyleThe histogram fill style
linestyleThe histogram line style
Returns
An error code.

Definition at line 337 of file BCMTF.cxx.

338 {
339  // check if process exists
340  for (int i = 0; i < fNProcesses; ++i) {
341  // compare names
342  if (GetProcessIndex(name) >= 0) {
343  BCLog::OutWarning("BCMultitemplateFitter::AddProcess() : Process with this name exists already.");
344  return -1;
345  }
346  }
347 
348  // create new process
349  BCMTFProcess * process = new BCMTFProcess(name);
350  process->SetHistogramColor(color);
351  process->SetHistogramFillStyle(fillstyle);
352  process->SetHistogramLineStyle(linestyle);
353 
354  // add process
355  fProcessContainer.push_back(process);
356 
357  // add process templates
358  for (int i = 0; i < fNChannels; ++i) {
359  // get channel
360  BCMTFChannel * channel = GetChannel(i);
361 
362  // create new template
363  BCMTFTemplate * bctemplate = new BCMTFTemplate(channel->GetName().c_str(), name);
364 
365  // add template
366  channel->AddTemplate(bctemplate);
367 
368  // loop over all systematic
369  for (int j = 0; j < fNSystematics; ++j) {
370  // get systematic variation
371  BCMTFSystematicVariation * variation = channel->GetSystematicVariation(j);
372 
373  // add histogram
374  variation->AddHistograms(0, 0);
375  }
376  }
377 
378  // increase number of processes
379  fNProcesses++;
380 
381  // add parameter index to container
383 
384  // add parameter
385  AddParameter(name, nmin, nmax);
386 
387  // add a functional form for the expectation
388  fExpectationFunctionContainer.push_back(0);
389 
390  // no error
391  return 1;
392 }
int BCMTF::AddSystematic ( const char *  name,
double  min = -5.,
double  max = 5. 
)

Add a source of systematic uncertainty and the associated BAT (nuisance) parameter.

Parameters
nameThe systematic uncertainty name.
minThe lower limit on the BAT parameter values, typically -5 sigma if Gaussian constraint is used.
maxThe upper limit on the BAT parameter values, typically +5 sigma if Gaussian constraint is used.
Returns

Definition at line 395 of file BCMTF.cxx.

396 {
397  // check if systematic exists
398  for (int i = 0; i < fNSystematics; ++i) {
399  // compare names
400  if (GetSystematicIndex(name) >= 0) {
401  BCLog::OutWarning("BCMultitemplateFitter::AddSystematic() : Systematic with this name exists already.");
402  return -1;
403  }
404  }
405 
406  // create new systematic
407  BCMTFSystematic * systematic = new BCMTFSystematic(name);
408 
409  // add systematic
410  fSystematicContainer.push_back(systematic);
411 
412  // add systematic variations
413  for (int i = 0; i < fNChannels; ++i) {
414  // get channel
415  BCMTFChannel * channel = GetChannel(i);
416 
417  // create new systematic variation
418  BCMTFSystematicVariation * variation = new BCMTFSystematicVariation(channel->GetName().c_str(), name, fNProcesses);
419 
420  // add systematic variation
421  channel->AddSystematicVariation(variation);
422  }
423  // ...
424 
425  // increase number of systematices
426  fNSystematics++;
427 
428  // add parameter index to container
430 
431  // add parameter
432  AddParameter(name, min, max);
433 
434  // add a functional form for the expectation
435  fExpectationFunctionContainer.push_back(0);
436 
437  // no error
438  return 1;
439 }
double BCMTF::CalculateCash ( int  channelindex,
const std::vector< double > &  parameters 
)

Calculate the Cash statistic for a single channel

Parameters
channelindexThe channel index.
parametersA reference to the parameters used to calculate the Cash statistic.
Returns
The Cash statistic.
See Also
CalculateCash(const std::vector<double> & parameters)

Definition at line 1098 of file BCMTF.cxx.

1099 {
1100  if (parameters.size() == 0)
1101  return -1;
1102 
1103  double cash = 0;
1104 
1105  // get channel
1106  BCMTFChannel * channel = GetChannel(channelindex);
1107 
1108  // get data
1109  BCMTFTemplate * data = channel->GetData();
1110 
1111  // get histogram
1112  TH1D * hist = data->GetHistogram();
1113 
1114  // check if histogram exists
1115  if (hist) {
1116  // get number of bins in data
1117  int nbins = hist->GetNbinsX();
1118 
1119  // loop over all bins
1120  for (int ibin = 1; ibin <= nbins; ++ibin) {
1121  // get expectation value
1122  double expectation = Expectation(channelindex, ibin, parameters);
1123 
1124  // get observation
1125  double observation = hist->GetBinContent(ibin);
1126 
1127  // calculate Cash statistic
1128  cash += 2. * (expectation - observation);
1129 
1130  // check negative log
1131  if (observation > 0)
1132  cash += 2. * observation * log (observation/expectation);
1133  }
1134  }
1135 
1136  // return cash;
1137  return cash;
1138 
1139 }
double BCMTF::CalculateCash ( const std::vector< double > &  parameters)

Calculate the Cash statistic for all channels

Parameters
parametersA reference to the parameters used to calculate the Cash statistic.
Returns
The Cash statistic.
See Also
CalculateCash(int channelindex, const std::vector<double> & parameters)

Definition at line 1142 of file BCMTF.cxx.

1143 {
1144  if (parameters.size() == 0)
1145  return -1;
1146 
1147  double cash = 0;
1148 
1149  // get number of channels
1150  int nchannels = GetNChannels();
1151 
1152  // loop over all channels
1153  for (int i = 0; i < nchannels; ++i) {
1154  cash += CalculateCash(i, parameters);
1155  }
1156 
1157  // return cash
1158  return cash;
1159 }
double BCMTF::CalculateChi2 ( int  channelindex,
const std::vector< double > &  parameters 
)

Calculate a chi2 for a single channel given a set of parameters.

Parameters
channelindexThe channel index.
parametersA reference to the parameters used to calculate the chi2.
Returns
A chi2 value.
See Also
CalculateChi2(const std::vector<double> & parameters)

Definition at line 1039 of file BCMTF.cxx.

1040 {
1041  if (parameters.size() == 0)
1042  return -1;
1043 
1044  double chi2 = 0;
1045 
1046  // get channel
1047  BCMTFChannel * channel = GetChannel(channelindex);
1048 
1049  // get data
1050  BCMTFTemplate * data = channel->GetData();
1051 
1052  // get histogram
1053  TH1D * hist = data->GetHistogram();
1054 
1055  // check if histogram exists
1056  if (hist) {
1057  // get number of bins in data
1058  int nbins = hist->GetNbinsX();
1059 
1060  // loop over all bins
1061  for (int ibin = 1; ibin <= nbins; ++ibin) {
1062  // get expectation value
1063  double expectation = Expectation(channelindex, ibin, parameters);
1064 
1065  // get observation
1066  double observation = hist->GetBinContent(ibin);
1067 
1068  // add Poisson term
1069  chi2 += (expectation - observation) * (expectation - observation) / expectation;
1070  }
1071  }
1072 
1073  // return chi2;
1074  return chi2;
1075 }
double BCMTF::CalculateChi2 ( const std::vector< double > &  parameters)

Calculate a chi2 for all channels together given a set of parameters.

Parameters
parametersA reference to the parameters used to calculate the chi2.
Returns
A chi2 value.
See Also
CalculateChi2(int channelindex, const std::vector<double> & parameters)

Definition at line 1078 of file BCMTF.cxx.

1079 {
1080  if (parameters.size() == 0)
1081  return -1;
1082 
1083  double chi2 = 0;
1084 
1085  // get number of channels
1086  int nchannels = GetNChannels();
1087 
1088  // loop over all channels
1089  for (int i = 0; i < nchannels; ++i) {
1090  chi2 += CalculateChi2(i, parameters);
1091  }
1092 
1093  // return chi2
1094  return chi2;
1095 }
double BCMTF::CalculatePValue ( int  channelindex,
const std::vector< double > &  parameters 
)

Calculates and returns the fast p-value for the total likelihood as test statistic.

See Also
BCMath::CorrectPValue for correcting the fitting bias
Parameters
channelindexThe channel index.
parametersA reference to the parameters for which the model expectations are computed.
Returns
the uncorrected p-value

Definition at line 1162 of file BCMTF.cxx.

1163 {
1164  // get channel
1165  BCMTFChannel * channel = GetChannel(channelindex);
1166 
1167  // get data histogram
1168  TH1D * hist = channel->GetData()->GetHistogram();
1169 
1170  // check if histogram exists
1171  if (!hist) {
1172  return -1;
1173  }
1174 
1175  // get number of bins in data
1176  int nbins = hist->GetNbinsX();
1177 
1178  // copy observed and expected values
1179  std::vector<unsigned> observation(nbins);
1180  std::vector<double> expectation(nbins);
1181 
1182  // loop over all bins
1183  for (int ibin = 0; ibin < nbins; ++ibin) {
1184  // get expectation value
1185  expectation[ibin] = Expectation(channelindex, ibin + 1, parameters);
1186 
1187  // get observation
1188  observation[ibin]= unsigned(hist->GetBinContent(ibin + 1));
1189  }
1190 
1191  // create pseudo experiments
1192  static const unsigned nIterations = unsigned (1e5);
1193  return BCMath::FastPValue(observation, expectation, nIterations, fRandom->GetSeed());
1194 }
double BCMTF::CalculatePValue ( const std::vector< double > &  parameters)

Calculates and returns the fast p-value for the total likelihood as test statistic.

Note
Obtain the results with
See Also
BCModel::GetPValue and the value corrected for degrees of freedom with
BCModel::GetPValueNDoF
Parameters
parametersA reference to the parameters for which the model expectations are computed.

Definition at line 1197 of file BCMTF.cxx.

1198 {
1199 
1200  // copy observed and expected values
1201  std::vector<unsigned> observation;
1202  std::vector<double> expectation;
1203 
1204  // loop over all channels
1205  for (int ichannel = 0; ichannel < fNChannels; ++ichannel) {
1206 
1207  // get channel
1208  BCMTFChannel * channel = fChannelContainer[ichannel];
1209 
1210  // check if channel is active
1211  if (!(channel->GetFlagChannelActive()))
1212  continue;
1213 
1214  // get data histogram
1215  TH1D * hist = channel->GetData()->GetHistogram();
1216 
1217  // check if histogram exists
1218  if (!hist) {
1219  return -1;
1220  }
1221 
1222  // get number of bins in data
1223  int nbins = hist->GetNbinsX();
1224 
1225  // loop over all bins
1226  for (int ibin = 0; ibin < nbins; ++ibin) {
1227  // get expectation value
1228  expectation.push_back(Expectation(ichannel, ibin + 1, parameters));
1229 
1230  // get observation
1231  observation.push_back(unsigned(hist->GetBinContent(ibin + 1)));
1232  }
1233  }
1234 
1235  // create pseudo experiments
1236  static const unsigned nIterations = unsigned(1e5);
1237  fPValue = BCMath::FastPValue(observation, expectation, nIterations, fRandom->GetSeed());
1238  fPValueNDoF = BCMath::CorrectPValue(fPValue, parameters.size(), observation.size());
1239 
1240  return fPValue;
1241 }
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.

Parameters
channelindexThe channel index.
processindexThe process index.
binindexThe bin index.
parametersA reference to the parameters used to calculate the efficiency.
Returns
The efficiency.

Definition at line 689 of file BCMTF.cxx.

690 {
691  // get channel
692  BCMTFChannel * channel = fChannelContainer[channelindex];
693 
694  double efficiency = channel->GetTemplate(processindex)->GetEfficiency();
695 
696  double defficiency = 1.;
697 
698  // loop over all systematics
699  for (int i = 0; i < fNSystematics; ++i) {
700  if (!(fSystematicContainer[i]->GetFlagSystematicActive()))
701  continue;
702 
703  // get parameter index
704  int parindex = fSystematicParIndexContainer[i];
705 
706  // get histogram
707  TH1D * hist = 0;
708 
709  if (parameters[parindex] > 0)
710  hist = channel->GetSystematicVariation(i)->GetHistogramUp(processindex);
711  else
712  hist = channel->GetSystematicVariation(i)->GetHistogramDown(processindex);
713 
714  // check if histogram exists
715  if (!hist)
716  continue;
717 
718  // multiply efficiency
719  defficiency += parameters[parindex] * hist->GetBinContent(binindex);
720  }
721 
722  // calculate efficiency
723  efficiency *= defficiency;
724 
725  // make sure efficiency is between 0 and 1
727  if (efficiency < 0.)
728  efficiency = 0.;
729  if (efficiency > 1.)
730  efficiency = 1.;
731  }
732 
733  return efficiency;
734 }
double BCMTF::Expectation ( int  channelindex,
int  binindex,
const std::vector< double > &  parameters 
)

Return the expected number of events for a channel and bin.

Parameters
channelindexThe channel index.
binindexThe bin index.
parametersA reference to the parameters used to calculate the expectation.
Returns
The expectation value

Definition at line 642 of file BCMTF.cxx.

643 {
644  double expectation = 0.;
645 
646  // loop over all processes
647  for (int i = 0; i < fNProcesses; ++i) {
648  // get efficiency
649  double efficiency = Efficiency(channelindex, i, binindex, parameters);
650 
651  // get probability
652  double probability = Probability(channelindex, i, binindex, parameters);
653 
654  // get parameter index
655  int parindex = fProcessParIndexContainer[i];
656 
657  // add to expectation
658  expectation += ExpectationFunction(parindex, channelindex, i, parameters)
659  * efficiency
660  * probability;
661  }
662 
663  // check if expectation is positive
664  if (expectation < 0)
665  expectation = 0.;
666 
667  return expectation;
668 }
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.

Parameters
parindexThe parameter index.
channelindexThe channel index.
processindexThe process index.
Areference to the parameters used to calculate the expectation.
Returns
The expectation function value.

Definition at line 671 of file BCMTF.cxx.

672 {
673  // get function container
674  std::vector<TF1 *> * funccont = fChannelContainer[channelindex]->GetTemplate(processindex)->GetFunctionContainer();
675 
676  if (funccont->size()>0)
677  return 1.;
678 
679  else if (!fExpectationFunctionContainer[parindex])
680  return parameters[parindex];
681 
682  else {
683  TF1 * func = fExpectationFunctionContainer[parindex];
684  return func->Eval(parameters[parindex]);
685  }
686 }
BCMTFChannel* BCMTF::GetChannel ( int  index)
inline
Parameters
nameThe channel index.
Returns
The channel object.

Definition at line 108 of file BCMTF.h.

109  { return fChannelContainer.at(index); };
int BCMTF::GetChannelIndex ( const char *  name)
Parameters
nameThe name of the channel.
Returns
The channel index.

Definition at line 61 of file BCMTF.cxx.

62 {
63  // loop over all channels and compare names
64  for (int i = 0; i < fNChannels; ++i) {
65  // get channel
66  BCMTFChannel * channel = GetChannel(i);
67 
68  // compare names
69  if (!channel->GetName().compare(name))
70  return i;
71  }
72 
73  // if channel does not exist, return -1
74  return -1;
75 }
int BCMTF::GetNChannels ( )
inline
Returns
The number of channels.

Definition at line 65 of file BCMTF.h.

66  { return fNChannels; };
int BCMTF::GetNProcesses ( )
inline
Returns
The number of processes.

Definition at line 70 of file BCMTF.h.

71  { return fNProcesses; };
int BCMTF::GetNSystematics ( )
inline
Returns
The number of systematics.

Definition at line 75 of file BCMTF.h.

76  { return fNSystematics; };
int BCMTF::GetParIndexProcess ( int  index)
inline
Parameters
indexThe parameter index (mtf counting) .
Returns
The parameter number corresponding to the parameter index (BAT counting).

Definition at line 96 of file BCMTF.h.

97  { return fProcessParIndexContainer.at(index); };
int BCMTF::GetParIndexSystematic ( int  index)
inline
Parameters
nameThe systematic uncertainty index (mtf counting).
Returns
The parameter number corresponding to the systematic uncertainty (BAT counting).

Definition at line 102 of file BCMTF.h.

103  { return fSystematicParIndexContainer.at(index); };
BCMTFProcess* BCMTF::GetProcess ( int  index)
inline
Parameters
nameThe process index.
Returns
The process object.

Definition at line 114 of file BCMTF.h.

115  { return fProcessContainer.at(index); };
int BCMTF::GetProcessIndex ( const char *  name)
Parameters
nameThe name of the process.
Returns
The process index.

Definition at line 78 of file BCMTF.cxx.

79 {
80  // loop over all processs and compare names
81  for (int i = 0; i < fNProcesses; ++i) {
82  // get process
83  BCMTFProcess * process = GetProcess(i);
84 
85  // compare names
86  if (!process->GetName().compare(name))
87  return i;
88  }
89 
90  // if process does not exist, return -1
91  return -1;
92 }
BCMTFSystematic* BCMTF::GetSystematic ( int  index)
inline
Parameters
nameThe systematic ucnertainty index.
Returns
The systematic uncertainty object.

Definition at line 120 of file BCMTF.h.

121  { return fSystematicContainer.at(index); };
int BCMTF::GetSystematicIndex ( const char *  name)
Parameters
nameThe name of the systematic.
Returns
The systematic uncertainty index.

Definition at line 95 of file BCMTF.cxx.

96 {
97  // loop over all systematics and compare names
98  for (int i = 0; i < fNSystematics; ++i) {
99  // get systematic
100  BCMTFSystematic * systematic = GetSystematic(i);
101 
102  // compare names
103  if (!systematic->GetName().compare(name))
104  return i;
105  }
106 
107  // if process does not exist, return -1
108  return -1;
109 }
double BCMTF::LogLikelihood ( const std::vector< double > &  parameters)
virtual

Calculates natural logarithm of the likelihood. Method needs to be overloaded by the user.

Parameters
paramsA set of parameter values
Returns
Natural logarithm of the likelihood

Implements BCModel.

Definition at line 1244 of file BCMTF.cxx.

1245 {
1246  double logprob = 0.;
1247 
1248  // loop over all channels
1249  for (int ichannel = 0; ichannel < fNChannels; ++ichannel) {
1250 
1251  // get channel
1252  BCMTFChannel * channel = fChannelContainer[ichannel];
1253 
1254  // check if channel is active
1255  if (!(channel->GetFlagChannelActive()))
1256  continue;
1257 
1258  // get data
1259  BCMTFTemplate * data = channel->GetData();
1260 
1261  // get histogram
1262  TH1D * hist = data->GetHistogram();
1263 
1264  // check if histogram exists
1265  if (!hist)
1266  continue;
1267 
1268  // get number of bins in data
1269  int nbins = data->GetNBins();
1270 
1271  // loop over all bins
1272  for (int ibin = 1; ibin <= nbins; ++ibin) {
1273 
1274  // get expectation value
1275  double expectation = Expectation(ichannel, ibin, parameters);
1276 
1277  // get observation
1278  double observation = hist->GetBinContent(ibin);
1279 
1280  // add Poisson term
1281  logprob += BCMath::LogPoisson(observation, expectation);
1282  }
1283  }
1284 
1285  return logprob;
1286 }
void BCMTF::MCMCUserIterationInterface ( )
virtual

Method executed for every iteration of the MCMC. User's code should be provided via overloading in the derived class

Reimplemented from BCEngineMCMC.

Definition at line 1289 of file BCMTF.cxx.

1290 {
1291  // loop over all channels
1292  for (int ichannel = 0; ichannel < fNChannels; ++ichannel) {
1293 
1294  // get channel
1295  BCMTFChannel * channel = fChannelContainer[ichannel];
1296 
1297  // check if channel is active
1298  if (!(channel->GetFlagChannelActive()))
1299  continue;
1300 
1301  // get data
1302  BCMTFTemplate * data = channel->GetData();
1303 
1304  // get histogram
1305  TH1D * hist_data = data->GetHistogram();
1306 
1307  // check if histogram exists
1308  if (!hist_data)
1309  continue;
1310 
1311  // get histogram for uncertainty band
1312  TH2D* hist_uncbandexp = channel->GetHistUncertaintyBandExpectation();
1313 
1314  // check if histogram exists
1315  if (!hist_uncbandexp)
1316  continue;
1317 
1318  // get number of bins in data
1319  int nbins = hist_data->GetNbinsX();
1320 
1321  // loop over all bins
1322  for (int ibin = 1; ibin <= nbins; ++ibin) {
1323 
1324  // get expectation value
1325  double expectation = Expectation(ichannel, ibin, fMCMCx);
1326 
1327  // fill uncertainty band on expectation
1328  hist_uncbandexp->Fill(hist_data->GetBinCenter(ibin), expectation);
1329  }
1330  }
1331 
1332 }
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

Parameters
channelindexThe channel index.
parametersA reference to the parameters used to scale the templates.
optionsThe plotting options.
Returns
An error code.

Definition at line 766 of file BCMTF.cxx.

767 {
768  // todo:
769  // - add difference/ratio/significance plot below
770  // - check for b0/1 if the mcmc was run
771 
772  // check if parameters are filled
773  if (!parameters.size())
774  return -1;
775 
776  // check options
777  bool flag_logx = false; // plot x-axis in log-scale
778  bool flag_logy = false; // plot y-axis in log-scale
779  bool flag_bw = false; // plot in black and white
780 
781  bool flag_sum = false; // plot sum of all templates
782  bool flag_stack = false; // plot stack of templates
783 
784  bool flag_e0 = false; // do not draw error bars on data
785  bool flag_e1 = false; // draw sqrt(N) error bars on data
786 
787  bool flag_b0 = false; // draw an error band on the expectation
788  bool flag_b1 = false; // draw an error band on the number of events
789 
790  if (std::string(options).find("logx") < std::string(options).size())
791  flag_logx = true;
792 
793  if (std::string(options).find("logy") < std::string(options).size())
794  flag_logy = true;
795 
796  if (std::string(options).find("bw") < std::string(options).size())
797  flag_bw = true;
798 
799  if (std::string(options).find("sum") < std::string(options).size())
800  flag_sum = true;
801 
802  if (std::string(options).find("stack") < std::string(options).size())
803  flag_stack = true;
804 
805  if (std::string(options).find("e0") < std::string(options).size())
806  flag_e0 = true;
807 
808  if (std::string(options).find("e1") < std::string(options).size())
809  flag_e1 = true;
810 
811  if (std::string(options).find("b0") < std::string(options).size())
812  flag_b0 = true;
813 
814  if (std::string(options).find("b1") < std::string(options).size())
815  flag_b1 = true;
816 
817  if (!flag_e0)
818  flag_e1=true;
819 
820  // check if MCMC ran
822  flag_b0 = false;
823  flag_b1 = false;
824  BCLog::OutWarning("BCMTF::PrintStack : Did not run MCMC. Error bands are not available.");
825  }
826 
827  // get channel
828  BCMTFChannel * channel = GetChannel(channelindex);
829 
830  // create canvas
831  TCanvas * c1 = new TCanvas();
832  c1->cd();
833 
834  // set log or linear scale
835  if (flag_logx)
836  c1->SetLogx();
837 
838  if (flag_logy)
839  c1->SetLogy();
840 
841  // get data histogram
842  TH1D* hist_data = channel->GetData()->GetHistogram();
843 
844  // get number of bins
845  int nbins = hist_data->GetNbinsX();
846 
847  // define sum of templates
848  TH1D* hist_sum = new TH1D(*hist_data);
849  hist_sum->SetLineColor(kBlack);
850  for (int i = 1; i <= nbins; ++i)
851  hist_sum->SetBinContent(i, 0);
852 
853  // define error band
854  TH1D* hist_error_band = new TH1D(*hist_data);
855  hist_error_band->SetFillColor(kBlack);
856  hist_error_band->SetFillStyle(3005);
857  hist_error_band->SetLineWidth(1);
858  hist_error_band->SetStats(kFALSE);
859  hist_error_band->SetMarkerSize(0);
860 
861  TGraphAsymmErrors * graph_error_exp = new TGraphAsymmErrors(nbins);
862  // graph_error_exp->SetLineWidth(2);
863  graph_error_exp->SetMarkerStyle(0);
864  graph_error_exp->SetFillColor(kBlack);
865  graph_error_exp->SetFillStyle(3005);
866 
867  // get histogram for uncertainty band
868  TH2D* hist_uncbandexp = channel->GetHistUncertaintyBandExpectation();
869 
870  // fill error band
871  if (flag_b0) {
872  for (int i = 1; i <= nbins; ++i) {
873  TH1D * proj = hist_uncbandexp->ProjectionY("_py", i, i);
874  if (proj->Integral() > 0)
875  proj->Scale(1.0 / proj->Integral());
876  double quantiles[3];
877  double sums[3] = {0.16, 0.5, 0.84};
878  proj->GetQuantiles(3, quantiles, sums);
879  graph_error_exp->SetPoint(i-1, hist_data->GetBinCenter(i), quantiles[1]);
880  graph_error_exp->SetPointError(i-1, 0.0, 0.0, quantiles[1] - quantiles[0], quantiles[2]-quantiles[1]);
881  hist_error_band->SetBinContent(i, 0.5*(quantiles[2]+quantiles[0]));
882  hist_error_band->SetBinError(i, 0, 0.5*(quantiles[2]-quantiles[0]));
883  delete proj;
884  }
885  }
886 
887  // create stack
888  THStack * stack = new THStack("", "");
889 
890  // create a container of temporary histograms
891  std::vector<TH1D *> histcontainer;
892 
893  // get number of templates
894  unsigned int ntemplates = GetNProcesses();
895 
896  // loop over all templates
897  for (unsigned int i = 0; i < ntemplates; ++i) {
898 
899  // get histogram
900  TH1D * temphist = channel->GetTemplate(i)->GetHistogram();
901 
902  // get function container
903  std::vector<TF1 *> * funccont = channel->GetTemplate(i)->GetFunctionContainer();
904 
905  // create new histogram
906  TH1D * hist(0);
907 
908  if (temphist)
909  hist = new TH1D( *(temphist) );
910  else if (funccont)
911  hist = new TH1D( *(channel->GetData()->GetHistogram()));
912  else
913  continue;
914 
915  // set histogram style
916  int color = GetProcess(i)->GetHistogramColor();
917  if (color < 0)
918  color = 2 + i;
919  int fillstyle = GetProcess(i)->GetHistogramFillStyle();
920  if (fillstyle < 0)
921  fillstyle = 1001;
922  int linestyle = GetProcess(i)->GetHistogramLineStyle();
923  if (linestyle < 0)
924  linestyle = 1;
925 
926  // set color and fill style
927  hist->SetFillColor(color);
928  hist->SetFillStyle(fillstyle);
929  hist->SetLineStyle(linestyle);
930 
931  if (flag_bw) {
932  hist->SetFillColor(0);
933  }
934 
935  // scale histogram
936  for (int ibin = 1; ibin <= nbins; ++ibin) {
937 
938  // get efficiency
939  double efficiency = Efficiency(channelindex, i, ibin, parameters);
940 
941  // get probability
942  double probability = Probability(channelindex, i, ibin, parameters);
943 
944  // get parameter index
945  int parindex = GetParIndexProcess(i);
946 
947  // add to expectation
948  double expectation = parameters[parindex] * efficiency * probability;
949 
950  // set bin content
951  hist->SetBinContent(ibin, expectation);
952 
953  // add bin content
954  hist_sum->SetBinContent(ibin, hist_sum->GetBinContent(ibin) + expectation);
955  }
956 
957  // add histogram to container (for memory management)
958  histcontainer.push_back(hist);
959 
960  // add histogram to stack
961  stack->Add(hist);
962  }
963 
964  //draw data
965  hist_data->Draw("P0");
966 
967  // define variable for maximum in y-direction
968  double ymax = 0;;
969 
970  if (flag_e1)
971  ymax = hist_data->GetMaximum() + sqrt(hist_data->GetMaximum());
972  else
973  ymax = hist_data->GetMaximum();
974 
975  // set range user
976  hist_data->GetYaxis()->SetRangeUser(channel->GetRangeYMin(), channel->GetRangeYMax());
977 
978  // draw stack
979  if (flag_stack) {
980  stack->Draw("SAMEHIST");
981  if (stack->GetMaximum() > ymax)
982  ymax = stack->GetMaximum();
983  }
984 
985  // draw error band on number of observed events
986  if (flag_b1) {
988  TH1D* hist_temp = channel->CalculateUncertaintyBandPoisson(0.001, 0.999, kRed);
989  hist_temp->Draw("SAMEE2");
990  channel->CalculateUncertaintyBandPoisson(0.023, 0.977, kOrange)->Draw("SAMEE2");
991  channel->CalculateUncertaintyBandPoisson(0.159, 0.841, kGreen)->Draw("SAMEE2");
992 
993  // get bin with maximum
994  int ymaxbin = hist_temp->GetMaximumBin();
995 
996  if (hist_temp->GetBinContent(ymaxbin)+hist_temp->GetBinError(ymaxbin)> ymax)
997  ymax = hist_temp->GetBinContent(ymaxbin)+hist_temp->GetBinError(ymaxbin);
998  }
999 
1000  // draw error band on expectation
1001  if (flag_b0) {
1002  hist_error_band->Draw("SAMEE2");
1003  }
1004 
1005  if (flag_sum)
1006  hist_sum->Draw("SAME");
1007 
1008  //draw data again
1009  if (flag_e0)
1010  hist_data->Draw("SAMEP0");
1011 
1012  if (flag_e1)
1013  hist_data->Draw("SAMEP0E");
1014 
1015  hist_data->GetYaxis()->SetRangeUser(0., 1.1* ymax);
1016 
1017  // redraw the axes
1018  gPad->RedrawAxis();
1019 
1020  // print
1021  c1->Print(filename);
1022 
1023  // free memory
1024  for (unsigned int i = 0; i < histcontainer.size(); ++i) {
1025  TH1D * hist = histcontainer.at(i);
1026  delete hist;
1027  }
1028  delete stack;
1029  delete c1;
1030  delete graph_error_exp;
1031  delete hist_error_band;
1032  delete hist_sum;
1033 
1034  // no error
1035  return 1;
1036 }
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.

Parameters
channelnameThe name of the channel.
parametersA reference to the parameters used to scale the templates.
optionsThe plotting options.
Returns
An error code.
See Also
PrintStack(int channelindex, const std::vector<double> & parameters, const char * filename = "stack.pdf", const char * options = "e1b0stack")

Definition at line 758 of file BCMTF.cxx.

759 {
760  int index = GetChannelIndex(channelname);
761 
762  return PrintStack(index, parameters, filename, options);
763 }
int BCMTF::PrintSummary ( const char *  filename = "summary.txt")

Print a summary of the fit into an ASCII file.

Parameters
filenameThe name of the file.
Returns
An error code

Definition at line 563 of file BCMTF.cxx.

564 {
565  // open file
566  std::ofstream ofi(filename);
567  ofi.precision(3);
568 
569  // check if file is open
570  if(!ofi.is_open()) {
571  BCLog::OutWarning(Form("BCMultitemplateFitter::PrintSummary() : Could not open file %s", filename));
572  return 0;
573  }
574 
575  ofi
576  << " Multi template fitter summary " << std::endl
577  << " ----------------------------- " << std::endl
578  << std::endl
579  << " Number of channels : " << fNChannels << std::endl
580  << " Number of processes : " << fNProcesses << std::endl
581  << " Number of systematics : " << fNSystematics << std::endl
582  << std::endl;
583 
584  ofi
585  << " Channels :" << std::endl;
586  for (int i = 0; i < GetNChannels(); ++i) {
587  ofi
588  << " " << i
589  << " : \"" << GetChannel(i)->GetName().c_str() << "\""
590  << std::endl;
591  }
592  ofi
593  << std::endl;
594 
595  ofi
596  << " Processes :" << std::endl;
597  for (int i = 0; i < GetNProcesses(); ++i) {
598  ofi
599  << " " << i
600  << " : \"" << GetProcess(i)->GetName().c_str() << "\""
601  << " (par index " << GetParIndexProcess(i) << ")"
602  << std::endl;
603  }
604  ofi
605  << std::endl;
606 
607  ofi
608  << " Systematics :" << std::endl;
609  for (int i = 0; i < GetNSystematics(); ++i) {
610  ofi
611  << " " << i
612  << " : \"" << GetSystematic(i)->GetName().c_str() << "\""
613  << " (par index " << GetParIndexSystematic(i) << ")"
614  << std::endl;
615  }
616  ofi
617  << std::endl;
618  if (GetNSystematics() == 0)
619  ofi
620  << " - none - " << std::endl;
621 
622  ofi
623  << " Goodness-of-fit: " << std::endl;
624  for (int i = 0; i < GetNChannels(); ++i) {
625  ofi
626  << " i : \"" << GetChannel(i)->GetName().c_str() << "\" : chi2 = "
628  << std::endl;
629  }
630  ofi
631  << std::endl;
632 
633 
634  // close file
635  ofi.close();
636 
637  // no error
638  return 1;
639 }
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.

Parameters
channelindexThe channel index.
processindexThe process index.
binindexThe bin index.
parametersA reference to the parameters used to calculate the probability.
Returns
The probability.

Definition at line 737 of file BCMTF.cxx.

738 {
739  // get histogram
740  TH1D * hist = fChannelContainer[channelindex]->GetTemplate(processindex)->GetHistogram();
741 
742  // get function container
743  std::vector<TF1 *> * funccont = fChannelContainer[channelindex]->GetTemplate(processindex)->GetFunctionContainer();
744 
745  // this needs to be fast
746  if (!hist && !(funccont->size()>0))
747  return 0.;
748 
749  if (hist)
750  return hist->GetBinContent(binindex);
751  else {
752  int parindex = fProcessParIndexContainer[processindex];
753  return funccont->at(binindex-1)->Eval(parameters[parindex]);
754  }
755 }
int BCMTF::SetData ( const char *  channelname,
TH1D  hist,
double  minimum = -1,
double  maximum = -1 
)

Set the data histogram in a particular channel.

Parameters
channelnameThe name of the channel.
histThe TH1D histogram.
minimumThe minimum number of expected events (used for calculation of uncertainty bands).
maximumThe maximum number of expected events (used for calculation of uncertainty bands).
Returns
An error code.

Definition at line 207 of file BCMTF.cxx.

208 {
209  int channelindex = GetChannelIndex(channelname);
210 
211  // check if channel exists
212  if (channelindex < 0) {
213  BCLog::OutWarning("BCMultitemplateFitter::SetTemplate() : Channel does not exist.");
214  return -1;
215  }
216 
217  // get channel
218  BCMTFChannel * channel = GetChannel(channelindex);
219 
220  // get template
221  BCMTFTemplate * data = channel->GetData();
222 
223  // remove statistics box
224  hist.SetStats(kFALSE);
225 
226  // set marker
227  hist.SetMarkerStyle(20);
228  hist.SetMarkerSize(1.1);
229 
230  // set divisions
231  hist.SetNdivisions(509);
232 
233  // remove old data set if it exists
234  if (data->GetHistogram()) {
235  delete data->GetHistogram();
236  data->SetHistogram(0);
237  }
238 
239  // remove old uncertainty histograms if they exist
240  if (channel->GetHistUncertaintyBandExpectation()) {
241  delete channel->GetHistUncertaintyBandExpectation();
243  }
244  if (channel->GetHistUncertaintyBandPoisson()) {
245  delete channel->GetHistUncertaintyBandPoisson();
246  channel->SetHistUncertaintyBandPoisson(0);
247  }
248 
249  // create new histograms for uncertainty bands
250  // double minimum = floor(TMath::Max(0., hist.GetMinimum() - 7.*sqrt(hist.GetMinimum())));
251  if (minimum==-1)
252  minimum = 0;
253  if (maximum==-1)
254  maximum = ceil(hist.GetMaximum() + 5.*sqrt(hist.GetMaximum()));
255 
256  std::vector<double> a(hist.GetNbinsX()+1);
257  for (int i = 0; i < hist.GetNbinsX()+1; ++i) {
258  a[i] = hist.GetXaxis()->GetBinLowEdge(i+1);
259  }
260 
261  TH2D* hist_uncbandexp = new TH2D(TString::Format("UncertaintyBandExpectation_%i", BCLog::GetHIndex()), "",
262  hist.GetNbinsX(), &a[0], 1000, minimum, maximum);
263  hist_uncbandexp->SetStats(kFALSE);
264 
265  TH2D* hist_uncbandpoisson = new TH2D(TString::Format("UncertaintyBandPoisson_%i", BCLog::GetHIndex()), "",
266  hist.GetNbinsX(), &a[0], int(maximum-minimum), minimum, maximum);
267  hist_uncbandpoisson->SetStats(kFALSE);
268 
269  // set histograms
270  data->SetHistogram(new TH1D(hist), hist.Integral());
271  channel->SetHistUncertaintyBandExpectation(hist_uncbandexp);
272  channel->SetHistUncertaintyBandPoisson(hist_uncbandpoisson);
273 
274  // set y-range for printing
275  channel->SetRangeY(minimum, maximum);
276 
277  // no error
278  return 1;
279 }
void BCMTF::SetExpectationFunction ( int  parindex,
TF1 *  func 
)
inline

Set an expectation function.

Parameters
parindexThe index of the parameter
funcThe pointer to a TF1 function.
See Also
SetTemplate(const char * channelname, const char * processname, std::vector<TF1 *> * funccont, int nbins, double efficiency = 1.)

Definition at line 167 of file BCMTF.h.

168  { fExpectationFunctionContainer[parindex] = func; };
void BCMTF::SetFlagEfficiencyConstraint ( bool  flag)
inline

Set a flag for the efficiency: if true then the total efficiency including all systematic uncertainties has to be between 0 and 1 at all times. Larger (smaller) values are set to 1 (0) during the calculation.

Parameters
flagThe flag

Definition at line 222 of file BCMTF.h.

223  { fFlagEfficiencyConstraint = flag; };
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.

Parameters
channelnameThe name of the channel.
processnameThe name of the process.
systematicnameThe name of the source of systematic uncertainty.
variation_upThe relative shift between the up-variation and the nominal template: (up-nom)/nom.
variation_downThe relative shift between the down-variation and the nominal template: (nom-down)/nom.
Returns
An error code.

Definition at line 442 of file BCMTF.cxx.

443 {
444 
445  // get channel index
446  int channelindex = GetChannelIndex(channelname);
447 
448  // check if channel exists
449  if (channelindex < 0) {
450  BCLog::OutWarning("BCMultitemplateFitter::SetTemplate() : Channel does not exist.");
451  return -1;
452  }
453 
454  // get process index
455  int processindex = GetProcessIndex(processname);
456 
457  // check if process exists
458  if (processindex < 0) {
459  BCLog::OutWarning("BCMultitemplateFitter::SetTemplate() : Process does not exist.");
460  return -1;
461  }
462 
463  // get systematic index
464  int systematicindex = GetSystematicIndex(systematicname);
465 
466  // check if systematic exists
467  if (systematicindex < 0) {
468  BCLog::OutWarning("BCMultitemplateFitter::SetTemplate() : Systematic does not exist.");
469  return -1;
470  }
471 
472  // get channel
473  BCMTFChannel * channel = GetChannel(channelindex);
474 
475  BCMTFTemplate * bctemplate = channel->GetTemplate(processindex);
476 
477  TH1D * hist_template = bctemplate->GetHistogram();
478 
479  TH1D hist_up = TH1D(*hist_template);
480  TH1D hist_down = TH1D(*hist_template);
481 
482  int nbins = hist_up.GetNbinsX();
483 
484  // loop over all bins
485  for (int ibin = 1; ibin <= nbins; ++ibin) {
486  hist_up.SetBinContent(ibin, variation_up);
487  hist_down.SetBinContent(ibin, variation_down);
488  }
489 
490  // get systematic variation
491  BCMTFSystematicVariation * variation = channel->GetSystematicVariation(systematicindex);
492 
493  // set histogram
494  variation->SetHistograms(processindex, new TH1D(hist_up), new TH1D(hist_down));
495 
496  // no error
497  return 1;
498 }
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.

Parameters
channelnameThe name of the channel.
processnameThe name of the process.
systematicnameThe name of the source of systematic uncertainty.
hist_upThe TH1D histogram defining the relative shift between the up-variation and the nominal template: (up-nom)/nom.
hist_downThe TH1D histogram defining the relative shift between the down-variation and the nominal template: (nom-down)/nom.
Returns
An error code.
See Also
SetSystematicVariation(const char * channelname, const char * processname, const char * systematicname, double variation_up, double variation_down)

Definition at line 501 of file BCMTF.cxx.

502 {
503  // get channel index
504  int channelindex = GetChannelIndex(channelname);
505 
506  // check if channel exists
507  if (channelindex < 0) {
508  BCLog::OutWarning("BCMultitemplateFitter::SetTemplate() : Channel does not exist.");
509  return -1;
510  }
511 
512  // get process index
513  int processindex = GetProcessIndex(processname);
514 
515  // check if process exists
516  if (processindex < 0) {
517  BCLog::OutWarning("BCMultitemplateFitter::SetTemplate() : Process does not exist.");
518  return -1;
519  }
520 
521  // get systematic index
522  int systematicindex = GetSystematicIndex(systematicname);
523 
524  // check if systematic exists
525  if (systematicindex < 0) {
526  BCLog::OutWarning("BCMultitemplateFitter::SetTemplate() : Systematic does not exist.");
527  return -1;
528  }
529 
530  // get channel
531  BCMTFChannel * channel = GetChannel(channelindex);
532 
533  // get systematic variation
534  BCMTFSystematicVariation * variation = channel->GetSystematicVariation(systematicindex);
535 
536  // set histogram
537  variation->SetHistograms(processindex, new TH1D(hist_up), new TH1D(hist_down));
538 
539  // no error
540  return 1;
541 }
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.

Parameters
channelnameThe name of the channel.
processnameThe name of the process.
systematicnameThe name of the source of systematic uncertainty.
histThe histogram with the nominal template
hist_upThe TH1D histogram after up-scaling of the systematic uncertainty.
hist_downThe TH1D histogram after down-scaling of the systematic uncertainty.
Returns
An error code.
See Also
SetSystematicVariation(const char * channelname, const char * processname, const char * systematicname, double variation_up, double variation_down)

Definition at line 544 of file BCMTF.cxx.

545 {
546  // get number of bins
547  int nbins = hist.GetNbinsX();
548 
549  TH1D * hist_up_rel = new TH1D(hist);
550  TH1D * hist_down_rel = new TH1D(hist);
551 
552  // loop over all bins
553  for (int ibin = 1; ibin <= nbins; ++ibin) {
554  hist_up_rel->SetBinContent(ibin, (hist_up.GetBinContent(ibin) - hist.GetBinContent(ibin)) / hist.GetBinContent(ibin));
555  hist_down_rel->SetBinContent(ibin, (hist.GetBinContent(ibin) - hist_down.GetBinContent(ibin)) / hist.GetBinContent(ibin));
556  }
557 
558  // set the systematic variation
559  return SetSystematicVariation(channelname, processname, systematicname, *hist_up_rel, *hist_down_rel);
560 }
int BCMTF::SetTemplate ( const char *  channelname,
const char *  processname,
TH1D  hist,
double  efficiency = 1.,
double  norm = 1. 
)

Set the template for a specific process in a particular channel.

Parameters
channelnameThe name of the channel.
processnameThe name of the process.
histThe TH1D histogram.
efficiencyThe efficiency of this process in this channel.
Returns
An error code.

Definition at line 112 of file BCMTF.cxx.

113 {
114  // get channel index
115  int channelindex = GetChannelIndex(channelname);
116 
117  // check if channel exists
118  if (channelindex < 0) {
119  BCLog::OutWarning("BCMultitemplateFitter::SetTemplate() : Channel does not exist.");
120  return -1;
121  }
122 
123  // get process index
124  int processindex = GetProcessIndex(processname);
125 
126  // check if process exists
127  if (processindex < 0) {
128  BCLog::OutWarning("BCMultitemplateFitter::SetTemplate() : Process does not exist.");
129  return -1;
130  }
131 
132  // get channel
133  BCMTFChannel * channel = GetChannel(channelindex);
134 
135  // get template
136  BCMTFTemplate * bctemplate = channel->GetTemplate(processindex);
137 
138  // remove statistics box
139  hist.SetStats(kFALSE);
140 
141  int color = GetProcess(processindex)->GetHistogramColor();
142  if (color < 0)
143  color = 2 + processindex;
144  int fillstyle = GetProcess(processindex)->GetHistogramFillStyle();
145  if (fillstyle < 0)
146  fillstyle = 1001;
147  int linestyle = GetProcess(processindex)->GetHistogramLineStyle();
148  if (linestyle < 0)
149  linestyle = 1;
150 
151  // set color and fill style
152  hist.SetFillColor(color);
153  hist.SetFillStyle(fillstyle);
154  hist.SetLineStyle(linestyle);
155 
156  // create new histogram
157  TH1D * temphist = new TH1D(hist);
158 
159  // set histogram
160  bctemplate->SetHistogram(temphist, norm);
161 
162  // set efficiency
163  bctemplate->SetEfficiency(efficiency);
164 
165  // no error
166  return 1;
167 }
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.

Parameters
channelnameThe name of the channel.
processnameThe name of the process.
funccontA vector of pointers of TF1 functions.
nbinsThe number of bins used for the histogram.
efficiencyThe efficiency of this process in this channel.
Returns
An error code.
See Also
SetTemplate(const char * channelname, const char * processname, TH1D hist, double efficiency = 1.)

Definition at line 170 of file BCMTF.cxx.

171 {
172  // get channel index
173  int channelindex = GetChannelIndex(channelname);
174 
175  // check if channel exists
176  if (channelindex < 0) {
177  BCLog::OutWarning("BCMultitemplateFitter::SetTemplate() : Channel does not exist.");
178  return -1;
179  }
180 
181  // get process index
182  int processindex = GetProcessIndex(processname);
183 
184  // check if process exists
185  if (processindex < 0) {
186  BCLog::OutWarning("BCMultitemplateFitter::SetTemplate() : Process does not exist.");
187  return -1;
188  }
189 
190  // get channel
191  BCMTFChannel * channel = GetChannel(channelindex);
192 
193  // get template
194  BCMTFTemplate * bctemplate = channel->GetTemplate(processindex);
195 
196  // set histogram
197  bctemplate->SetFunctionContainer(funccont, nbins);
198 
199  // set efficiency
200  bctemplate->SetEfficiency(efficiency);
201 
202  // no error
203  return 1;
204 }

Member Data Documentation

std::vector<BCMTFChannel *> BCMTF::fChannelContainer
private

A container of channels.

Definition at line 405 of file BCMTF.h.

std::vector<TF1 *> BCMTF::fExpectationFunctionContainer
private

A container of functions for the expectation.

Definition at line 443 of file BCMTF.h.

bool BCMTF::fFlagEfficiencyConstraint
private

A flag for the efficiency constraint: efficiency within 0 and 1 (true) or not (false).

Definition at line 439 of file BCMTF.h.

int BCMTF::fNChannels
private

The number of channels.

Definition at line 417 of file BCMTF.h.

int BCMTF::fNProcesses
private

The number of processes.

Definition at line 421 of file BCMTF.h.

int BCMTF::fNSystematics
private

The number of systematics uncertainties.

Definition at line 425 of file BCMTF.h.

std::vector<BCMTFProcess *> BCMTF::fProcessContainer
private

A container of processes.

Definition at line 409 of file BCMTF.h.

std::vector<int> BCMTF::fProcessParIndexContainer
private

A container of parameter indeces for the process normalization.

Definition at line 430 of file BCMTF.h.

std::vector<BCMTFSystematic *> BCMTF::fSystematicContainer
private

A container of sources of systematic uncertainty.

Definition at line 413 of file BCMTF.h.

std::vector<int> BCMTF::fSystematicParIndexContainer
private

A container of parameter indeces for the systematics.

Definition at line 434 of file BCMTF.h.


The documentation for this class was generated from the following files: