Jpp  18.2.1-ARCA-DF-PATCH
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 "TApplication.h"
9 #include "TKey.h"
10 #include "TRegexp.h"
11 #include "TH3.h"
12 
13 #include "JTools/JRange.hh"
14 #include "JGizmo/JRootObjectID.hh"
15 #include "JGizmo/JGizmoToolkit.hh"
16 
17 #include "Jeep/JPrint.hh"
18 #include "Jeep/JParser.hh"
19 #include "Jeep/JMessage.hh"
20 
21 
22 /**
23  * \file
24  * Auxiliary program to print the ranges of x, y, z and c values of 3D ROOT objects.
25  * The option <tt>-f</tt> corresponds to <tt><file name>:<object name></tt>.
26  * \author mdejong
27  */
28 int main(int argc, char **argv)
29 {
30  using namespace std;
31  using namespace JPP;
32 
33  typedef JRange<double> JRange_t;
34 
35  vector<JRootObjectID> inputFile;
36  JRange_t x;
37  JRange_t y;
38  JRange_t z;
39  JRange_t c;
40  int debug;
41 
42  try {
43 
44  JParser<> zap("Auxiliary program to print the ranges of x, y, z and c values of 3D 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();
49  zap['z'] = make_field(z, "z range") = JRange_t();
50  zap['c'] = make_field(c, "c range") = JRange_t();
51  zap['d'] = make_field(debug) = 0;
52 
53  zap(argc, argv);
54  }
55  catch(const exception &error) {
56  FATAL(error.what() << endl);
57  }
58 
59 
60  JRange_t X = JRange_t::DEFAULT_RANGE();
61  JRange_t Y = JRange_t::DEFAULT_RANGE();
62  JRange_t Z = JRange_t::DEFAULT_RANGE();
63  JRange_t C = JRange_t::DEFAULT_RANGE();
64 
65  for (vector<JRootObjectID>::const_iterator input = inputFile.begin(); input != inputFile.end(); ++input) {
66 
67  DEBUG("Input: " << *input << endl);
68 
69  TDirectory* dir = getDirectory(*input);
70 
71  if (dir == NULL) {
72  ERROR("File: " << input->getFullFilename() << " not opened." << endl);
73  continue;
74  }
75 
76  const TRegexp regexp(input->getObjectName());
77 
78  TIter iter(dir->GetListOfKeys());
79 
80  for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
81 
82  const TString tag(key->GetName());
83 
84  DEBUG("Key: " << tag << " match = " << tag.Contains(regexp) << endl);
85 
86  // option match
87 
88  if (tag.Contains(regexp) && isTObject(key)) {
89 
90  TObject* object = key->ReadObj();
91 
92  try {
93 
94  TH3& h3 = dynamic_cast<TH3&>(*object);
95 
96  X.combine(x.join(JRange_t(h3.GetXaxis()->GetXmin(), h3.GetXaxis()->GetXmax())));
97  Y.combine(y.join(JRange_t(h3.GetYaxis()->GetXmin(), h3.GetYaxis()->GetXmax())));
98  Z.combine(z.join(JRange_t(h3.GetZaxis()->GetXmin(), h3.GetZaxis()->GetXmax())));
99  C.combine(c.join(JRange_t(h3.GetMinimum(), h3.GetMaximum())));
100  }
101  catch(exception&) {}
102  }
103  }
104  }
105 
106 
107  cout << SCIENTIFIC(15,5) << X.getLowerLimit() << ' '
108  << SCIENTIFIC(15,5) << Y.getLowerLimit() << ' '
109  << SCIENTIFIC(15,5) << Z.getLowerLimit() << ' '
110  << SCIENTIFIC(15,5) << C.getLowerLimit() << ' '
111  << SCIENTIFIC(15,5) << X.getUpperLimit() << ' '
112  << SCIENTIFIC(15,5) << Y.getUpperLimit() << ' '
113  << SCIENTIFIC(15,5) << Z.getUpperLimit() << ' '
114  << SCIENTIFIC(15,5) << C.getUpperLimit() << endl;
115 }
Utility class to parse command line options.
Definition: JParser.hh:1514
int main(int argc, char *argv[])
Definition: Main.cc:15
Definition: JRoot.hh:19
then fatal Wrong number of arguments fi set_variable STRING $argv[1] set_variable DETECTORXY_TXT $WORKDIR $DETECTORXY_TXT tail read X Y CHI2 RMS printf optimum n $X $Y $CHI2 $RMS awk v Y
static const double C
Physics constants.
I/O formatting auxiliaries.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
#define ERROR(A)
Definition: JMessage.hh:66
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
$WORKDIR ev_configure_dqsimulator txt echo process $DQ_SIMULATOR $i $SOURCE_HOST[$index] csh c(setenv ROOTSYS $ROOTSYS &&source $JPP_DIR/setenv.csh $JPP_DIR &&($DQ_SIMULATOR\-u\$NAME\$\-H\$SERVER\$\-M\$LOGGER\$\-d $DEBUG</dev/null > &/dev/null &))'
Auxiliary class to define a range between two values.
Utility class to parse command line options.
bool isTObject(const TKey *key)
Check if given key corresponds to a TObject.
no fit printf nominal n $STRING awk v X
TDirectory * getDirectory(const JRootObjectID &id)
Get TDirectory pointer.
do set_variable MODULE getModule a $WORKDIR detector_a datx L $STRING JEditDetector a $WORKDIR detector_a datx M $MODULE setz o $WORKDIR detector_a datx JEditDetector a $WORKDIR detector_b datx M $MODULE setz o $WORKDIR detector_b datx done echo Output stored at $WORKDIR detector_a datx and $WORKDIR tripod_a txt JDrawDetector2D a $WORKDIR detector_a datx a $WORKDIR detector_b datx L BL o detector $FORMAT $BATCH JDrawDetector2D T $WORKDIR tripod_a txt T $WORKDIR tripod_b txt L BL o tripod $FORMAT $BATCH JCompareDetector a $WORKDIR detector_a datx b $WORKDIR detector_b datx o $WORKDIR abc root &dev null for KEY in X Y Z
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:484
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62