Jpp  18.2.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JTrigger/JSummaryRouter.hh
Go to the documentation of this file.
1 #ifndef __JTRIGGER__JSUMMARYSLICEROUTER__
2 #define __JTRIGGER__JSUMMARYSLICEROUTER__
3 
7 #include "JTools/JRouter.hh"
8 
9 
10 /**
11  * \author mdejong
12  */
13 
14 namespace JTRIGGER {}
15 namespace JPP { using namespace JTRIGGER; }
16 
17 namespace JTRIGGER {
18 
23 
24 
25  /**
26  * Router for fast addressing of summary data in JDAQSummaryslice data structure
27  * as a function of the optical module identifier.
28  *
29  * Note that this class derives from KM3NETDAQ::JSummaryslice
30  * which in turn derives from KM3NETDAQ::JDAQSummaryslice so that:
31  * - standard summary data can efficiently be updated via method JSummaryRouter::update; and
32  * - a posteriori corrected for use in simulations via method JSummaryslice::correct.
33  */
35  public JSummaryslice
36  {
37  public:
38  /**
39  * Default constructor.
40  */
42  router(-1) // default address
43  {}
44 
45 
46  /**
47  * Update router.
48  *
49  * \param ps pointer to new summary slice (will be overwritten)
50  */
52  {
53  if (ps != NULL) {
54 
55  // reset internal router
56 
57  for (iterator i = this->begin(); i != this->end(); ++i) {
58  router.put(i->getModuleID(), router.getDefaultAddress());
59  }
60 
62 
63  this->swap(*ps);
64 
65  // set internal router
66 
67  for (iterator i = this->begin(); i != this->end(); ++i) {
68  router.put(i->getModuleID(), std::distance(this->begin(), i));
69  }
70  }
71  }
72 
73 
74  /**
75  * Get address of module.
76  *
77  * \param module module
78  * \return address
79  */
80  const int getAddress(const JDAQModuleIdentifier& module) const
81  {
82  return router.get(module.getModuleID());
83  }
84 
85 
86  /**
87  * Get summary frame.
88  *
89  * \param module module
90  * \return summary frame
91  */
93  {
94  return (*this)[getAddress(module)];
95  }
96 
97 
98  /**
99  * Has summary frame.
100  *
101  * \param module module
102  * \return true if module present; else false
103  */
104  bool hasSummaryFrame(const JDAQModuleIdentifier& module) const
105  {
106  return router.has(module.getModuleID());
107  }
108 
109 
110  private:
112  };
113 }
114 
115 #endif
int getModuleID() const
Get module identifier.
Router for fast addressing of summary data in JDAQSummaryslice data structure as a function of the op...
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
Auxiliaries for creation of summary data.
Data storage class for rate measurements of all PMTs in one module.
Auxiliary class to create summary data.
const JDAQChronometer & getDAQChronometer() const
Get DAQ chronometer.
void setDAQChronometer(const JDAQChronometer &chronometer)
Set DAQ chronometer.
const JDAQSummaryFrame & getSummaryFrame(const JDAQModuleIdentifier &module) const
Get summary frame.
const int getAddress(const JDAQModuleIdentifier &module) const
Get address of module.
JSummaryRouter()
Default constructor.
void update(JDAQSummaryslice *ps)
Update router.
bool hasSummaryFrame(const JDAQModuleIdentifier &module) const
Has summary frame.