Jpp  debug
the software that should make you happy
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),
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 consecutive hits when matched according given criterion.
137  *
138  * \param match match criterion
139  */
140  void filter(const match_type& match)
141  {
142  iterator out = this->begin();
143 
144  for (const_iterator p = this->begin(); p != this->end(); ) {
145 
146  *out = *p;
147 
148  for (const_iterator i = p++; p != this->end() && match(*i,*p); ++i, ++p) {}
149 
150  ++out;
151  }
152 
153  if (out != this->end()) {
154  this->erase(out, this->end());
155  this->putEndMarker();
156  }
157  }
158 
159 
160  /**
161  * Remove consecutive hits when matched according given criterion.
162  *
163  * \param match match criterion
164  */
165  void remove(const match_type& match)
166  {
167  iterator out = this->begin();
168 
169  for (const_iterator p = this->begin(); p != this->end(); ) {
170 
171  const_iterator q = p;
172 
173  for (const_iterator i = q++; q != this->end() && match(*i,*q); ++i, ++q) {}
174 
175  if (std::distance(p,q) == 1) {
176  *out = *p;
177  ++out;
178  }
179 
180  p = q;
181  }
182 
183  if (out != this->end()) {
184  this->erase(out, this->end());
185  this->putEndMarker();
186  }
187  }
188  };
189 }
190 
191 #endif
Tools for handling different hit types.
Base class for match operations for cluster and hit-preprocessing methods.
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
Data structure for time calibration.
const JCalibration & getCalibration() const
Get calibration.
Axis object.
Definition: JAxis3D.hh:41
Data frame with end marker.
Definition: JFrame_t.hh:30
Data frame for calibrated hits of one PMT.
Definition: JFrame.hh:38
JFrame(const JDAQChronometer &chronometer, const JDAQPMTIdentifier &id, const JAxis3D &axis, const JCalibration &calibration)
Constructor.
Definition: JFrame.hh:68
container_type::iterator iterator
Definition: JFrame.hh:45
JElement_t value_type
Definition: JFrame.hh:42
void remove(const match_type &match)
Remove consecutive hits when matched according given criterion.
Definition: JFrame.hh:165
container_type::const_reverse_iterator const_reverse_iterator
Definition: JFrame.hh:48
void filter(const match_type &match)
Filter consecutive hits when matched according given criterion.
Definition: JFrame.hh:140
container_type::const_iterator const_iterator
Definition: JFrame.hh:46
container_type::reverse_iterator reverse_iterator
Definition: JFrame.hh:47
JMatch< JElement_t > match_type
Definition: JFrame.hh:43
void join(const match_type &match)
Join consecutive hits when matched according given criterion.
Definition: JFrame.hh:113
void applyHighRateVeto(const double rate_Hz)
Apply high-rate veto.
Definition: JFrame.hh:98
JFrame_t< JElement_t, JAllocator_t > container_type
Definition: JFrame.hh:41
JFrame()
Default constructor.
Definition: JFrame.hh:56
void push_back(const JDAQHit &hit)
Append DAQ hit.
Definition: JFrame.hh:85
Function object interface for hit matching.
Definition: JMatch.hh:27
Hit data structure.
Definition: JDAQHit.hh:35
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary classes and methods for triggering.
double getFrameTime()
Get frame time duration.
Definition: JDAQClock.hh:162
Calibration.
Definition: JHead.hh:330
Template definition of hit toolkit.
Definition: JHitToolkit.hh:60
Header for PMT.
Definition: JPMTHeader.hh:30