Jpp  19.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JTestL1.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/JTimesliceL1.hh"
20 #include "JTrigger/JBuildL1.hh"
21 #include "JTrigger/JBuildL2.hh"
22 #include "JTrigger/JHitToolkit.hh"
23 
24 #include "Jeep/JParser.hh"
25 #include "Jeep/JMessage.hh"
26 
27 namespace {
28 
30  using namespace JPP;
31 
32  /**
33  * Print time slice.
34  *
35  * \param out output stream
36  * \param title title
37  * \param timeslice time slice
38  */
39  template<class T>
40  void print(std::ostream& out, const std::string& title, JTimeslice<T>& timeslice)
41  {
42  using namespace std;
43  using namespace JPP;
44 
45  out << title << endl;
46 
47  for (typename JTimeslice<T>::const_iterator frame = timeslice.begin(); frame != timeslice.end(); ++frame) {
48 
49  out << "module " << frame->getModuleID();
50 
51  for (typename JTimeslice<T>::value_type::const_iterator hit = frame->begin(); hit != frame->end(); ++hit) {
52  out << ' ' << JHitToolkit<T>::getT(*hit);
53  }
54 
55  out << endl;
56  }
57  }
58 }
59 
60 /**
61  * \file
62  *
63  * Example program to test JTRIGGER::JBuildL1 and JTRIGGER::JBuildL2 hit coincidence building with user data.
64  * \author mdejong
65  */
66 int main(int argc, char **argv)
67 {
68  using namespace std;
69  using namespace KM3NETDAQ;
70  using namespace JPP;
71 
74  int debug;
75 
76  try {
77 
78  JParser<> zap("Example program to test hit coincidence building with user data."\
79  "\nformat: -u \"(<PMT> <time> <time-over-threshold>)+\"");
80 
81  zap['u'] = make_field(data);
83  zap['d'] = make_field(debug) = 0;
84 
85  zap(argc, argv);
86  }
87  catch(const exception &error) {
88  FATAL(error.what() << endl);
89  }
90 
91  using namespace KM3NETDAQ;
92 
93 
94  setDAQLongprint(true);
95 
96  parameters.set();
97 
98  cout << parameters << endl;
99 
100 
102 
103  const JModule module = getModule<JKM3NeT_t>(1001);
104 
105  detector.push_back(module);
106 
107  const JModuleRouter moduleRouter(detector);
108 
109 
110  typedef double hit_type;
111  typedef JSuperFrame1D<hit_type> JSuperFrame1D_t;
112  typedef JSuperFrame2D<hit_type> JSuperFrame2D_t;
113  typedef JTimeslice <hit_type> JTimeslice_t;
114  typedef JBuildL1 <hit_type> JBuildL1_t;
115  typedef JBuildL2 <hit_type> JBuildL2_t;
116 
117  const JBuildL1_t buildL1(parameters);
118  const JBuildL2_t buildL2(parameters.L2);
119 
120  JTimesliceRouter timesliceRouter(parameters.numberOfBins);
121 
122 
123  JDAQTimeslice timeslice;
124 
125  JDAQSuperFrame frame(JDAQSuperFrameHeader(timeslice.getDAQChronometer(), module.getID()));
126 
127  frame.add(data.size(), data.data());
128 
129  timeslice.push_back(frame);
130 
131  cout << timeslice << endl;
132 
133  timesliceRouter.configure(timeslice);
134 
135  const JSuperFrame2D_t& buffer = JSuperFrame2D_t::demultiplex(timeslice[0], module);
136 
137  JTimeslice_t timesliceL0;
138  JTimeslice_t timesliceL1;
139  JTimeslice_t timesliceL2;
140 
141  timesliceL0.push_back(JSuperFrame1D_t(buffer));
142  timesliceL1.push_back(JSuperFrame1D_t(JDAQChronometer(), module.getID(), module.getPosition()));
143  timesliceL2.push_back(JSuperFrame1D_t(JDAQChronometer(), module.getID(), module.getPosition()));
144 
145  buildL1(buffer, back_inserter(timesliceL1[0]));
146  buildL2(buffer, timesliceL1[0], back_inserter(timesliceL2[0]));
147 
148  print(cout, "Trigger L0", timesliceL0);
149  print(cout, "Trigger L1", timesliceL1);
150  print(cout, "Trigger L2", timesliceL2);
151 
152  JTimesliceL1<JDAQTimesliceL1> outputL1(timesliceL1, timesliceRouter, moduleRouter, parameters.TMaxLocal_ns);
153  JTimesliceL1<JDAQTimesliceL2> outputL2(timesliceL2, timesliceRouter, moduleRouter, parameters.L2.TMaxLocal_ns);
154 
155  cout << outputL1;
156  cout << outputL2;
157 }
158 
Utility class to parse command line options.
Definition: JParser.hh:1711
std::vector< value_type >::const_iterator const_iterator
Definition: JTimeslice.hh:34
int main(int argc, char *argv[])
Definition: Main.cc:15
Data structure for a composite optical module.
Definition: JModule.hh:67
Router for fast addressing of hits in KM3NETDAQ::JDAQTimeslice data structure as a function of the op...
Detector data structure.
Definition: JDetector.hh:89
void configure(const JDAQTimeslice &timeslice)
Configure.
Router for direct addressing of module data in detector data structure.
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Definition: diff-Tuna.sh:38
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:84
Data structure for detector geometry and calibration.
Tools for handling different hit types.
1-dimensional frame with time calibrated data from one optical module.
void setDAQLongprint(const bool option)
Set DAQ print option.
Definition: JDAQPrint.hh:28
Template L2 builder.
Definition: JBuildL2.hh:45
Detector file.
Definition: JHead.hh:226
Detector support kit.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2158
const JDAQChronometer & getDAQChronometer() const
Get DAQ chronometer.
Data time slice.
print
Definition: JConvertDusj.sh:44
General purpose messaging.
Template L1 hit builder.
Definition: JBuildL1.hh:85
#define FATAL(A)
Definition: JMessage.hh:67
Direct access to module in detector data structure.
Auxiliary class to build JDAQTimeslice for L1 timeslice.
Definition: JTimesliceL1.hh:36
Utility class to parse command line options.
2-dimensional frame with time calibrated data from one optical module.
do set_variable DETECTOR_TXT $WORKDIR detector
Data frame of one optical module.
JDAQSuperFrame & add(const JDAQSuperFrame &super_frame)
Add data from same optical module.
int debug
debug level
Time slice with calibrated data.
Definition: JTimeslice.hh:26