Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JSuperFrame2D.hh
Go to the documentation of this file.
1 #ifndef __JTRIGGER__JSUPERFRAME2D__
2 #define __JTRIGGER__JSUPERFRAME2D__
3 
4 #include <vector>
5 
8 #include "JDetector/JModule.hh"
10 #include "JTrigger/JFrame.hh"
14 
15 
16 /**
17  * \author mdejong
18  */
19 
20 namespace JTRIGGER {}
21 namespace JPP { using namespace JTRIGGER; }
22 
23 namespace JTRIGGER {
24 
26  using JDETECTOR::JModule;
27 
28 
29  /**
30  * 2-dimensional frame with time calibrated data from one optical module.\n
31  * For each PMT, data are stored in a separate frame.
32  * In the following, the data of a single PMT are assumed to be time ordered.\n
33  * Note that the data of each PMT are terminated with an end marker.
34  *
35  * The data of a given PMT are limited to a single end marker when either
36  * of the results of methods getDAQStatus or getPMTStatus is false.
37  *
38  * The data member JSuperFrame2D::demultiplex can be used as an I/O buffer.
39  */
40  template<class JElement_t, class JAllocator_t = std::allocator<JElement_t> >
41  class JSuperFrame2D :
42  public JModuleHeader,
43  public std::vector< JFrame<JElement_t, JAllocator_t> >
44  {
45  public:
46 
49 
54 
55 
56  /**
57  * Default constructor.
58  */
60  {}
61 
62 
63  /**
64  * Process DAQ super frame.
65  *
66  * The time calibration is applied and an appropriate end marker is added.
67  *
68  * \param input DAQ super frame
69  * \param module module data
70  * \param selector DAQ hit selector
71  * \return this 2D super frame
72  */
74  const JModule& module,
75  const JDAQHitSelector& selector = JDAQHitDefaultSelector())
76  {
78  using namespace JPP;
79 
80  this->setDAQChronometer (input.getDAQChronometer());
82  this->setPosition (module.getPosition());
83 
84  this->resize(NUMBER_OF_PMTS);
85 
86  for (int i = 0; i != NUMBER_OF_PMTS; ++i) {
87 
88  JFrame<JElement_t, JAllocator_t>& frame = (*this)[i];
89 
90  frame.clear();
91 
92  frame.setDAQChronometer(this->getDAQChronometer());
94  frame.setAxis (module.getPMT(i).getAxis());
95  frame.setCalibration (module.getPMT(i).getCalibration());
96  }
97 
98  int n = input.size();
99 
100  if (dynamic_cast<const JDAQHitDefaultSelector*>(&selector) != NULL) {
101 
102  for (JDAQSuperFrame::const_iterator i = input.begin(); n != 0; --n, ++i) {
103  (*this)[i->getPMT()].push_back(*i);
104  }
105 
106  } else {
107 
108  for (JDAQSuperFrame::const_iterator i = input.begin(); n != 0; --n, ++i) {
109  if (selector(*i)) {
110  (*this)[i->getPMT()].push_back(*i);
111  }
112  }
113  }
114 
115  for (int i = 0; i != NUMBER_OF_PMTS; ++i) {
116  if (!getDAQStatus(input, module, i) ||
117  !getPMTStatus(input, module, i) ||
118  module.getPMT(i).has(PMT_DISABLE)) {
119  (*this)[i].clear();
120  }
121  }
122 
123  for (int i = 0; i != NUMBER_OF_PMTS; ++i) {
124  (*this)[i].putEndMarker();
125  }
126 
127  return *this;
128  }
129 
130 
131  /**
132  * Apply high-rate veto.
133  *
134  * \param rate_Hz high-rate veto [Hz]
135  */
136  void applyHighRateVeto(const double rate_Hz)
137  {
138  for (iterator i = this->begin(); i != this->end(); ++i) {
139  i->applyHighRateVeto(rate_Hz);
140  }
141  }
142 
143 
144  /**
145  * Pre-process data.
146  *
147  * \param option option
148  * \param match match criterion
149  */
150  void preprocess(JPreprocessor::JOption_t option, const match_type& match)
151  {
152  switch (option) {
153 
155  for (iterator i = this->begin(); i != this->end(); ++i) {
156  i->join(match);
157  }
158  break;
159 
161  for (iterator i = this->begin(); i != this->end(); ++i) {
162  i->filter(match);
163  }
164  break;
165 
166  default:
167  break;
168  }
169  }
170 
171 
172  /**
173  * Demultiplexer.
174  */
176  };
177 
178 
179  /**
180  * Demultiplexer.
181  */
182  template<class JElement_t, class JAllocator_t>
184 }
185 
186 #endif
Auxiliaries for pre-processing of hits.
int getModuleID() const
Get module identifier.
Data structure for a composite optical module.
Definition: JModule.hh:57
const JCalibration & getCalibration() const
Get calibration.
std::vector< value_type >::reverse_iterator reverse_iterator
JMatch< JElement_t > match_type
void setAxis(const JAxis3D &axis)
Set axis.
Definition: JAxis3D.hh:109
JFrame< JElement_t, JAllocator_t > value_type
Function object interface for hit matching.
Definition: JMatch.hh:25
Default class to select DAQ hits.
void preprocess(JPreprocessor::JOption_t option, const match_type &match)
Pre-process data.
JSuperFrame2D()
Default constructor.
static JSuperFrame2D< JElement_t, JAllocator_t > demultiplex
Demultiplexer.
join consecutive hits according match criterion
Hit data structure.
Definition: JDAQHit.hh:34
void setPMTIdentifier(const JDAQPMTIdentifier &pmt)
Set PMT identifier.
const_iterator begin() const
Definition: JDAQFrame.hh:136
Data frame for calibrated hits of one PMT.
Definition: JFrame.hh:32
static const int PMT_DISABLE
KM3NeT Data Definitions v1.3.1-43-g5270ad8 https://git.km3net.de/common/km3net-dataformat.
Definition: pmt_status.hh:12
const JDAQChronometer & getDAQChronometer() const
Get DAQ chronometer.
void setDAQChronometer(const JDAQChronometer &chronometer)
Set DAQ chronometer.
const JPosition3D & getPosition() const
Get position.
Definition: JPosition3D.hh:130
const JPMT & getPMT(const int index) const
Get PMT.
Definition: JModule.hh:211
Header for Module.
std::vector< value_type >::iterator iterator
bool has(const int bit) const
Test PMT status.
Definition: JStatus.hh:113
std::vector< value_type >::const_reverse_iterator const_reverse_iterator
bool getPMTStatus(const JStatus &status)
Test status of PMT.
void setModuleIdentifier(const JDAQModuleIdentifier &module)
Set Module identifier.
void setCalibration(const JCalibration &cal)
Set calibration.
void applyHighRateVeto(const double rate_Hz)
Apply high-rate veto.
alias put_queue eval echo n
Definition: qlib.csh:19
JOption_t
Preprocessing options.
const JAxis3D & getAxis() const
Get axis.
Definition: JAxis3D.hh:98
filter-out consecutive hits according match criterion
2-dimensional frame with time calibrated data from one optical module.
Auxiliary class to select DAQ hits.
std::vector< value_type >::const_iterator const_iterator
JSuperFrame2D & operator()(const JDAQSuperFrame &input, const JModule &module, const JDAQHitSelector &selector=JDAQHitDefaultSelector())
Process DAQ super frame.
const JDAQModuleIdentifier & getModuleIdentifier() const
Get Module identifier.
bool getDAQStatus(const JDAQFrameStatus &frame, const JStatus &status)
Test status of DAQ.
KM3NeT DAQ constants, bit handling, etc.
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Definition: JDAQ.hh:26
int size() const
Definition: JDAQFrame.hh:154
Data frame of one optical module.
void setPosition(const JVector3D &pos)
Set position.
Definition: JPosition3D.hh:152
Data structure for a composite optical module.