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