Jpp  15.0.4
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JFileTuna.cc File Reference

Auxiliary program to write test criteria to file. More...

#include <string>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <vector>
#include <utility>
#include "TROOT.h"
#include "TFile.h"
#include "TObject.h"
#include "TKey.h"
#include "TString.h"
#include "TRegexp.h"
#include "TGraph.h"
#include "JGizmo/JRootObjectID.hh"
#include "JGizmo/JGizmoToolkit.hh"
#include "JTools/JRange.hh"
#include "JLang/JLangToolkit.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"
#include "Jeep/JPrint.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Auxiliary program to write test criteria to file.

The option -f corresponds to <file name>:<object name>.

Definition in file JFileTuna.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 61 of file JFileTuna.cc.

62 {
63  using namespace std;
64  using namespace JPP;
65 
66  JRootObjectID inputFile;
67  string outputFile;
68  int numberOfEntries;
69  int numberOfOutliers;
70  map_type y_expand;
71  map_type y_margin;
72  int debug;
73 
74  try {
75 
76  JParser<> zap("Auxiliary program to write test criteria to file.");
77 
78  zap['f'] = make_field(inputFile, "<input file>:<object name>");
79  zap['P'] = make_field(outputFile, "ASCII formatted output file with test criteria");
80  zap['N'] = make_field(numberOfEntries, "Minimal number of entries");
81  zap['O'] = make_field(numberOfOutliers, "Maximal number of outliers");
82  zap['Y'] = make_field(y_expand, "Expand range of values") = JPARSER::initialised();
83  zap['D'] = make_field(y_margin, "Margin range of values") = JPARSER::initialised();
84  zap['d'] = make_field(debug) = 1;
85 
86  zap(argc, argv);
87  }
88  catch(const exception &error) {
89  FATAL(error.what() << endl);
90  }
91 
92 
93  ofstream out(outputFile.c_str());
94 
95  if (out) {
96 
97  TDirectory* dir = getDirectory(inputFile);
98 
99  if (dir == NULL) {
100  FATAL("File: " << inputFile.getFullFilename() << " not opened." << endl);
101  }
102 
103  const TRegexp regexp(inputFile.getObjectName());
104 
105  TIter iter(dir->GetListOfKeys());
106 
107  for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
108 
109  const TString tag(key->GetName());
110 
111  DEBUG("Key: " << tag << " match = " << tag.Contains(regexp) << endl);
112 
113  // option match
114 
115  if (tag.Contains(regexp)) {
116 
117  TGraph* g1 = dynamic_cast<TGraph*>(key->ReadObj());
118 
119  if (g1 != NULL) {
120 
121  const JRange<double> range(g1->GetY(), g1->GetY() + g1->GetN());
122 
123  const double extra = (getValue(y_expand, tag, 0.0) * (range.getUpperLimit() - range.getLowerLimit()) +
124  getValue(y_margin, tag, 0.0));
125 
126  out << setw(64) << left << g1->GetName() << right << ' '
127  << setw(5) << numberOfEntries << ' '
128  << setw(3) << numberOfOutliers << ' '
129  << FIXED(15,3) << range.getLowerLimit() - extra << ' '
130  << FIXED(15,3) << range.getUpperLimit() + extra << endl;
131  }
132  }
133  }
134  } else {
135  FATAL("Error opening file: " << outputFile << endl);
136  }
137 }
Utility class to parse command line options.
Definition: JParser.hh:1500
double getValue(const JScale_t scale)
Get numerical value corresponding to scale.
Definition: JScale.hh:47
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:66
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
string outputFile
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
int debug
debug level
Definition: JSirene.cc:63
#define FATAL(A)
Definition: JMessage.hh:67
z range($ZMAX-$ZMIN)< $MINIMAL_DZ." fi fi typeset -Z 4 STRING typeset -Z 2 FLOOR JPlot1D -f $
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
TDirectory * getDirectory(const JRootObjectID &id)
Get TDirectory pointer.
Double_t g1(const Double_t x)
Function.
Definition: JQuantiles.cc:25