123{
  127 
  129  
  131  string                usr;
  132  string                pwd;
  133  string                cookie;
  134  string                detectorFile;
  137  double                precision;
  138  double                Wmin         = 100.0;
  140  string                option;
  142 
  143  try {
  144 
  146 
  148    
  149    JParser<> zap(
"Auxiliary program to check t0's.");
 
  150    
  156    zap[
'f'] = 
make_field(inputFile,         
"pair of input files (output of JCalibrateK40)");
 
  158    zap[
'e'] = 
make_field(precision,         
"precision for HV comparison")             = 0.5;
 
  160    zap[
'x'] = 
make_field(X,                 
"ROOT fit range (PMT pairs).")             = 
JRange_t(300, numeric_limits<size_t>::max());
 
  161    zap[
'O'] = 
make_field(option,            
"ROOT fit option, see TH1::Fit.")          = 
"";
 
  164 
  165    zap(argc, argv);
  166  }
  167  catch(const exception &error) {
  168    FATAL(error.what() << endl);
 
  169  }
  170 
  171  
  172  try {
  173    JDB::reset(usr, pwd, cookie);
  174  }
  175  catch(const exception& error) {
  176    FATAL(error.what() << endl);
 
  177  }
  178 
  182  };
  183 
  184  for (int i = 0; i != 2; ++i) {
  185    DEBUG(setw(32) << setups[i].file_name << 
' ' << setups[i].header.getDetectorID() << 
' ' << setups[i].header.getRunNumber() << endl);
 
  186  }
  187    
  189 
  190  try {
  192  }
  195  }
  196 
  197  if (option.find('S') == string::npos) { option += 'S'; }
  199 
  200 
  202 
  203 
  204  TF1 
f1(
"f1", 
"[0]*TMath::Gaus(x,[1],[2]) + [3]");
 
  205 
  206  for (JDetector::const_iterator module = 
detector.begin(); module != 
detector.end(); ++module) {
 
  207 
  208    TH2D* h2[] = {
  211    };
  212 
  213    DEBUG(
"Module " << setw(10) << module->getID() << 
' ' << (h2[0] != NULL) << (h2[0] != NULL) << endl);
 
  214    
  215    if (h2[0] == NULL ||
  216        h2[1] == NULL) {
  217      continue;
  218    }
  219 
  221 
  223 
  225 
  227    
  229 
  231 
  232      const JLocation_t location_1(module->getString(), module->getFloor(), 
pair.first);
 
  233      const JLocation_t location_2(module->getString(), module->getFloor(), 
pair.second);
 
  234 
  235      const bool hv_1 = (fabs(setups[0].HV[location_1] - setups[1].HV[location_1]) < precision);
  236      const bool hv_2 = (fabs(setups[0].HV[location_2] - setups[1].HV[location_2]) < precision);
  237 
  238      double t1[] = {
  239        numeric_limits<double>::max(),
  240        numeric_limits<double>::max()
  241      };
  242      
  243      const Int_t ix = ip + 1;
  244 
  245      for (int i = 0; i != 2; ++i) {
  246      
  247        TH1D h1("__py", NULL, h2[i]->GetYaxis()->GetNbins(), h2[i]->GetYaxis()->GetXmin(), h2[i]->GetYaxis()->GetXmax());
  248 
  249        
  250 
  251        Double_t ymin   =  numeric_limits<double>::max();
  252        Double_t ymax   =  numeric_limits<double>::lowest();
  253        Double_t mean   =  0.0;
  254        Double_t 
sigma  =  4.5;
 
  255        Double_t W      =  0.0;
  256 
  257        for (int iy = 1; iy <= h1.GetNbinsX(); ++iy) {
  258 
  259          const Double_t 
x = h1.GetBinCenter(iy);
 
  260          const Double_t 
y = h2[i]->GetBinContent(ix,iy);
 
  261        
  262          h1.SetBinContent(iy, y);
  263          h1.SetBinError  (iy, sqrt(y));
  264 
  265          if (y > ymax) { 
  268          }
  269 
  270          if (y < ymin) {
  272          }
  273 
  275        }
  276 
  277        if (W >= Wmin) {
  278        
  279          f1.SetParameter(0, ymax);
 
  280          f1.SetParameter(1, mean);
 
  281          f1.SetParameter(2, sigma);
 
  282          f1.SetParameter(3, ymin);
 
  283 
  284          for (Int_t i = 0; i != 
f1.GetNpar(); ++i) {
 
  285            f1.SetParError(i, 0.0);
 
  286          }
  287        
  288          TFitResultPtr 
result = h1.Fit(&f1, option.c_str(), 
"same");
 
  289 
  290          if (
result.Get() == NULL) {
 
  291            FATAL(
"Invalid TFitResultPtr " << h1.GetName() << endl);
 
  292          }
  293 
  295            cout << "Histogram slice: "
  296                 << setw(3)    << ix                    << ' '
  297                 << 
FIXED(7,3) << 
f1.GetParameter(1)    << 
" +/- " 
  298                 << 
FIXED(7,3) << 
f1.GetParError(1)     << 
' ' 
  301                 << (
result->IsValid() ? 
"" : 
"failed") << endl;
 
  302          }
  303 
  304          t1[i] = 
f1.GetParameter(1);
 
  305        }
  306      }
  307 
  308      if (t1[0] != numeric_limits<double>::max() &&
  309          t1[1] != numeric_limits<double>::max()) {
  310 
  311        if (hv_1 != hv_2) {
  312 
  314          
  315          if (hv_1) {
  317          }
  318 
  319          if (hv_2) {
  321          }
  322 
  324            cout << setw(10) << module->getID() << 
"." << 
FILL(2,
'0') << p2.first  << 
FILL() << 
' ';
 
  325            cout << 
"(" << 
FILL(2,
'0') << p2.second << 
FILL() << 
")" << 
' ';
 
  326            cout << 
FIXED(6,2) << (combinatorics.
getSign(p2) * (t1[1] - t1[0])) << endl;
 
  327          }
  328 
  329          Q[p2.first].put(combinatorics.
getSign(p2) * (t1[1] - t1[0]));
 
  330        }
  331      }
  332    }
  333 
  336        H1[module->getID()]->SetBinContent(i+1, Q[i].
getMean());
 
  337        H1[module->getID()]->SetBinError  (i+1, Q[i].getSTDev());
  338      }
  339    }
  340  }
  341 
  344  }
  345}
double getMean(vector< double > &v)
get mean of vector content
 
#define DEBUG(A)
Message macros.
 
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
 
#define MAKE_CSTRING(A)
Make C-string.
 
#define gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
 
Utility class to parse parameter values.
 
Utility class to parse command line options.
 
Auxiliary class to manage set of compatible ROOT objects (e.g. histograms) using unique keys.
 
const JPolynome f1(1.0, 2.0, 3.0)
Function.
 
static const char *const _2S
Name extension for 2D counts.
 
std::vector< JServer > getServernames()
Get list of names of available database servers.
 
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
 
size_t getCount(const array_type< T > &buffer, const JCompare_t &compare)
Count number of unique values.
 
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
 
KM3NeT DAQ data structures and auxiliaries.
 
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
 
Auxiliary data structure for sequence of same character.
 
Auxiliary data structure for floating point format specification.
 
Type definition of range.
 
Auxiliary data structure for setup of complete system.
 
Auxiliary class to sort pairs of PMT addresses within optical module.
 
Auxiliary data structure for location of product in detector.
 
Wrapper class for server name.
 
Empty structure for specification of parser element that is initialised (i.e. does not require input)...