Jpp
Functions
JFileTuna.cc File Reference
#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

◆ main()

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 }
FIXED
Auxiliary data structure for floating point format specification.
Definition: JPrint.hh:481
g1
Double_t g1(const Double_t x)
Function.
Definition: JQuantiles.cc:25
JPARSER::initialised
Empty structure for specification of parser element that is initialised (i.e.
Definition: JParser.hh:63
JPARSER::JParser
Utility class to parse command line options.
Definition: JParser.hh:1493
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
debug
int debug
debug level
Definition: JSirene.cc:59
JGIZMO::getDirectory
TDirectory * getDirectory(const JRootObjectID &id)
Get TDirectory pointer.
Definition: JGizmoToolkit.hh:121
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
DEBUG
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
std
Definition: jaanetDictionary.h:36
JEEP::getValue
double getValue(const JScale_t scale)
Get numerical value corresponding to scale.
Definition: JScale.hh:47
FATAL
#define FATAL(A)
Definition: JMessage.hh:67
outputFile
string outputFile
Definition: JDAQTimesliceSelector.cc:37