Jpp 19.3.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
JPreprocessor.cc
Go to the documentation of this file.
1
2#include <string>
3#include <iostream>
4#include <iomanip>
5#include <vector>
6
9
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 */
37template<class T>
38inline 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 */
58int main(int argc, char **argv)
59{
60 using namespace std;
61 using namespace KM3NETDAQ;
62 using namespace JPP;
63
64 vector<JDAQHit> data;
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}
Detector support kit.
Data structure for detector geometry and calibration.
Basic data structure for L0 hit.
Reduced data structure for L1 hit.
Basic data structure for R2 hit.
Match operator for consecutive hits.
General purpose messaging.
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
Direct access to module in detector data structure.
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
int main(int argc, char **argv)
Auxiliaries for pre-processing of hits.
Detector data structure.
Definition JDetector.hh:96
Router for direct addressing of module data in detector data structure.
Data structure for a composite optical module.
Definition JModule.hh:75
int getID() const
Get identifier.
Definition JObjectID.hh:50
Utility class to parse command line options.
Definition JParser.hh:1698
Template L0 hit builder.
Definition JBuildL0.hh:38
Template L1 hit builder.
Definition JBuildL1.hh:90
Template L2 builder.
Definition JBuildL2.hh:49
static void setSlewing(const bool slewing)
Set slewing option.
L0 match criterion.
Definition JMatchL0.hh:29
2-dimensional frame with time calibrated data from one optical module.
const JDAQChronometer & getDAQChronometer() const
Get DAQ chronometer.
Data frame of one optical module.
JDAQSuperFrame & add(const JDAQSuperFrame &super_frame)
Add data from same optical module.
std::ostream & print(std::ostream &out, const JTestSummary &summary, const char delimiter=' ', const bool useColors=true)
Print test summary.
@ debug_t
debug
Definition JMessage.hh:29
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39
void setDAQLongprint(const bool option)
Set DAQ print option.
Definition JDAQPrint.hh:28
Detector file.
Definition JHead.hh:227
Auxiliary data structure for L1 build parameters.
Definition JBuildL1.hh:38
void setPreprocessor(const JPreprocessor::JOption_t option, const match_type &match)
Set pre-processor of consecutive hits.
Definition JBuild.hh:59
Data structure for L2 parameters.
Auxiliary class for specifying the way of pre-processing of hits.
static std::vector< JPreprocessor > getOptions()
Get options.