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