Jpp  18.5.0
the software that should make you happy
 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 PMT identifier.
60  *
61  * \return PMT identifier
62  */
64  {
65  return static_cast<const JPMTIdentifier&>(*this);
66  }
67 
68 
69  /**
70  * Set PMT identifier.
71  *
72  * \param id PMT identifier
73  */
75  {
76  static_cast<JPMTIdentifier&>(*this) = id;
77  }
78 
79 
80  /**
81  * Get module identifier.
82  *
83  * \return module identifier
84  */
85  int getModuleID() const
86  {
87  return getID();
88  }
89 
90 
91  /**
92  * Get PMT address (= TDC).
93  *
94  * \return PMT address
95  */
96  int getPMTAddress() const
97  {
98  return tdc;
99  }
100 
101 
102  /**
103  * Check validity.
104  *
105  * \return true if PMT identifier is valid; else false
106  */
107  bool is_valid() const
108  {
109  return !(getID() < 0 || tdc < 0);
110  }
111 
112 
113  /**
114  * Read PMT identifier from input.
115  *
116  * \param in input stream
117  * \param object PMT identifier
118  * \return input stream
119  */
120  friend inline std::istream& operator>>(std::istream& 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 output stream
133  * \param object PMT identifier
134  * \return output stream
135  */
136  friend inline std::ostream& operator<<(std::ostream& out, const JPMTIdentifier& object)
137  {
138  using namespace std;
139 
140  out << setw(10) << static_cast<const JModuleIdentifier&> (object) << ' ';
141  out << setw(2) << static_cast<const JPMTReadoutAddress&>(object);
142 
143  return out;
144  }
145 
146 
147  /**
148  * Read PMT identifier from input.
149  *
150  * \param in reader
151  * \param object PMT identifier
152  * \return reader
153  */
154  friend inline JReader& operator>>(JReader& in, JPMTIdentifier& object)
155  {
156  in >> static_cast<JModuleIdentifier&> (object);
157  in >> static_cast<JPMTReadoutAddress&>(object);
158 
159  return in;
160  }
161 
162 
163  /**
164  * Write PMT identifier to output.
165  *
166  * \param out writer
167  * \param object PMT identifier
168  * \return writer
169  */
170  friend inline JWriter& operator<<(JWriter& out, const JPMTIdentifier& object)
171  {
172  out << static_cast<const JModuleIdentifier&> (object);
173  out << static_cast<const JPMTReadoutAddress&>(object);
174 
175  return out;
176  }
177  };
178 
179 
180  /**
181  * Less than operator for PMT identifiers.
182  *
183  * \param first PMT identifier
184  * \param second PMT identifier
185  * \result true if first PMT lower than second PMT; else false
186  */
187  inline bool operator<(const JPMTIdentifier& first, const JPMTIdentifier& second)
188  {
189  if (first.getModuleID() == second.getModuleID())
190  return first.getPMTAddress() < second.getPMTAddress();
191  else
192  return first.getModuleID() < second.getModuleID();
193  }
194 
195 
196  /**
197  * Equal operator for PMT identifiers.
198  *
199  * \param first PMT identifier
200  * \param second PMT identifier
201  * \result true if first PMT equal second PMT; else false
202  */
203  inline bool operator==(const JPMTIdentifier& first, const JPMTIdentifier& second)
204  {
205  return (first.getModuleID() == second.getModuleID() &&
206  first.getPMTAddress() == second.getPMTAddress());
207  }
208 
209 
210  /**
211  * Get PMT label for monitoring and other applications.\n
212  * The format is "(XXXXXXXXXX,YY)", where XXXXXXXXXX is the module idetifier and YY the PMT readout channel.
213  *
214  * \param id PMT identifier
215  * \return label
216  */
218  {
219  using namespace std;
220  using namespace JPP;
221 
222  return MAKE_STRING("(" << FILL(10,'0') << id.getID() << "," << FILL(2,'0') << id.getPMTAddress() << ")");
223  }
224 }
225 
226 #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.
const JPMTIdentifier & getPMTIdentifier() const
Get PMT identifier.
void setPMTIdentifier(const JPMTIdentifier &id)
Set PMT identifier.
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.
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:127
I/O formatting auxiliaries.
int getID() const
Get identifier.
Definition: JObjectID.hh:50
JPMTIdentifier()
Default constructor.
then awk string
int getPMTAddress() const
Get PMT address (= TDC).
bool is_valid() const
Check validity.
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: JManip.hh:328
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.
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:48
Auxiliary class for object identification.
Definition: JObjectID.hh:22
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