Jpp  18.2.0
the software that should make you happy
 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 #include <algorithm>
6 
9 #include "JDetector/JModule.hh"
11 #include "JTrigger/JFrame.hh"
15 
16 
17 /**
18  * \author mdejong
19  */
20 
21 namespace JTRIGGER {}
22 namespace JPP { using namespace JTRIGGER; }
23 
24 namespace JTRIGGER {
25 
27  using JDETECTOR::JModule;
28 
29 
30  /**
31  * 2-dimensional frame with time calibrated data from one optical module.
32  *
33  * For each PMT, data are stored in a separate frame.
34  * In the following, the data of a single PMT are assumed to be time ordered.
35  *
36  * Note that the data of each PMT are terminated with an end marker (see class JFrame_t).\n
37  * The data of a given PMT are cleared when the return value of
38  * method JTRIGGER::getDAQStatus or JTRIGGER::getPMTStatus is false.
39  *
40  * The static data member JSuperFrame2D::demultiplex can be used as an I/O buffer.
41  */
42  template<class JElement_t, class JAllocator_t = std::allocator<JElement_t> >
43  class JSuperFrame2D :
44  public JModuleHeader,
45  public std::vector< JFrame<JElement_t, JAllocator_t> >
46  {
47  public:
48 
51 
56 
57 
58  /**
59  * Default constructor.
60  */
62  {}
63 
64 
65  /**
66  * Process DAQ super frame.
67  *
68  * The time calibration is applied and an appropriate end marker is added.
69  *
70  * \param input DAQ super frame
71  * \param module module data
72  * \param selector DAQ hit selector
73  * \return this 2D super frame
74  */
76  const JModule& module,
77  const JDAQHitSelector& selector = JDAQHitDefaultSelector())
78  {
80  using namespace JPP;
81 
82  this->setDAQChronometer (input.getDAQChronometer());
84  this->setPosition (module.getPosition());
85 
86  this->resize(NUMBER_OF_PMTS);
87 
88  for (int i = 0; i != NUMBER_OF_PMTS; ++i) {
89 
90  JFrame<JElement_t, JAllocator_t>& frame = (*this)[i];
91 
92  frame.clear();
93 
94  frame.setDAQChronometer(this->getDAQChronometer());
96  frame.setAxis (module.getPMT(i).getAxis());
97  frame.setCalibration (module.getPMT(i).getCalibration());
98  }
99 
100  int n = input.size();
101 
102  if (dynamic_cast<const JDAQHitDefaultSelector*>(&selector) != NULL) {
103 
104  for (JDAQSuperFrame::const_iterator i = input.begin(); n != 0; --n, ++i) {
105  (*this)[i->getPMT()].push_back(*i);
106  }
107 
108  } else {
109 
110  for (JDAQSuperFrame::const_iterator i = input.begin(); n != 0; --n, ++i) {
111  if (selector(*i)) {
112  (*this)[i->getPMT()].push_back(*i);
113  }
114  }
115  }
116 
117  for (int i = 0; i != NUMBER_OF_PMTS; ++i) {
118  if (!getDAQStatus(input, module, i) ||
119  !getPMTStatus(input, module, i) ||
120  module.getPMT(i).has(PMT_DISABLE)) {
121  (*this)[i].clear();
122  }
123  }
124 
125  for (int i = 0; i != NUMBER_OF_PMTS; ++i) {
126  (*this)[i].putEndMarker();
127  }
128 
129  return *this;
130  }
131 
132 
133  /**
134  * Apply high-rate veto.
135  *
136  * \param rate_Hz high-rate veto [Hz]
137  */
138  void applyHighRateVeto(const double rate_Hz)
139  {
140  for (iterator i = this->begin(); i != this->end(); ++i) {
141  i->applyHighRateVeto(rate_Hz);
142  }
143  }
144 
145 
146  /**
147  * Pre-process data.
148  *
149  * \param option option
150  * \param match match criterion
151  */
152  void preprocess(JPreprocessor::JOption_t option, const match_type& match)
153  {
154  switch (option) {
155 
157  for (iterator i = this->begin(); i != this->end(); ++i) {
158  i->join(match);
159  }
160  break;
161 
163  for (iterator i = this->begin(); i != this->end(); ++i) {
164  i->filter(match);
165  }
166  break;
167 
169  for (iterator i = this->begin(); i != this->end(); ++i) {
170  i->remove(match);
171  }
172  break;
173 
174  default:
175  break;
176  }
177  }
178 
179 
180  /**
181  * Demultiplexer.
182  */
184  };
185 
186 
187  /**
188  * Demultiplexer.
189  */
190  template<class JElement_t, class JAllocator_t>
192 }
193 
194 #endif
remove consecutive hits according match criterion
Auxiliaries for pre-processing of hits.
int getModuleID() const
Get module identifier.
Data structure for a composite optical module.
Definition: JModule.hh:68
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.
const int n
Definition: JPolint.hh:742
join consecutive hits according match criterion
bool has(const int bit) const
Test PMT status.
Definition: JStatus.hh:120
Hit data structure.
Definition: JDAQHit.hh:34
void setPMTIdentifier(const JDAQPMTIdentifier &pmt)
Set PMT identifier.
const_iterator begin() const
Definition: JDAQFrame.hh:165
Data frame for calibrated hits of one PMT.
Definition: JFrame.hh:34
static const int PMT_DISABLE
KM3NeT Data Definitions v3.2.0-2-gaaf0dd0 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:173
Header for Module.
std::vector< value_type >::iterator iterator
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.
JOption_t
Preprocessing options.
const JAxis3D & getAxis() const
Get axis.
Definition: JAxis3D.hh:98
filter 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:183
Data frame of one optical module.
void setPosition(const JVector3D &pos)
Set position.
Definition: JPosition3D.hh:152
Data structure for optical module.