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
JPMTAddress.hh
Go to the documentation of this file.
1 #ifndef __JDETECTOR__JPMTADDRESS__
2 #define __JDETECTOR__JPMTADDRESS__
3 
4 #include <istream>
5 #include <ostream>
6 
7 #include "JLang/JComparable.hh"
9 
10 
11 /**
12  * \author mdejong
13  */
14 
15 namespace JDETECTOR {}
16 namespace JPP { using namespace JDETECTOR; }
17 
18 namespace JDETECTOR {
19 
20  using JLANG::JComparable;
21 
22 
23  /**
24  * Address of PMT in detector data structure.
25  *
26  * The address of a PMT consists of a pair of integer values, where
27  * - JPMTAddress::first refers to the index of the parent module in the detector data structure; and
28  * - JPMTAddress::second refers to the index of the PMT in the corresponding module data structure.
29  *
30  * This class implements the JLANG::JComparable interface.
31  */
32  class JPMTAddress :
33  public JModuleAddress,
34  public JComparable<JPMTAddress>
35  {
36  public:
37  /**
38  * Default constructor.
39  */
41  JModuleAddress(-1),
42  second(-1)
43  {}
44 
45 
46  /**
47  * Constructor.
48  *
49  * \param module module address
50  * \param pmt PMT index
51  */
52  JPMTAddress(const JModuleAddress& module,
53  const int pmt) :
54  JModuleAddress(module),
55  second(pmt)
56  {}
57 
58 
59  /**
60  * Less than method.
61  *
62  * \param address PMT address
63  * \result true if this PMT address is less than given PMT address; else false
64  */
65  inline bool less(const JPMTAddress& address) const
66  {
67  if (this->first == address.first)
68  return this->second < address.second;
69  else
70  return this->first < address.first;
71  }
72 
73 
74  /**
75  * Read PMT address from input.
76  *
77  * \param in input stream
78  * \param object PMT address
79  * \return input stream
80  */
81  friend inline std::istream& operator>>(std::istream& in, JPMTAddress& object)
82  {
83  return in >> static_cast<JModuleAddress&>(object) >> object.second;
84  }
85 
86 
87  /**
88  * Write PMT address to output.
89  *
90  * \param out output stream
91  * \param object PMT address
92  * \return output stream
93  */
94  friend inline std::ostream& operator<<(std::ostream& out, const JPMTAddress& object)
95  {
96  return out << static_cast<const JModuleAddress&>(object) << ' ' << object.second;
97  }
98 
99 
100  int second; //!< index of PMT in module data structure.
101  };
102 }
103 
104 #endif
int second
index of PMT in module data structure.
Definition: JPMTAddress.hh:100
int first
index of module in detector data structure
JPMTAddress(const JModuleAddress &module, const int pmt)
Constructor.
Definition: JPMTAddress.hh:52
JPMTAddress()
Default constructor.
Definition: JPMTAddress.hh:40
friend std::istream & operator>>(std::istream &in, JPMTAddress &object)
Read PMT address from input.
Definition: JPMTAddress.hh:81
Address of module in detector data structure.
Template definition of auxiliary base class for comparison of data structures.
Definition: JComparable.hh:24
Address of PMT in detector data structure.
Definition: JPMTAddress.hh:32
friend std::ostream & operator<<(std::ostream &out, const JPMTAddress &object)
Write PMT address to output.
Definition: JPMTAddress.hh:94
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
bool less(const JPMTAddress &address) const
Less than method.
Definition: JPMTAddress.hh:65