Jpp
JChecksum.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <iomanip>
4 #include <limits>
5 #include <deque>
6 
8 #include "JMath/JRandom.hh"
9 
11 #include "JSupport/JSupport.hh"
14 #include "JTrigger/JChecksum.hh"
15 
16 #include "Jeep/JParser.hh"
17 #include "Jeep/JMessage.hh"
18 
19 namespace {
20 
21  /**
22  * Print DAQ hit.
23  *
24  * \param out output stream
25  * \param hit DAQ hit
26  */
27  void print(std::ostream& out, const KM3NETDAQ::JDAQHit& hit)
28  {
29  using namespace std;
30 
31  out << "\thit: " << setw(3) << (int) hit.getPMT() << ' ' << setw(11) << (int) hit.getT() << ' ' << setw(3) << (int) hit.getToT();
32  }
33 }
34 
35 
36 /**
37  * \file
38  *
39  * Example program to histogram KM3NETDAQ::JDAQTimeslice.
40  * \author mdejong
41  */
42 int main(int argc, char **argv)
43 {
44  using namespace std;
45  using namespace JPP;
46  using namespace KM3NETDAQ;
47 
49  JLimit_t & numberOfEvents = inputFile.getLimit();
50  JROOTClassSelector selector;
51  int N;
52  int debug;
53 
54  try {
55 
56  JParser<> zap("Example program to histogram timeslice data.");
57 
58  zap['f'] = make_field(inputFile);
59  zap['n'] = make_field(numberOfEvents) = JLimit::max();
60  zap['C'] = make_field(selector) = getROOTClassSelection<JDAQTimesliceTypes_t>();
61  zap['N'] = make_field(N) = 10;
62  zap['d'] = make_field(debug) = 1;
63 
64  zap(argc, argv);
65  }
66  catch(const exception& error) {
67  FATAL(error.what() << endl);
68  }
69 
70  cout.tie(&cerr);
71 
73 
74  for (counter_type counter = 0; in.hasNext(); ++counter) {
75 
76  STATUS("event: " << setw(10) << counter << '\r'); DEBUG(endl);
77 
78  JDAQTimeslice* timeslice = in.next();
79 
80  for (JDAQTimeslice::const_iterator frame = timeslice->begin(); frame != timeslice->end(); ++frame) {
81 
82  const JChecksum::result_type result = checksum.get(*frame);
83 
84  for (JChecksum::const_iterator error = result.begin(); error != result.end(); ++error) {
85 
86  const int pmt = (*frame)[error->pos].getPMT();
87 
88  cerr << "Module "
89  << setw(10) << frame->getModuleID() << " "
90  << setw(1) << frame->testHighRateVeto(pmt) << ""
91  << setw(1) << frame->testFIFOStatus (pmt) << " "
92  << setw(2) << frame->getUDPNumberOfReceivedPackets() << "/"
93  << setw(2) << frame->getUDPMaximalSequenceNumber() << endl;
94  cerr << "Error at "
95  << setw(6) << error->pos << '/'
96  << setw(6) << frame->size() << ' '
97  << error->type << endl;
98 
99  deque<JDAQHit> buffer;
100 
101  for (int i = error->pos - 1, n = 0; i >= 0 && n <= N; --i) {
102  if ((*frame)[i].getPMT() == (*frame)[error->pos].getPMT()) {
103  buffer.push_front((*frame)[i]);
104  ++n;
105  }
106  }
107 
108  for (deque<JDAQHit>::const_iterator i = buffer.begin(); i != buffer.end(); ++i) {
109  print(cerr, *i); cerr << endl;
110  }
111 
112  print(cerr, (*frame)[error->pos]); cerr << " ***" << endl;
113 
114  for (int i = error->pos + 1, n = 0; i < frame->size() && n <= N; ++i) {
115  if ((*frame)[i].getPMT() == (*frame)[error->pos].getPMT()) {
116  print(cerr, (*frame)[i]); cerr << endl;
117  ++n;
118  }
119  }
120  }
121  }
122  }
123  STATUS(endl);
124 }
JTRIGGER::JChecksum::const_iterator
result_type::const_iterator const_iterator
Definition: JChecksum.hh:79
JChecksum.hh
JSUPPORT::JLimit
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
JMessage.hh
KM3NETDAQ::JDAQHit::getPMT
JPMT_t getPMT() const
Get PMT.
Definition: JDAQHit.hh:75
main
int main(int argc, char **argv)
Definition: JChecksum.cc:42
JLANG::JObjectMultiplexer::hasNext
virtual bool hasNext()
Check availability of next element.
Definition: JObjectMultiplexer.hh:62
JTOOLS::n
const int n
Definition: JPolint.hh:628
std::vector< error >
JROOTClassSelector.hh
KM3NETDAQ::JDAQTimeslice
Data time slice.
Definition: JDAQTimeslice.hh:30
JPARSER::JParser
Utility class to parse command line options.
Definition: JParser.hh:1493
JLANG::JObjectMultiplexer::next
virtual const pointer_type & next()
Get next element.
Definition: JObjectMultiplexer.hh:76
JSupport.hh
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
KM3NETDAQ::JDAQHit::getT
JTDC_t getT() const
Get time.
Definition: JDAQHit.hh:86
JDAQTimesliceIO.hh
JROOT::JROOTClassSelector
Auxiliary class to select ROOT class based on class name.
Definition: JROOTClassSelector.hh:32
debug
int debug
debug level
Definition: JSirene.cc:59
JTOOLS::result
return result
Definition: JPolint.hh:695
JTRIGGER::JChecksum::get
const result_type & get(const JDAQSuperFrame &frame) const
Check sum.
Definition: JChecksum.hh:98
JLANG::JObjectMultiplexer
Auxiliary class for multiplexing object iterators.
Definition: JObjectIterator.hh:35
KM3NETDAQ::JDAQHit::getToT
JTOT_t getToT() const
Get time-over-threshold.
Definition: JDAQHit.hh:97
JObjectMultiplexer.hh
JMultipleFileScanner.hh
STATUS
#define STATUS(A)
Definition: JMessage.hh:63
JTRIGGER::checksum
static const JChecksum checksum
Function object to perform check-sum of raw data.
Definition: JChecksum.hh:161
JParser.hh
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
JSUPPORT::JMultipleFileScanner
General purpose class for object reading from a list of file names.
Definition: JMultipleFileScanner.hh:167
DEBUG
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
std
Definition: jaanetDictionary.h:36
KM3NETDAQ
KM3NeT DAQ data structures and auxiliaries.
Definition: DataQueue.cc:39
KM3NETDAQ::JDAQHit
Hit data structure.
Definition: JDAQHit.hh:34
print
void print(const TH1 &h1, std::ostream &out)
Print histogram parameters.
Definition: JTriggerMonitor.cc:38
FATAL
#define FATAL(A)
Definition: JMessage.hh:67
JRandom.hh
JROOT::counter_type
Long64_t counter_type
Type definition for counter.
Definition: JCounter.hh:24