Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 #include "Jeep/JPrint.hh"
13 
14 
15 /**
16  * \author mdejong
17  */
18 
19 namespace JDETECTOR {}
20 namespace JPP { using namespace JDETECTOR; }
21 
22 namespace JDETECTOR {
23 
24  using JIO::JReader;
25  using JIO::JWriter;
26 
27 
28  /**
29  * PMT identifier.
30  */
32  public JModuleIdentifier,
33  public JPMTReadoutAddress
34  {
35  public:
36  /**
37  * Default constructor.
38  */
42  {}
43 
44 
45  /**
46  * Constructor.
47  *
48  * \param id module identifier
49  * \param tdc TDC
50  */
52  const int tdc) :
53  JModuleIdentifier (id),
55  {}
56 
57 
58  /**
59  * Get module identifier.
60  *
61  * \return module identifier
62  */
63  int getModuleID() const
64  {
65  return getID();
66  }
67 
68 
69  /**
70  * Get PMT identifier (= TDC).
71  *
72  * \return PMT identifier
73  */
74  int getPMTAddress() const
75  {
76  return tdc;
77  }
78 
79 
80  /**
81  * Read PMT identifier from input.
82  *
83  * \param in input stream
84  * \param object PMT identifier
85  * \return input stream
86  */
87  friend inline std::istream& operator>>(std::istream& in, JPMTIdentifier& object)
88  {
89  in >> static_cast<JModuleIdentifier&> (object);
90  in >> static_cast<JPMTReadoutAddress&>(object);
91 
92  return in;
93  }
94 
95 
96  /**
97  * Write PMT identifier to output.
98  *
99  * \param out output stream
100  * \param object PMT identifier
101  * \return output stream
102  */
103  friend inline std::ostream& operator<<(std::ostream& out, const JPMTIdentifier& object)
104  {
105  using namespace std;
106 
107  out << setw(10) << static_cast<const JModuleIdentifier&> (object) << ' ';
108  out << setw(2) << static_cast<const JPMTReadoutAddress&>(object);
109 
110  return out;
111  }
112 
113 
114  /**
115  * Read PMT identifier from input.
116  *
117  * \param in reader
118  * \param object PMT identifier
119  * \return reader
120  */
121  friend inline JReader& operator>>(JReader& in, JPMTIdentifier& object)
122  {
123  in >> static_cast<JModuleIdentifier&> (object);
124  in >> static_cast<JPMTReadoutAddress&>(object);
125 
126  return in;
127  }
128 
129 
130  /**
131  * Write PMT identifier to output.
132  *
133  * \param out writer
134  * \param object PMT identifier
135  * \return writer
136  */
137  friend inline JWriter& operator<<(JWriter& out, const JPMTIdentifier& object)
138  {
139  out << static_cast<const JModuleIdentifier&> (object);
140  out << static_cast<const JPMTReadoutAddress&>(object);
141 
142  return out;
143  }
144  };
145 
146 
147  /**
148  * Less than operator for PMT identifiers.
149  *
150  * \param first PMT identifier
151  * \param second PMT identifier
152  * \result true if first PMT lower than second PMT; else false
153  */
154  inline bool operator<(const JPMTIdentifier& first, const JPMTIdentifier& second)
155  {
156  if (first.getModuleID() == second.getModuleID())
157  return first.getPMTAddress() < second.getPMTAddress();
158  else
159  return first.getModuleID() < second.getModuleID();
160  }
161 
162 
163  /**
164  * Equal operator for PMT identifiers.
165  *
166  * \param first PMT identifier
167  * \param second PMT identifier
168  * \result true if first PMT equal second PMT; else false
169  */
170  inline bool operator==(const JPMTIdentifier& first, const JPMTIdentifier& second)
171  {
172  return (first.getModuleID() == second.getModuleID() &&
173  first.getPMTAddress() == second.getPMTAddress());
174  }
175 
176 
177  /**
178  * Get PMT label for monitoring and other applications.\n
179  * The format is "(XXXXXXXXXX,YY)", where XXXXXXXXXX is the module idetifier and YY the PMT readout channel.
180  *
181  * \param id PMT identifier
182  * \return label
183  */
184  inline std::string getLabel(const JPMTIdentifier& id)
185  {
186  using namespace std;
187  using namespace JPP;
188 
189  return MAKE_STRING("(" << FILL(10,'0') << id.getID() << "," << FILL(2,'0') << id.getPMTAddress() << ")");
190  }
191 }
192 
193 #endif
Interface for binary output.
friend JReader & operator>>(JReader &in, JPMTIdentifier &object)
Read PMT identifier from input.
friend JWriter & operator<<(JWriter &out, const JPMTIdentifier &object)
Write PMT identifier to output.
std::string getLabel(const JLocation &location)
Get module label for monitoring and other applications.
Definition: JLocation.hh:246
JPMTIdentifier(const JModuleIdentifier &id, const int tdc)
Constructor.
int getModuleID() const
Get module identifier.
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
Definition: JSirene.sh:45
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
#define MAKE_STRING(A)
Make string.
Definition: JPrint.hh:699
I/O formatting auxiliaries.
int getID() const
Get identifier.
Definition: JObjectID.hh:55
JPMTIdentifier()
Default constructor.
int getPMTAddress() const
Get PMT identifier (= TDC).
Interface for binary input.
friend bool operator==(const JObjectID &first, typename JClass< JNullType >::argument_type second)
Equal operator.
Definition: JComparable.hh:260
Auxiliary data structure for sequence of same character.
Definition: JPrint.hh:361
friend std::istream & operator>>(std::istream &in, JPMTIdentifier &object)
Read PMT identifier from input.
friend std::ostream & operator<<(std::ostream &out, const JPMTIdentifier &object)
Write PMT identifier to output.
Auxiliary class for object identification.
Definition: JObjectID.hh:27
Data structure for PMT readout address.
friend bool operator<(const JObjectID &first, typename JClass< JNullType >::argument_type second)
Less than operator.
Definition: JComparable.hh:147