Jpp
JTestL1.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <iostream>
4 #include <iomanip>
5 #include <vector>
6 
7 #include "JDAQ/JDAQHit.hh"
8 #include "JDAQ/JDAQSuperFrame.hh"
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;
71  JTriggerParameters parameters;
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);
80  zap['@'] = make_field(parameters) = JPARSER::initialised();
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 
JTRIGGER::JTriggerParameters::numberOfBins
int numberOfBins
number of bins for lookup table of timeslice
Definition: JTriggerParameters.hh:324
main
int main(int argc, char **argv)
Definition: JTestL1.cc:64
JTriggerParameters.hh
JSuperFrame2D.hh
JMessage.hh
JTRIGGER::JTriggerParameters::set
void set(const double DMax_m=0.0)
Set dependent trigger parameters.
Definition: JTriggerParameters.hh:141
JLANG::getInstance
T & getInstance(const T &object)
Get static instance from temporary object.
Definition: JObject.hh:73
JTRIGGER::JTriggerParameters::TMaxLocal_ns
double TMaxLocal_ns
maximal time difference between L0 hits for L1
Definition: JTriggerParameters.hh:322
JTRIGGER::JTriggerParameters
Data structure for all trigger parameters.
Definition: JTriggerParameters.hh:116
JTRIGGER::JBuildL1
Template L1 hit builder.
Definition: JBuildL1.hh:85
JPARSER::initialised
Empty structure for specification of parser element that is initialised (i.e.
Definition: JParser.hh:63
JTRIGGER::JSuperFrame1D
1-dimensional frame with time calibrated data from one optical module.
Definition: JSuperFrame1D.hh:35
std::vector
Definition: JSTDTypes.hh:12
KM3NETDAQ::JDAQTimeslice
Data time slice.
Definition: JDAQTimeslice.hh:36
JPARSER::JParser
Utility class to parse command line options.
Definition: JParser.hh:1493
JTRIGGER::JTriggerParameters::L2
JL2Parameters L2
L2 processing.
Definition: JTriggerParameters.hh:327
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
JBuildL1.hh
debug
int debug
debug level
Definition: JSirene.cc:59
JTRIGGER::JTimesliceL1
Auxiliary class to build JDAQTimeslice for L1 timeslice.
Definition: JTimesliceL1.hh:36
JHitToolkit.hh
JLANG::JObjectID::setID
void setID(const int id)
Set identifier.
Definition: JObjectID.hh:66
JLANG::JObjectID::getID
int getID() const
Get identifier.
Definition: JObjectID.hh:55
JTimesliceL1.hh
JTRIGGER::JTimeslice
Time slice with calibrated data.
Definition: JTimeslice.hh:26
JModuleRouter.hh
JDETECTOR::JModule
Data structure for a composite optical module.
Definition: JModule.hh:49
KM3NETDAQ::JDAQSuperFrameHeader
DAQ super frame header.
Definition: JDAQSuperFrameHeader.hh:25
JBuildL2.hh
JParser.hh
JDETECTOR::JModuleRouter
Router for direct addressing of module data in detector data structure.
Definition: JModuleRouter.hh:34
JTRIGGER::JTimesliceRouter::configure
void configure(const JDAQTimeslice &timeslice)
Configure.
Definition: JTimesliceRouter.hh:112
JTimesliceRouter.hh
JTRIGGER::JTimeslice::const_iterator
std::vector< value_type >::const_iterator const_iterator
Definition: JTimeslice.hh:34
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:80
JDETECTOR::JDetector
Detector data structure.
Definition: JDetector.hh:80
JGEOMETRY3D::JPosition3D::getPosition
const JPosition3D & getPosition() const
Get position.
Definition: JPosition3D.hh:129
JAANET::detector
Detector file.
Definition: JHead.hh:130
KM3NETDAQ::JDAQChronometer::getDAQChronometer
const JDAQChronometer & getDAQChronometer() const
Get DAQ chronometer.
Definition: JDAQChronometer.hh:88
JSuperFrame1D.hh
std
Definition: jaanetDictionary.h:36
JDAQSuperFrame.hh
KM3NETDAQ
KM3NeT DAQ data structures and auxiliaries.
Definition: DataQueue.cc:39
KM3NETDAQ::JDAQSuperFrame
Data frame of one optical module.
Definition: JDAQSuperFrame.hh:27
KM3NETDAQ::setDAQLongprint
void setDAQLongprint(const bool option)
Set DAQ print option.
Definition: JDAQPrint.hh:28
JDetector.hh
print
void print(const TH1 &h1, std::ostream &out)
Print histogram parameters.
Definition: JTriggerMonitor.cc:38
JDAQHit.hh
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
JTRIGGER::JL2Parameters::TMaxLocal_ns
double TMaxLocal_ns
maximal time difference [ns]
Definition: JTriggerParameters.hh:108
KM3NETDAQ::JDAQChronometer
DAQ chronometer.
Definition: JDAQChronometer.hh:26
JTRIGGER::JTimesliceRouter
Router for fast addressing of hits in KM3NETDAQ::JDAQTimeslice data structure as a function of the op...
Definition: JTimesliceRouter.hh:62
JTRIGGER::JBuildL2
Template L2 builder.
Definition: JBuildL2.hh:45