#include #include #include #include "TROOT.h" #include "TFile.h" #include "TClass.h" #include "TKey.h" #include "TRegexp.h" #include "TH3.h" #include "JTools/JRange.hh" #include "JGizmo/JRootObjectID.hh" #include "JGizmo/JGizmoToolkit.hh" #include "Jeep/JPrint.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * Auxiliary program to print the ranges of x, y, z and c values of 3D ROOT objects. * The option -f corresponds to \:\. * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; typedef JRange JRange_t; vector inputFile; JRange_t x; JRange_t y; JRange_t z; JRange_t c; int debug; try { JParser<> zap("Auxiliary program to print the ranges of x, y, z and c values of 3D ROOT objects."); zap['f'] = make_field(inputFile, ":"); zap['x'] = make_field(x, "x range") = JRange_t(); zap['y'] = make_field(y, "y range") = JRange_t(); zap['z'] = make_field(z, "z range") = JRange_t(); zap['c'] = make_field(c, "c range") = JRange_t(); zap['d'] = make_field(debug) = 0; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } JRange_t X = JRange_t::DEFAULT_RANGE(); JRange_t Y = JRange_t::DEFAULT_RANGE(); JRange_t Z = JRange_t::DEFAULT_RANGE(); JRange_t C = JRange_t::DEFAULT_RANGE(); 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(); try { TH3& h3 = dynamic_cast(*object); X.combine(x.join(JRange_t(h3.GetXaxis()->GetXmin(), h3.GetXaxis()->GetXmax()))); Y.combine(y.join(JRange_t(h3.GetYaxis()->GetXmin(), h3.GetYaxis()->GetXmax()))); Z.combine(z.join(JRange_t(h3.GetZaxis()->GetXmin(), h3.GetZaxis()->GetXmax()))); C.combine(c.join(JRange_t(h3.GetMinimum(), h3.GetMaximum()))); } catch(exception&) {} } } } cout << SCIENTIFIC(15,5) << X.getLowerLimit() << ' ' << SCIENTIFIC(15,5) << Y.getLowerLimit() << ' ' << SCIENTIFIC(15,5) << Z.getLowerLimit() << ' ' << SCIENTIFIC(15,5) << C.getLowerLimit() << ' ' << SCIENTIFIC(15,5) << X.getUpperLimit() << ' ' << SCIENTIFIC(15,5) << Y.getUpperLimit() << ' ' << SCIENTIFIC(15,5) << Z.getUpperLimit() << ' ' << SCIENTIFIC(15,5) << C.getUpperLimit() << endl; }