Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JDAQHitSelector.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <iostream>
4 #include <iomanip>
5 #include <vector>
6 
8 #include "JDetector/JModule.hh"
9 #include "JTrigger/JHit.hh"
10 #include "JTrigger/JHitR0.hh"
11 #include "JTrigger/JBuildL0.hh"
13 
14 #include "Jeep/JParser.hh"
15 #include "Jeep/JMessage.hh"
16 
17 
18 /**
19  * \file
20  *
21  * Example program to test DAQ hit selection using JTRIGGER::JBuildL0.
22  * \author mdejong
23  */
24 int main(int argc, char **argv)
25 {
26  using namespace std;
27  using namespace JPP;
28  using namespace KM3NETDAQ;
29 
30  int debug;
31 
32  try {
33 
34  JParser<> zap("Example program to test DAQ hit selection using JTRIGGER::JBuildL0.");
35 
36  zap['d'] = make_field(debug) = 3;
37 
38  zap(argc, argv);
39  }
40  catch(const exception &error) {
41  FATAL(error.what() << endl);
42  }
43 
44  cout.tie(&cerr);
45 
46 
47  const JModule module = JModule::getInstance();
48 
49  const JDAQHit::JTOT_t tot = 5;
50  const JDAQHit::JTOT_t tot_min = 10;
51  const JDAQHit::JTOT_t tot_max = 20;
52 
53  JDAQSuperFrame frame(JDAQSuperFrameHeader(JDAQChronometer(), module.getID()));
54 
55  {
56  vector<JDAQHit> buffer;
57 
58  for (int i = 0; i != 100; ++i) {
59  buffer.push_back(JDAQHit(0, 0, tot));
60  }
61 
62  frame.add(buffer.size(), buffer.data());
63  }
64 
65  ASSERT(!frame.empty());
66 
67 
68  JBuildL0<double> buildL0;
69  vector <double> buffer;
70 
71 
72  buildL0(frame, module, back_inserter(buffer));
73 
74  ASSERT(buffer.size() == (size_t) frame.size(), "Test of L0 hit building w/o DAQ hit selection " << buffer.size() << " ?= " << frame.size());
75 
76 
77  buildL0.setDAQHitSelector(JDAQHitToTSelector(tot_min, tot_max));
78 
79  buffer.clear();
80 
81  buildL0(frame, module, back_inserter(buffer));
82 
83  ASSERT(buffer.size() == 0u, "Test of L0 hit building with DAQ hit selection " << buffer.size() << " ?= " << 0u);
84 
85 
86  buildL0.resetDAQHitSelector();
87 
88  buffer.clear();
89 
90  buildL0(frame, module, back_inserter(buffer));
91 
92  ASSERT(buffer.size() == (size_t) frame.size(), "Test of L0 hit building w/o DAQ hit selection " << buffer.size() << " ?= " << frame.size());
93 
94  return 0;
95 }
Utility class to parse command line options.
Definition: JParser.hh:1500
int main(int argc, char *argv[])
Definition: Main.cc:15
bool empty() const
Definition: JDAQFrame.hh:152
Basic data structure for L0 hit.
Data structure for a composite optical module.
Definition: JModule.hh:57
Basic data structure for time and time over threshold information of hit.
#define ASSERT(A,...)
Assert macro.
Definition: JMessage.hh:90
T & getInstance(const T &object)
Get static instance from temporary object.
Definition: JObject.hh:75
unsigned char JTOT_t
time over threshold [ns]
Definition: JDAQHit.hh:40
Hit data structure.
Definition: JDAQHit.hh:34
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
int debug
debug level
Definition: JSirene.cc:63
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Utility class to parse command line options.
Auxiliary class to select DAQ hits based on time-over-treshold value.
Template L0 hit builder.
Definition: JBuildL0.hh:35
double u[N+1]
Definition: JPolint.hh:739
int size() const
Definition: JDAQFrame.hh:154
Data frame of one optical module.
JDAQSuperFrame & add(const JDAQSuperFrame &super_frame)
Add data from same optical module.
Data structure for a composite optical module.