Jpp - the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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

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

Definition at line 27 of file JFitL1dtSlices.cc.

27  {
28  if (nhat < 0.0 || n < 0.0) {
29  FATAL("logPoisson: n (" << n <<") or nhat (" << nhat << ") is < 0.0" << std::endl);
30  }
31  if (n == 0.0 && nhat == 0.0) {
32  return 0.0; // ok.
33  }
34  if (n == 0.0 && nhat > 0.0) {
35  return -1*nhat; // log( lab^0 * e^-lab / 0! ) = log( e^-lab ) = -lab, ok.
36  }
37  if (n >= 0.0 && nhat == 0.0) {
38  return 0.0; // should be -inf, we only consider bins where we expect non-zero entries: no expected entries we throw away.
39  }
40  Double_t poisson = TMath::Poisson(n, nhat);
41  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.
42  else return TMath::Log(poisson);
43  }
#define FATAL(A)
Definition: JMessage.hh:67
alias put_queue eval echo n
Definition: qlib.csh:19
double FITL1DTSLICES::getLogQuality ( const TH1D *  data,
const TH1D *  model,
int  di,
double  data_bkg = 0.0001,
double  model_bkg = 0.0001 
)

Definition at line 45 of file JFitL1dtSlices.cc.

45  {
46 
47  double q = 0.0;
48 
49  // If you calculate over the whole histogram you lose bins at edges: only when dt=0 are all N bins considered, everywhere else
50  // either data or model bins get lost at the edge. So integrate over a smaller range:
51  int i_low = data->GetNbinsX() / 4; // Start at a quarter of the hist
52  int i_hgh = data->GetNbinsX() / 4 * 3; // End at three quarters
53  for (int i = i_low; i <= i_hgh; ++i) {
54  double n = data_bkg;
55  double nhat = model_bkg;
56  if (i >= 1 && i <= data->GetNbinsX()) {
57  // Count in bin i for the data
58  n = data->GetBinContent(i);
59  }
60  if (i+di >= 1 && i+di <= model->GetNbinsX()) {
61  // Count in bin i+di for the model
62  nhat = model->GetBinContent(i+di);
63  }
64  double logP = logPoison(n, nhat);
65  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
66  }
67  return q;
68  }
alias put_queue eval echo n
Definition: qlib.csh:19
double logPoison(double n, double nhat, double logP_min=-999999.9)