Jpp - the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JPreprocessor.cc File Reference

Example program to test JTRIGGER::JPreprocessor. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <vector>
#include "km3net-dataformat/online/JDAQHit.hh"
#include "JDAQ/JDAQSuperFrameIO.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JModuleRouter.hh"
#include "JTrigger/JSuperFrame2D.hh"
#include "JTrigger/JHitR0.hh"
#include "JTrigger/JHitR1.hh"
#include "JTrigger/JHitR2.hh"
#include "JTrigger/JMatchL0.hh"
#include "JTrigger/JBuildL0.hh"
#include "JTrigger/JBuildL1.hh"
#include "JTrigger/JBuildL2.hh"
#include "JTrigger/JPreprocessor.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

template<class T >
void print (std::ostream &out, const char *const title, T __begin, T __end)
 Print data. More...
 
int main (int argc, char **argv)
 

Detailed Description

Example program to test JTRIGGER::JPreprocessor.

Author
mdejong

Definition in file JPreprocessor.cc.

Function Documentation

template<class T >
void print ( std::ostream &  out,
const char *const  title,
T  __begin,
T  __end 
)
inline

Print data.

Parameters
outoutput stream
titletitle
__beginbegin of data
__endend of data

Definition at line 36 of file JPreprocessor.cc.

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 }
do set_variable OUTPUT_DIRECTORY $WORKDIR T
int main ( int  argc,
char **  argv 
)

Definition at line 56 of file JPreprocessor.cc.

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 }
Utility class to parse command line options.
Definition: JParser.hh:1500
debug
Definition: JMessage.hh:29
Data structure for a composite optical module.
Definition: JModule.hh:57
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:80
Router for direct addressing of module data in detector data structure.
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:196
T & getInstance(const T &object)
Get static instance from temporary object.
Definition: JObject.hh:75
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
Data time slice.
Template specialisation of L1 builder for JHitR1 data type.
Definition: JBuildL1.hh:284
int debug
debug level
Definition: JSirene.cc:63
print
Definition: JConvertDusj.sh:44
#define FATAL(A)
Definition: JMessage.hh:67
Data structure for L2 parameters.
Auxiliary data structure for L1 build parameters.
Definition: JBuildL1.hh:37
Template specialisation of L2 builder for JHitR2 data type.
Definition: JBuildL2.hh:332
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.
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62