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