Jpp  19.0.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 
9 
10 #include "JIO/JSerialisable.hh"
11 
14 #include "Jeep/JPrint.hh"
15 
16 
17 /**
18  * \author mdejong
19  */
20 
21 namespace JDETECTOR {}
22 namespace JPP { using namespace JDETECTOR; }
23 
24 namespace JDETECTOR {
25 
27  using JLANG::JTYPELIST;
28  using JIO::JReader;
29  using JIO::JWriter;
30 
31 
32  /**
33  * PMT identifier.
34  */
36  public JModuleIdentifier,
37  public JPMTReadoutAddress,
38  public JMultiComparable<JPMTIdentifier, JTYPELIST<JModuleIdentifier, JPMTReadoutAddress>::typelist>
39  {
40  public:
41  /**
42  * Default constructor.
43  */
47  {}
48 
49 
50  /**
51  * Constructor.
52  *
53  * \param id module identifier
54  * \param tdc TDC
55  */
57  const int tdc) :
58  JModuleIdentifier (id),
60  {}
61 
62 
63  /**
64  * Get PMT identifier.
65  *
66  * \return PMT identifier
67  */
69  {
70  return static_cast<const JPMTIdentifier&>(*this);
71  }
72 
73 
74  /**
75  * Set PMT identifier.
76  *
77  * \param id PMT identifier
78  */
80  {
81  static_cast<JPMTIdentifier&>(*this) = id;
82  }
83 
84 
85  /**
86  * Get module identifier.
87  *
88  * \return module identifier
89  */
90  int getModuleID() const
91  {
92  return getID();
93  }
94 
95 
96  /**
97  * Get PMT address (= TDC).
98  *
99  * \return PMT address
100  */
101  int getPMTAddress() const
102  {
103  return tdc;
104  }
105 
106 
107  /**
108  * Check validity.
109  *
110  * \return true if PMT identifier is valid; else false
111  */
112  bool is_valid() const
113  {
114  return !(getID() < 0 || tdc < 0);
115  }
116 
117 
118  /**
119  * Read PMT identifier from input.
120  *
121  * \param in input stream
122  * \param object PMT identifier
123  * \return input stream
124  */
125  friend inline std::istream& operator>>(std::istream& in, JPMTIdentifier& object)
126  {
127  in >> static_cast<JModuleIdentifier&> (object);
128  in >> static_cast<JPMTReadoutAddress&>(object);
129 
130  return in;
131  }
132 
133 
134  /**
135  * Write PMT identifier to output.
136  *
137  * \param out output stream
138  * \param object PMT identifier
139  * \return output stream
140  */
141  friend inline std::ostream& operator<<(std::ostream& out, const JPMTIdentifier& object)
142  {
143  using namespace std;
144 
145  out << setw(10) << static_cast<const JModuleIdentifier&> (object) << ' ';
146  out << setw(2) << static_cast<const JPMTReadoutAddress&>(object);
147 
148  return out;
149  }
150 
151 
152  /**
153  * Read PMT identifier from input.
154  *
155  * \param in reader
156  * \param object PMT identifier
157  * \return reader
158  */
159  friend inline JReader& operator>>(JReader& in, JPMTIdentifier& object)
160  {
161  in >> static_cast<JModuleIdentifier&> (object);
162  in >> static_cast<JPMTReadoutAddress&>(object);
163 
164  return in;
165  }
166 
167 
168  /**
169  * Write PMT identifier to output.
170  *
171  * \param out writer
172  * \param object PMT identifier
173  * \return writer
174  */
175  friend inline JWriter& operator<<(JWriter& out, const JPMTIdentifier& object)
176  {
177  out << static_cast<const JModuleIdentifier&> (object);
178  out << static_cast<const JPMTReadoutAddress&>(object);
179 
180  return out;
181  }
182  };
183 
184 
185  /**
186  * Get PMT label for monitoring and other applications.\n
187  * The format is "(XXXXXXXXXX,YY)", where XXXXXXXXXX is the module idetifier and YY the PMT readout channel.
188  *
189  * \param id PMT identifier
190  * \return label
191  */
192  inline std::string getLabel(const JPMTIdentifier& id)
193  {
194  using namespace std;
195  using namespace JPP;
196 
197  return MAKE_STRING("(" << FILL(10,'0') << id.getID() << "," << FILL(2,'0') << id.getPMTAddress() << ")");
198  }
199 }
200 
201 #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.
#define MAKE_STRING(A)
Make string.
Definition: JPrint.hh:127
I/O formatting auxiliaries.
Auxiliary class for recursive type list generation.
Definition: JTypeList.hh:351
int getID() const
Get identifier.
Definition: JObjectID.hh:50
JPMTIdentifier()
Default constructor.
int getPMTAddress() const
Get PMT address (= TDC).
bool is_valid() const
Check validity.
Interface for binary input.
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 The output file must have the wildcard in the e g root fi 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.
Template definition of auxiliary base class for composite data structures composed of base classes wi...