Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JPMTIdentifier.hh
Go to the documentation of this file.
1#ifndef __JDETECTOR__JPMTIDENTIFIER__
2#define __JDETECTOR__JPMTIDENTIFIER__
3
4#include <istream>
5#include <ostream>
6#include <iomanip>
7
9#include "JLang/JManip.hh"
10
11#include "JIO/JSerialisable.hh"
12
15#include "Jeep/JPrint.hh"
16
17
18/**
19 * \author mdejong
20 */
21
22namespace JDETECTOR {}
23namespace JPP { using namespace JDETECTOR; }
24
25namespace JDETECTOR {
26
28 using JLANG::JTYPELIST;
29 using JIO::JReader;
30 using JIO::JWriter;
31
32
33 /**
34 * PMT identifier.
35 */
37 public JModuleIdentifier,
38 public JPMTReadoutAddress,
39 public JMultiComparable<JPMTIdentifier, JTYPELIST<JModuleIdentifier, JPMTReadoutAddress>::typelist>
40 {
41 public:
42 /**
43 * Default constructor.
44 */
49
50
51 /**
52 * Constructor.
53 *
54 * \param id module identifier
55 * \param tdc TDC
56 */
58 const int tdc) :
61 {}
62
63
64 /**
65 * Get PMT identifier.
66 *
67 * \return PMT identifier
68 */
70 {
71 return static_cast<const JPMTIdentifier&>(*this);
72 }
73
74
75 /**
76 * Set PMT identifier.
77 *
78 * \param id PMT identifier
79 */
81 {
82 static_cast<JPMTIdentifier&>(*this) = id;
83 }
84
85
86 /**
87 * Get module identifier.
88 *
89 * \return module identifier
90 */
91 int getModuleID() const
92 {
93 return getID();
94 }
95
96
97 /**
98 * Get PMT address (= TDC).
99 *
100 * \return PMT address
101 */
102 int getPMTAddress() const
103 {
104 return tdc;
105 }
106
107
108 /**
109 * Check validity.
110 *
111 * \return true if PMT identifier is valid; else false
112 */
113 bool is_valid() const
114 {
115 return !(getID() < 0 || tdc < 0);
116 }
117
118
119 /**
120 * Read PMT identifier from input.
121 *
122 * \param in input stream
123 * \param object PMT identifier
124 * \return input stream
125 */
126 friend inline std::istream& operator>>(std::istream& in, JPMTIdentifier& object)
127 {
128 in >> static_cast<JModuleIdentifier&> (object);
129 in >> static_cast<JPMTReadoutAddress&>(object);
130
131 return in;
132 }
133
134
135 /**
136 * Write PMT identifier to output.
137 *
138 * \param out output stream
139 * \param object PMT identifier
140 * \return output stream
141 */
142 friend inline std::ostream& operator<<(std::ostream& out, const JPMTIdentifier& object)
143 {
144 using namespace std;
145
146 out << setw(10) << static_cast<const JModuleIdentifier&> (object) << ' ';
147 out << setw(2) << static_cast<const JPMTReadoutAddress&>(object);
148
149 return out;
150 }
151
152
153 /**
154 * Read PMT identifier from input.
155 *
156 * \param in reader
157 * \param object PMT identifier
158 * \return reader
159 */
160 friend inline JReader& operator>>(JReader& in, JPMTIdentifier& object)
161 {
162 in >> static_cast<JModuleIdentifier&> (object);
163 in >> static_cast<JPMTReadoutAddress&>(object);
164
165 return in;
166 }
167
168
169 /**
170 * Write PMT identifier to output.
171 *
172 * \param out writer
173 * \param object PMT identifier
174 * \return writer
175 */
176 friend inline JWriter& operator<<(JWriter& out, const JPMTIdentifier& object)
177 {
178 out << static_cast<const JModuleIdentifier&> (object);
179 out << static_cast<const JPMTReadoutAddress&>(object);
180
181 return out;
182 }
183 };
184
185
186 /**
187 * Get PMT label for monitoring and other applications.\n
188 * The format is "(XXXXXXXXXX,YY)", where XXXXXXXXXX is the module idetifier and YY the PMT readout channel.
189 *
190 * \param id PMT identifier
191 * \return label
192 */
193 inline std::string getLabel(const JPMTIdentifier& id)
194 {
195 using namespace std;
196 using namespace JPP;
197
198 return MAKE_STRING("(" << FILL(10,'0') << id.getID() << "," << FILL(2,'0') << id.getPMTAddress() << ")");
199 }
200}
201
202#endif
I/O manipulators.
I/O formatting auxiliaries.
#define MAKE_STRING(A)
Make string.
Definition JPrint.hh:63
friend std::istream & operator>>(std::istream &in, JPMTIdentifier &object)
Read PMT identifier from input.
JPMTIdentifier()
Default constructor.
friend JReader & operator>>(JReader &in, JPMTIdentifier &object)
Read PMT identifier from input.
const JPMTIdentifier & getPMTIdentifier() const
Get PMT identifier.
bool is_valid() const
Check validity.
int getModuleID() const
Get module identifier.
int getPMTAddress() const
Get PMT address (= TDC).
friend std::ostream & operator<<(std::ostream &out, const JPMTIdentifier &object)
Write PMT identifier to output.
void setPMTIdentifier(const JPMTIdentifier &id)
Set PMT identifier.
JPMTIdentifier(const JModuleIdentifier &id, const int tdc)
Constructor.
friend JWriter & operator<<(JWriter &out, const JPMTIdentifier &object)
Write PMT identifier to output.
Data structure for PMT readout address.
Interface for binary input.
Interface for binary output.
Auxiliary class for object identification.
Definition JObjectID.hh:25
int getID() const
Get identifier.
Definition JObjectID.hh:50
file Auxiliary data structures and methods for detector calibration.
Definition JAnchor.hh:12
std::string getLabel(const JLocation &location)
Get module label for monitoring and other applications.
Definition JLocation.hh:247
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure for sequence of same character.
Definition JManip.hh:330
Template definition of auxiliary base class for composite data structures composed of base classes wi...
Auxiliary class for recursive type list generation.
Definition JTypeList.hh:351