Jpp  18.5.0
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"
14 
16 #include "JTrigger/JHitR0.hh"
17 #include "JTrigger/JHitR1.hh"
18 #include "JTrigger/JHitR2.hh"
19 #include "JTrigger/JMatchL0.hh"
20 #include "JTrigger/JBuildL0.hh"
21 #include "JTrigger/JBuildL1.hh"
22 #include "JTrigger/JBuildL2.hh"
24 
25 #include "Jeep/JParser.hh"
26 #include "Jeep/JMessage.hh"
27 
28 
29 /**
30  * Print data.
31  *
32  * \param out output stream
33  * \param title title
34  * \param __begin begin of data
35  * \param __end end of data
36  */
37 template<class T>
38 inline void print(std::ostream& out, const char* const title, T __begin, T __end)
39 {
40  using namespace std;
41 
42  out << title;
43 
44  for (T i = __begin; i != __end; ++i) {
45  out << ' ' << setw(4) << (int) i->getT();
46  }
47 
48  out << endl;
49 }
50 
51 
52 /**
53  * \file
54  *
55  * Example program to test JTRIGGER::JPreprocessor.
56  * \author mdejong
57  */
58 int main(int argc, char **argv)
59 {
60  using namespace std;
61  using namespace KM3NETDAQ;
62  using namespace JPP;
63 
65  double Tmax_ns;
66  JPreprocessor option;
67  int debug;
68 
69  try {
70 
71  JParser<> zap("Example program to test hit pre-processing with user data."\
72  "\nformat: -u \"(<PMT> <time> <time-over-threshold>)+\"");
73 
74  zap['u'] = make_field(data);
75  zap['T'] = make_field(Tmax_ns);
76  zap['O'] = make_field(option) = JPreprocessor::getOptions();
77  zap['d'] = make_field(debug) = 0;
78 
79  zap(argc, argv);
80  }
81  catch(const exception &error) {
82  FATAL(error.what() << endl);
83  }
84 
85 
87 
89 
90  const JModule module = getModule<JKM3NeT_t>(1001);
91 
92  detector.push_back(module);
93 
94  const JModuleRouter router(detector);
95 
96  JHit::setSlewing(false);
97 
98  JDAQTimeslice timeslice;
99 
100  JDAQSuperFrame frame(JDAQSuperFrameHeader(timeslice.getDAQChronometer(), module.getID()));
101 
102  frame.add(data.size(), data.data());
103 
104  timeslice.push_back(frame);
105 
106  DEBUG(timeslice);
107 
108  {
109  typedef JSuperFrame2D<JHit> JSuperFrame2D_t;
110 
111  JSuperFrame2D_t& buffer = JSuperFrame2D_t::demultiplex(timeslice[0], module);
112 
113  buffer.preprocess(option, JMatchL0<JHit>(Tmax_ns));
114 
115  JBuildL0<JHitR0> buildL0;
116  vector <JHitR0> output;
117 
118  buildL0(buffer, back_inserter(output));
119 
120  print(cout, "L0:", output.begin(), output.end());
121  }
122 
123  {
124  JBuildL0<JHitL0> buildL0;
125  vector <JHitL0> output;
126 
127  buildL0.setPreprocessor(option, JMatchL0<JHit>(Tmax_ns));
128 
129  buildL0(timeslice, router, back_inserter(output));
130 
131  print(cout, "L0:", output.begin(), output.end());
132  }
133  {
134  JBuildL1<JHitR1> buildL1(JBuildL1Parameters(Tmax_ns, true));
135  vector <JHitR1> output;
136 
137  buildL1.setPreprocessor(option, JMatchL0<JHit>(Tmax_ns));
138 
139  buildL1(timeslice, router, back_inserter(output));
140 
141  print(cout, "L1:", output.begin(), output.end());
142  }
143  {
144  JBuildL2<JHitR2> buildL2(JL2Parameters(2, Tmax_ns, -1.0));
145  vector <JHitR2> output;
146 
147  buildL2.setPreprocessor(option, JMatchL0<JHit>(Tmax_ns));
148 
149  buildL2(timeslice, router, back_inserter(output));
150 
151  print(cout, "L2:", output.begin(), output.end());
152  }
153 
154  return 0;
155 }
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:67
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
Detector support kit.
#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