Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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) << 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() << '.' << setw(2) << setfill('0') << pmt << setfill(' ') << ' '
90  << setw(6) << error->pos << '/' << setw(6) << frame->size() << ' '
91  << setw(2) << error->type << ' ';
92 
93  if (pmt < NUMBER_OF_PMTS) {
94  cerr << setw(1) << frame->testHighRateVeto(pmt)
95  << setw(1) << frame->testFIFOStatus (pmt) << ' '
96  << setw(2) << frame->getUDPNumberOfReceivedPackets() << '/'
97  << setw(2) << frame->getUDPMaximalSequenceNumber();
98  }
99  cerr << endl << endl;
100 
101  deque<JDAQHit> buffer;
102 
103  for (int i = error->pos - 1, n = 0; i >= 0 && n <= N; --i) {
104  if ((*frame)[i].getPMT() == (*frame)[error->pos].getPMT()) {
105  buffer.push_front((*frame)[i]);
106  ++n;
107  }
108  }
109 
110  for (deque<JDAQHit>::const_iterator i = buffer.begin(); i != buffer.end(); ++i) {
111  print(cerr, *i); cerr << endl;
112  }
113 
114  print(cerr, (*frame)[error->pos]);
115 
116  if (error->type != JChecksum::TIME_t)
117  cerr << " ***" << endl;
118  else
119  cerr << " <<<" << endl;
120 
121  for (int i = error->pos + 1, n = 0; i < frame->size() && n <= N; ++i) {
122  if ((*frame)[i].getPMT() == (*frame)[error->pos].getPMT()) {
123  print(cerr, (*frame)[i]); cerr << endl;
124  ++n;
125  }
126  }
127  }
128  }
129  }
130  STATUS(endl);
131 }
Utility class to parse command line options.
Definition: JParser.hh:1500
ROOT TTree parameter settings of various packages.
#define STATUS(A)
Definition: JMessage.hh:63
Auxiliary class to select ROOT class based on class name.
Definition of random value generator.
Long64_t counter_type
Type definition for counter.
result_type::const_iterator const_iterator
Definition: JChecksum.hh:77
Auxiliary class for multiplexing object iterators.
JTDC_t getT() const
Get time.
Definition: JDAQHit.hh:86
JPMT_t getPMT() const
Get PMT.
Definition: JDAQHit.hh:75
static const JChecksum checksum
Function object to perform check-sum of raw data.
Definition: JChecksum.hh:167
JTOT_t getToT() const
Get time-over-threshold.
Definition: JDAQHit.hh:97
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
Hit data structure.
Definition: JDAQHit.hh:34
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
return result
Definition: JPolint.hh:727
Data time slice.
virtual const pointer_type & next() override
Get next element.
int debug
debug level
Definition: JSirene.cc:63
virtual bool hasNext() override
Check availability of next element.
print
Definition: JConvertDusj.sh:44
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Scanning of objects from multiple files according a format that follows from the extension of each fi...
General purpose class for object reading from a list of file names.
Utility class to parse command line options.
alias put_queue eval echo n
Definition: qlib.csh:19
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Definition: JDAQ.hh:26
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 source JAcoustics sh $DETECTOR_ID typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:36
then usage $script[input file[working directory[option]]] nWhere option can be N
Definition: JMuonPostfit.sh:37
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
const result_type & get(const JDAQSuperFrame &frame) const
Check sum.
Definition: JChecksum.hh:102
int main(int argc, char *argv[])
Definition: Main.cpp:15