30int main(
int argc, 
char **argv)
 
   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);
 
   66  for (vector<JRootObjectID>::const_iterator input = inputFile.begin(); input != inputFile.end(); ++input) {
 
   68    DEBUG(
"Input: " << *input << endl);
 
   70    TDirectory* dir = getDirectory(*input);
 
   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);