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

Auxiliary program to print quantiles from ROOT histograms. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cmath>
#include "TROOT.h"
#include "TFile.h"
#include "TObject.h"
#include "TKey.h"
#include "TH1.h"
#include "TRegexp.h"
#include "JGizmo/JRootObjectID.hh"
#include "JGizmo/JGizmoToolkit.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 print quantiles from ROOT histograms.

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

Author
mdejong

Definition in file JPrintQuantiles.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 30 of file JPrintQuantiles.cc.

31 {
32  using namespace std;
33  using namespace JPP;
34 
35  vector<JRootObjectID> inputFile;
37  int debug;
38 
39  try {
40 
41  JParser<> zap("Auxiliary program to print quantiles from ROOT histograms.");
42 
43  zap['f'] = make_field(inputFile, "<input file>:<object name>");
44  zap['Q'] = make_field(Q, "quantiles");
45  zap['d'] = make_field(debug) = 0;
46 
47  zap(argc, argv);
48  }
49  catch(const exception &error) {
50  FATAL(error.what() << endl);
51  }
52 
53 
54  for (vector<JRootObjectID>::const_iterator input = inputFile.begin(); input != inputFile.end(); ++input) {
55 
56  DEBUG("Input: " << *input << endl);
57 
58  TDirectory* dir = getDirectory(*input);
59 
60  if (dir == NULL) {
61  ERROR("File: " << input->getFullFilename() << " not opened." << endl);
62  continue;
63  }
64 
65  const TRegexp regexp(input->getObjectName());
66 
67  TIter iter(dir->GetListOfKeys());
68 
69  for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
70 
71  const TString tag(key->GetName());
72 
73  DEBUG("Key: " << tag << " match = " << tag.Contains(regexp) << endl);
74 
75  // option match
76 
77  if (tag.Contains(regexp)) {
78 
79  TObject* object = key->ReadObj();
80 
81  TH1* h1 = dynamic_cast<TH1*>(object);
82 
83  if (h1 != NULL) {
84 
85  vector<Double_t> X(Q.size(), 0.0);
86 
87  h1->GetQuantiles(Q.size(), X.data(), Q.data());
88 
89  for (vector<Double_t>::const_iterator i = X.begin(); i != X.end(); ++i) {
90  cout << ' ' << *i;
91  }
92 
93  cout << endl;
94  }
95  }
96  }
97  }
98 }
Utility class to parse command line options.
Definition: JParser.hh:1500
Q(UTCMax_s-UTCMin_s)-livetime_s
Definition: JRoot.hh:19
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:69
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
#define ERROR(A)
Definition: JMessage.hh:66
then break fi done getCenter read X Y Z let X
int debug
debug level
Definition: JSirene.cc:63
#define FATAL(A)
Definition: JMessage.hh:67
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.