Jpp  master_rocky-43-ge265d140c
the software that should make you happy
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
Auxiliaries for creation of summary data.
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
Router for fast addressing of summary data in JDAQSummaryslice data structure as a function of the op...
bool hasSummaryFrame(const JDAQModuleIdentifier &module) const
Has summary frame.
void update(JDAQSummaryslice *ps)
Update router.
const int getAddress(const JDAQModuleIdentifier &module) const
Get address of module.
const JDAQSummaryFrame & getSummaryFrame(const JDAQModuleIdentifier &module) const
Get summary frame.
JSummaryRouter()
Default constructor.
const JDAQChronometer & getDAQChronometer() const
Get DAQ chronometer.
void setDAQChronometer(const JDAQChronometer &chronometer)
Set DAQ chronometer.
int getModuleID() const
Get module identifier.
Data storage class for rate measurements of all PMTs in one module.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary classes and methods for triggering.
Auxiliary class to create summary data.