#include #include #include #include #include #include "TROOT.h" #include "TFile.h" #include "TObject.h" #include "TKey.h" #include "TH1.h" #include "TRegexp.h" #include "JGizmo/JRootObjectID.hh" #include "JGizmo/JGizmoToolkit.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" #include "Jeep/JPrint.hh" /** * \file * * Auxiliary program to print quantiles from ROOT histograms. * The option -f corresponds to \:\. * * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; vector inputFile; vector Q; int debug; try { JParser<> zap("Auxiliary program to print quantiles from ROOT histograms."); zap['f'] = make_field(inputFile, ":"); zap['Q'] = make_field(Q, "quantiles"); zap['d'] = make_field(debug) = 0; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } for (vector::const_iterator input = inputFile.begin(); input != inputFile.end(); ++input) { DEBUG("Input: " << *input << endl); TDirectory* dir = getDirectory(*input); if (dir == NULL) { ERROR("File: " << input->getFullFilename() << " not opened." << endl); continue; } const TRegexp regexp(input->getObjectName()); TIter iter(dir->GetListOfKeys()); for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) { const TString tag(key->GetName()); DEBUG("Key: " << tag << " match = " << tag.Contains(regexp) << endl); // option match if (tag.Contains(regexp) && isTObject(key)) { TObject* object = key->ReadObj(); TH1* h1 = dynamic_cast(object); if (h1 != NULL) { vector X(Q.size(), 0.0); h1->GetQuantiles(Q.size(), X.data(), Q.data()); for (vector::const_iterator i = X.begin(); i != X.end(); ++i) { cout << ' ' << *i; } cout << endl; } } } } }