Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JPrintRange3D.cc
Go to the documentation of this file.
1#include <string>
2#include <iostream>
3#include <iomanip>
4
5#include "TROOT.h"
6#include "TFile.h"
7#include "TClass.h"
8#include "TKey.h"
9#include "TRegexp.h"
10#include "TH3.h"
11
12#include "JTools/JRange.hh"
15
16#include "Jeep/JPrint.hh"
17#include "Jeep/JParser.hh"
18#include "Jeep/JMessage.hh"
19
20
21/**
22 * \file
23 * Auxiliary program to print the ranges of x, y, z and c values of 3D ROOT objects.
24 * The option <tt>-f</tt> corresponds to <tt><file name>:<object name></tt>.
25 * \author mdejong
26 */
27int main(int argc, char **argv)
28{
29 using namespace std;
30 using namespace JPP;
31
32 typedef JRange<double> JRange_t;
33
34 vector<JRootObjectID> inputFile;
35 JRange_t x;
36 JRange_t y;
37 JRange_t z;
38 JRange_t c;
39 int debug;
40
41 try {
42
43 JParser<> zap("Auxiliary program to print the ranges of x, y, z and c values of 3D 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();
48 zap['z'] = make_field(z, "z range") = JRange_t();
49 zap['c'] = make_field(c, "c range") = JRange_t();
50 zap['d'] = make_field(debug) = 0;
51
52 zap(argc, argv);
53 }
54 catch(const exception &error) {
55 FATAL(error.what() << endl);
56 }
57
58
59 JRange_t X = JRange_t::DEFAULT_RANGE();
60 JRange_t Y = JRange_t::DEFAULT_RANGE();
61 JRange_t Z = JRange_t::DEFAULT_RANGE();
62 JRange_t C = JRange_t::DEFAULT_RANGE();
63
64 for (vector<JRootObjectID>::const_iterator input = inputFile.begin(); input != inputFile.end(); ++input) {
65
66 DEBUG("Input: " << *input << endl);
67
68 TDirectory* dir = getDirectory(*input);
69
70 if (dir == NULL) {
71 ERROR("File: " << input->getFullFilename() << " not opened." << endl);
72 continue;
73 }
74
75 const TRegexp regexp(input->getObjectName());
76
77 TIter iter(dir->GetListOfKeys());
78
79 for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
80
81 const TString tag(key->GetName());
82
83 DEBUG("Key: " << tag << " match = " << tag.Contains(regexp) << endl);
84
85 // option match
86
87 if (tag.Contains(regexp) && isTObject(key)) {
88
89 TObject* object = key->ReadObj();
90
91 try {
92
93 TH3& h3 = dynamic_cast<TH3&>(*object);
94
95 X.combine(x.join(JRange_t(h3.GetXaxis()->GetXmin(), h3.GetXaxis()->GetXmax())));
96 Y.combine(y.join(JRange_t(h3.GetYaxis()->GetXmin(), h3.GetYaxis()->GetXmax())));
97 Z.combine(z.join(JRange_t(h3.GetZaxis()->GetXmin(), h3.GetZaxis()->GetXmax())));
98 C.combine(c.join(JRange_t(h3.GetMinimum(), h3.GetMaximum())));
99 }
100 catch(exception&) {}
101 }
102 }
103 }
104
105
106 cout << SCIENTIFIC(15,5) << X.getLowerLimit() << ' '
107 << SCIENTIFIC(15,5) << Y.getLowerLimit() << ' '
108 << SCIENTIFIC(15,5) << Z.getLowerLimit() << ' '
109 << SCIENTIFIC(15,5) << C.getLowerLimit() << ' '
110 << SCIENTIFIC(15,5) << X.getUpperLimit() << ' '
111 << SCIENTIFIC(15,5) << Y.getUpperLimit() << ' '
112 << SCIENTIFIC(15,5) << Z.getUpperLimit() << ' '
113 << SCIENTIFIC(15,5) << C.getUpperLimit() << endl;
114}
General purpose messaging.
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define ERROR(A)
Definition JMessage.hh:66
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
int main(int argc, char **argv)
I/O formatting auxiliaries.
Auxiliary class to define a range between two values.
Utility class to parse command line options.
Definition JParser.hh:1698
Range of values.
Definition JRange.hh:42
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure for floating point format specification.
Definition JManip.hh:488