Jpp  16.0.3
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  cout.tie(&cerr);
46 
47 
48  const JModule module = getModule<JKM3NeT_t>(1001);
49 
50  const JDAQHit::JTOT_t tot = 5;
51  const JDAQHit::JTOT_t tot_min = 10;
52  const JDAQHit::JTOT_t tot_max = 20;
53 
54  JDAQSuperFrame frame(JDAQSuperFrameHeader(JDAQChronometer(), module.getID()));
55 
56  {
57  vector<JDAQHit> buffer;
58 
59  for (int i = 0; i != 100; ++i) {
60  buffer.push_back(JDAQHit(0, 0, tot));
61  }
62 
63  frame.add(buffer.size(), buffer.data());
64  }
65 
66  ASSERT(!frame.empty());
67 
68 
69  JBuildL0<double> buildL0;
70  vector <double> buffer;
71 
72 
73  buildL0(frame, module, back_inserter(buffer));
74 
75  ASSERT(buffer.size() == (size_t) frame.size(), "Test of L0 hit building w/o DAQ hit selection " << buffer.size() << " ?= " << frame.size());
76 
77 
78  buildL0.setDAQHitSelector(JDAQHitToTSelector(tot_min, tot_max));
79 
80  buffer.clear();
81 
82  buildL0(frame, module, back_inserter(buffer));
83 
84  ASSERT(buffer.size() == 0u, "Test of L0 hit building with DAQ hit selection " << buffer.size() << " ?= " << 0u);
85 
86 
87  buildL0.resetDAQHitSelector();
88 
89  buffer.clear();
90 
91  buildL0(frame, module, back_inserter(buffer));
92 
93  ASSERT(buffer.size() == (size_t) frame.size(), "Test of L0 hit building w/o DAQ hit selection " << buffer.size() << " ?= " << frame.size());
94 
95  return 0;
96 }
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:180
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: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:755
int size() const
Definition: JDAQFrame.hh:182
Data frame of one optical module.
JDAQSuperFrame & add(const JDAQSuperFrame &super_frame)
Add data from same optical module.
Data structure for optical module.