Jpp  18.0.0-rc.4
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JPreprocessor.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <iostream>
4 #include <iomanip>
5 #include <vector>
6 
9 
10 #include "JDetector/JDetector.hh"
13 
15 #include "JTrigger/JHitR0.hh"
16 #include "JTrigger/JHitR1.hh"
17 #include "JTrigger/JHitR2.hh"
18 #include "JTrigger/JMatchL0.hh"
19 #include "JTrigger/JBuildL0.hh"
20 #include "JTrigger/JBuildL1.hh"
21 #include "JTrigger/JBuildL2.hh"
23 
24 #include "Jeep/JParser.hh"
25 #include "Jeep/JMessage.hh"
26 
27 
28 /**
29  * Print data.
30  *
31  * \param out output stream
32  * \param title title
33  * \param __begin begin of data
34  * \param __end end of data
35  */
36 template<class T>
37 inline void print(std::ostream& out, const char* const title, T __begin, T __end)
38 {
39  using namespace std;
40 
41  out << title;
42 
43  for (T i = __begin; i != __end; ++i) {
44  out << ' ' << setw(4) << (int) i->getT();
45  }
46 
47  out << endl;
48 }
49 
50 
51 /**
52  * \file
53  *
54  * Example program to test JTRIGGER::JPreprocessor.
55  * \author mdejong
56  */
57 int main(int argc, char **argv)
58 {
59  using namespace std;
60  using namespace KM3NETDAQ;
61  using namespace JPP;
62 
64  double Tmax_ns;
65  JPreprocessor option;
66  int debug;
67 
68  try {
69 
70  JParser<> zap("Example program to test hit pre-processing with user data."\
71  "\nformat: -u \"(<PMT> <time> <time-over-threshold>)+\"");
72 
73  zap['u'] = make_field(data);
74  zap['T'] = make_field(Tmax_ns);
75  zap['O'] = make_field(option) = JPreprocessor::getOptions();
76  zap['d'] = make_field(debug) = 0;
77 
78  zap(argc, argv);
79  }
80  catch(const exception &error) {
81  FATAL(error.what() << endl);
82  }
83 
84 
86 
88 
89  const JModule module = getModule<JKM3NeT_t>(1001);
90 
91  detector.push_back(module);
92 
93  const JModuleRouter router(detector);
94 
95  JHit::setSlewing(false);
96 
97  JDAQTimeslice timeslice;
98 
99  JDAQSuperFrame frame(JDAQSuperFrameHeader(timeslice.getDAQChronometer(), module.getID()));
100 
101  frame.add(data.size(), data.data());
102 
103  timeslice.push_back(frame);
104 
105  DEBUG(timeslice);
106 
107  {
108  typedef JSuperFrame2D<JHit> JSuperFrame2D_t;
109 
110  JSuperFrame2D_t& buffer = JSuperFrame2D_t::demultiplex(timeslice[0], module);
111 
112  buffer.preprocess(option, JMatchL0<JHit>(Tmax_ns));
113 
114  JBuildL0<JHitR0> buildL0;
115  vector <JHitR0> output;
116 
117  buildL0(buffer, back_inserter(output));
118 
119  print(cout, "L0:", output.begin(), output.end());
120  }
121 
122  {
123  JBuildL0<JHitL0> buildL0;
124  vector <JHitL0> output;
125 
126  buildL0.setPreprocessor(option, JMatchL0<JHit>(Tmax_ns));
127 
128  buildL0(timeslice, router, back_inserter(output));
129 
130  print(cout, "L0:", output.begin(), output.end());
131  }
132  {
133  JBuildL1<JHitR1> buildL1(JBuildL1Parameters(Tmax_ns, true));
134  vector <JHitR1> output;
135 
136  buildL1.setPreprocessor(option, JMatchL0<JHit>(Tmax_ns));
137 
138  buildL1(timeslice, router, back_inserter(output));
139 
140  print(cout, "L1:", output.begin(), output.end());
141  }
142  {
143  JBuildL2<JHitR2> buildL2(JL2Parameters(2, Tmax_ns, -1.0));
144  vector <JHitR2> output;
145 
146  buildL2.setPreprocessor(option, JMatchL0<JHit>(Tmax_ns));
147 
148  buildL2(timeslice, router, back_inserter(output));
149 
150  print(cout, "L2:", output.begin(), output.end());
151  }
152 
153  return 0;
154 }
Utility class to parse command line options.
Definition: JParser.hh:1514
Auxiliaries for pre-processing of hits.
debug
Definition: JMessage.hh:29
int main(int argc, char *argv[])
Definition: Main.cc:15
Basic data structure for L0 hit.
Data structure for a composite optical module.
Definition: JModule.hh:68
void setPreprocessor(const JPreprocessor::JOption_t option, const match_type &match)
Set pre-processor of consecutive hits.
Definition: JBuild.hh:59
Template specialisation of L0 builder for JHitL0 data type.
Definition: JBuildL0.hh:102
L0 match criterion.
Definition: JMatchL0.hh:27
Detector data structure.
Definition: JDetector.hh:89
Router for direct addressing of module data in detector data structure.
Basic data structure for R2 hit.
Data structure for detector geometry and calibration.
void setDAQLongprint(const bool option)
Set DAQ print option.
Definition: JDAQPrint.hh:28
Template specialisation of L0 builder for JHitR0 data type.
Definition: JBuildL0.hh:174
Detector file.
Definition: JHead.hh:226
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
do set_variable OUTPUT_DIRECTORY $WORKDIR T
Data time slice.
Template specialisation of L1 builder for JHitR1 data type.
Definition: JBuildL1.hh:284
Match operator for consecutive hits.
print
Definition: JConvertDusj.sh:44
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Direct access to module in detector data structure.
Data structure for L2 parameters.
Reduced data structure for L1 hit.
Utility class to parse command line options.
Auxiliary data structure for L1 build parameters.
Definition: JBuildL1.hh:37
Template specialisation of L2 builder for JHitR2 data type.
Definition: JBuildL2.hh:339
2-dimensional frame with time calibrated data from one optical module.
do set_variable DETECTOR_TXT $WORKDIR detector
Auxiliary class for specifying the way of pre-processing of hits.
Data frame of one optical module.
JDAQSuperFrame & add(const JDAQSuperFrame &super_frame)
Add data from same optical module.
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62