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/JDAQEvent.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 
47  typedef JTreeScanner<JDAQEvent, JDAQEvaluator> JTreeScanner_t;
48 
50 
51  JTreeScanner_t in(inputFile, inputFile.getLimit());
52 
53  NOTICE("forward iteration:" << endl);
54 
55  for (JTreeScanner_t::iterator i = in.begin(); i != in.end(); ++i) {
56  NOTICE(setw(6) << i->getFrameIndex() << endl);
57  }
58 
59  NOTICE("reverse iteration:" << endl);
60 
61  for (JTreeScanner_t::reverse_iterator i = in.rbegin(); i != in.rend(); ++i) {
62  NOTICE(setw(6) << i->getFrameIndex() << endl);
63  }
64 
65  ASSERT(in.getEntries() > 1);
66 
67  for (JTreeScanner_t::iterator j = in.begin(), i = j++; j != in.end(); ++i, ++j) {
68  ASSERT(i->getFrameIndex() < j->getFrameIndex());
69  }
70 
71  for (JTreeScanner_t::reverse_iterator j = in.rbegin(), i = j++; j != in.rend(); ++i, ++j) {
72  ASSERT(i->getFrameIndex() > j->getFrameIndex());
73  }
74 
75  return 0;
76 }
Utility class to parse command line options.
Definition: JParser.hh:1410
JLimit JLimit_t
Type definition of limit.
Definition: JLimit.hh:214
#define ASSERT(A)
Assert macro.
Definition: JMessage.hh:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1836
#define NOTICE(A)
Definition: JMessage.hh:62
int debug
debug level
Definition: JSirene.cc:59
#define FATAL(A)
Definition: JMessage.hh:65
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:72