28{
   31 
   33 
   34  string       inputFile;
   35  string       detectorFile;
   36  JRange_t     range;
   37  double       fraction;
   38  bool         overwriteDetector;
   40 
   41  try {
   42 
   43    JParser<> zap(
"Auxiliary program to update the PMT status in the detector file based on the fraction of short time-over-threshold values.");
 
   44 
   45    zap[
'f'] = 
make_field(inputFile,         
"input file (output from JCalibrateToT).");
 
   46    zap[
'a'] = 
make_field(detectorFile,      
"detector file.");
 
   47    zap[
'x'] = 
make_field(range,             
"integration range for noise.")                  = JRange_t(0.0, 8.0);
 
   48    zap[
't'] = 
make_field(fraction,          
"maximal fraction of signal allowed for noise.") = 0.5;
 
   49    zap[
'A'] = 
make_field(overwriteDetector, 
"overwrite detector file.");
 
   51 
   52    zap(argc, argv);
   53  }
   54  catch(const exception& error) {
   55    FATAL(error.what() << endl);
 
   56  }
   57 
   58 
   60 
   61  try {
   63  }
   66  }
   67 
   69 
   71    NOTICE(
"Set detector version to " << 
detector.getVersion() << endl);
 
   72  }
   73 
   74 
   75  gErrorIgnoreLevel = kError;
   76 
   77  TFile* in = TFile::Open(inputFile.c_str(), "exist");
   78 
   79  if (in == NULL || !in->IsOpen()) {
   80    FATAL(
"File: " << inputFile << 
" not opened." << endl);
 
   81  }
   82 
   83 
   84  for (JDetector::iterator module = 
detector.begin(); module != 
detector.end(); ++module) {
 
   85 
   86    if (!module->empty()) {
   87 
   88      TH2D* h2s = (TH2D*) in->Get(
MAKE_CSTRING(module->getID() << _2SToT));
 
   89 
   90      if (h2s != NULL) {
   91 
   92        for (int ix = 1; ix <= h2s->GetXaxis()->GetNbins(); ++ix) {
   93 
   94          double noise  = 0.0;
   95          double signal = 0.0;
   96 
   97          for (int iy = 1; iy <= h2s->GetYaxis()->GetNbins(); ++iy) {
   98 
   99            const double x = h2s->GetYaxis()->GetBinCenter(iy);
 
  100            const double y = h2s->GetBinContent(ix, iy);
 
  101 
  103 
  104            if (range(x)) {
  106            }
  107          }
  108 
  109          const bool disable = noise > fraction * signal;
  110 
  111          if (
debug >= debug_t || disable) {
 
  112            cout << 
"PMT " << 
FILL(10,
'0') << module->getID() << 
"." << 
FILL(2,
'0') << (ix - 1) << 
FILL()
 
  113                 << 
" noise/signal " << 
FIXED(7,0) << noise << 
"/" << 
FIXED(7,0) << signal << (disable ? 
" *" : 
"") << endl;
 
  114          }
  115 
  116          if (overwriteDetector) {
  117            if (disable) {
  118              module->getPMT(ix - 1).getStatus().set(PMT_DISABLE);
  119            }
  120          }
  121        }
  122 
  123      } else {
  124 
  125        WARNING(
"No histogram for module " << module->getID() << 
"; skip." << endl);
 
  126      }
  127    }
  128  }
  129 
  130  in->Close();
  131  
  132  if (overwriteDetector) {
  133  
  134    NOTICE(
"Store PMT status on file " << detectorFile << endl);
 
  135 
  137  }
  138}
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
 
#define MAKE_CSTRING(A)
Make C-string.
 
Utility class to parse command line options.
 
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
 
void store(const std::string &file_name, const JDetector &detector)
Store detector to output file.
 
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
 
Auxiliary data structure for sequence of same character.
 
Auxiliary data structure for floating point format specification.