Jpp  18.2.0-rc.1
the software that should make you happy
 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"
10 #include "JTrigger/JHit.hh"
11 #include "JTrigger/JHitR0.hh"
12 #include "JTrigger/JBuildL0.hh"
14 
15 #include "Jeep/JParser.hh"
16 #include "Jeep/JMessage.hh"
17 
18 
19 /**
20  * \file
21  *
22  * Example program to test DAQ hit selection using JTRIGGER::JBuildL0.
23  * \author mdejong
24  */
25 int main(int argc, char **argv)
26 {
27  using namespace std;
28  using namespace JPP;
29  using namespace KM3NETDAQ;
30 
31  int debug;
32 
33  try {
34 
35  JParser<> zap("Example program to test DAQ hit selection using JTRIGGER::JBuildL0.");
36 
37  zap['d'] = make_field(debug) = 3;
38 
39  zap(argc, argv);
40  }
41  catch(const exception &error) {
42  FATAL(error.what() << endl);
43  }
44 
45 
46  const JModule module = getModule<JKM3NeT_t>(1001);
47 
48  const JDAQHit::JTOT_t tot = 5;
49  const JDAQHit::JTOT_t tot_min = 10;
50  const JDAQHit::JTOT_t tot_max = 20;
51 
52  JDAQSuperFrame frame(JDAQSuperFrameHeader(JDAQChronometer(), module.getID()));
53 
54  {
55  vector<JDAQHit> buffer;
56 
57  for (int i = 0; i != 100; ++i) {
58  buffer.push_back(JDAQHit(0, 0, tot));
59  }
60 
61  frame.add(buffer.size(), buffer.data());
62  }
63 
64  ASSERT(!frame.empty());
65 
66 
67  JBuildL0<double> buildL0;
68  vector <double> buffer;
69 
70 
71  buildL0(frame, module, back_inserter(buffer));
72 
73  ASSERT(buffer.size() == (size_t) frame.size(), "Test of L0 hit building w/o DAQ hit selection " << buffer.size() << " ?= " << frame.size());
74 
75 
76  buildL0.setDAQHitSelector(JDAQHitToTSelector(tot_min, tot_max));
77 
78  buffer.clear();
79 
80  buildL0(frame, module, back_inserter(buffer));
81 
82  ASSERT(buffer.size() == 0u, "Test of L0 hit building with DAQ hit selection " << buffer.size() << " ?= " << 0u);
83 
84 
85  buildL0.resetDAQHitSelector();
86 
87  buffer.clear();
88 
89  buildL0(frame, module, back_inserter(buffer));
90 
91  ASSERT(buffer.size() == (size_t) frame.size(), "Test of L0 hit building w/o DAQ hit selection " << buffer.size() << " ?= " << frame.size());
92 
93  return 0;
94 }
Utility class to parse command line options.
Definition: JParser.hh:1514
int main(int argc, char *argv[])
Definition: Main.cc:15
bool empty() const
Definition: JDAQFrame.hh:181
Basic data structure for L0 hit.
Data structure for a composite optical module.
Definition: JModule.hh:68
Basic data structure for time and time over threshold information of hit.
#define ASSERT(A,...)
Assert macro.
Definition: JMessage.hh:90
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:1989
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:776
int size() const
Definition: JDAQFrame.hh:183
Data frame of one optical module.
JDAQSuperFrame & add(const JDAQSuperFrame &super_frame)
Add data from same optical module.
int debug
debug level
Data structure for optical module.