29 double logPoison(
double n,
double nhat,
double logP_min = -999999.9) {
30 if (nhat < 0.0 || n < 0.0) {
31 FATAL(
"logPoisson: n (" << n <<
") or nhat (" << nhat <<
") is < 0.0" << std::endl);
33 if (n == 0.0 && nhat == 0.0) {
36 if (n == 0.0 && nhat > 0.0) {
39 if (n >= 0.0 && nhat == 0.0) {
42 Double_t poisson = TMath::Poisson(n, nhat);
43 if (poisson == 0)
return 0.0;
44 else return TMath::Log(poisson);
47 double getLogQuality(
const TH1D* data,
const TH1D* model,
int di,
double data_bkg = 0.0001,
double model_bkg = 0.0001) {
53 int i_low = data->GetNbinsX() / 4;
54 int i_hgh = data->GetNbinsX() / 4 * 3;
55 for (
int i = i_low; i <= i_hgh; ++i) {
57 double nhat = model_bkg;
58 if (i >= 1 && i <= data->GetNbinsX()) {
60 n = data->GetBinContent(i);
62 if (i+di >= 1 && i+di <= model->GetNbinsX()) {
64 nhat = model->GetBinContent(i+di);
81int main(
int argc,
char **argv)
99 JParser<> zap(
"Program to calculate log-likelihood distributions between DOM pairs and fit a poly2 to find the shape, used in FitL1dt to find time offsets");
101 zap[
'f'] =
make_field(inputFile,
"input file") =
"monitor.root";
105 zap[
'T'] =
make_field(TMax_ns,
"scan range around 0 in data-model comparison [ns]") = 50.0;
115 catch(
const exception &error) {
132 TFile* in = TFile::Open(inputFile.c_str(),
"exist");
135 if (in ==
NULL || !in->IsOpen()) {
136 FATAL(
"File: " << inputFile <<
" not opened." <<
endl);
154 h2A.GetXaxis()->SetBinLabel(
idom+1, label);
155 h2A.GetYaxis()->SetBinLabel(
idom+1, label);
156 h2B.GetXaxis()->SetBinLabel(
idom+1, label);
157 h2B.GetYaxis()->SetBinLabel(
idom+1, label);
158 h2C.GetXaxis()->SetBinLabel(
idom+1, label);
159 h2C.GetYaxis()->SetBinLabel(
idom+1, label);
172 TH2D*
d2s = (
TH2D*) in->Get((title +
".2S").c_str());
173 TH1D*
d1l = (
TH1D*) in->Get((title +
".1L").c_str());
176 WARNING(
"No data in data histogram " << title <<
endl);
185 WARNING(
"No mata in model histogram " << title <<
endl);
202 d2s->GetXaxis()->FindBin(TString(
Form(
"%i",
moduleB->getID()))),
"e");
205 m2s->GetXaxis()->FindBin(TString(
Form(
"%i",
moduleB->getID()))),
"e");
207 if (
d1s->Integral() <= 0.0 ||
m1s->Integral() <= 0.0) {
215 for (
int j = 1; j <=
d1s->GetXaxis()->
GetNbins(); ++j) {
227 for (
int j = 1; j <=
m1s->GetXaxis()->
GetNbins(); ++j) {
236 const double Ld =
d1l->GetBinContent(
d1l->GetXaxis()->FindBin(TString(
Form(
"%i",
moduleB->getID()))));
237 const double Lm =
m1l->GetBinContent(
m1l->GetXaxis()->FindBin(TString(
Form(
"%i",
moduleB->getID()))));
239 for (
int j = 1; j <=
d1s->GetXaxis()->
GetNbins(); ++j) {
240 const double y =
d1s->GetBinContent(j);
241 const double dy =
d1s->GetBinError(j);
243 d1s->SetBinContent(j, y);
244 d1s->SetBinError(j,
dy);
248 for (
int j = 1; j <=
m1s->GetXaxis()->
GetNbins(); ++j) {
249 const double y =
m1s->GetBinContent(j);
250 const double dy =
m1s->GetBinError(j);
252 m1s->SetBinContent(j, y *
Ld/
Lm);
276 for (
int di = 1;
di <=
q1.GetNbinsX();
di++) {
277 q1.SetBinContent(
di, getLogQuality(
d1s,
m1s, (
int)(
q1.GetBinCenter(
di)/rebin), 0.0, 0.0));
281 const double dt_fitmid =
q1.GetBinCenter(
q1.GetMaximumBin());
284 q1f.SetParLimits(0, -1
e5, 0.0);
296 const double Aij =
q1f.GetParameter(0);
297 const double Bij =
q1f.GetParameter(1);
298 const double Cij =
q1f.GetParameter(2);
KM3NeT DAQ constants, bit handling, etc.
Data structure for detector geometry and calibration.
int main(int argc, char **argv)
#define DEBUG(A)
Message macros.
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Wrapper class around STL string class.
Template definition of a multi-dimensional oscillation probability interpolation table.
JReader & read(JReader &in) override final
Read from input.
Utility class to parse command line options.
double getLogQuality(const TH1D *data, const TH1D *model, int di, double data_bkg=0.0001, double model_bkg=0.0001)
double logPoison(double n, double nhat, double logP_min=-999999.9)
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).