Jpp  pmt_effective_area_update
the software that should make you happy
 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 
11 
12 #include "JSupport/JSupport.hh"
15 #include "JTrigger/JChecksum.hh"
16 
17 #include "Jeep/JParser.hh"
18 #include "Jeep/JMessage.hh"
19 
20 namespace {
21 
22  /**
23  * Print DAQ hit.
24  *
25  * \param out output stream
26  * \param hit DAQ hit
27  */
28  void print(std::ostream& out, const KM3NETDAQ::JDAQHit& hit)
29  {
30  using namespace std;
31 
32  out << "\thit: "
33  << setw(3) << (int) hit.getPMT() << ' '
34  << setw(8) << hex << hit.getT() << ' '
35  << setw(10) << dec << hit.getT() << ' '
36  << setw(3) << (int) hit.getToT();
37  }
38 
39  /**
40  * Print error type.
41  *
42  * \param out output stream
43  * \param type error type
44  */
45  void print(std::ostream& out, const int type)
46  {
47  using namespace std;
48  using namespace JPP;
49 
50  switch (type) {
51 
52  case JChecksum::TIME_t:
53  out << "time";
54  break;
55 
56  case JChecksum::ETDC_t:
57  out << "TDC ";
58  break;
59 
60  case JChecksum::EPMT_t:
61  out << "PMT ";
62  break;
63 
64  case JChecksum::EUDP_t:
65  out << "UDP ";
66  break;
67 
68  case JChecksum::SIZE_t:
69  out << "size ";
70  break;
71 
72  default:
73  out << "? ";
74  break;
75  }
76  }
77 }
78 
79 
80 /**
81  * \file
82  *
83  * Example program to histogram KM3NETDAQ::JDAQTimeslice.
84  * \author mdejong
85  */
86 int main(int argc, char **argv)
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
int main(int argc, char *argv[])
Definition: Main.cc:15
ROOT TTree parameter settings of various packages.
#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.
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:176
static int MAXIMAL_FRAME_SIZE
Maximal frame size.
Definition: JChecksum.hh:32
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
double getFrameTime()
Get frame time duration.
Definition: JDAQClock.hh:162
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
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:40
then usage $script[input file[working directory[option]]] nWhere option can be N
Definition: JMuonPostfit.sh:36
const result_type & get(const JDAQSuperFrame &frame) const
Check sum.
Definition: JChecksum.hh:108