Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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
friend std::ostream & operator<<(std::ostream &out, const JPMTSelector &object)
Write vector of PMT identifiers to output.
Definition: JPMTSelector.hh:84
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
Definition: JSirene.sh:45
Definition: JRoot.hh:19
ClassDef(JPMTSelector, 1)
esac $JPP_DIR examples JDetector JTransitTime o $OUTPUT_FILE n N $NPE T $TTS_NS d $DEBUG for HISTOGRAM in tts tt2 pmt
Definition: JTransitTime.sh:36
virtual ~JPMTSelector()
Virtual destructor.
Definition: JPMTSelector.hh:36
static bool compare(const JPMTIdentifier_t &first, const JPMTIdentifier_t &second)
Compare PMT identifiers.
JPMTSelector()
Default constructor.
Definition: JPMTSelector.hh:29
friend std::istream & operator>>(std::istream &in, JPMTSelector &object)
Read vector of PMT identifiers from input.
Definition: JPMTSelector.hh:65
bool operator()(const JPMTIdentifier_t &pmt) const
Test match with given PMT.
Definition: JPMTSelector.hh:46
Auxiliary data structure for set of PMT identifiers.
Definition: JPMTSelector.hh:22