Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JBuildL0.hh
Go to the documentation of this file.
1 #ifndef __JTRIGGER__JBUILDL0__
2 #define __JTRIGGER__JBUILDL0__
3 
6 #include "JTrigger/JHit.hh"
7 #include "JTrigger/JHitL0.hh"
9 #include "JGeometry3D/JAxis3D.hh"
10 #include "JDAQ/JDAQSuperFrame.hh"
11 #include "JDAQ/JDAQTimeslice.hh"
12 #include "JDAQ/JDAQEvent.hh"
13 #include "JDetector/JModule.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  * Template L0 hit builder.
31  *
32  * An L0 hit is a hit from a PMT.
33  */
34  template<class JElement_t>
35  class JBuildL0 :
36  public JHitToolkit<JElement_t>,
37  public JBuildHelper< JBuildL0<JElement_t> >
38  {
39  public:
40 
41  using JBuildHelper< JBuildL0<JElement_t> >::operator();
42 
43  typedef JElement_t value_type;
44 
45 
46  /**
47  * Default constructor.
48  */
50  {}
51 
52 
53  /**
54  * Build hits from calibrated data.
55  *
56  * Note that the output data are not time sorted.
57  *
58  * \param input input L0 data
59  * \param out output L0 data
60  */
61  template<class JOutput_t>
62  void operator()(const JSuperFrame2D<JElement_t>& input, JOutput_t out) const
63  {
64  for (typename JSuperFrame2D<JElement_t>::const_iterator frame = input.begin(); frame != input.end(); ++frame) {
65 
66  int n = frame->size() - 1; // remove end marker
67 
68  for (typename JSuperFrame2D<JElement_t>::value_type::const_iterator i = frame->begin(); n != 0; ++i, --n) {
69  *out = *i;
70  ++out;
71  }
72  }
73  }
74 
75 
76  /**
77  * Build hits from uncalibrated DAQ data.
78  *
79  * The time calibration is applied.
80  * Note that the output data are not time sorted.
81  *
82  * \param input DAQ super frame
83  * \param module module
84  * \param out output L0 data
85  */
86  template<class JOutput_t>
87  void operator()(const JDAQSuperFrame& input,
88  const JModule& module,
89  JOutput_t out) const
90  {
91  if (!input.empty()) {
92  (*this)(JSuperFrame2D<JElement_t>::demultiplex(input, module), out);
93  }
94  }
95  };
96 
97 
98  /**
99  * Template specialisation of L0 builder for JHitL0 data type.
100  */
101  template<>
102  class JBuildL0<JHitL0> :
103  public JBuildHelper< JBuildL0<JHitL0> >
104  {
105  public:
106 
107  using JBuildHelper< JBuildL0<JHitL0> >::operator();
108 
110 
111 
112  /**
113  * Default constructor.
114  */
116  {}
117 
118 
119  /**
120  * Build hits from calibrated data.
121  *
122  * Note that the output data are not time sorted.
123  *
124  * \param input input L0 data
125  * \param out output L0 data
126  */
127  template<class JElement_t, class JOutput_t>
128  void operator()(const JSuperFrame2D<JElement_t>& input, JOutput_t out) const
129  {
130  for (typename JSuperFrame2D<JElement_t>::const_iterator frame = input.begin(); frame != input.end(); ++frame) {
131 
132  const JDAQPMTIdentifier& id = frame->getPMTIdentifier();
133  const JGEOMETRY3D::JAxis3D& axis = frame->getAxis();
134 
135  int n = frame->size() - 1; // remove end marker
136 
137  for (typename JSuperFrame2D<JElement_t>::value_type::const_iterator i = frame->begin(); n != 0; ++i, --n) {
138  *out = JHitL0(id, axis, JHitToolkit<JElement_t>::getJHit(*i));
139  ++out;
140  }
141  }
142  }
143 
144 
145  /**
146  * Build hits from uncalibrated DAQ data.
147  *
148  * The time calibration is applied.
149  * Note that the output data are not time sorted.
150  *
151  * \param input DAQ super frame
152  * \param module module
153  * \param out output L0 data
154  */
155  template<class JOutput_t>
156  void operator()(const JDAQSuperFrame& input,
157  const JModule& module,
158  JOutput_t out) const
159  {
160  if (!input.empty()) {
161  (*this)(JSuperFrame2D<JHit>::demultiplex(input, module), out);
162  }
163  }
164  };
165 }
166 
167 #endif
bool empty() const
Definition: JDAQFrame.hh:155
Data structure for a composite optical module.
Definition: JModule.hh:47
JBuildL0()
Default constructor.
Definition: JBuildL0.hh:115
static JSuperFrame2D< JElement_t > demultiplex
Demultiplexer.
const JDAQPMTIdentifier & getPMTIdentifier() const
Get PMT identifier.
void operator()(const JSuperFrame2D< JElement_t > &input, JOutput_t out) const
Build hits from calibrated data.
Definition: JBuildL0.hh:62
JBuildL0()
Default constructor.
Definition: JBuildL0.hh:49
Tools for handling different hit types.
Basic data structure for L0 hit.
Axis object.
Definition: JAxis3D.hh:37
Basic data structure for time and time over threshold information of hit.
void operator()(const JSuperFrame2D< JElement_t > &input, JOutput_t out) const
Build hits from calibrated data.
Definition: JBuildL0.hh:128
std::vector< frame_type >::const_iterator const_iterator
void operator()(const JDAQSuperFrame &input, const JModule &module, JOutput_t out) const
Build hits from uncalibrated DAQ data.
Definition: JBuildL0.hh:87
void operator()(const JDAQSuperFrame &input, const JModule &module, JOutput_t out) const
Build hits from uncalibrated DAQ data.
Definition: JBuildL0.hh:156
Data structure for L0 hit.
Definition: JHitL0.hh:27
const JAxis3D & getAxis() const
Get axis.
Definition: JAxis3D.hh:108
2-dimensional frame with time calibrated data from one optical module.
Template definition of hit toolkit.
Definition: JHitToolkit.hh:60
Template L0 hit builder.
Definition: JBuildL0.hh:35
Auxiliary class to extend hit building functionality to all DAQ data types.
Definition: JBuildHelper.hh:44
Data frame of one optical module.
JElement_t value_type
Definition: JBuildL0.hh:43
Data structure for a composite optical module.