Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JTreeIterator.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <iostream>
4 #include <iomanip>
5 
6 #include "JDAQ/JDAQEvent.hh"
7 #include "JDAQ/JDAQEvaluator.hh"
8 
10 #include "JSupport/JTreeScanner.hh"
11 #include "JSupport/JSupport.hh"
12 
13 #include "Jeep/JParser.hh"
14 #include "Jeep/JMessage.hh"
15 
16 
17 /**
18  * \file
19  *
20  * Program to test iteration using JSUPPORT::JTreeScanner.
21  * \author mdejong
22  */
23 int main(int argc, char **argv)
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
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:65
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Utility class to parse command line options.
ROOT TTree parameter settings.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:72
int main(int argc, char *argv[])
Definition: Main.cpp:15