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

Example program to read Monte Carlo events. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "km3net-dataformat/offline/Head.hh"
#include "km3net-dataformat/offline/Evt.hh"
#include "km3net-dataformat/offline/Hit.hh"
#include "JDAQ/JDAQEventIO.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JTriggeredFileScanner.hh"
#include "JSupport/JMonteCarloFileSupportkit.hh"
#include "JSupport/JSupport.hh"
#include "Jeep/JPrint.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

Example program to read Monte Carlo events.

Author
mdejong

Definition in file JABCnet.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 26 of file JABCnet.cc.

27 {
28  using namespace std;
29  using namespace JPP;
30  using namespace KM3NETDAQ;
31 
32  JMultipleFileScanner<> inputFile;
33  JLimit_t numberOfEvents;
34  int debug;
35 
36  try {
37 
38  JParser<> zap("Example program to read Monte Carlo events.");
39 
40  zap['f'] = make_field(inputFile, "list of files");
41  zap['n'] = make_field(numberOfEvents, "number of events to read from file(s)") = JLimit::max();
42  zap['d'] = make_field(debug, "debug level") = 3;
43 
44  zap(argc, argv);
45  }
46  catch(const exception &error) {
47  FATAL(error.what() << endl);
48  }
49 
50 
51  {
52  // template argument corresponds to objects which will be read from file(s)
53 
54  JMultipleFileScanner<Evt> in(inputFile, numberOfEvents);
55 
56  while (in.hasNext()) {
57 
58  STATUS("event: " << setw(10) << in.getCounter() << '\r'); DEBUG(endl);
59 
60  Evt* event = in.next(); // pointer to Monte Carlo event
61 
62  DEBUG("Monte Carlo event " << event->mc_id << endl);
63  }
64  STATUS(endl);
65  }
66 
67  {
68  // optional template argument(s) will be read in parallel to DAQ events
69 
70  JTriggeredFileScanner<> in(inputFile, numberOfEvents);
71 
72  while (in.hasNext()) {
73 
74  STATUS("event: " << setw(10) << in.getCounter() << '\r'); DEBUG(endl);
75 
77 
78  const JDAQEvent* tev = ps; // pointer to DAQ event
79  const Evt* event = ps; // pointer to corresponding Monte Carlo event
80 
81  DEBUG("DAQ event " << tev->getCounter() << endl);
82  DEBUG("Monte Carlo event " << event->mc_id << endl);
83  }
84  STATUS(endl);
85  }
86 }
Utility class to parse command line options.
Definition: JParser.hh:1517
#define STATUS(A)
Definition: JMessage.hh:63
Auxiliary class to synchronously read DAQ events and Monte Carlo events (and optionally other events)...
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1993
#define FATAL(A)
Definition: JMessage.hh:67
General purpose class for multiple pointers.
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 JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46
JTriggerCounter_t getCounter() const
Get trigger counter.
int debug
debug level
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:20
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62