Jpp  15.0.0-rc.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JSuperFrame1D.hh
Go to the documentation of this file.
1 #ifndef __JTRIGGER__JSUPERFRAME1D__
2 #define __JTRIGGER__JSUPERFRAME1D__
3 
4 #include <vector>
5 
7 #include "JDetector/JModule.hh"
8 #include "JTools/JMergeSort.hh"
11 #include "JLang/JSTDToolkit.hh"
12 
13 
14 /**
15  * \author mdejong
16  */
17 
18 namespace JTRIGGER {}
19 namespace JPP { using namespace JTRIGGER; }
20 
21 namespace JTRIGGER {
22 
24  using JDETECTOR::JModule;
25 
26 
27  /**
28  * 1-dimensional frame with time calibrated data from one optical module.
29  *
30  * This class can be used to merge the data from different PMTs contained in a JSuperFrame2D object.\n
31  * The data will then be time sorted.
32  *
33  * The static data member JSuperFrame1D::multiplex can be used as an I/O buffer.
34  */
35  template<class JElement_t, class JAllocator_t = std::allocator<JElement_t> >
36  class JSuperFrame1D :
37  public JModuleHeader,
38  public std::vector<JElement_t, JAllocator_t>,
39  public JHitToolkit<JElement_t>
40  {
41  public:
42  /**
43  * Default constructor.
44  */
46  JModuleHeader(),
47  std::vector<JElement_t, JAllocator_t>(),
48  JHitToolkit<JElement_t>()
49  {}
50 
51 
52  /**
53  * Constructor.
54  *
55  * \param chronometer DAQ chronometer
56  * \param id module identifier
57  * \param pos module position
58  */
59  JSuperFrame1D(const JDAQChronometer& chronometer,
60  const JDAQModuleIdentifier& id,
61  const JPosition3D& pos) :
62  JModuleHeader(chronometer, id, pos),
63  std::vector<JElement_t, JAllocator_t>(),
64  JHitToolkit<JElement_t>()
65  {}
66 
67 
68  /**
69  * Constructor.
70  *
71  * \param input 2D super frame
72  */
75  std::vector<JElement_t, JAllocator_t>(),
76  JHitToolkit<JElement_t>()
77  {
78  merge(input.begin(), input.end(), static_cast<std::vector<JElement_t, JAllocator_t>&>(*this), this->getToolkit());
79  }
80 
81 
82  /**
83  * Copy constructor.
84  *
85  * \param input 1D super frame
86  */
89  std::vector<JElement_t, JAllocator_t>(input.begin(), input.end()),
90  JHitToolkit<JElement_t>()
91  {
92  if (input.hasEndMarker()) {
93  this->putEndMarker();
94  }
95  }
96 
97 
98  /**
99  * Check presence of end marker.
100  *
101  * \return true if end marker present; else false
102  */
103  bool hasEndMarker() const
104  {
105  return (this->capacity() > this->size() && this->getT(*(this->end())) == this->getT(this->getEndMarker()));
106  }
107 
108 
109  /**
110  * Append end marker to data.
111  *
112  * Note that the end marker is put within the capacity of the container whilst its size is maintained.
113  */
115  {
116  JPP::putEndMarker(*this, this->getEndMarker());
117  }
118 
119 
120  /**
121  * Process 2D super frame.
122  *
123  * The data are sorted in time and an appropriate end marker is added.
124  *
125  * \param input 2D super frame
126  * \return this 1D super frame
127  */
129  {
130  this->setModuleHeader(input.getModuleHeader());
131 
132  merge(input.begin(), input.end(), static_cast<std::vector<JElement_t, JAllocator_t>&>(*this), this->getToolkit());
133 
134  return *this;
135  }
136 
137 
138  /**
139  * Process set of 2D super frame data.
140  *
141  * The data are sorted in time and an appropriate end marker is added.
142  * Note that this method only updates the data in the container.
143  *
144  * \param __begin begin of 2D super frame data
145  * \param __end end of 2D super frame data
146  * \return this 1D super frame
147  */
150  {
151  merge(__begin, __end, static_cast<std::vector<JElement_t, JAllocator_t>&>(*this), this->getToolkit());
152 
153  return *this;
154  }
155 
156 
157  /**
158  * Process DAQ super frame.
159  *
160  * The time calibration is applied, data are sorted in time and an appropriate end marker is added.
161  *
162  * \param input DAQ super frame
163  * \param module module data
164  * \return this 1D super frame
165  */
167  const JModule& module)
168  {
169  return (*this)(buffer(input, module));
170  }
171 
172 
173  /**
174  * Multiplexer.
175  */
177 
178 
179  private:
182  };
183 
184 
185  /**
186  * Internal merge method.
187  */
188  template<class JElement_t, class JAllocator_t>
190 
191 
192  /**
193  * Internal buffer.
194  */
195  template<class JElement_t, class JAllocator_t>
197 
198 
199  /**
200  * Multiplexer.
201  */
202  template<class JElement_t, class JAllocator_t>
204 }
205 
206 #endif
JSuperFrame1D & operator()(const JDAQSuperFrame &input, const JModule &module)
Process DAQ super frame.
Data structure for a composite optical module.
Definition: JModule.hh:68
static JSuperFrame1D< JElement_t, JAllocator_t > multiplex
Multiplexer.
JSuperFrame1D(const JDAQChronometer &chronometer, const JDAQModuleIdentifier &id, const JPosition3D &pos)
Constructor.
This class implements a merge and sort algorithm based on the divide-and-conquer concept.
Definition: JMergeSort.hh:51
1-dimensional frame with time calibrated data from one optical module.
void setModuleHeader(const JModuleHeader &header)
Set module header.
JSuperFrame1D & operator()(typename JSuperFrame2D< JElement_t >::const_iterator __begin, typename JSuperFrame2D< JElement_t >::const_iterator __end)
Process set of 2D super frame data.
JSuperFrame1D(const JSuperFrame2D< JElement_t > &input)
Constructor.
const JModuleHeader & getModuleHeader() const
Get module header.
Header for Module.
JSuperFrame1D()
Default constructor.
static JTOOLS::JMergeSort< JElement_t > merge
Internal merge method.
Template definition of hit toolkit.
Definition: JHitToolkit.hh:60
JSuperFrame1D & operator()(const JSuperFrame2D< JElement_t > &input)
Process 2D super frame.
Data structure for position in three dimensions.
Definition: JPosition3D.hh:36
bool hasEndMarker() const
Check presence of end marker.
void putEndMarker(std::vector< JElement_t, JAllocator_t > &buffer, const JElement_t &value)
Put end marker.
Definition: JSTDToolkit.hh:47
void putEndMarker()
Append end marker to data.
Data frame of one optical module.
static JSuperFrame2D< JElement_t > buffer
Internal buffer.
JSuperFrame1D(const JSuperFrame1D< JElement_t, JAllocator_t > &input)
Copy constructor.
Data structure for optical module.