30 int main(
int argc,
char **argv)
35 typedef JRange<double> JRange_t;
47 JParser<> zap(
"Auxiliary program to make cumulative ROOT histogram.");
49 zap[
'f'] =
make_field(inputFile,
"<input file>:<object name>");
51 zap[
'x'] =
make_field(
X,
"accepted x-range values") = JRange_t();
52 zap[
'B'] =
make_field(binwidth,
"multiply by bin width");
53 zap[
'R'] =
make_field(reverse,
"sum right to left instead of left to right");
54 zap[
'N'] =
make_field(normalise,
"normalise histogram contents");
59 catch(
const exception &error) {
60 FATAL(error.what() << endl);
68 DEBUG(
"Input: " << *input << endl);
73 ERROR(
"File: " << input->getFullFilename() <<
" not opened." << endl);
77 const TRegexp regexp(input->getObjectName());
79 TIter iter(dir->GetListOfKeys());
81 for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
83 const TString tag(key->GetName());
85 DEBUG(
"Key: " << tag <<
" match = " << tag.Contains(regexp) << endl);
89 if (tag.Contains(regexp) &&
isTObject(key)) {
91 TObject*
object = key->ReadObj();
95 TH1& h1 =
dynamic_cast<TH1&
>(*object);
101 for (Int_t i = 0; i <= h1.GetXaxis()->GetNbins() + 1; ++i) {
103 if (
X(h1.GetBinCenter(i))) {
104 W += h1.GetBinContent(i) * (binwidth ? h1.GetBinWidth(i) : 1.0);
107 h1.SetBinContent(i, W);
109 if (h1.GetSumw2N()) {
110 h1.SetBinError(i, h1.GetBinError(i) * (binwidth ? h1.GetBinWidth(i) : 1.0));
116 for (Int_t i = h1.GetXaxis()->GetNbins() + 1; i >= 0; --i) {
118 if (
X(h1.GetBinCenter(i))) {
119 W += h1.GetBinContent(i) * (binwidth ? h1.GetBinWidth(i) : 1.0);
122 h1.SetBinContent(i, W);
124 if (h1.GetSumw2N()) {
125 h1.SetBinError(i, h1.GetBinError(i) * (binwidth ? h1.GetBinWidth(i) : 1.0));
130 NOTICE(setw(24) << left << h1.GetName() <<
' ' <<
SCIENTIFIC(12,3) << W << endl);
132 if (normalise && W != 0.0) {
136 out.WriteTObject(&h1);
Utility class to parse command line options.
int main(int argc, char *argv[])
I/O formatting auxiliaries.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
General purpose messaging.
Auxiliary class to define a range between two values.
Utility class to parse command line options.
bool isTObject(const TKey *key)
Check if given key corresponds to a TObject.
no fit printf nominal n $STRING awk v X
TDirectory * getDirectory(const JRootObjectID &id)
Get TDirectory pointer.
Auxiliary data structure for floating point format specification.
#define DEBUG(A)
Message macros.