Jpp
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 
8 #include "JIO/JSerialisable.hh"
9 
12 
13 
14 /**
15  * \author mdejong
16  */
17 
18 namespace JDETECTOR {}
19 namespace JPP { using namespace JDETECTOR; }
20 
21 namespace JDETECTOR {
22 
23  using JIO::JReader;
24  using JIO::JWriter;
25 
26 
27  /**
28  * PMT identifier.
29  */
31  public JModuleIdentifier,
32  public JPMTReadoutAddress
33  {
34  public:
35  /**
36  * Default constructor.
37  */
41  {}
42 
43 
44  /**
45  * Constructor.
46  *
47  * \param id module identifier
48  * \param tdc TDC
49  */
51  const int tdc) :
52  JModuleIdentifier (id),
54  {}
55 
56 
57  /**
58  * Get module identifier.
59  *
60  * \return module identifier
61  */
62  int getModuleID() const
63  {
64  return getID();
65  }
66 
67 
68  /**
69  * Get PMT identifier (= TDC).
70  *
71  * \return PMT identifier
72  */
73  int getPMTAddress() const
74  {
75  return tdc;
76  }
77 
78 
79  /**
80  * Read PMT identifier from input.
81  *
82  * \param in input stream
83  * \param object PMT identifier
84  * \return input stream
85  */
86  friend inline std::istream& operator>>(std::istream& in, JPMTIdentifier& object)
87  {
88  in >> static_cast<JModuleIdentifier&> (object);
89  in >> static_cast<JPMTReadoutAddress&>(object);
90 
91  return in;
92  }
93 
94 
95  /**
96  * Write PMT identifier to output.
97  *
98  * \param out output stream
99  * \param object PMT identifier
100  * \return output stream
101  */
102  friend inline std::ostream& operator<<(std::ostream& out, const JPMTIdentifier& object)
103  {
104  using namespace std;
105 
106  out << setw(10) << static_cast<const JModuleIdentifier&> (object) << ' ';
107  out << setw(2) << static_cast<const JPMTReadoutAddress&>(object);
108 
109  return out;
110  }
111 
112 
113  /**
114  * Read PMT identifier from input.
115  *
116  * \param in reader
117  * \param object PMT identifier
118  * \return reader
119  */
120  friend inline JReader& operator>>(JReader& in, JPMTIdentifier& object)
121  {
122  in >> static_cast<JModuleIdentifier&> (object);
123  in >> static_cast<JPMTReadoutAddress&>(object);
124 
125  return in;
126  }
127 
128 
129  /**
130  * Write PMT identifier to output.
131  *
132  * \param out writer
133  * \param object PMT identifier
134  * \return writer
135  */
136  friend inline JWriter& operator<<(JWriter& out, const JPMTIdentifier& object)
137  {
138  out << static_cast<const JModuleIdentifier&> (object);
139  out << static_cast<const JPMTReadoutAddress&>(object);
140 
141  return out;
142  }
143  };
144 
145 
146  /**
147  * Less than operator for PMT identifiers.
148  *
149  * \param first PMT identifier
150  * \param second PMT identifier
151  * \result true if first PMT lower than second PMT; else false
152  */
153  inline bool operator<(const JPMTIdentifier& first, const JPMTIdentifier& second)
154  {
155  if (first.getModuleID() == second.getModuleID())
156  return first.getPMTAddress() < second.getPMTAddress();
157  else
158  return first.getModuleID() < second.getModuleID();
159  }
160 
161 
162  /**
163  * Equal operator for PMT identifiers.
164  *
165  * \param first PMT identifier
166  * \param second PMT identifier
167  * \result true if first PMT equal second PMT; else false
168  */
169  inline bool operator==(const JPMTIdentifier& first, const JPMTIdentifier& second)
170  {
171  return (first.getModuleID() == second.getModuleID() &&
172  first.getPMTAddress() == second.getPMTAddress());
173  }
174 }
175 
176 #endif
JDETECTOR::JPMTIdentifier::operator<<
friend JWriter & operator<<(JWriter &out, const JPMTIdentifier &object)
Write PMT identifier to output.
Definition: JPMTIdentifier.hh:136
JIO::JReader
Interface for binary input.
Definition: JSerialisable.hh:62
JDETECTOR::JPMTIdentifier::getModuleID
int getModuleID() const
Get module identifier.
Definition: JPMTIdentifier.hh:62
JDETECTOR::JPMTIdentifier::operator>>
friend JReader & operator>>(JReader &in, JPMTIdentifier &object)
Read PMT identifier from input.
Definition: JPMTIdentifier.hh:120
JModuleIdentifier.hh
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
JSerialisable.hh
JLANG::JObjectID::getID
int getID() const
Get identifier.
Definition: JObjectID.hh:55
JIO::JWriter
Interface for binary output.
Definition: JSerialisable.hh:130
JLANG::JComparable< JObjectID >::operator<
friend bool operator<(const JObjectID &first, typename JClass< JSecond_t >::argument_type second)
Less than operator.
Definition: JComparable.hh:147
JDETECTOR::JPMTReadoutAddress::tdc
int tdc
TDC channel.
Definition: JPMTReadoutAddress.hh:113
JDETECTOR::JPMTIdentifier::operator>>
friend std::istream & operator>>(std::istream &in, JPMTIdentifier &object)
Read PMT identifier from input.
Definition: JPMTIdentifier.hh:86
JPMTReadoutAddress.hh
JLANG::JObjectID
Auxiliary class for object identification.
Definition: JObjectID.hh:27
JDETECTOR::JPMTIdentifier::getPMTAddress
int getPMTAddress() const
Get PMT identifier (= TDC).
Definition: JPMTIdentifier.hh:73
JDETECTOR::JPMTIdentifier::JPMTIdentifier
JPMTIdentifier()
Default constructor.
Definition: JPMTIdentifier.hh:38
JDETECTOR::JPMTIdentifier::JPMTIdentifier
JPMTIdentifier(const JModuleIdentifier &id, const int tdc)
Constructor.
Definition: JPMTIdentifier.hh:50
JDETECTOR::JPMTIdentifier
PMT identifier.
Definition: JPMTIdentifier.hh:30
std
Definition: jaanetDictionary.h:36
JDETECTOR::JPMTIdentifier::operator<<
friend std::ostream & operator<<(std::ostream &out, const JPMTIdentifier &object)
Write PMT identifier to output.
Definition: JPMTIdentifier.hh:102
JDETECTOR::JPMTReadoutAddress
Data structure for PMT readout address.
Definition: JPMTReadoutAddress.hh:27
JDETECTOR
Auxiliary classes and methods for detector calibration.
Definition: JAnchor.hh:12
JLANG::JComparable< JObjectID >::operator==
friend bool operator==(const JObjectID &first, typename JClass< JSecond_t >::argument_type second)
Equal operator.
Definition: JComparable.hh:260