Jpp
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"
12 
14 #include "JTrigger/JHitR0.hh"
15 #include "JTrigger/JHitR1.hh"
16 #include "JTrigger/JHitR2.hh"
17 #include "JTrigger/JMatchL0.hh"
18 #include "JTrigger/JBuildL0.hh"
19 #include "JTrigger/JBuildL1.hh"
20 #include "JTrigger/JBuildL2.hh"
22 
23 #include "Jeep/JParser.hh"
24 #include "Jeep/JMessage.hh"
25 
26 
27 /**
28  * Print data.
29  *
30  * \param out output stream
31  * \param title title
32  * \param __begin begin of data
33  * \param __end end of data
34  */
35 template<class T>
36 inline void print(std::ostream& out, const char* const title, T __begin, T __end)
37 {
38  using namespace std;
39 
40  out << title;
41 
42  for (T i = __begin; i != __end; ++i) {
43  out << ' ' << setw(4) << (int) i->getT();
44  }
45 
46  out << endl;
47 }
48 
49 
50 /**
51  * \file
52  *
53  * Example program to test JTRIGGER::JPreprocessor.
54  * \author mdejong
55  */
56 int main(int argc, char **argv)
57 {
58  using namespace std;
59  using namespace KM3NETDAQ;
60  using namespace JPP;
61 
62  vector<JDAQHit> data;
63  double Tmax_ns;
64  JPreprocessor option;
65  int debug;
66 
67  try {
68 
69  JParser<> zap("Example program to test hit pre-processing with user data."\
70  "\nformat: -u \"(<PMT> <time> <time-over-threshold>)+\"");
71 
72  zap['u'] = make_field(data);
73  zap['T'] = make_field(Tmax_ns);
74  zap['O'] = make_field(option) = JPreprocessor::getOptions();
75  zap['d'] = make_field(debug) = 0;
76 
77  zap(argc, argv);
78  }
79  catch(const exception &error) {
80  FATAL(error.what() << endl);
81  }
82 
83  using namespace KM3NETDAQ;
84 
85  cout.tie(&cerr);
86 
88 
90 
91  JModule module = JModule::getInstance();
92 
93  module.setID(1001);
94 
95  detector.push_back(module);
96 
97  const JModuleRouter router(detector);
98 
99  JHit::setSlewing(false);
100 
101  JDAQTimeslice timeslice;
102 
103  JDAQSuperFrame frame(JDAQSuperFrameHeader(timeslice.getDAQChronometer(), module.getID()));
104 
105  frame.add(data.size(), data.data());
106 
107  timeslice.push_back(frame);
108 
109  DEBUG(timeslice);
110 
111  {
112  typedef JSuperFrame2D<JHit> JSuperFrame2D_t;
113 
114  JSuperFrame2D_t& buffer = JSuperFrame2D_t::demultiplex(timeslice[0], module);
115 
116  buffer.preprocess(option, JMatchL0<JHit>(Tmax_ns));
117 
118  JBuildL0<JHitR0> buildL0;
119  vector <JHitR0> output;
120 
121  buildL0(buffer, back_inserter(output));
122 
123  print(cout, "L0:", output.begin(), output.end());
124  }
125 
126  {
127  JBuildL0<JHitL0> buildL0;
128  vector <JHitL0> output;
129 
130  buildL0.setPreprocessor(option, JMatchL0<JHit>(Tmax_ns));
131 
132  buildL0(timeslice, router, back_inserter(output));
133 
134  print(cout, "L0:", output.begin(), output.end());
135  }
136  {
137  JBuildL1<JHitR1> buildL1(JBuildL1Parameters(Tmax_ns, true));
138  vector <JHitR1> output;
139 
140  buildL1.setPreprocessor(option, JMatchL0<JHit>(Tmax_ns));
141 
142  buildL1(timeslice, router, back_inserter(output));
143 
144  print(cout, "L1:", output.begin(), output.end());
145  }
146  {
147  JBuildL2<JHitR2> buildL2(JL2Parameters(2, Tmax_ns, -1.0));
148  vector <JHitR2> output;
149 
150  buildL2.setPreprocessor(option, JMatchL0<JHit>(Tmax_ns));
151 
152  buildL2(timeslice, router, back_inserter(output));
153 
154  print(cout, "L2:", output.begin(), output.end());
155  }
156 
157  return 0;
158 }
JPreprocessor.hh
JSuperFrame2D.hh
JMessage.hh
JTRIGGER::JL2Parameters
Data structure for L2 parameters.
Definition: JTriggerParameters.hh:33
JLANG::getInstance
T & getInstance(const T &object)
Get static instance from temporary object.
Definition: JObject.hh:75
JTRIGGER::JBuildL1< JHitR1 >
Template specialisation of L1 builder for JHitR1 data type.
Definition: JBuildL1.hh:284
JTRIGGER::JBuild::setPreprocessor
void setPreprocessor(const JPreprocessor::JOption_t option, const match_type &match)
Set pre-processor.
Definition: JBuild.hh:52
std::vector
Definition: JSTDTypes.hh:12
KM3NETDAQ::JDAQTimeslice
Data time slice.
Definition: JDAQTimeslice.hh:30
JPARSER::JParser
Utility class to parse command line options.
Definition: JParser.hh:1493
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
JBuildL1.hh
JBuildL0.hh
main
int main(int argc, char **argv)
Definition: JPreprocessor.cc:56
JTRIGGER::JBuildL1Parameters
Auxiliary data structure for L1 build parameters.
Definition: JBuildL1.hh:37
debug
int debug
debug level
Definition: JSirene.cc:59
JLANG::JObjectID::setID
void setID(const int id)
Set identifier.
Definition: JObjectID.hh:66
JDAQSuperFrameIO.hh
JLANG::JObjectID::getID
int getID() const
Get identifier.
Definition: JObjectID.hh:55
JMatchL0.hh
JModuleRouter.hh
JDETECTOR::JModule
Data structure for a composite optical module.
Definition: JModule.hh:49
JHitR1.hh
KM3NETDAQ::JDAQSuperFrameHeader
DAQ super frame header.
Definition: JDAQSuperFrameHeader.hh:19
JBuildL2.hh
JParser.hh
JDETECTOR::JModuleRouter
Router for direct addressing of module data in detector data structure.
Definition: JModuleRouter.hh:34
print
void print(std::ostream &out, const char *const title, T __begin, T __end)
Print data.
Definition: JPreprocessor.cc:36
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
KM3NETDAQ::JDAQSuperFrame::add
JDAQSuperFrame & add(const JDAQSuperFrame &super_frame)
Add data from same optical module.
Definition: JDAQSuperFrame.hh:78
JTRIGGER::JMatchL0
L0 match criterion.
Definition: JMatchL0.hh:27
JDETECTOR::JDetector
Detector data structure.
Definition: JDetector.hh:80
JAANET::detector
Detector file.
Definition: JHead.hh:130
KM3NETDAQ::JDAQChronometer::getDAQChronometer
const JDAQChronometer & getDAQChronometer() const
Get DAQ chronometer.
Definition: JDAQChronometer.hh:88
DEBUG
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
JTRIGGER::JBuildL2< JHitR2 >
Template specialisation of L2 builder for JHitR2 data type.
Definition: JBuildL2.hh:299
std
Definition: jaanetDictionary.h:36
KM3NETDAQ
KM3NeT DAQ data structures and auxiliaries.
Definition: DataQueue.cc:39
KM3NETDAQ::JDAQSuperFrame
Data frame of one optical module.
Definition: JDAQSuperFrame.hh:22
JHitR0.hh
KM3NETDAQ::setDAQLongprint
void setDAQLongprint(const bool option)
Set DAQ print option.
Definition: JDAQPrint.hh:28
JTRIGGER::JBuildL0< JHitL0 >
Template specialisation of L0 builder for JHitL0 data type.
Definition: JBuildL0.hh:101
JDetector.hh
JDAQHit.hh
JTRIGGER::JPreprocessor
Auxiliary class for specifying the way of pre-processing of hits.
Definition: JPreprocessor.hh:31
JTRIGGER::JSuperFrame2D
2-dimensional frame with time calibrated data from one optical module.
Definition: JSuperFrame2D.hh:41
FATAL
#define FATAL(A)
Definition: JMessage.hh:67
JEEP::debug_t
debug
Definition: JMessage.hh:29
JHitR2.hh
JTRIGGER::JBuildL0< JHitR0 >
Template specialisation of L0 builder for JHitR0 data type.
Definition: JBuildL0.hh:173