Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
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

◆ main()

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
60
61 while (inputFile.hasNext()) {
62
63 STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
64
65 JDAQEvent* event = inputFile.next();
66
67 {
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}
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define STATUS(A)
Definition JMessage.hh:63
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Utility class to parse command line options.
Definition JParser.hh:1698
General purpose class for object reading from a list of file names.
virtual bool hasNext() override
Check availability of next element.
counter_type getCounter() const
Get counter.
virtual const pointer_type & next() override
Get next element.
Template const_iterator.
Definition JDAQEvent.hh:68
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Long64_t counter_type
Type definition for counter.
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39
Auxiliary class to set-up Hit.
Definition JSirene.hh:58
Auxiliary class for defining the range of iterations of objects.
Definition JLimit.hh:45
static counter_type max()
Get maximum counter value.
Definition JLimit.hh:128