31 int main(
int argc,
char **argv)
36 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[
'R'] =
make_field(reverse,
"sum right to left instead of left to right");
53 zap[
'N'] =
make_field(normalise,
"normalise histogram contents");
58 catch(
const exception &error) {
59 FATAL(error.what() << endl);
67 DEBUG(
"Input: " << *input << endl);
72 ERROR(
"File: " << input->getFullFilename() <<
" not opened." << endl);
76 const TRegexp regexp(input->getObjectName());
78 TIter iter(dir->GetListOfKeys());
80 for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
82 const TString tag(key->GetName());
84 DEBUG(
"Key: " << tag <<
" match = " << tag.Contains(regexp) << endl);
88 if (tag.Contains(regexp)) {
90 TObject*
object = key->ReadObj();
94 TH1& h1 = dynamic_cast<TH1&>(*
object);
100 for (Int_t i = 0; i <= h1.GetXaxis()->GetNbins() + 1; ++i) {
102 if (X(h1.GetBinCenter(i))) {
103 W += h1.GetBinContent(i);
106 h1.SetBinContent(i, W);
111 for (Int_t i = h1.GetXaxis()->GetNbins() + 1; i >= 0; --i) {
113 if (X(h1.GetBinCenter(i))) {
114 W += h1.GetBinContent(i);
117 h1.SetBinContent(i, W);
121 NOTICE(setw(24) << left << h1.GetName() <<
' ' <<
SCIENTIFIC(12,3) << W << endl);
123 if (normalise && W != 0.0) {
127 out.WriteTObject(&h1);