Jpp  17.0.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JDAQPMTIdentifier.hh
Go to the documentation of this file.
1 #ifndef __JDAQPMTIDENTIFIER__
2 #define __JDAQPMTIDENTIFIER__
3 
4 #include <istream>
5 #include <ostream>
6 
9 
10 
11 /**
12  * \author mdejong
13  */
14 
15 namespace KM3NETDAQ {
16 
17  /**
18  * PMT identifier.
19  */
22  {
23  public:
24 
25  friend size_t getSizeof<JDAQPMTIdentifier>();
27  friend JWriter& operator<<(JWriter&, const JDAQPMTIdentifier&);
28 
29  /**
30  * Default constructor.
31  */
34  address (0)
35  {}
36 
37 
38  /**
39  * Constructor.
40  *
41  * \param id module identifier
42  * \param pmt_address PMT address
43  */
45  const int pmt_address) :
47  address (pmt_address)
48  {}
49 
50 
51  /**
52  * Get PMT identifier.
53  *
54  * \return PMT identifier
55  */
57  {
58  return *this;
59  }
60 
61 
62  /**
63  * Set PMT identifier.
64  *
65  * \param pmt PMT identifier
66  */
68  {
69  *this = pmt;
70  }
71 
72 
73  /**
74  * Get PMT identifier.
75  *
76  * \return PMT identifier
77  */
78  int getPMTAddress() const
79  {
80  return address;
81  }
82 
83 
84  /**
85  * Read PMT identifier from input.
86  *
87  * \param in input stream
88  * \param pmt PMT identifier
89  * \return input stream
90  */
91  friend inline std::istream& operator>>(std::istream& in, JDAQPMTIdentifier& pmt)
92  {
93  in >> static_cast<JDAQModuleIdentifier&>(pmt);
94  in >> pmt.address;
95 
96  return in;
97  }
98 
99 
100  /**
101  * Write PMT identifier to output.
102  *
103  * \param out output stream
104  * \param pmt PMT identifier
105  * \return output stream
106  */
107  friend inline std::ostream& operator<<(std::ostream& out, const JDAQPMTIdentifier& pmt)
108  {
109  out << static_cast<const JDAQModuleIdentifier&>(pmt) << ' ';
110  out << pmt.address;
111 
112  return out;
113  }
114 
115 
116  /**
117  * Compare PMT identifiers.
118  *
119  * The comparison is applied to the module identifer and to the PMT address.
120  * If the module identifier or PMT address is <tt>-1</tt>, the corresponding comparison evaluates to <tt>true</tt>.
121  *
122  * \param first PMT identifier
123  * \param second PMT identifier
124  * \result true if first PMT equal second PMT; else false
125  */
126  static inline bool compare(const JDAQPMTIdentifier& first, const JDAQPMTIdentifier& second)
127  {
128  return ((first .getModuleIdentifier() == second.getModuleIdentifier() ||
129  first .getModuleIdentifier() == -1 ||
130  second.getModuleIdentifier() == -1) &&
131  (first .getPMTAddress() == second.getPMTAddress() ||
132  first .getPMTAddress() == -1 ||
133  second.getPMTAddress() == -1));
134  }
135 
136 
138 
139 
140  protected:
141  int address;
142  };
143 
144 
145  /**
146  * Less than operator for PMT identifiers.
147  *
148  * The less than operator is applied first to the module identifer and then to the PMT address.
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 JDAQPMTIdentifier& first, const JDAQPMTIdentifier& second)
155  {
156  if (first.getModuleIdentifier() == second.getModuleIdentifier())
157  return first.getPMTAddress() < second.getPMTAddress();
158  else
159  return first.getModuleIdentifier() < second.getModuleIdentifier();
160  }
161 
162 
163  /**
164  * Equal operator for PMT identifiers.
165  *
166  * The equal operator is applied to the module identifer and to the PMT address.
167  *
168  * \param first PMT identifier
169  * \param second PMT identifier
170  * \result true if first PMT equal second PMT; else false
171  */
172  inline bool operator==(const JDAQPMTIdentifier& first, const JDAQPMTIdentifier& second)
173  {
174  return (first.getModuleIdentifier() == second.getModuleIdentifier() &&
175  first.getPMTAddress() == second.getPMTAddress());
176  }
177 
178 
179  /**
180  * Not-equal operator for PMT identifiers.
181  *
182  * \param first PMT identifier
183  * \param second PMT identifier
184  * \result true if first PMT identifier not equal to second; else false
185  */
186  inline bool operator!=(const JDAQPMTIdentifier& first,
187  const JDAQPMTIdentifier& second)
188  {
189  return !(first == second);
190  }
191 }
192 
193 #endif
bool operator==(const JDAQChronometer &first, const JDAQChronometer &second)
Equal operator for DAQ chronometers.
Interface for binary output.
friend JWriter & operator<<(JWriter &, const JDAQPMTIdentifier &)
Write PMT identifier to output.
const JDAQPMTIdentifier & getPMTIdentifier() const
Get PMT identifier.
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
int getPMTAddress() const
Get PMT identifier.
JDAQPMTIdentifier(const JDAQModuleIdentifier &id, const int pmt_address)
Constructor.
friend std::ostream & operator<<(std::ostream &out, const JDAQPMTIdentifier &pmt)
Write PMT identifier to output.
static bool compare(const JDAQPMTIdentifier &first, const JDAQPMTIdentifier &second)
Compare PMT identifiers.
void setPMTIdentifier(const JDAQPMTIdentifier &pmt)
Set PMT identifier.
size_t getSizeof< JDAQPMTIdentifier >()
Get size of type.
friend std::istream & operator>>(std::istream &in, JDAQPMTIdentifier &pmt)
Read PMT identifier from input.
Interface for binary input.
JDAQPMTIdentifier()
Default constructor.
ClassDefNV(JDAQPMTIdentifier, 1)
const JDAQModuleIdentifier & getModuleIdentifier() const
Get Module identifier.
friend JReader & operator>>(JReader &, JDAQPMTIdentifier &)
Read PMT identifier from input.
bool operator!=(const JDAQChronometer &first, const JDAQChronometer &second)
Not-equal operator for DAQ chronometers.
bool operator<(const JDAQHit &first, const JDAQHit &second)
Less than operator for DAQ hits.
Definition: JDAQHit.hh:174
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:46