Jpp
15.0.4
the software that should make you happy
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
software
JGizmo
JPrintQuantiles.cc
Go to the documentation of this file.
1
#include <string>
2
#include <iostream>
3
#include <iomanip>
4
#include <sstream>
5
#include <cmath>
6
7
#include "TROOT.h"
8
#include "TFile.h"
9
#include "TObject.h"
10
#include "TKey.h"
11
#include "TH1.h"
12
#include "TRegexp.h"
13
14
#include "
JGizmo/JRootObjectID.hh
"
15
#include "
JGizmo/JGizmoToolkit.hh
"
16
17
#include "
Jeep/JParser.hh
"
18
#include "
Jeep/JMessage.hh
"
19
#include "
Jeep/JPrint.hh
"
20
21
22
/**
23
* \file
24
*
25
* Auxiliary program to print quantiles from ROOT histograms.
26
* The option <tt>-f</tt> corresponds to <tt><file name>:<object name></tt>.
27
*
28
* \author mdejong
29
*/
30
int
main
(
int
argc,
char
**argv)
31
{
32
using namespace
std;
33
using namespace
JPP;
34
35
vector<JRootObjectID>
inputFile;
36
vector<Double_t>
Q
;
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
}
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1500
Q
Q(UTCMax_s-UTCMin_s)-livetime_s
main
int main(int argc, char *argv[])
Definition:
Main.cc:15
TObject
Definition:
JRoot.hh:19
h1
then for HISTOGRAM in h0 h1
Definition:
JMatrixNZ.sh:71
std::vector
Definition:
JSTDTypes.hh:12
JPrint.hh
I/O formatting auxiliaries.
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:1961
ERROR
#define ERROR(A)
Definition:
JMessage.hh:66
X
then break fi done getCenter read X Y Z let X
Definition:
acoustics-fit.sh:387
JGizmoToolkit.hh
debug
int debug
debug level
Definition:
JSirene.cc:63
JRootObjectID.hh
JMessage.hh
General purpose messaging.
FATAL
#define FATAL(A)
Definition:
JMessage.hh:67
JParser.hh
Utility class to parse command line options.
DEBUG
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
Definition:
JCalibratePMT.sh:21
JGIZMO::getDirectory
TDirectory * getDirectory(const JRootObjectID &id)
Get TDirectory pointer.
Definition:
JGizmoToolkit.hh:131
Generated by
1.8.5