31{
34
36
41
42 try {
43
44 JParser<> zap(
"Auxiliary program to print the ranges of x and y values of 1D ROOT objects.");
45
46 zap[
'f'] =
make_field(inputFile,
"<input file>:<object name>");
47 zap[
'x'] =
make_field(x,
"x range") = JRange_t();
48 zap[
'y'] =
make_field(y,
"y range") = JRange_t();
50
51 zap(argc, argv);
52 }
53 catch(const exception &error) {
54 FATAL(error.what() << endl);
55 }
56
57
58 JRange_t X = JRange_t::DEFAULT_RANGE();
59 JRange_t Y = JRange_t::DEFAULT_RANGE();
60
61 for (vector<JRootObjectID>::const_iterator input = inputFile.begin(); input != inputFile.end(); ++input) {
62
63 DEBUG(
"Input: " << *input << endl);
64
66
67 if (dir == NULL) {
68 ERROR(
"File: " << input->getFullFilename() <<
" not opened." << endl);
69 continue;
70 }
71
72 const TRegexp regexp(input->getObjectName());
73
74 TIter iter(dir->GetListOfKeys());
75
76 for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
77
78 const TString tag(key->GetName());
79
80 DEBUG(
"Key: " << tag <<
" match = " << tag.Contains(regexp) << endl);
81
82
83
84 if (tag.Contains(regexp) &&
isTObject(key)) {
85
86 TObject*
object = key->ReadObj();
87
88 try {
89
90 TH1& h1 = dynamic_cast<TH1&>(*object);
91
92 X.combine(
x.join(JRange_t(h1.GetXaxis()->GetXmin(), h1.GetXaxis()->GetXmax())));
93 Y.combine(
y.join(JRange_t(h1.GetMinimum(), h1.GetMaximum())));
94 }
95 catch(exception&) {}
96
97 try {
98
99 TProfile& h1 = dynamic_cast<TProfile&>(*object);
100
101 X.combine(
x.join(JRange_t(h1.GetXaxis()->GetXmin(), h1.GetXaxis()->GetXmax())));
102 Y.combine(
y.join(JRange_t(h1.GetMinimum(), h1.GetMaximum())));
103 }
104 catch(exception&) {}
105
106 try {
107
108 TGraph&
g1 =
dynamic_cast<TGraph&
>(*object);
109
110 for (Int_t i = 0; i !=
g1.GetN(); ++i) {
111 if (
x(
g1.GetX()[i]) &&
113 X.include(
g1.GetX()[i]);
114 Y.include(
g1.GetY()[i]);
115 }
116 }
117 }
118 catch(exception&) {}
119 }
120 }
121 }
122
123
124 cout <<
SCIENTIFIC(15,5) << X.getLowerLimit() <<
' '
125 <<
SCIENTIFIC(15,5) << Y.getLowerLimit() <<
' '
126 <<
SCIENTIFIC(15,5) << X.getUpperLimit() <<
' '
127 <<
SCIENTIFIC(15,5) << Y.getUpperLimit() << endl;
128}
#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.