Jpp
Functions
JTreeIterator.cc File Reference
#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

◆ main()

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 }
ASSERT
#define ASSERT(A,...)
Assert macro.
Definition: JMessage.hh:90
JSUPPORT::JLimit_t
JLimit JLimit_t
Type definition of limit.
Definition: JLimit.hh:215
JTOOLS::j
int j
Definition: JPolint.hh:634
JPARSER::JParser
Utility class to parse command line options.
Definition: JParser.hh:1493
NOTICE
#define NOTICE(A)
Definition: JMessage.hh:64
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
debug
int debug
debug level
Definition: JSirene.cc:59
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
JSUPPORT::JMultipleFileScanner<>
std
Definition: jaanetDictionary.h:36
KM3NETDAQ
KM3NeT DAQ data structures and auxiliaries.
Definition: DataQueue.cc:39
FATAL
#define FATAL(A)
Definition: JMessage.hh:67