Jpp
JPMTSelector.hh
Go to the documentation of this file.
1 #ifndef __JTRIGGER__JPMTSELECTOR__
2 #define __JTRIGGER__JPMTSELECTOR__
3 
4 #include <vector>
5 #include <istream>
6 #include <ostream>
7 
8 #include <TROOT.h>
9 #include <TObject.h>
10 
12 
13 
14 namespace JTRIGGER {}
15 namespace JPP { using namespace JTRIGGER; }
16 
17 namespace JTRIGGER {
18 
19  /**
20  * Auxiliary data structure for set of PMT identifiers.
21  */
22  struct JPMTSelector :
23  public std::vector<JPMTIdentifier_t>,
24  public TObject
25  {
26  /**
27  * Default constructor.
28  */
30  {}
31 
32 
33  /**
34  * Virtual destructor.
35  */
36  virtual ~JPMTSelector()
37  {}
38 
39 
40  /**
41  * Test match with given PMT.
42  *
43  * \param pmt PMT
44  * \return true if match; else false
45  */
46  bool operator()(const JPMTIdentifier_t& pmt) const
47  {
48  for (const_iterator i = this->begin(); i != this->end(); ++i) {
49  if (JPMTIdentifier_t::compare(*i, pmt)) {
50  return true;
51  }
52  }
53 
54  return false;
55  }
56 
57 
58  /**
59  * Read vector of PMT identifiers from input.
60  *
61  * \param in input stream
62  * \param object PMT identifiers
63  * \return input stream
64  */
65  friend inline std::istream& operator>>(std::istream& in, JPMTSelector& object)
66  {
67  object.clear();
68 
69  for (JPMTIdentifier_t pmt; in >> pmt; ) {
70  object.push_back(pmt);
71  }
72 
73  return in;
74  }
75 
76 
77  /**
78  * Write vector of PMT identifiers to output.
79  *
80  * \param out output stream
81  * \param object PMT identifiers
82  * \return output stream
83  */
84  friend inline std::ostream& operator<<(std::ostream& out, const JPMTSelector& object)
85  {
86  for (JPMTSelector::const_iterator i = object.begin(); i != object.end(); ++i) {
87  out << ' ' << i->getModuleID() << ' ' << i->getPMTAddress();
88  }
89 
90  return out;
91  }
92 
93 
95  };
96 }
97 #endif
TObject
Definition: JRoot.hh:19
JTRIGGER::JPMTSelector
Auxiliary data structure for set of PMT identifiers.
Definition: JPMTSelector.hh:22
JTRIGGER::JPMTSelector::JPMTSelector
JPMTSelector()
Default constructor.
Definition: JPMTSelector.hh:29
std::vector
Definition: JSTDTypes.hh:12
JTRIGGER::JPMTSelector::operator>>
friend std::istream & operator>>(std::istream &in, JPMTSelector &object)
Read vector of PMT identifiers from input.
Definition: JPMTSelector.hh:65
JPMTIdentifier_t.hh
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
JTRIGGER::JPMTSelector::~JPMTSelector
virtual ~JPMTSelector()
Virtual destructor.
Definition: JPMTSelector.hh:36
JTRIGGER::JPMTSelector::ClassDef
ClassDef(JPMTSelector, 1)
JTRIGGER::JPMTSelector::operator()
bool operator()(const JPMTIdentifier_t &pmt) const
Test match with given PMT.
Definition: JPMTSelector.hh:46
JTRIGGER::JPMTIdentifier_t::compare
static bool compare(const JPMTIdentifier_t &first, const JPMTIdentifier_t &second)
Compare PMT identifiers.
Definition: JPMTIdentifier_t.hh:99
JTRIGGER::JPMTIdentifier_t
Definition: JPMTIdentifier_t.hh:21
JTRIGGER
Checksum.
Definition: JSupport/JSupport.hh:35
JTRIGGER::JPMTSelector::operator<<
friend std::ostream & operator<<(std::ostream &out, const JPMTSelector &object)
Write vector of PMT identifiers to output.
Definition: JPMTSelector.hh:84