Jpp  pmt_effective_area_update
the software that should make you happy
 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("Distance " << distance(in. begin(), in. end()) << endl);
55  DEBUG("Distance " << distance(in.rbegin(), in.rend()) << endl);
56  DEBUG("Limit " << inputFile.getLimit() << endl);
57 
58  DEBUG("hasNext iteration:");
59  while (in.hasNext()) {
60 
61  JDAQEvent* tev = in.next();
62 
63  DEBUG(' ' << setw(2) << tev->getFrameIndex());
64  }
65  DEBUG(endl);
66 
67  DEBUG("indexed iteration:");
68  for (counter_type i = inputFile.getLowerLimit(); i != inputFile.getUpperLimit(); ++i) {
69  DEBUG(' ' << setw(2) << in.getEntry(i)->getFrameIndex());
70  }
71  DEBUG(endl);
72 
73  DEBUG("forward iteration:");
74  for (JTreeScanner_t::iterator i = in.begin(); i != in.end(); ++i) {
75  DEBUG(' ' << setw(2) << i->getFrameIndex());
76  }
77  DEBUG(endl);
78 
79  DEBUG("reverse iteration:");
80  for (JTreeScanner_t::reverse_iterator i = in.rbegin(); i != in.rend(); ++i) {
81  DEBUG(' ' << setw(2) << i->getFrameIndex());
82  }
83  DEBUG(endl);
84 
85  // tests
86 
87  ASSERT(in.getEntries() > 1, "check number of entries");
88  ASSERT(inputFile.getUpperLimit() < in.getEntries() && inputFile.getLength() > 1, "check limit");
89 
90  ASSERT(distance(in. begin(), in. end()), inputFile.getLimit().getLength());
91  ASSERT(distance(in.rbegin(), in.rend()), inputFile.getLimit().getLength());
92 
93  for (JTreeScanner_t::iterator j = in.begin(), i = j++; j != in.end(); ++i, ++j) {
94  ASSERT(i->getFrameIndex() < j->getFrameIndex());
95  }
96 
97  for (JTreeScanner_t::reverse_iterator j = in.rbegin(), i = j++; j != in.rend(); ++i, ++j) {
98  ASSERT(i->getFrameIndex() > j->getFrameIndex());
99  }
100 
101  return 0;
102 }
Utility class to parse command line options.
Definition: JParser.hh:1500
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
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:1961
int debug
debug level
Definition: JSirene.cc:63
#define FATAL(A)
Definition: JMessage.hh:67
Base class for JTreeScanner.
Definition: JTreeScanner.hh:52
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
int j
Definition: JPolint.hh:666
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:40