31{
34
36
39 JRange_t X;
41 bool reverse;
42 bool normalise;
44
45 try {
46
47 JParser<> zap(
"Auxiliary program to make cumulative ROOT histogram.");
48
49 zap[
'f'] =
make_field(inputFile,
"<input file>:<object name>");
51 zap[
'x'] =
make_field(X,
"accepted x-range values") = JRange_t();
53 zap[
'R'] =
make_field(reverse,
"sum right to left instead of left to right");
54 zap[
'N'] =
make_field(normalise,
"normalise histogram contents");
56
58 }
59 catch(const exception &error) {
61 }
62
63
65
67
69
71
73 ERROR(
"File: " << input->getFullFilename() <<
" not opened." <<
endl);
74 continue;
75 }
76
78
80
82
83 const TString tag(
key->GetName());
84
86
87
88
90
92
93 try {
94
95 TH1& h1 =
dynamic_cast<TH1&
>(*object);
96
97 double W = 0.0;
98
99 if (!reverse) {
100
102
103 if (X(h1.GetBinCenter(i))) {
104 W += h1.GetBinContent(i) * (
binwidth ? h1.GetBinWidth(i) : 1.0);
105 }
106
107 h1.SetBinContent(i, W);
108
109 if (h1.GetSumw2N()) {
110 h1.SetBinError(i, h1.GetBinError(i) * (
binwidth ? h1.GetBinWidth(i) : 1.0));
111 }
112 }
113
114 } else {
115
116 for (
Int_t i = h1.GetXaxis()->GetNbins() + 1; i >= 0; --i) {
117
118 if (X(h1.GetBinCenter(i))) {
119 W += h1.GetBinContent(i) * (
binwidth ? h1.GetBinWidth(i) : 1.0);
120 }
121
122 h1.SetBinContent(i, W);
123
124 if (h1.GetSumw2N()) {
125 h1.SetBinError(i, h1.GetBinError(i) * (
binwidth ? h1.GetBinWidth(i) : 1.0));
126 }
127 }
128 }
129
131
132 if (normalise && W != 0.0) {
133 h1.Scale(1.0/W);
134 }
135
136 out.WriteTObject(&h1);
137 }
138 catch(exception&) {}
139 }
140 }
141 }
142
143 out.Write();
144 out.Close();
145}
#define DEBUG(A)
Message macros.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Template definition of a multi-dimensional oscillation probability interpolation table.
Utility class to parse command line options.
TDirectory * getDirectory(const JRootObjectID &id)
Get TDirectory pointer.
bool isTObject(const TKey *key)
Check if given key corresponds to a TObject.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure for floating point format specification.