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

Example program to search for spurious hits. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <bitset>
#include "km3net-dataformat/online/JDAQTimeslice.hh"
#include "km3net-dataformat/online/JDAQPMTIdentifier.hh"
#include "JDAQ/JDAQTimesliceIO.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JSupport.hh"
#include "JLang/JObjectMultiplexer.hh"
#include "JROOT/JROOTClassSelector.hh"
#include "JTools/JRange.hh"
#include "JSystem/JKeypress.hh"
#include "Jeep/JPrint.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 search for spurious hits.

Author
mdejong

Definition in file Jaws.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 101 of file Jaws.cc.

102 {
103  using namespace std;
104  using namespace JPP;
105  using namespace KM3NETDAQ;
106 
107  typedef JRange<int> JRange_t;
108 
110  JLimit_t& numberOfEvents = inputFile.getLimit();
111  JROOTClassSelector selector;
112  JRange_t ToT_ns;
113  JPeriod is_periodic;
114  int numberOfHits;
115  int numberOfColumns;
117  int debug;
118 
119  try {
120 
121  JParser<> zap("Example program to search for spurious hits.");
122 
123  zap['f'] = make_field(inputFile, "input file).");
124  zap['n'] = make_field(numberOfEvents) = JLimit::max();
125  zap['C'] = make_field(selector, "timeslice selector, e.g. JDAQTimeslice.") = getROOTClassSelection<JDAQTimesliceTypes_t>();
126  zap['T'] = make_field(ToT_ns, "time-over-threshold range [ns]");
127  zap['p'] = make_field(is_periodic, "periodicity");
128  zap['M'] = make_field(numberOfHits, "minimum number of hits for periodicity");
129  zap['N'] = make_field(numberOfColumns, "number of columns for printing") = 5;
130  zap['V'] = make_field(veto, "veto PMT from analysis") = JPARSER::initialised();
131  zap['d'] = make_field(debug, "debug.") = 3;
132 
133  zap(argc, argv);
134  }
135  catch(const exception& error) {
136  FATAL(error.what() << endl);
137  }
138 
139 
141 
142  for (counter_type counter = 0; in.hasNext() && counter != inputFile.getLimit(); ++counter) {
143 
144  STATUS("event: " << setw(10) << counter << '\r'); DEBUG(endl);
145 
146  const JDAQTimeslice* timeslice = in.next();
147 
148  for (JDAQTimeslice::const_iterator frame = timeslice->begin(); frame != timeslice->end(); ++frame) {
149 
150  // organise data per PMT
151 
152  typedef vector<JDAQHit> buffer1D_type;
153  typedef vector<buffer1D_type> buffer2D_type;
154 
155  buffer2D_type buffer(numeric_limits<JDAQHit::JPMT_t>::max(), buffer1D_type());
156 
157  for (JDAQFrame::const_iterator hit = frame->begin(); hit != frame->end(); ++hit) {
158  buffer[hit->getPMT()].push_back(*hit);
159  }
160 
161  // detection of perodic signal
162 
164 
165  for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) {
166 
167  if (!buffer[pmt].empty()) {
168 
169  const JDAQPMTIdentifier id(frame->getModuleID(), pmt);
170 
171  for (buffer1D_type::iterator i = buffer[pmt].begin(); i != buffer[pmt].end(); ) {
172 
173  if (ToT_ns(i->getToT())) {
174 
175  buffer1D_type::iterator p = i;
176 
177  for (++p; p != buffer[pmt].end() && ToT_ns(p->getToT()) && is_periodic(*i, *p); ++p) {}
178 
179  if (distance(i, p) >= numberOfHits) {
180  top[id].push_back(*i);
181  }
182 
183  i = p;
184 
185  } else {
186 
187  ++i;
188  }
189  }
190  }
191  }
192 
193 
194  if (debug >= debug_t) {
195 
196  for (map<JDAQPMTIdentifier, vector<JDAQHit> >::const_iterator i = top.begin(); i != top.end(); ++i) {
197 
198  if (veto.count(i->first) == 0) {
199 
200  const int pmt = i->first.getPMTAddress();
201 
202  cout << timeslice->getRunNumber() << '/' << FILL(6,'0') << timeslice->getFrameIndex() << FILL() << ' '
203  << setw(9) << i->first.getModuleID() << '.' << FILL(2,'0') << i->first.getPMTAddress() << FILL() << ' '
204  << setw(1) << frame->testHighRateVeto(pmt)
205  << setw(1) << frame->testFIFOStatus (pmt) << endl;
206 
207  int count = 0;
208 
209  string eol = "";
210 
211  for (JDAQFrame::const_iterator hit = frame->begin(); hit != frame->end(); ++hit) {
212 
213  const bool has_pmt = (hit->getPMT() == i->first.getPMTAddress());
214  const bool has_hit = (find(i->second.begin(), i->second.end(), *hit) != i->second.end());
215 
216  if (has_pmt) {
217 
218  if (has_hit) {
219  eol = "*";
220  }
221 
222  cout << setw(10) << hit->getT() << ' ' << setw(3) << (int) hit->getToT() << ' ' << RESET;
223 
224  if ((++count % numberOfColumns) == 0) {
225 
226  cout << eol << endl;
227 
228  eol = "";
229  }
230  }
231  }
232 
233  cout << endl << "press any key to continue> " << flush;
234 
235  JKeypress(false).get();
236 
237  cout << endl;
238  }
239  }
240  }
241  }
242  }
243  STATUS(endl);
244 }
Utility class to parse command line options.
Definition: JParser.hh:1517
debug
Definition: JMessage.hh:29
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
#define STATUS(A)
Definition: JMessage.hh:63
Auxiliary class to select ROOT class based on class name.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:83
Long64_t counter_type
Type definition for counter.
Auxiliary class for multiplexing object iterators.
int getRunNumber() const
Get run number.
int getFrameIndex() const
Get frame index.
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
Type definition of range.
Definition: JHead.hh:41
char get()
Get single character.
Definition: JKeypress.hh:74
Hit data structure.
Definition: JDAQHit.hh:34
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1993
Enable unbuffered terminal input.
Definition: JKeypress.hh:32
Data time slice.
Auxiliary data structure for sequence of same character.
Definition: JManip.hh:328
#define FATAL(A)
Definition: JMessage.hh:67
General purpose class for object reading from a list of file names.
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 JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62