Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JTreeIterator.cc File Reference

Program to test iteration using JSUPPORT::JTreeScanner. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "JDAQ/JDAQEventIO.hh"
#include "JDAQ/JDAQEvaluator.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JTreeScanner.hh"
#include "JSupport/JSupport.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Program to test iteration using JSUPPORT::JTreeScanner.

Author
mdejong

Definition in file JTreeIterator.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 23 of file JTreeIterator.cc.

24 {
25  using namespace std;
26  using namespace JPP;
27  using namespace KM3NETDAQ;
28 
29  JMultipleFileScanner<> inputFile;
30  JLimit_t& numberOfEvents = inputFile.getLimit();
31  int debug;
32 
33  try {
34 
35  JParser<> zap("Program to test iteration from a ROOT TTree.");
36 
37  zap['f'] = make_field(inputFile);
38  zap['n'] = make_field(numberOfEvents) = JLimit::max();
39  zap['d'] = make_field(debug) = 3;
40 
41  zap(argc, argv);
42  }
43  catch(const exception& error) {
44  FATAL(error.what() << endl);
45  }
46 
48 
49  //JTreeScanner_t::debug = debug;
50 
51  JTreeScanner_t in(inputFile, inputFile.getLimit());
52 
53  DEBUG("Number of entries " << in.getEntries() << endl);
54  DEBUG("Limit " << inputFile.getLimit() << endl);
55 
56  DEBUG("hasNext iteration:");
57  while (in.hasNext()) {
58 
59  JDAQEvent* tev = in.next();
60 
61  DEBUG(' ' << setw(2) << tev->getFrameIndex());
62  }
63  DEBUG(endl);
64 
65  DEBUG("indexed iteration:");
66  for (counter_type i = inputFile.getLowerLimit(); i != inputFile.getUpperLimit(); ++i) {
67  DEBUG(' ' << setw(2) << in.getEntry(i)->getFrameIndex());
68  }
69  DEBUG(endl);
70 
71  DEBUG("forward iteration:");
72  for (JTreeScanner_t::iterator i = in.begin(); i != in.end(); ++i) {
73  DEBUG(' ' << setw(2) << i->getFrameIndex());
74  }
75  DEBUG(endl);
76 
77  DEBUG("reverse iteration:");
78  for (JTreeScanner_t::reverse_iterator i = in.rbegin(); i != in.rend(); ++i) {
79  DEBUG(' ' << setw(2) << i->getFrameIndex());
80  }
81  DEBUG(endl);
82 
83  // tests
84 
85  ASSERT(in.getEntries() > 1, "check number of entries");
86  ASSERT(inputFile.getUpperLimit() < in.getEntries() && inputFile.getLength() > 1, "check limit");
87 
88  for (JTreeScanner_t::iterator j = in.begin(), i = j++; j != in.end(); ++i, ++j) {
89  ASSERT(i->getFrameIndex() < j->getFrameIndex());
90  }
91 
92  for (JTreeScanner_t::reverse_iterator j = in.rbegin(), i = j++; j != in.rend(); ++i, ++j) {
93  ASSERT(i->getFrameIndex() > j->getFrameIndex());
94  }
95 
96  return 0;
97 }
Utility class to parse command line options.
Definition: JParser.hh:1493
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
Definition: JSirene.sh:45
Long64_t counter_type
Type definition for counter.
Template definition for direct access of elements in ROOT TChain.
Definition: JTreeScanner.hh:91
int getFrameIndex() const
Get frame index.
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
#define ASSERT(A,...)
Assert macro.
Definition: JMessage.hh:90
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
int debug
debug level
Definition: JSirene.cc:61
#define FATAL(A)
Definition: JMessage.hh:67
Base class for JTreeScanner.
Definition: JTreeScanner.hh:52
int j
Definition: JPolint.hh:634
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62