Jpp
JPMTPhysicalAddress.hh
Go to the documentation of this file.
1 #ifndef __JDETECTOR__JPMTPHYSICALADDRESS__
2 #define __JDETECTOR__JPMTPHYSICALADDRESS__
3 
4 #include <istream>
5 #include <ostream>
6 
7 #include "JLang/JComparable.hh"
8 #include "JIO/JSerialisable.hh"
9 
10 
11 /**
12  * \author mdejong
13  */
14 
15 namespace JDETECTOR {}
16 namespace JPP { using namespace JDETECTOR; }
17 
18 namespace JDETECTOR {
19 
20  using JLANG::JComparable;
21 
22 
23  /**
24  * Data structure for PMT physical address.
25  */
27  public JComparable<JPMTPhysicalAddress>
28  {
29  public:
30  /**
31  * Default constructor.
32  */
34  {
35  this->ring = '\0';
36  this->position = -1;
37  }
38 
39 
40  /**
41  * Constructor.
42  *
43  * \param ring ring
44  * \param position position
45  */
47  const int position)
48  {
49  this->ring = ring;
50  this->position = position;
51  }
52 
53 
54  /**
55  * Less than method.
56  *
57  * \param address PMT physical address
58  * \result true if this address before given address; else false
59  */
60  inline bool less(const JPMTPhysicalAddress& address) const
61  {
62  if (this->ring == address.ring)
63  return this->position < address.position;
64  else
65  return this->ring < address.ring;
66  }
67 
68 
69  /**
70  * Read PMT physical address from input.
71  *
72  * \param in input stream
73  * \param object PMT physical address
74  * \return input stream
75  */
76  friend inline std::istream& operator>>(std::istream& in, JPMTPhysicalAddress& object)
77  {
78  in >> object.ring;
79  in >> object.position;
80 
81  return in;
82  }
83 
84 
85  /**
86  * Write PMT physical address to output.
87  *
88  * \param out output stream
89  * \param object PMT physical address
90  * \return output stream
91  */
92  friend inline std::ostream& operator<<(std::ostream& out, const JPMTPhysicalAddress& object)
93  {
94  out << object.ring;
95  out << object.position;
96 
97  return out;
98  }
99 
100 
101  /**
102  * Read PMT physical address from input.
103  *
104  * \param in reader
105  * \param object PMT physical address
106  * \return reader
107  */
108  friend inline JReader& operator>>(JReader& in, JPMTPhysicalAddress& object)
109  {
110  in >> object.ring;
111  in >> object.position;
112 
113  return in;
114  }
115 
116 
117  /**
118  * Write PMT physical address to output.
119  *
120  * \param out writer
121  * \param object PMT physical address
122  * \return writer
123  */
124  friend inline JWriter& operator<<(JWriter& out, const JPMTPhysicalAddress& object)
125  {
126  out << object.ring;
127  out << object.position;
128 
129  return out;
130  }
131 
132 
133  /**
134  * Convert PMT physical address to string.
135  * \return string
136  */
137  std::string toString() const {
138  std::ostringstream os;
139  os << *this;
140  return os.str();
141  }
142 
143 
144  char ring; //!< ring number ['A','F']
145  int position; //!< position within ring [1,6]
146  };
147 }
148 
149 #endif
JIO::JReader
Interface for binary input.
Definition: JSerialisable.hh:62
JDETECTOR::JPMTPhysicalAddress
Data structure for PMT physical address.
Definition: JPMTPhysicalAddress.hh:26
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
JDETECTOR::JPMTPhysicalAddress::ring
char ring
ring number ['A','F']
Definition: JPMTPhysicalAddress.hh:144
JDETECTOR::JPMTPhysicalAddress::position
int position
position within ring [1,6]
Definition: JPMTPhysicalAddress.hh:145
JSerialisable.hh
JComparable.hh
JIO::JWriter
Interface for binary output.
Definition: JSerialisable.hh:131
JDETECTOR::JPMTPhysicalAddress::less
bool less(const JPMTPhysicalAddress &address) const
Less than method.
Definition: JPMTPhysicalAddress.hh:60
JDETECTOR::JPMTPhysicalAddress::JPMTPhysicalAddress
JPMTPhysicalAddress(const char ring, const int position)
Constructor.
Definition: JPMTPhysicalAddress.hh:46
JLANG::JComparable
Template definition of auxiliary base class for comparison of data structures.
Definition: JComparable.hh:24
JDETECTOR::JPMTPhysicalAddress::JPMTPhysicalAddress
JPMTPhysicalAddress()
Default constructor.
Definition: JPMTPhysicalAddress.hh:33
JDETECTOR::JPMTPhysicalAddress::operator<<
friend JWriter & operator<<(JWriter &out, const JPMTPhysicalAddress &object)
Write PMT physical address to output.
Definition: JPMTPhysicalAddress.hh:124
JDETECTOR::JPMTPhysicalAddress::operator>>
friend std::istream & operator>>(std::istream &in, JPMTPhysicalAddress &object)
Read PMT physical address from input.
Definition: JPMTPhysicalAddress.hh:76
JDETECTOR::JPMTPhysicalAddress::operator>>
friend JReader & operator>>(JReader &in, JPMTPhysicalAddress &object)
Read PMT physical address from input.
Definition: JPMTPhysicalAddress.hh:108
JDETECTOR
Auxiliary classes and methods for detector calibration.
Definition: JAnchor.hh:12
JDETECTOR::JPMTPhysicalAddress::toString
std::string toString() const
Convert PMT physical address to string.
Definition: JPMTPhysicalAddress.hh:137
JDETECTOR::JPMTPhysicalAddress::operator<<
friend std::ostream & operator<<(std::ostream &out, const JPMTPhysicalAddress &object)
Write PMT physical address to output.
Definition: JPMTPhysicalAddress.hh:92