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  * Check validity.
82  *
83  * \return true if PMT identifier is valid; else false
84  */
85  bool is_valid() const
86  {
87  return !(getID() < 0 || tdc < 0);
88  }
89 
90 
91  /**
92  * Read PMT identifier from input.
93  *
94  * \param in input stream
95  * \param object PMT identifier
96  * \return input stream
97  */
98  friend inline std::istream& operator>>(std::istream& in, JPMTIdentifier& object)
99  {
100  in >> static_cast<JModuleIdentifier&> (object);
101  in >> static_cast<JPMTReadoutAddress&>(object);
102 
103  return in;
104  }
105 
106 
107  /**
108  * Write PMT identifier to output.
109  *
110  * \param out output stream
111  * \param object PMT identifier
112  * \return output stream
113  */
114  friend inline std::ostream& operator<<(std::ostream& out, const JPMTIdentifier& object)
115  {
116  using namespace std;
117 
118  out << setw(10) << static_cast<const JModuleIdentifier&> (object) << ' ';
119  out << setw(2) << static_cast<const JPMTReadoutAddress&>(object);
120 
121  return out;
122  }
123 
124 
125  /**
126  * Read PMT identifier from input.
127  *
128  * \param in reader
129  * \param object PMT identifier
130  * \return reader
131  */
132  friend inline JReader& operator>>(JReader& in, JPMTIdentifier& object)
133  {
134  in >> static_cast<JModuleIdentifier&> (object);
135  in >> static_cast<JPMTReadoutAddress&>(object);
136 
137  return in;
138  }
139 
140 
141  /**
142  * Write PMT identifier to output.
143  *
144  * \param out writer
145  * \param object PMT identifier
146  * \return writer
147  */
148  friend inline JWriter& operator<<(JWriter& out, const JPMTIdentifier& object)
149  {
150  out << static_cast<const JModuleIdentifier&> (object);
151  out << static_cast<const JPMTReadoutAddress&>(object);
152 
153  return out;
154  }
155  };
156 
157 
158  /**
159  * Less than operator for PMT identifiers.
160  *
161  * \param first PMT identifier
162  * \param second PMT identifier
163  * \result true if first PMT lower than second PMT; else false
164  */
165  inline bool operator<(const JPMTIdentifier& first, const JPMTIdentifier& second)
166  {
167  if (first.getModuleID() == second.getModuleID())
168  return first.getPMTAddress() < second.getPMTAddress();
169  else
170  return first.getModuleID() < second.getModuleID();
171  }
172 
173 
174  /**
175  * Equal operator for PMT identifiers.
176  *
177  * \param first PMT identifier
178  * \param second PMT identifier
179  * \result true if first PMT equal second PMT; else false
180  */
181  inline bool operator==(const JPMTIdentifier& first, const JPMTIdentifier& second)
182  {
183  return (first.getModuleID() == second.getModuleID() &&
184  first.getPMTAddress() == second.getPMTAddress());
185  }
186 
187 
188  /**
189  * Get PMT label for monitoring and other applications.\n
190  * The format is "(XXXXXXXXXX,YY)", where XXXXXXXXXX is the module idetifier and YY the PMT readout channel.
191  *
192  * \param id PMT identifier
193  * \return label
194  */
195  inline std::string getLabel(const JPMTIdentifier& id)
196  {
197  using namespace std;
198  using namespace JPP;
199 
200  return MAKE_STRING("(" << FILL(10,'0') << id.getID() << "," << FILL(2,'0') << id.getPMTAddress() << ")");
201  }
202 }
203 
204 #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.
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:142
I/O formatting auxiliaries.
int getID() const
Get identifier.
Definition: JObjectID.hh:50
JPMTIdentifier()
Default constructor.
int getPMTAddress() const
Get PMT identifier (= 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:327
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: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
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 source JAcoustics sh $DETECTOR_ID typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:36