Jpp
18.2.1-ARCA-DF-PATCH
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 "TGraph.h"
13
#include "TRegexp.h"
14
15
#include "
JTools/JQuantile.hh
"
16
17
#include "
JGizmo/JRootObjectID.hh
"
18
#include "
JGizmo/JGizmoToolkit.hh
"
19
20
#include "
Jeep/JParser.hh
"
21
#include "
Jeep/JMessage.hh
"
22
#include "
Jeep/JPrint.hh
"
23
24
25
/**
26
* \file
27
*
28
* Auxiliary program to print quantiles from ROOT histograms or graphs.
29
* The option <tt>-f</tt> corresponds to <tt><file name>:<object name></tt>.
30
*
31
* \author mdejong
32
*/
33
int
main
(
int
argc,
char
**argv)
34
{
35
using namespace
std;
36
using namespace
JPP;
37
38
vector<JRootObjectID>
inputFile;
39
vector<Double_t>
Q
;
40
int
debug
;
41
42
try
{
43
44
JParser<>
zap(
"Auxiliary program to print quantiles from ROOT histograms."
);
45
46
zap[
'f'
] =
make_field
(inputFile,
"<input file>:<object name>"
);
47
zap[
'Q'
] =
make_field
(
Q
,
"quantiles"
);
48
zap[
'd'
] =
make_field
(
debug
) = 0;
49
50
zap(argc, argv);
51
}
52
catch
(
const
exception &error) {
53
FATAL
(error.what() << endl);
54
}
55
56
57
for
(
vector<JRootObjectID>::const_iterator
input = inputFile.begin(); input != inputFile.end(); ++input) {
58
59
DEBUG
(
"Input: "
<< *input << endl);
60
61
TDirectory* dir =
getDirectory
(*input);
62
63
if
(dir == NULL) {
64
ERROR
(
"File: "
<< input->getFullFilename() <<
" not opened."
<< endl);
65
continue
;
66
}
67
68
const
TRegexp regexp(input->getObjectName());
69
70
TIter iter(dir->GetListOfKeys());
71
72
for
(TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
73
74
const
TString tag(key->GetName());
75
76
DEBUG
(
"Key: "
<< tag <<
" match = "
<< tag.Contains(regexp) << endl);
77
78
// option match
79
80
if
(tag.Contains(regexp) &&
isTObject
(key)) {
81
82
TObject
*
object
= key->ReadObj();
83
84
vector<Double_t>
X
(
Q
.size(), 0.0);
85
86
try
{
87
88
TH1& h1 =
dynamic_cast<
TH1&
>
(*object);
89
90
h1.GetQuantiles(
Q
.size(), X.data(),
Q
.data());
91
}
92
catch
(
const
exception&) {}
93
94
try
{
95
96
TGraph&
g1
=
dynamic_cast<
TGraph&
>
(*object);
97
98
JQuantile Q1(
""
,
true
);
99
100
for
(Int_t
i
= 0;
i
!= g1.GetN(); ++
i
) {
101
Q1.put(g1.GetX()[
i
], g1.GetY()[
i
]);
102
}
103
104
for
(
size_t
i
= 0;
i
!=
Q
.size(); ++
i
) {
105
X[
i
] = Q1.getQuantile(
Q
[
i
]);
106
}
107
}
108
catch
(
const
exception&) {}
109
110
for
(
vector<Double_t>::const_iterator
i
= X.begin();
i
!= X.end(); ++
i
) {
111
cout <<
' '
<< *
i
;
112
}
113
114
cout << endl;
115
}
116
}
117
}
118
}
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1514
Q
Q(UTCMax_s-UTCMin_s)-livetime_s
main
int main(int argc, char *argv[])
Definition:
Main.cc:15
TObject
Definition:
JRoot.hh:19
std::vector
Definition:
JSTDTypes.hh:12
i
then rm i
Definition:
JEvtReweightMupageParameterScan.sh:309
JPrint.hh
I/O formatting auxiliaries.
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:1989
ERROR
#define ERROR(A)
Definition:
JMessage.hh:66
JGizmoToolkit.hh
JRootObjectID.hh
JMessage.hh
General purpose messaging.
FATAL
#define FATAL(A)
Definition:
JMessage.hh:67
JParser.hh
Utility class to parse command line options.
JQuantile.hh
JGIZMO::isTObject
bool isTObject(const TKey *key)
Check if given key corresponds to a TObject.
Definition:
JGizmoToolkit.hh:1520
X
no fit printf nominal n $STRING awk v X
Definition:
detector-XY:fit.sh:102
JGIZMO::getDirectory
TDirectory * getDirectory(const JRootObjectID &id)
Get TDirectory pointer.
Definition:
JGizmoToolkit.hh:140
debug
int debug
debug level
Definition:
archive-put-wiki-detectors.sh:92
DEBUG
#define DEBUG(A)
Message macros.
Definition:
JMessage.hh:62
g1
Double_t g1(const Double_t x)
Function.
Definition:
JQuantiles.cc:25
Generated by
1.8.5