30{
   33 
   36 
   37  try {
   38 
   39    JParser<> zap(
"Auxiliary program to print (x) of the maximum of 1D ROOT objects.");
 
   40    
   41    zap[
'f'] = 
make_field(inputFile,  
"<input file>:<object name>");
 
   43     
   44    zap(argc, argv);
   45  }
   46  catch(const exception &error) {
   47    FATAL(error.what() << endl);
 
   48  }
   49 
   50 
   51  for (vector<JRootObjectID>::const_iterator input = inputFile.begin(); input != inputFile.end(); ++input) {
   52 
   53    DEBUG(
"Input: " << *input << endl);
 
   54 
   56 
   57    if (dir == NULL) {
   58      ERROR(
"File: " << input->getFullFilename() << 
" not opened." << endl);
 
   59      continue;
   60    }
   61 
   62    const TRegexp regexp(input->getObjectName());
   63 
   64    TIter iter(dir->GetListOfKeys());
   65 
   66    for (TKey* key; (
key = (TKey*) iter.Next()) != NULL; ) {
 
   67 
   68      const TString tag(
key->GetName());
 
   69 
   70      DEBUG(
"Key: " << tag << 
" match = " << tag.Contains(regexp) << endl);
 
   71        
   72      
   73 
   74      if (tag.Contains(regexp) && 
isTObject(key)) {
 
   75 
   77 
   79        double ymax = numeric_limits<double>::lowest();
   80 
   81        try {
   82 
   83          TH1& h1 = dynamic_cast<TH1&>(*object);
   84 
   85          for (Int_t ix = 1; ix <= h1.GetXaxis()->GetNbins(); ++ix) {
   86 
   87            double y = h1.GetBinContent(ix);
 
   88 
   89            if (y > ymax) {
   91              x    = h1.GetXaxis()->GetBinCenter(ix);
 
   92            }
   93          }
   94        }
   95        catch(exception&) {}
   96 
   97        try {
   98 
   99          TProfile& h1 = dynamic_cast<TProfile&>(*object);
  100 
  101          for (Int_t ix = 1; ix <= h1.GetXaxis()->GetNbins(); ++ix) {
  102 
  103            double y = h1.GetBinContent(ix);
 
  104 
  105            if (y > ymax) {
  107              x    = h1.GetXaxis()->GetBinCenter(ix);
 
  108            }
  109          }
  110        }
  111        catch(exception&) {}
  112 
  113        try {
  114 
  115          TGraph& 
g1 = 
dynamic_cast<TGraph&
>(*object);
 
  116 
  117          for (Int_t i = 0; i != 
g1.GetN(); ++i) {
 
  118            if (
g1.GetY()[i] > ymax) {
 
  121            }
  122          }
  123        }
  124        catch(exception&) {}
  125 
  126        if (ymax != numeric_limits<double>::lowest()) {
  127          cout << setw(32) << left << 
key->GetName() << right << 
' ' << 
SCIENTIFIC(15,5) << 
x << endl;
 
  128        }
  129      }
  130    }
  131  }
  132}
#define DEBUG(A)
Message macros.
 
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
 
Double_t g1(const Double_t x)
Function.
 
Utility class to parse command line options.
 
TDirectory * getDirectory(const JRootObjectID &id)
Get TDirectory pointer.
 
bool isTObject(const TKey *key)
Check if given key corresponds to a TObject.
 
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
 
Auxiliary data structure for floating point format specification.