Jpp - the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JChecksum.cc File Reference

Example program to histogram KM3NETDAQ::JDAQTimeslice. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <limits>
#include <deque>
#include "km3net-dataformat/online/JDAQClock.hh"
#include "JDAQ/JDAQTimesliceIO.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JSupport.hh"
#include "JROOT/JROOTClassSelector.hh"
#include "JLang/JObjectMultiplexer.hh"
#include "JTrigger/JChecksum.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 histogram KM3NETDAQ::JDAQTimeslice.

Author
mdejong

Definition in file JChecksum.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 86 of file JChecksum.cc.

87 {
88  using namespace std;
89  using namespace JPP;
90  using namespace KM3NETDAQ;
91 
93  JLimit_t & numberOfEvents = inputFile.getLimit();
94  JROOTClassSelector selector;
95  int N;
96  double rate_Hz;
97  int debug;
98 
99  try {
100 
101  JParser<> zap("Example program to histogram timeslice data.");
102 
103  zap['f'] = make_field(inputFile);
104  zap['n'] = make_field(numberOfEvents) = JLimit::max();
105  zap['C'] = make_field(selector) = getROOTClassSelection<JDAQTimesliceTypes_t>();
106  zap['N'] = make_field(N, "number of rows to print") = 10;
107  zap['R'] = make_field(rate_Hz, "high-rate veto [Hz]") = 0.0;
108  zap['d'] = make_field(debug) = 1;
109 
110  zap(argc, argv);
111  }
112  catch(const exception& error) {
113  FATAL(error.what() << endl);
114  }
115 
116  cout.tie(&cerr);
117 
119 
120 
121  if (rate_Hz > 0.0) {
122  MAXIMAL_FRAME_SIZE = (int) (getFrameTime() * 1.0e-9 * rate_Hz * NUMBER_OF_PMTS + 0.5);
123  }
124 
125  for (counter_type counter = 0; in.hasNext(); ++counter) {
126 
127  STATUS("event: " << setw(10) << counter << '\r'); DEBUG(endl);
128 
129  JDAQTimeslice* timeslice = in.next();
130 
131  for (JDAQTimeslice::const_iterator frame = timeslice->begin(); frame != timeslice->end(); ++frame) {
132 
133  const JChecksum::result_type result = checksum.get(*frame);
134 
135  for (JChecksum::const_iterator error = result.begin(); error != result.end(); ++error) {
136 
137  if (error->pos >= 0) {
138 
139  const int pmt = (*frame)[error->pos].getPMT();
140 
141  cerr << "Module "
142  << setw(10) << frame->getModuleID() << '.' << setw(2) << setfill('0') << pmt << setfill(' ') << ' '
143  << setw(8) << frame->getFrameIndex() << ' '
144  << setw(6) << error->pos << '/' << setw(8) << frame->size() << ' '
145  << setw(2) << error->type << ' ';
146 
147  if (pmt < NUMBER_OF_PMTS) {
148  cerr << setw(1) << frame->testHighRateVeto(pmt)
149  << setw(1) << frame->testFIFOStatus (pmt) << ' ';
150  }
151 
152  cerr << setw(4) << frame->getUDPNumberOfReceivedPackets() << '/'
153  << setw(4) << frame->getUDPMaximalSequenceNumber();
154 
155  cerr << " ";
156 
157  print(cerr, error->type);
158 
159  cerr << endl << endl;
160 
161  deque<JDAQHit> buffer;
162 
163  for (int i = error->pos - 1, n = 0; i >= 0 && n <= N; --i) {
164  if ((*frame)[i].getPMT() == (*frame)[error->pos].getPMT()) {
165  buffer.push_front((*frame)[i]);
166  ++n;
167  }
168  }
169 
170  for (deque<JDAQHit>::const_iterator i = buffer.begin(); i != buffer.end(); ++i) {
171  print(cerr, *i); cerr << endl;
172  }
173 
174  print(cerr, (*frame)[error->pos]);
175 
176  cerr << " <<< " << endl;
177 
178  for (int i = error->pos + 1, n = 0; i < frame->size() && n <= N; ++i) {
179  if ((*frame)[i].getPMT() == (*frame)[error->pos].getPMT()) {
180  print(cerr, (*frame)[i]); cerr << endl;
181  ++n;
182  }
183  }
184 
185  } else {
186 
187  cerr << "Module "
188  << setw(10) << frame->getModuleID() << ' ' << setw(2) << ' ' << ' '
189  << setw(8) << frame->getFrameIndex() << ' '
190  << setw(6) << error->pos << '/' << setw(8) << frame->size() << ' '
191  << setw(2) << error->type << ' ';
192 
193  cerr << setw(1) << ' '
194  << setw(1) << ' ' << ' ';
195 
196  cerr << setw(4) << frame->getUDPNumberOfReceivedPackets() << '/'
197  << setw(4) << frame->getUDPMaximalSequenceNumber();
198 
199  cerr << " ";
200 
201  print(cerr, error->type);
202 
203  cerr << endl << endl;
204  }
205  }
206  }
207  }
208  STATUS(endl);
209 }
Utility class to parse command line options.
Definition: JParser.hh:1500
#define STATUS(A)
Definition: JMessage.hh:63
Auxiliary class to select ROOT class based on class name.
Long64_t counter_type
Type definition for counter.
result_type::const_iterator const_iterator
Definition: JChecksum.hh:83
Auxiliary class for multiplexing object iterators.
static const JChecksum checksum
Function object to perform check-sum of raw data.
Definition: JChecksum.hh:176
static int MAXIMAL_FRAME_SIZE
Maximal frame size.
Definition: JChecksum.hh:32
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
double getFrameTime()
Get frame time duration.
Definition: JDAQClock.hh:162
return result
Definition: JPolint.hh:727
Data time slice.
int debug
debug level
Definition: JSirene.cc:63
print
Definition: JConvertDusj.sh:44
#define FATAL(A)
Definition: JMessage.hh:67
General purpose class for object reading from a list of file names.
alias put_queue eval echo n
Definition: qlib.csh:19
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
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 CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:38
then usage $script[input file[working directory[option]]] nWhere option can be N
Definition: JMuonPostfit.sh:35
const result_type & get(const JDAQSuperFrame &frame) const
Check sum.
Definition: JChecksum.hh:108