32int main(
int argc, 
char **argv)
 
   50    JParser<> zap(
"Auxiliary program to set disable status of transmission based on time-of-arrival histograms.");
 
   52    zap[
'f'] = 
make_field(inputFile,       
"input file (output from JCanberra).");
 
   54    zap[
'N'] = 
make_field(Nmin,            
"minimum number of entries")      = 1;
 
   55    zap[
'T'] = 
make_field(Tmax_us,         
"maximal time [us]");
 
   57    zap[
'!'] = 
make_field(disableFile,     
"disable transmission file")      = 
"";
 
   62  catch(
const exception &error) {
 
   63    FATAL(error.what() << endl);
 
   67  inputFile = getFilenames(inputFile);
 
   69  disable_container disable;
 
   71  if (disableFile != 
"" && getFileStatus(disableFile.c_str())) {
 
   72    disable.load(disableFile.c_str());
 
   75  disable.comment.add(
JMeta(argc, argv));
 
   79  TH1D ha(
"ha", NULL, 1000, 0.0, 1.0e4);
 
   80  TH1D hb(
"hb", NULL, 1000, 0.0, 1.0e3);
 
   82  for (vector<string>::const_iterator i = inputFile.begin(); i != inputFile.end(); ++i) {
 
   84    NOTICE(
"Processing " << *i << endl) ;
 
   86    TFile in(i->c_str(), 
"read");
 
   88    TIter iter(in.GetListOfKeys());
 
   90    for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
 
   92      if (TString(key->GetName()).EndsWith(
".toa")) {
 
   94        TH1* h1 = 
dynamic_cast<TH1*
>(key->ReadObj());
 
   98          TString buffer(h1->GetName());
 
  100          const char* regexp = 
"[^0-9][0-9]* [0-9]*[^0-9]";
 
  102          buffer = buffer(TRegexp(regexp));
 
  103          buffer = buffer(1, buffer.Length() - 2);
 
  105          if (buffer.Length() > 0 && buffer.IsDigit()) {
 
  109            istringstream(buffer.Data()) >> id;
 
  111            const int N = h1->GetEntries();
 
  113            if (N > 0 && N < Nmin) {
 
  115              NOTICE(
"disable: " << setw(2) << 
id.tx << 
' ' << setw(8) << 
id.rx << 
' ' << setw(6) << N << 
" < " << setw(6) << Nmin << endl);
 
  126              h1->GetQuantiles(Q.size(), R.data(), Q.data());
 
  128              const double T_us = (*R.rbegin() - *R.begin()) * 1.0e6;
 
  132              DEBUG(
"transmission: " << setw(2) << 
id.tx << 
' ' << setw(8) << 
id.rx << 
' ' << setw(6) << N << 
' ' << 
FIXED(6,1) << T_us << 
" [us]" << endl);
 
  134              if (T_us > Tmax_us) {
 
  136                NOTICE(
"disable: " << setw(2) << 
id.tx << 
' ' << setw(8) << 
id.rx << 
' ' << 
FIXED(6,1) << T_us << 
" > " << 
FIXED(6,1) << Tmax_us << 
" [us]" << endl);
 
  144            ERROR(
"Histogram name " << h1->GetName() << 
" not compatible with regular expression " << regexp << 
"." << endl);
 
  153  if (disableFile != 
"") {
 
  154    disable.store(disableFile.c_str());