Jpp
 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"
12 
14 #include "JTrigger/JTimesliceL1.hh"
18 #include "JTrigger/JBuildL1.hh"
19 #include "JTrigger/JBuildL2.hh"
20 #include "JTrigger/JHitToolkit.hh"
21 
22 #include "Jeep/JParser.hh"
23 #include "Jeep/JMessage.hh"
24 
25 namespace {
26 
28  using namespace JPP;
29 
30  /**
31  * Print time slice.
32  *
33  * \param out output stream
34  * \param title title
35  * \param timeslice time slice
36  */
37  template<class T>
38  void print(std::ostream& out, const std::string& title, JTimeslice<T>& timeslice)
39  {
40  using namespace std;
41  using namespace JPP;
42 
43  out << title << endl;
44 
45  for (typename JTimeslice<T>::const_iterator frame = timeslice.begin(); frame != timeslice.end(); ++frame) {
46 
47  out << "module " << frame->getModuleID();
48 
49  for (typename JTimeslice<T>::value_type::const_iterator hit = frame->begin(); hit != frame->end(); ++hit) {
50  out << ' ' << JHitToolkit<T>::getT(*hit);
51  }
52 
53  out << endl;
54  }
55  }
56 }
57 
58 /**
59  * \file
60  *
61  * Example program to test JTRIGGER::JBuildL1 and JTRIGGER::JBuildL2 hit coincidence building with user data.
62  * \author mdejong
63  */
64 int main(int argc, char **argv)
65 {
66  using namespace std;
67  using namespace KM3NETDAQ;
68  using namespace JPP;
69 
70  vector<JDAQHit> data;
72  int debug;
73 
74  try {
75 
76  JParser<> zap("Example program to test hit coincidence building with user data."\
77  "\nformat: -u \"(<PMT> <time> <time-over-threshold>)+\"");
78 
79  zap['u'] = make_field(data);
81  zap['d'] = make_field(debug) = 0;
82 
83  zap(argc, argv);
84  }
85  catch(const exception &error) {
86  FATAL(error.what() << endl);
87  }
88 
89  using namespace KM3NETDAQ;
90 
91  cout.tie(&cerr);
92 
93  setDAQLongprint(true);
94 
95  parameters.set();
96 
97  cout << parameters << endl;
98 
99 
101 
102  JModule module = JModule::getInstance();
103 
104  module.setID(1001);
105 
106  detector.push_back(module);
107 
108  const JModuleRouter moduleRouter(detector);
109 
110 
111  typedef double hit_type;
112  typedef JSuperFrame1D<hit_type> JSuperFrame1D_t;
113  typedef JSuperFrame2D<hit_type> JSuperFrame2D_t;
114  typedef JTimeslice <hit_type> JTimeslice_t;
115  typedef JBuildL1 <hit_type> JBuildL1_t;
116  typedef JBuildL2 <hit_type> JBuildL2_t;
117 
118  const JBuildL1_t buildL1(parameters);
119  const JBuildL2_t buildL2(parameters.L2);
120 
121  JTimesliceRouter timesliceRouter(parameters.numberOfBins);
122 
123 
124  JDAQTimeslice timeslice;
125 
126  JDAQSuperFrame frame(JDAQSuperFrameHeader(timeslice.getDAQChronometer(), module.getID()));
127 
128  frame.add(data.size(), data.data());
129 
130  timeslice.push_back(frame);
131 
132  cout << timeslice << endl;
133 
134  timesliceRouter.configure(timeslice);
135 
136  const JSuperFrame2D_t& buffer = JSuperFrame2D_t::demultiplex(timeslice[0], module);
137 
138  JTimeslice_t timesliceL0;
139  JTimeslice_t timesliceL1;
140  JTimeslice_t timesliceL2;
141 
142  timesliceL0.push_back(JSuperFrame1D_t(buffer));
143  timesliceL1.push_back(JSuperFrame1D_t(JDAQChronometer(), module.getID(), module.getPosition()));
144  timesliceL2.push_back(JSuperFrame1D_t(JDAQChronometer(), module.getID(), module.getPosition()));
145 
146  buildL1(buffer, back_inserter(timesliceL1[0]));
147  buildL2(buffer, timesliceL1[0], back_inserter(timesliceL2[0]));
148 
149  print(cout, "Trigger L0", timesliceL0);
150  print(cout, "Trigger L1", timesliceL1);
151  print(cout, "Trigger L2", timesliceL2);
152 
153  JTimesliceL1<JDAQTimesliceL1> outputL1(timesliceL1, timesliceRouter, moduleRouter, parameters.TMaxLocal_ns);
154  JTimesliceL1<JDAQTimesliceL2> outputL2(timesliceL2, timesliceRouter, moduleRouter, parameters.L2.TMaxLocal_ns);
155 
156  cout << outputL1;
157  cout << outputL2;
158 }
159 
Utility class to parse command line options.
Definition: JParser.hh:1500
std::vector< value_type >::const_iterator const_iterator
Definition: JTimeslice.hh:34
Data structure for a composite optical module.
Definition: JModule.hh:57
void configure(const JDAQTimeslice &timeslice)
Configure.
Detector data structure.
Definition: JDetector.hh:80
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:66
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:196
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
Router for fast addressing of hits in KM3NETDAQ::JDAQTimeslice data structure as a function of the op...
const JDAQChronometer & getDAQChronometer() const
Get DAQ chronometer.
Data time slice.
int debug
debug level
Definition: JSirene.cc:63
static const JModule & getInstance()
Get reference to unique instance of this class object.
Definition: JModule.hh:103
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.
Time slice with calibrated data.
Definition: JTimeslice.hh:26
int main(int argc, char *argv[])
Definition: Main.cpp:15