Jpp  18.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JFrame.hh
Go to the documentation of this file.
1 #ifndef __JTRIGGER__JFRAME__
2 #define __JTRIGGER__JFRAME__
3 
4 #include <vector>
5 
8 #include "JTrigger/JMatch.hh"
9 #include "JTrigger/JPMTHeader.hh"
10 #include "JTrigger/JHitToolkit.hh"
11 #include "JTrigger/JCalibration.hh"
12 #include "JTrigger/JFrame_t.hh"
13 
14 
15 
16 /**
17  * \author mdejong
18  */
19 
20 namespace JTRIGGER {}
21 namespace JPP { using namespace JTRIGGER; }
22 
23 namespace JTRIGGER {
24 
25  using KM3NETDAQ::JDAQHit;
26 
27 
28  /**
29  * Data frame for calibrated hits of one PMT.
30  *
31  * Note that the calibration is applied on the fly in the member method JFrame::push_back.
32  */
33  template<class JElement_t, class JAllocator_t = std::allocator<JElement_t> >
34  class JFrame :
35  public JPMTHeader,
36  public JCalibration,
37  public JFrame_t<JElement_t, JAllocator_t>
38  {
39  public:
40 
42  typedef JElement_t value_type;
44 
45  typedef typename container_type::iterator iterator;
46  typedef typename container_type::const_iterator const_iterator;
47  typedef typename container_type::reverse_iterator reverse_iterator;
48  typedef typename container_type::const_reverse_iterator const_reverse_iterator;
49 
51 
52 
53  /**
54  * Default constructor.
55  */
57  {}
58 
59 
60  /**
61  * Constructor.
62  *
63  * \param chronometer DAQ chronometer
64  * \param id PMT identifier
65  * \param axis PMT axis
66  * \param calibration calibration
67  */
68  JFrame(const JDAQChronometer& chronometer,
69  const JDAQPMTIdentifier& id,
70  const JAxis3D& axis,
71  const JCalibration& calibration) :
72  JPMTHeader (chronometer, id, axis),
73  JCalibration(calibration),
74  JFrame_t<JElement_t, JAllocator_t>()
75  {}
76 
77 
78  /**
79  * Append DAQ hit.
80  *
81  * The time calibration is applied before the hit is appended.
82  *
83  * \param hit DAQ hit
84  */
85  void push_back(const JDAQHit& hit)
86  {
87  container_type::push_back(this->getHit(hit, this->getCalibration()));
88  }
89 
90 
91  /**
92  * Apply high-rate veto.
93  *
94  * If vetoed, the container is cleared and an end marker is put.
95  *
96  * \param rate_Hz high-rate veto [Hz]
97  */
98  void applyHighRateVeto(const double rate_Hz)
99  {
101 
102  if (this->size() * 1.0e9 / getFrameTime() > rate_Hz) {
103  this->reset();
104  }
105  }
106 
107 
108  /**
109  * Join consecutive hits when matched according given criterion.
110  *
111  * \param match match criterion
112  */
113  void join(const match_type& match)
114  {
115  iterator out = this->begin();
116 
117  for (const_iterator p = this->begin(); p != this->end(); ) {
118 
119  *out = *p;
120 
121  while (++p != this->end() && match(*out,*p)) {
122  *out = join(*out,*p);
123  }
124 
125  ++out;
126  }
127 
128  if (out != this->end()) {
129  this->erase(out, this->end());
130  this->putEndMarker();
131  }
132  }
133 
134 
135  /**
136  * Filter-out consecutive hits when matched according given criterion.
137  *
138  * Note that all hits which are matched are removed.
139  *
140  * \param match match criterion
141  */
142  void filter(const match_type& match)
143  {
144  iterator out = this->begin();
145 
146  for (const_iterator p = this->begin(); p != this->end(); ) {
147 
148  const_iterator q = p;
149 
150  for (const_iterator i = p; ++q != this->end() && match(*i,*q); ++i) {}
151 
152  if (std::distance(p,q) == 1) {
153  *out = *p;
154  ++out;
155  }
156 
157  p = q;
158  }
159 
160  if (out != this->end()) {
161  this->erase(out, this->end());
162  this->putEndMarker();
163  }
164  }
165  };
166 }
167 
168 #endif
Data frame with end marker.
Definition: JFrame_t.hh:27
container_type::const_iterator const_iterator
Definition: JFrame.hh:46
void join(const match_type &match)
Join consecutive hits when matched according given criterion.
Definition: JFrame.hh:113
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
const JCalibration & getCalibration() const
Get calibration.
Header for PMT.
Definition: JPMTHeader.hh:26
JElement_t value_type
Definition: JFrame.hh:42
Function object interface for hit matching.
Definition: JMatch.hh:25
Data structure for time calibration.
Tools for handling different hit types.
container_type::reverse_iterator reverse_iterator
Definition: JFrame.hh:47
void reset()
Reset.
Definition: JFrame_t.hh:126
Axis object.
Definition: JAxis3D.hh:38
JFrame(const JDAQChronometer &chronometer, const JDAQPMTIdentifier &id, const JAxis3D &axis, const JCalibration &calibration)
Constructor.
Definition: JFrame.hh:68
Base class for match operations for cluster and hit-preprocessing methods.
Hit data structure.
Definition: JDAQHit.hh:34
double getFrameTime()
Get frame time duration.
Definition: JDAQClock.hh:162
Data frame for calibrated hits of one PMT.
Definition: JFrame.hh:34
void filter(const match_type &match)
Filter-out consecutive hits when matched according given criterion.
Definition: JFrame.hh:142
JMatch< JElement_t > match_type
Definition: JFrame.hh:43
JFrame()
Default constructor.
Definition: JFrame.hh:56
container_type::const_reverse_iterator const_reverse_iterator
Definition: JFrame.hh:48
JFrame_t< JElement_t, JAllocator_t > container_type
Definition: JFrame.hh:41
container_type::iterator iterator
Definition: JFrame.hh:45
Template definition of hit toolkit.
Definition: JHitToolkit.hh:60
void putEndMarker()
Append end marker to data.
Definition: JFrame_t.hh:111
void applyHighRateVeto(const double rate_Hz)
Apply high-rate veto.
Definition: JFrame.hh:98
void push_back(const JDAQHit &hit)
Append DAQ hit.
Definition: JFrame.hh:85