Jpp test-rotations-old-533-g2bdbdb559
the software that should make you happy
Loading...
Searching...
No Matches
JChecksum.cc File Reference

Example program to check KM3NETDAQ::JDAQTimeslice for errors. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <limits>
#include <deque>
#include <map>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "km3net-dataformat/online/JDAQClock.hh"
#include "JDAQ/JDAQTimesliceIO.hh"
#include "JSupport/JSingleFileScanner.hh"
#include "JSupport/JSupportToolkit.hh"
#include "JSupport/JSupport.hh"
#include "JROOT/JROOTClassSelector.hh"
#include "JROOT/JManager.hh"
#include "JLang/JPredicate.hh"
#include "JLang/JComparison.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 check KM3NETDAQ::JDAQTimeslice for errors.

Author
mdejong

Definition in file software/JTrigger/JChecksum.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 98 of file software/JTrigger/JChecksum.cc.

99{
100 using namespace std;
101 using namespace JPP;
102 using namespace KM3NETDAQ;
103
105 JLimit_t & numberOfEvents = inputFile.getLimit();
106 JROOTClassSelector selector;
107 string outputFile;
108 int N;
109 double rate_Hz;
110 int debug;
111
112 try {
113
114 JParser<> zap("Example program to check timeslice data for errors.");
115
116 zap['f'] = make_field(inputFile);
117 zap['n'] = make_field(numberOfEvents) = JLimit::max();
119 zap['o'] = make_field(outputFile) = "checksum.root";
120 zap['N'] = make_field(N, "number of rows to print") = 10;
121 zap['R'] = make_field(rate_Hz, "high-rate veto [Hz]") = 0.0;
122 zap['d'] = make_field(debug) = 3;
123
124 zap(argc, argv);
125 }
126 catch(const exception& error) {
127 FATAL(error.what() << endl);
128 }
129
130
132
133
134 if (rate_Hz > 0.0) {
135 MAXIMAL_FRAME_SIZE = (int) (getFrameTime() * 1.0e-9 * rate_Hz * NUMBER_OF_PMTS + 0.5);
136 }
137
138 map<int, int> errors;
139 map<int, int> misses;
140
142
143 const Long64_t nx = frame_index.second - frame_index.first + 1;
144 const Double_t xmin = (Double_t) frame_index.first - 0.5;
145 const Double_t xmax = (Double_t) frame_index.second + 0.5;
146
147 JManager<int, TH1D> H1(new TH1D("[%]", NULL, nx, xmin, xmax));
148
149 for (counter_type counter = 0; in.hasNext(); ++counter) {
150
151 STATUS("event: " << setw(10) << counter << '\r'); DEBUG(endl);
152
153 const JDAQTimeslice* timeslice = in.next();
154
155 for (JDAQTimeslice::const_iterator frame = timeslice->begin(); frame != timeslice->end(); ++frame) {
156
157 const JChecksum::result_type& result = checksum(*frame);
158
160
161 if (count_if(result.begin(), result.end(), make_predicate(&JChecksum::error::type, type)) != 0) {
162 misses[frame->getModuleID()] += 1;
163 }
164 }
165
166 for (JChecksum::const_iterator error = result.begin(); error != result.end(); ++error) {
167
168 errors[error->type] += 1;
169
170 H1[error->type]->Fill((Double_t) frame->getFrameIndex());
171 }
172
173 if (debug >= debug_t) {
174
175 for (JChecksum::const_iterator error = result.begin(); error != result.end(); ++error) {
176
177 if (error->pos >= 0) {
178
179 const int pmt = (*frame)[error->pos].getPMT();
180
181 cout << "Module "
182 << setw(10) << frame->getModuleID() << '.' << setw(2) << setfill('0') << pmt << setfill(' ') << ' '
183 << setw(8) << frame->getFrameIndex() << ' '
184 << setw(6) << error->pos << '/' << setw(8) << frame->size() << ' '
185 << setw(2) << error->type << ' ';
186
187 if (pmt < NUMBER_OF_PMTS) {
188 cout << setw(1) << frame->testHighRateVeto(pmt)
189 << setw(1) << frame->testFIFOStatus (pmt) << ' ';
190 }
191
192 cout << setw(4) << frame->getUDPNumberOfReceivedPackets() << '/'
193 << setw(4) << frame->getUDPMaximalSequenceNumber();
194
195 cout << " ";
196
197 print(cout, error->type);
198
199 cout << endl << endl;
200
201 deque<JDAQHit> buffer;
202
203 for (int i = error->pos - 1, n = 0; i >= 0 && n <= N; --i) {
204 if ((*frame)[i].getPMT() == (*frame)[error->pos].getPMT()) {
205 buffer.push_front((*frame)[i]);
206 ++n;
207 }
208 }
209
210 for (deque<JDAQHit>::const_iterator i = buffer.begin(); i != buffer.end(); ++i) {
211 print(cout, *i); cout << endl;
212 }
213
214 print(cout, (*frame)[error->pos]);
215
216 cout << " <<< " << endl;
217
218 for (int i = error->pos + 1, n = 0; i < frame->size() && n <= N; ++i) {
219 if ((*frame)[i].getPMT() == (*frame)[error->pos].getPMT()) {
220 print(cout, (*frame)[i]); cout << endl;
221 ++n;
222 }
223 }
224
225 } else {
226
227 cout << "Module "
228 << setw(10) << frame->getModuleID() << ' ' << setw(2) << ' ' << ' '
229 << setw(8) << frame->getFrameIndex() << ' '
230 << setw(6) << error->pos << '/' << setw(8) << frame->size() << ' '
231 << setw(2) << error->type << ' ';
232
233 cout << setw(1) << ' '
234 << setw(1) << ' ' << ' ';
235
236 cout << setw(4) << frame->getUDPNumberOfReceivedPackets() << '/'
237 << setw(4) << frame->getUDPMaximalSequenceNumber();
238
239 cout << " ";
240
241 print(cout, error->type);
242
243 cout << endl << endl;
244 }
245 }
246 }
247 }
248 }
249 STATUS(endl);
250
251 for (map<int, int>::const_iterator i = errors.begin(); i != errors.end(); ++i) {
252
253 print(cout, i->first);
254
255 cout << ' ' << setw(8) << i->second << endl;
256 }
257
258 int ns = 0;
259
260 for (map<int, int>::const_iterator i = misses.begin(); i != misses.end(); ++i) {
261
262 cout << "misses " << setw(10) << i->first << ' ' << setw(8) << i->second << endl;
263
264 ns += i->second;
265 }
266 {
267 cout << "misses " << setw(10) << "total" << ' ' << setw(8) << ns << endl;
268 }
269
270 H1.Write(outputFile.c_str());
271}
string outputFile
#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
Auxiliary class for multiplexing object iterators.
Utility class to parse command line options.
Definition JParser.hh:1698
Auxiliary class to manage set of compatible ROOT objects (e.g. histograms) using unique keys.
Definition JManager.hh:47
Object reading from a list of files.
JKey_t first
Definition JPair.hh:128
JValue_t second
Definition JPair.hh:129
std::ostream & print(std::ostream &out, const JTestSummary &summary, T __begin, T __end, const bool useColors=true, const JFormat_t &formatting=JFormat_t(18, 3, std::ios::fixed))
Print test summary.
@ debug_t
debug
Definition JMessage.hh:29
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
std::set< JROOTClassSelector > getROOTClassSelection(const bool option=false)
Get ROOT class selection.
Long64_t counter_type
Type definition for counter.
JFrameIndexRange getFrameIndexRange(JTreeScannerInterface< T, KM3NETDAQ::JDAQEvaluator > &in)
Get range of frame indices.
return result
Definition JPolint.hh:862
const int n
Definition JPolint.hh:791
static const JChecksum checksum
Function object to perform check-sum of raw data.
Definition JChecksum.hh:200
static int MAXIMAL_FRAME_SIZE
Maximal frame size.
Definition JChecksum.hh:35
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39
double getFrameTime()
Get frame time duration.
Definition JDAQClock.hh:162
Auxiliary class to select ROOT class based on class name.
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
Auxiliary data structure for result of checksum.
Definition JChecksum.hh:90
@ ETDC_t
TDC value error.
Definition JChecksum.hh:47
@ EPMT_t
PMT number error.
Definition JChecksum.hh:46
@ TIME_t
Time order error.
Definition JChecksum.hh:48
result_type::const_iterator const_iterator
Definition JChecksum.hh:119