Jpp
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 turn 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
KM3NETDAQ::JDAQChronometer::setDAQChronometer
void setDAQChronometer(const JDAQChronometer &chronometer)
Set DAQ chronometer.
Definition: JDAQChronometer.hh:99
std::iterator
Definition: JSTDTypes.hh:18
JTRIGGER::JSummaryRouter::getSummaryFrame
const JDAQSummaryFrame & getSummaryFrame(const JDAQModuleIdentifier &module) const
Get summary frame.
Definition: JSummaryRouter.hh:90
JTRIGGER::JSummaryRouter::hasSummaryFrame
bool hasSummaryFrame(const JDAQModuleIdentifier &module) const
Has summary frame.
Definition: JSummaryRouter.hh:102
KM3NETDAQ::JDAQModuleIdentifier::getModuleID
int getModuleID() const
Get module identifier.
Definition: JDAQModuleIdentifier.hh:72
distance
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
Definition: PhysicsEvent.hh:434
JDAQSummaryslice.hh
JTRIGGER::JSummaryRouter::router
JTOOLS::JRouter< int > router
Definition: JSummaryRouter.hh:109
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
JTOOLS::JRouter< int >
KM3NETDAQ::JDAQSummaryFrame
Data storage class for rate measurements of all PMTs in one module.
Definition: JDAQSummaryFrame.hh:320
JTRIGGER::JSummaryRouter::JSummaryRouter
JSummaryRouter()
Default constructor.
Definition: JSummaryRouter.hh:39
KM3NETDAQ::JSummaryslice
Auxiliary class to create summary data.
Definition: JSummaryslice.hh:33
KM3NETDAQ::JDAQSummaryslice
Data summary slice.
Definition: JDAQSummaryslice.hh:25
JTRIGGER::JSummaryRouter::getAddress
const int getAddress(const JDAQModuleIdentifier &module) const
Get address of module.
Definition: JSummaryRouter.hh:78
KM3NETDAQ::JDAQModuleIdentifier
Module identifier.
Definition: JDAQModuleIdentifier.hh:19
JTRIGGER::JSummaryRouter
Router for fast addressing of summary data in JDAQSummaryslice data structure as a function of the op...
Definition: JSummaryRouter.hh:32
JSummaryslice.hh
KM3NETDAQ::JDAQChronometer::getDAQChronometer
const JDAQChronometer & getDAQChronometer() const
Get DAQ chronometer.
Definition: JDAQChronometer.hh:88
JTRIGGER::JSummaryRouter::update
void update(JDAQSummaryslice *ps)
Update router.
Definition: JSummaryRouter.hh:49
JRouter.hh
JDAQModuleIdentifier.hh
JTRIGGER
Checksum.
Definition: JSupport/JSupport.hh:35