Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JSummaryRouter.hh
Go to the documentation of this file.
1 #ifndef __JTRIGGER__JSUMMARYSLICEROUTER__
2 #define __JTRIGGER__JSUMMARYSLICEROUTER__
3 
4 #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 JSUPPORT::JSummaryslice which in trun derives from KM3NETDAQ::JDAQSummaryslice
30  * so that the summary data can efficiently be updated (JSummaryRouter::update) and a posteriori corrected (JSummaryslice::correct).
31  */
33  public JSummaryslice
34  {
35  public:
36  /**
37  * Default constructor.
38  */
40  router(-1) // default address
41  {}
42 
43 
44  /**
45  * Update router.
46  *
47  * \param ps pointer to new summary slice (will be overwritten)
48  */
50  {
51  if (ps != NULL) {
52 
53  // reset internal router
54 
55  for (iterator i = this->begin(); i != this->end(); ++i) {
56  router.put(i->getModuleID(), router.getDefaultAddress());
57  }
58 
60 
61  this->swap(*ps);
62 
63  // set internal router
64 
65  for (iterator i = this->begin(); i != this->end(); ++i) {
66  router.put(i->getModuleID(), distance(this->begin(), i));
67  }
68  }
69  }
70 
71 
72  /**
73  * Get address of module.
74  *
75  * \param module module
76  * \return address
77  */
78  const int getAddress(const JDAQModuleIdentifier& module) const
79  {
80  return router.get(module.getModuleID());
81  }
82 
83 
84  /**
85  * Get summary frame.
86  *
87  * \param module module
88  * \return summary frame
89  */
91  {
92  return (*this)[getAddress(module)];
93  }
94 
95 
96  /**
97  * Has summary frame.
98  *
99  * \param module module
100  * \return true if module present; else false
101  */
102  bool hasSummaryFrame(const JDAQModuleIdentifier& module) const
103  {
104  return router.has(module.getModuleID());
105  }
106 
107 
108  private:
110  };
111 }
112 
113 #endif
JTOOLS::JRouter< int > router
int getModuleID() const
Get module identifier.
Router for fast addressing of summary data in JDAQSummaryslice data structure as a function of the op...
Auxiliary class to create summary data.
Data storage class for rate measurements of all PMTs in one module.
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.
Auxiliaries for creation of summary data.
bool hasSummaryFrame(const JDAQModuleIdentifier &module) const
Has summary frame.