Jpp  16.0.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JTreeScanner.cc File Reference

Program to test ordered reading using JSUPPORT::JTreeScanner. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <limits>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "JDAQ/JDAQEventIO.hh"
#include "JDAQ/JDAQSummarysliceIO.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 ordered reading using JSUPPORT::JTreeScanner.

Author
mdejong

Definition in file JTreeScanner.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 30 of file JTreeScanner.cc.

31 {
32  using namespace std;
33  using namespace JPP;
34  using namespace KM3NETDAQ;
35 
36  JMultipleFileScanner<> inputFile;
37  JLimit_t& numberOfEvents = inputFile.getLimit();
38  string outputFile;
39  int debug;
40 
41  try {
42 
43  JParser<> zap("Program to test ordered reading from a ROOT TTree.");
44 
45  zap['f'] = make_field(inputFile);
46  zap['n'] = make_field(numberOfEvents) = JLimit::max();
47  zap['o'] = make_field(outputFile) = "histogram.root";
48  zap['d'] = make_field(debug) = 2;
49 
50  zap(argc, argv);
51  }
52  catch(const exception& error) {
53  FATAL(error.what() << endl);
54  }
55 
56 
57  TFile out(outputFile.c_str(), "recreate");
58 
59  TH1D h0("h0", NULL, 401, -200.5, +200.5);
60  TH1D h1("h1", NULL, 401, -200.5, +200.5);
61 
62 
64 
66 
67  int frame_index = 0;
68 
69  for (JTreeScanner<JDAQEvent, JDAQEvaluator> in(inputFile); in.hasNext(); ) {
70 
71  STATUS("event: " << setw(10) << in.getCounter() << '\r'); DEBUG(endl);
72 
73  JDAQEvent* event = in.next();
74  Long64_t index = scan.find(*event);
75 
76  JDAQSummaryslice* summary = scan.getEntry(index);
77 
78  h0.Fill(event ->getFrameIndex() - frame_index);
79  h1.Fill(summary->getFrameIndex() - event->getFrameIndex());
80 
81  frame_index = event->getFrameIndex();
82  }
83 
84  out.Write();
85  out.Close();
86 }
Utility class to parse command line options.
Definition: JParser.hh:1500
#define STATUS(A)
Definition: JMessage.hh:63
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:71
string outputFile
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
int getFrameIndex(const double t_ns)
Get frame index for a given time in ns.
Definition: JDAQClock.hh:251
#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
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
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:42