30{
33
36
37 try {
38
39 JParser<> zap(
"Auxiliary program to print (x,y) of the maximum of 2D 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
80 double zmax = numeric_limits<double>::lowest();
81
82 try {
83
84 TH2& h2 = dynamic_cast<TH2&>(*object);
85
86 for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
87 for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
88
89 double z = h2.GetBinContent(ix,iy);
90
91 if (z > zmax) {
92 zmax = z;
93 x = h2.GetXaxis()->GetBinCenter(ix);
94 y = h2.GetYaxis()->GetBinCenter(iy);
95 }
96 }
97 }
98 }
99 catch(exception&) {}
100
101 try {
102
103 TProfile2D& h2 = dynamic_cast<TProfile2D&>(*object);
104
105 for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
106 for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
107
108 double z = h2.GetBinContent(ix,iy);
109
110 if (z > zmax) {
111 zmax = z;
112 x = h2.GetXaxis()->GetBinCenter(ix);
113 y = h2.GetYaxis()->GetBinCenter(iy);
114 }
115 }
116 }
117 }
118 catch(exception&) {}
119
120 try {
121
122 TGraph2D& g2 = dynamic_cast<TGraph2D&>(*object);
123
124 for (Int_t i = 0; i != g2.GetN(); ++i) {
125 if (g2.GetZ()[i] > zmax) {
126 zmax = g2.GetZ()[i];
129 }
130 }
131 }
132 catch(exception&) {}
133
134 if (zmax != numeric_limits<double>::lowest()) {
135 cout << setw(32) << left <<
key->GetName() << right <<
' ' <<
SCIENTIFIC(15,5) <<
x <<
' ' <<
SCIENTIFIC(15,5) <<
y << endl;
136 }
137 }
138 }
139 }
140}
#define DEBUG(A)
Message macros.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
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.