Jpp  15.0.1-rc.1-highqe
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 
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.
31  *
32  * For each PMT, data are stored in a separate frame.
33  * In the following, the data of a single PMT are assumed to be time ordered.
34  *
35  * Note that the data of each PMT are terminated with an end marker (see method JFrame::putEndMarker).\n
36  * The data of a given PMT are cleared when the return value of
37  * method JTRIGGER::getDAQStatus or JTRIGGER::getPMTStatus is false.
38  *
39  * The static data member JSuperFrame2D::demultiplex can be used as an I/O buffer.
40  */
41  template<class JElement_t, class JAllocator_t = std::allocator<JElement_t> >
42  class JSuperFrame2D :
43  public JModuleHeader,
44  public std::vector< JFrame<JElement_t, JAllocator_t> >
45  {
46  public:
47 
50 
55 
56 
57  /**
58  * Default constructor.
59  */
61  {}
62 
63 
64  /**
65  * Process DAQ super frame.
66  *
67  * The time calibration is applied and an appropriate end marker is added.
68  *
69  * \param input DAQ super frame
70  * \param module module data
71  * \param selector DAQ hit selector
72  * \return this 2D super frame
73  */
75  const JModule& module,
76  const JDAQHitSelector& selector = JDAQHitDefaultSelector())
77  {
79  using namespace JPP;
80 
81  this->setDAQChronometer (input.getDAQChronometer());
83  this->setPosition (module.getPosition());
84 
85  this->resize(NUMBER_OF_PMTS);
86 
87  for (int i = 0; i != NUMBER_OF_PMTS; ++i) {
88 
89  JFrame<JElement_t, JAllocator_t>& frame = (*this)[i];
90 
91  frame.clear();
92 
93  frame.setDAQChronometer(this->getDAQChronometer());
95  frame.setAxis (module.getPMT(i).getAxis());
96  frame.setCalibration (module.getPMT(i).getCalibration());
97  }
98 
99  int n = input.size();
100 
101  if (dynamic_cast<const JDAQHitDefaultSelector*>(&selector) != NULL) {
102 
103  for (JDAQSuperFrame::const_iterator i = input.begin(); n != 0; --n, ++i) {
104  (*this)[i->getPMT()].push_back(*i);
105  }
106 
107  } else {
108 
109  for (JDAQSuperFrame::const_iterator i = input.begin(); n != 0; --n, ++i) {
110  if (selector(*i)) {
111  (*this)[i->getPMT()].push_back(*i);
112  }
113  }
114  }
115 
116  for (int i = 0; i != NUMBER_OF_PMTS; ++i) {
117  if (!getDAQStatus(input, module, i) ||
118  !getPMTStatus(input, module, i) ||
119  module.getPMT(i).has(PMT_DISABLE)) {
120  (*this)[i].clear();
121  }
122  }
123 
124  for (int i = 0; i != NUMBER_OF_PMTS; ++i) {
125  (*this)[i].putEndMarker();
126  }
127 
128  return *this;
129  }
130 
131 
132  /**
133  * Apply high-rate veto.
134  *
135  * \param rate_Hz high-rate veto [Hz]
136  */
137  void applyHighRateVeto(const double rate_Hz)
138  {
139  for (iterator i = this->begin(); i != this->end(); ++i) {
140  i->applyHighRateVeto(rate_Hz);
141  }
142  }
143 
144 
145  /**
146  * Pre-process data.
147  *
148  * \param option option
149  * \param match match criterion
150  */
151  void preprocess(JPreprocessor::JOption_t option, const match_type& match)
152  {
153  switch (option) {
154 
156  for (iterator i = this->begin(); i != this->end(); ++i) {
157  i->join(match);
158  }
159  break;
160 
162  for (iterator i = this->begin(); i != this->end(); ++i) {
163  i->filter(match);
164  }
165  break;
166 
167  default:
168  break;
169  }
170  }
171 
172 
173  /**
174  * Demultiplexer.
175  */
177  };
178 
179 
180  /**
181  * Demultiplexer.
182  */
183  template<class JElement_t, class JAllocator_t>
185 }
186 
187 #endif
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:660
join consecutive hits according match criterion
bool has(const int bit) const
Test PMT status.
Definition: JStatus.hh:108
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:33
static const int PMT_DISABLE
KM3NeT Data Definitions v2.1.0-7-g97845ea 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-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 optical module.