Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
examples/JTrigger/JDAQHit.cc
Go to the documentation of this file.
1
2#include <string>
3#include <iostream>
4#include <iomanip>
5#include <limits>
6#include <map>
7
8#include "JDAQ/JDAQEventIO.hh"
9
11#include "JSupport/JSupport.hh"
12
13#include "Jeep/JParser.hh"
14#include "Jeep/JMessage.hh"
15
16
17/**
18 * \file
19 *
20 * Example program to count event data.
21 * \author mdejong
22 */
23int main(int argc, char **argv)
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}
General purpose messaging.
#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
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
ROOT TTree parameter settings of various packages.
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
int main(int argc, char **argv)
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