Jpp  17.0.0-rc.1
the software that should make you happy
 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 
24 
25 
26  /**
27  * Data structure for input to trigger algorithm.
28  *
29  * The input data for the trigger are time ordered and contain an end marker.
30  * The member methods <tt>size()</tt> and <tt>end()</tt> 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  size_t 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->reserve(n + 1); // reserve space for end marker
55  this->resize (n + 0); // reserve space for data
56 
57  std::vector<JHitR1>::iterator out = this->begin();
58 
59  for (typename JTimeslice<JHit_t>::const_iterator frame = input.begin(); frame != input.end(); ++frame) {
60 
61  const JDAQModuleIdentifier& id = frame->getModuleID();
62  const JPosition3D& pos = frame->getPosition();
63 
64  for (typename JFrame<JHit_t>::const_iterator i = frame->begin(); i != frame->end(); ++i, ++out) {
65  *out = JHitR1(id, pos, getJHit(*i));
66  }
67  }
68 
69  *out = JHitR1(JDAQPMTIdentifier(), JPosition3D(), getEndMarker());
70 
71  std::sort(this->begin(), this->end(), getToolkit());
72  }
73  };
74 }
75 
76 #endif
std::vector< value_type >::const_iterator const_iterator
Definition: JTimeslice.hh:34
container_type::const_iterator const_iterator
Definition: JFrame.hh:46
int getModuleID() const
Get module identifier.
JTriggerInput(const JTimeslice< JHit_t > &input)
Constructor.
Tools for handling different hit types.
const int n
Definition: JPolint.hh:676
const JDAQChronometer & getDAQChronometer() const
Get DAQ chronometer.
const JPosition3D & getPosition() const
Get position.
Definition: JPosition3D.hh:130
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:36
Time slice with calibrated data.
Definition: JTimeslice.hh:26