Jpp  master_rocky-40-g5f0272dcd
the software that should make you happy
Functions
FITL1DTSLICES Namespace Reference

Functions

double logPoison (double n, double nhat, double logP_min=-999999.9)
 
double getLogQuality (const TH1D *data, const TH1D *model, int di, double data_bkg=0.0001, double model_bkg=0.0001)
 

Function Documentation

◆ logPoison()

double FITL1DTSLICES::logPoison ( double  n,
double  nhat,
double  logP_min = -999999.9 
)

Definition at line 29 of file JFitL1dtSlices.cc.

29  {
30  if (nhat < 0.0 || n < 0.0) {
31  FATAL("logPoisson: n (" << n <<") or nhat (" << nhat << ") is < 0.0" << std::endl);
32  }
33  if (n == 0.0 && nhat == 0.0) {
34  return 0.0; // ok.
35  }
36  if (n == 0.0 && nhat > 0.0) {
37  return -1*nhat; // log( lab^0 * e^-lab / 0! ) = log( e^-lab ) = -lab, ok.
38  }
39  if (n >= 0.0 && nhat == 0.0) {
40  return 0.0; // should be -inf, we only consider bins where we expect non-zero entries: no expected entries we throw away.
41  }
42  Double_t poisson = TMath::Poisson(n, nhat);
43  if (poisson == 0) return 0.0; // only when model and data are close enough do we care about their values, so if P=0, do nothing, since we are not in the region we care about.
44  else return TMath::Log(poisson);
45  }
#define FATAL(A)
Definition: JMessage.hh:67
double poisson(const size_t n, const double mu)
Poisson probability density distribition.
double Poisson(const size_t n, const double mu)
Poisson cumulative density distribition.
JLog< JF1_t > Log(const JF1_t &f1)
Logarithm of function.
Definition: JMathlib.hh:2629
const int n
Definition: JPolint.hh:786

◆ getLogQuality()

double FITL1DTSLICES::getLogQuality ( const TH1D *  data,
const TH1D *  model,
int  di,
double  data_bkg = 0.0001,
double  model_bkg = 0.0001 
)

Definition at line 47 of file JFitL1dtSlices.cc.

47  {
48 
49  double q = 0.0;
50 
51  // If you calculate over the whole histogram you lose bins at edges: only when dt=0 are all N bins considered, everywhere else
52  // either data or model bins get lost at the edge. So integrate over a smaller range:
53  int i_low = data->GetNbinsX() / 4; // Start at a quarter of the hist
54  int i_hgh = data->GetNbinsX() / 4 * 3; // End at three quarters
55  for (int i = i_low; i <= i_hgh; ++i) {
56  double n = data_bkg;
57  double nhat = model_bkg;
58  if (i >= 1 && i <= data->GetNbinsX()) {
59  // Count in bin i for the data
60  n = data->GetBinContent(i);
61  }
62  if (i+di >= 1 && i+di <= model->GetNbinsX()) {
63  // Count in bin i+di for the model
64  nhat = model->GetBinContent(i+di);
65  }
66  double logP = logPoison(n, nhat);
67  q += logP; // Added 0 for when the background is zero in model and data, but then P(n|0) gives inf! So removed overwritten logPmin
68  }
69  return q;
70  }
double logPoison(double n, double nhat, double logP_min=-999999.9)