14 #include "TFitResult.h" 
   41 int main(
int argc, 
char **argv) {
 
   54     JParser<> zap(
"Auxiliary program to fit multiplicity rates from JMonitorMultiplicity output.");
 
   56     zap[
'f'] = 
make_field(inputFile,         
"input file (output from JMonitorMultiplicity).");
 
   58     zap[
'O'] = 
make_field(option,            
"fitting option")                                         = 
"Q";
 
   59     zap[
'B'] = 
make_field(fitBackground,     
"fit and subtract background instead of fitting signal");
 
   64   catch(
const exception &error) {
 
   65     FATAL(error.what() << endl);
 
   68   TFile* in = TFile::Open(inputFile.c_str(), 
"exist");
 
   70   if (in == NULL || !in->IsOpen()) {
 
   71     FATAL(
"File: " << inputFile << 
" not opened." << endl);
 
   80   const double xmin = -0.5;
 
   81   const double xmax = nx - 0.5;
 
   85   JManager_t HTF(
new TH1D(
"%F", 
"",  nx, xmin, xmax));
 
   89   JManager_t HTFE(
new TH1D(
"%FE", 
"", nx, xmin, xmax));
 
   97   if (hLiveTime == NULL) {
 
   98     FATAL(
"File " << inputFile << 
" does not contain livetime histogram." << endl);
 
  108   for (
int bin = 2; bin <= hLiveTime->GetNbinsX(); bin++) { 
 
  110     TString hLabel = hLiveTime->GetXaxis()->GetBinLabel(bin) + TString(
"_HT");
 
  112     DEBUG(
"Reading livetime for " << hLabel << endl);
 
  114     double T = hLiveTime->GetBinContent(bin);
 
  118       TDirectory *cdir = out.mkdir(hLabel);
 
  122       TH2D* hDOM = (TH2D*) in->Get(hLabel);
 
  126         ERROR(
"Histogram " << hLabel << 
" not found, skipping DOM." << endl);
 
  138         int Mbin = hDOM->GetXaxis()->FindBin(M);
 
  140         TH1D* hM = hDOM->ProjectionY(hLabel + Form(
"_%d", M), Mbin, Mbin);
 
  143           hI = (TH1D*) hM->Clone(hLabel + 
"I");
 
  148         if (hI->GetEntries() > 0) {
 
  150           const double W = (hI->GetXaxis()->GetXmax() - hI->GetXaxis()->GetXmin()); 
 
  151           const double N = hI->GetNbinsX();
 
  152           const double V = W / N;
 
  154           double inclusiveCountVal = 0, inclusiveCountErr = 0;
 
  156           hIF = (TH1D*) hI->Clone(hLabel + 
"IF" + Form(
"_%d", M)); hIF->Sumw2();
 
  158           if (hIF->GetRMS() > 0.1) {
 
  162             TF1 f1(
"f1", 
"[0]*exp(-0.5*(x-[1])*(x-[1])/([2]*[2]))/(TMath::Sqrt(2*TMath::Pi())*[2]) + [3]");
 
  164             f1.SetParameter(0, hIF->GetMaximum());
 
  165             f1.SetParameter(1, hIF->GetMean());
 
  166             f1.SetParameter(2, hIF->GetRMS() * 0.25);
 
  167             f1.SetParameter(3, hIF->GetMinimum());
 
  169             hIF->Fit(&f1, option.c_str(), 
"same");
 
  171             double sg_v = f1.GetParameter(0);
 
  172             double sg_e = f1.GetParError( 0);
 
  174             double bg_v = f1.GetParameter(3);
 
  175             double bg_e = f1.GetParError( 3);
 
  178             if (bg_v / bg_e <= 2.0) { bg_v = bg_e = 0; }
 
  179             if (sg_v / sg_e <= 2.0) { sg_v = sg_e = 0; }
 
  181             double integral = hIF->GetSumOfWeights();
 
  185               inclusiveCountVal = V * (integral - (bg_v * N));
 
  186               inclusiveCountErr = V * bg_e * N;
 
  190               inclusiveCountErr = sg_e;
 
  191               inclusiveCountVal = sg_v;
 
  196             hIF->Fit(&f1, option.c_str(), 
"same");
 
  201           if (inclusiveCountVal <= 0) { inclusiveCountVal = 0; }
 
  213           int bin = HTF[hLabel]->FindBin(M);
 
  215           HTF[hLabel]->SetBinContent(bin, inclusiveCountVal);
 
  217           double binError = sqrt(inclusiveCountVal + pow(inclusiveCountErr, 2));
 
  219           HTF[hLabel]->SetBinError(bin, binError);
 
  225           double exclusiveCountVal = 0;
 
  228             exclusiveCountVal = inclusiveCountVal;
 
  230             int prevBin = HTF[hLabel]->GetXaxis()->FindBin(M+1);
 
  231             exclusiveCountVal = inclusiveCountVal - HTF[hLabel]->GetBinContent(prevBin); 
 
  234           HTFE[hLabel]->SetBinContent(HTFE[hLabel]->FindBin(M), exclusiveCountVal);
 
  243       HTFE[hLabel]->Sumw2();
 
  245       HTF[hLabel ]->Scale(1.0 / T);
 
  246       HTFE[hLabel]->Scale(1.0 / T);
 
Utility class to parse command line options. 
 
Auxiliary class to manage set of histograms. 
 
Dynamic ROOT object management. 
 
I/O formatting auxiliaries. 
 
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object 
 
General purpose messaging. 
 
Auxiliary class to define a range between two values. 
 
Utility class to parse command line options. 
 
KM3NeT DAQ constants, bit handling, etc. 
 
static const int NUMBER_OF_PMTS
Total number of PMTs in module. 
 
#define DEBUG(A)
Message macros. 
 
int main(int argc, char *argv[])