Jpp  16.0.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
examples/JTrigger/JDAQHit.cc File Reference

Example program to count event data. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include "JDAQ/JDAQEventIO.hh"
#include "JSupport/JMultipleFileScanner.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

Example program to count event data.

Author
mdejong

Definition in file examples/JTrigger/JDAQHit.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 23 of file examples/JTrigger/JDAQHit.cc.

24 {
25  using namespace std;
26  using namespace JPP;
27  using namespace KM3NETDAQ;
28 
30  JLimit_t& numberOfEvents = inputFile.getLimit();
31  int debug;
32 
33  try {
34 
35  JParser<> zap("Example program to count event data.");
36 
37  zap['f'] = make_field(inputFile);
38  zap['n'] = make_field(numberOfEvents) = JLimit::max();
39  zap['d'] = make_field(debug) = 1;
40 
41  zap(argc, argv);
42  }
43  catch(const exception& error) {
44  FATAL(error.what() << endl);
45  }
46 
47 
48  struct counter_type {
49 
50  counter_type() :
51  trigger (0),
52  snapshot()
53  {}
54 
55  int trigger;
56  int snapshot;
57  };
58 
59  map<int, counter_type> counter;
60 
61  while (inputFile.hasNext()) {
62 
63  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
64 
65  JDAQEvent* event = inputFile.next();
66 
67  {
68  typedef JDAQTriggeredHit JHit_t;
69 
70  for (JDAQEvent::const_iterator<JHit_t> hit = event->begin<JHit_t>(); hit != event->end<JHit_t>(); ++hit) {
71  counter[hit->getModuleID()].trigger += 1;
72  }
73  }
74 
75  {
76  typedef JDAQSnapshotHit JHit_t;
77 
78  for (JDAQEvent::const_iterator<JHit_t> hit = event->begin<JHit_t>(); hit != event->end<JHit_t>(); ++hit) {
79  counter[hit->getModuleID()].snapshot += 1;
80  }
81  }
82  }
83  STATUS(endl);
84 
85  for (map<int, counter_type>::const_iterator i = counter.begin(); i != counter.end(); ++i) {
86  cout << setw(10) << i->first << ' '
87  << setw (8) << i->second.trigger << ' '
88  << setw (8) << i->second.snapshot << endl;
89  }
90 }
Auxiliary class to set-up Hit.
Definition: JHit_t.hh:25
Utility class to parse command line options.
Definition: JParser.hh:1500
DAQ key hit.
Definition: JDAQKeyHit.hh:19
#define STATUS(A)
Definition: JMessage.hh:63
Template const_iterator.
Definition: JDAQEvent.hh:68
Long64_t counter_type
Type definition for counter.
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:1961
int debug
debug level
Definition: JSirene.cc:63
#define FATAL(A)
Definition: JMessage.hh:67
General purpose class for object reading from a list of file names.
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
JTriggerCounter_t next()
Increment trigger counter.