Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JTriggerInput.hh
Go to the documentation of this file.
1 #ifndef __JTRIGGER__JTRIGGERINPUT__
2 #define __JTRIGGER__JTRIGGERINPUT__
3 
4 #include <vector>
5 #include <algorithm>
6 
8 #include "JTrigger/JTimeslice.hh"
9 #include "JTrigger/JHitR1.hh"
10 #include "JTrigger/JHitToolkit.hh"
12 
13 
14 /**
15  * \author mdejong
16  */
17 
18 namespace JTRIGGER {}
19 namespace JPP { using namespace JTRIGGER; }
20 
21 namespace JTRIGGER {
22 
25 
26 
27  /**
28  * Data structure for input to trigger algorithm.
29  * The input data for the trigger are time ordered and contain an end marker.
30  * The member methods JTriggerInput::size() and JTriggerInput::end() refer to the position before the end marker.
31  */
32  class JTriggerInput :
33  public JDAQChronometer,
34  public std::vector<JHitR1>,
35  public JHitToolkit<JHit>
36  {
37  public:
38  /**
39  * Constructor.
40  *
41  * \param input input data
42  */
43  template<class JHit_t>
46  std::vector<JHitR1>()
47  {
48  int n = 0;
49 
50  for (typename JTimeslice<JHit_t>::const_iterator frame = input.begin(); frame != input.end(); ++frame) {
51  n += frame->size();
52  }
53 
54  this->resize(n + 1); // reserve space for end marker
55 
56  __end = this->begin();
57 
58  for (typename JTimeslice<JHit_t>::const_iterator frame = input.begin(); frame != input.end(); ++frame) {
59 
60  const JDAQModuleIdentifier& id = frame->getModuleID();
61  const JPosition3D& pos = frame->getPosition();
62 
63  for (typename JFrame<JHit_t>::const_iterator i = frame->begin(); i != frame->end(); ++i, ++__end) {
64  *__end = JHitR1(id, pos, getJHit(*i));
65  }
66  }
67 
68  *__end = JHitR1(JDAQPMTIdentifier(), JPosition3D(), getEndMarker());
69 
70  std::sort(this->begin(), this->end(), getToolkit());
71  }
72 
73 
74  const_iterator end() const { return __end; } //!< get iterator to end of data (without end marker)
75  iterator end() { return __end; } //!< get iterator to end of data (without end marker)
76 
77  int size() const { return std::distance(this->begin(), this->end()); } //!< get size of data (without end marker)
78  bool empty() const { return size() == 0; } //!< test emptyness (without end marker)
79 
80 
81  private:
83  };
84 }
85 
86 #endif
std::vector< value_type >::const_iterator const_iterator
Definition: JTimeslice.hh:34
int getModuleID() const
Get module identifier.
JTriggerInput(const JTimeslice< JHit_t > &input)
Constructor.
Tools for handling different hit types.
const_iterator end() const
get iterator to end of data (without end marker)
bool empty() const
test emptyness (without end marker)
Data frame for calibrated hits of one PMT.
Definition: JFrame.hh:31
iterator end()
get iterator to end of data (without end marker)
const JDAQChronometer & getDAQChronometer() const
Get DAQ chronometer.
const JPosition3D & getPosition() const
Get position.
Definition: JPosition3D.hh:129
int size() const
get size of data (without end marker)
Reduced data structure for L1 hit.
Reduced data structure for L1 hit.
Definition: JHitR1.hh:31
Template definition of hit toolkit.
Definition: JHitToolkit.hh:60
Data structure for input to trigger algorithm.
Data structure for position in three dimensions.
Definition: JPosition3D.hh:35
std::vector< JHitR1 >::iterator __end
Time slice with calibrated data.
Definition: JTimeslice.hh:26