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

A class describing a template. More...

#include <BCMTFTemplate.h>

Public Member Functions

Constructors and destructors
 BCMTFTemplate (const char *channelname, const char *processname)
 
 ~BCMTFTemplate ()
 
Member functions (get)
std::string GetChannelName ()
 
std::string GetProcessName ()
 
double GetEfficiency ()
 
TH1D * GetHistogram ()
 
double GetNorm ()
 
double GetOriginalNorm ()
 
TH1D FluctuateHistogram (std::string options="GZ", double norm=1)
 
std::vector< TF1 * > * GetFunctionContainer ()
 
int GetNBins ()
 
Member functions (set)
void SetEfficiency (double eff)
 
void SetHistogram (TH1D *hist, double norm=1)
 
void SetOrignialNormalization (double norm)
 
void SetFunctionContainer (std::vector< TF1 * > *funccont, int nbins)
 

Private Attributes

double fEfficiency
 
TH1D * fHistogram
 
std::vector< TF1 * > * fFunctionContainer
 
int fNBins
 
double fNormalization
 
double fOriginalNormalization
 
std::string fChannelName
 
std::string fProcessName
 
TRandom3 * fRandom
 

Detailed Description

A class describing a template.

Author
Daniel Kollar
Kevin Kröninger
Version
1.1
Date
06.2012 This class describes a template.

Definition at line 32 of file BCMTFTemplate.h.

Constructor & Destructor Documentation

BCMTFTemplate::BCMTFTemplate ( const char *  channelname,
const char *  processname 
)

The default constructor.

Parameters
channelnameThe name of the channel.
processname The name of the process.

Definition at line 19 of file BCMTFTemplate.cxx.

20  : fEfficiency(0)
21  , fHistogram(0)
22  , fNBins(0)
23  , fNormalization(0)
25 {
26  fChannelName = channelname;
27  fProcessName = processname;
28  fFunctionContainer = new std::vector<TF1 *>(0);
29  fRandom = new TRandom3(0);
30 }
BCMTFTemplate::~BCMTFTemplate ( )

The default destructor.

Definition at line 33 of file BCMTFTemplate.cxx.

34 {
35 }

Member Function Documentation

TH1D BCMTFTemplate::FluctuateHistogram ( std::string  options = "GZ",
double  norm = 1 
)

Fluctuate the original template histogram by the uncertainty on the bin content.

Parameters
optionsA set of options. "P" : use Poisson model, the expectation value parameter is the bin content and also defines the uncertainties. "G" [default] : use a Gaussian mode, the expectation value paramer mu is the bin content, the uncertainty sigma is defined by the uncertainty in the histogram. "Z" [default] : make sure that the bin content is positive.
normThe target normalization.
Returns
A histogram with each bin fluctuated by the uncertainty on the bin content.

Definition at line 71 of file BCMTFTemplate.cxx.

72 {
73  // option flags
74  bool flag_p = false;
75  bool flag_g = false;
76  bool flag_z = false;
77 
78  // check content of options string
79  if (options.find("P") < options.size()) {
80  flag_p = true;
81  }
82 
83  if (options.find("G") < options.size()) {
84  flag_g = true;
85  }
86 
87  if (options.find("Z") < options.size()) {
88  flag_z = true;
89  }
90 
91  if (flag_p && flag_g) {
92  flag_g = false;
93  }
94 
95  TH1D hist_temp = TH1D(*fHistogram);
96 
97  for (int i = 1; i <= fNBins; ++i) {
98  double expectation = fOriginalNormalization * hist_temp.GetBinContent(i);
99  double error = fOriginalNormalization * hist_temp.GetBinError(i);
100  double n = 0;
101 
102  // throw random number according to Poisson distribution
103  if (flag_p) {
104  n = (double) fRandom->Poisson(expectation);
105  }
106 
107  // throw random number according to Gauss distribution
108  else if (flag_g) {
109  double dn = fRandom->Gaus(expectation, error);
110 
111  // make it a truncated Gaussian
112  if (flag_z) {
113  while (n + dn < 0)
114  dn = fRandom->Gaus(expectation, error);
115  }
116  n += dn;
117  }
118 
119  // set the number of events in the template
120  hist_temp.SetBinContent(i, n);
121  }
122 
123  // normalize histogram
124  double orignorm = hist_temp.Integral();
125 
126  if (orignorm)
127  hist_temp.Scale(norm / orignorm);
128 
129  return hist_temp;
130 }
std::string BCMTFTemplate::GetChannelName ( )
inline
Returns
The name of the channel.

Definition at line 56 of file BCMTFTemplate.h.

57  { return fChannelName; };
double BCMTFTemplate::GetEfficiency ( )
inline
Returns
The efficiency.

Definition at line 66 of file BCMTFTemplate.h.

67  { return fEfficiency; };
std::vector<TF1 *>* BCMTFTemplate::GetFunctionContainer ( )
inline
Returns
The function container.

Definition at line 97 of file BCMTFTemplate.h.

98  { return fFunctionContainer; };
TH1D* BCMTFTemplate::GetHistogram ( )
inline
Returns
The TH1D histogram.

Definition at line 71 of file BCMTFTemplate.h.

72  { return fHistogram; };
int BCMTFTemplate::GetNBins ( )
inline
Returns
The number of bins.

Definition at line 102 of file BCMTFTemplate.h.

103  { return fNBins; };
double BCMTFTemplate::GetNorm ( )
inline
Returns
The normalization.

Definition at line 76 of file BCMTFTemplate.h.

77  { return fNormalization; };
double BCMTFTemplate::GetOriginalNorm ( )
inline
Returns
The original normalization.

Definition at line 81 of file BCMTFTemplate.h.

82  { return fOriginalNormalization; };
std::string BCMTFTemplate::GetProcessName ( )
inline
Returns
The name of the process.

Definition at line 61 of file BCMTFTemplate.h.

62  { return fProcessName; };
void BCMTFTemplate::SetEfficiency ( double  eff)
inline

Set the efficiency.

Parameters
effThe efficiency.

Definition at line 113 of file BCMTFTemplate.h.

114  { fEfficiency = eff; };
void BCMTFTemplate::SetFunctionContainer ( std::vector< TF1 * > *  funccont,
int  nbins 
)

Set a function container funccont The function container nbins The number of bins (and functions)

Definition at line 64 of file BCMTFTemplate.cxx.

65 {
66  fFunctionContainer = funccont;
67  fNBins = nbins;
68 }
void BCMTFTemplate::SetHistogram ( TH1D *  hist,
double  norm = 1 
)

Set the histogram.

Parameters
histThe TH1D histogram.
normThe target normalization.

Definition at line 38 of file BCMTFTemplate.cxx.

39 {
40  // set histogram
41  fHistogram = hist;
42 
43  // check if histogram exists
44  if (!hist)
45  return;
46 
47  // get number of bins
48  fNBins = fHistogram->GetNbinsX();
49 
50  // set original normalization
51  double orignorm = fHistogram->Integral();
52  SetOrignialNormalization(orignorm);
53 
54  // normalize histogram
55  if (orignorm && norm)
56  fHistogram->Scale(norm / orignorm);
57 
58  // set normalization
59  if (norm)
60  fNormalization = norm;
61 }
void BCMTFTemplate::SetOrignialNormalization ( double  norm)
inline

Set the original normalization.

Parameters
normThe normalization.

Definition at line 126 of file BCMTFTemplate.h.

126  {
127  fOriginalNormalization = norm; };

Member Data Documentation

std::string BCMTFTemplate::fChannelName
private

The name of the channel.

Definition at line 164 of file BCMTFTemplate.h.

double BCMTFTemplate::fEfficiency
private

The efficiency of the contribution.

Definition at line 140 of file BCMTFTemplate.h.

std::vector<TF1 *>* BCMTFTemplate::fFunctionContainer
private

A histogram alternative for templates: a vector of TF1 functions.

Definition at line 148 of file BCMTFTemplate.h.

TH1D* BCMTFTemplate::fHistogram
private

The TH1D histogram.

Definition at line 144 of file BCMTFTemplate.h.

int BCMTFTemplate::fNBins
private

The number of bins in the histogram.

Definition at line 152 of file BCMTFTemplate.h.

double BCMTFTemplate::fNormalization
private

The normalization.

Definition at line 156 of file BCMTFTemplate.h.

double BCMTFTemplate::fOriginalNormalization
private

The original normalization.

Definition at line 160 of file BCMTFTemplate.h.

std::string BCMTFTemplate::fProcessName
private

The name of the process.

Definition at line 168 of file BCMTFTemplate.h.

TRandom3* BCMTFTemplate::fRandom
private

A random number generator.

Definition at line 172 of file BCMTFTemplate.h.


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