Jpp - the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JPMT.hh
Go to the documentation of this file.
1 #ifndef __JDETECTOR__JPMT__
2 #define __JDETECTOR__JPMT__
3 
4 #include <istream>
5 #include <ostream>
6 #include <iomanip>
7 
8 #include "JLang/JType.hh"
9 #include "JLang/JObjectID.hh"
10 #include "JLang/JMultiEquals.hh"
11 #include "JLang/JSTDToolkit.hh"
12 #include "JGeometry3D/JAxis3D.hh"
15 #include "JDetector/JStatus.hh"
16 #include "JDetector/JVersion.hh"
17 #include "Jeep/JeepToolkit.hh"
18 #include "JIO/JSerialisable.hh"
19 
20 
21 /**
22  * \file
23  *
24  * Data structure for PMT geometry and calibration.
25  * \author mdejong
26  */
27 namespace JDETECTOR {}
28 namespace JPP { using namespace JDETECTOR; }
29 
30 namespace JDETECTOR {
31 
32  using JLANG::JType;
33  using JLANG::JObjectID;
34  using JLANG::JMultiEquals;
35  using JLANG::JTYPELIST;
37  using JIO::JReader;
38  using JIO::JWriter;
39 
40 
41  /**
42  * Data structure for PMT geometry and calibration.
43  *
44  * N.B.
45  * The axis of the PMT points in the direction of the field of view of the photo-cathode.
46  */
47  class JPMT :
48  public JObjectID,
49  public JAxis3D,
50  public JCalibration,
51  public JStatus,
52  public JMultiEquals<JPMT, JTYPELIST<JObjectID>::typelist>
53  {
54  public:
55  /**
56  * Default constructor.
57  */
58  JPMT() :
59  JObjectID(),
60  JAxis3D(),
61  JCalibration(),
62  JStatus()
63  {}
64 
65 
66  /**
67  * Constructor.
68  *
69  * \param id identifier
70  * \param axis axis
71  * \param status status
72  */
73  JPMT(const int id,
74  const JAxis3D& axis,
75  const JStatus& status = JStatus()) :
76  JObjectID(id),
77  JAxis3D(axis),
78  JCalibration(),
80  {}
81 
82 
83  /**
84  * Constructor.
85  *
86  * \param id identifier
87  * \param axis axis
88  * \param cal calibration
89  * \param status status
90  */
91  JPMT(const int id,
92  const JAxis3D& axis,
93  const JCalibration& cal,
94  const JStatus& status = JStatus()) :
95  JObjectID(id),
96  JAxis3D(axis),
97  JCalibration(cal),
99  {}
100 
101 
102  /**
103  * Get detector version.
104  */
106  {
107  static JDetectorVersion version;
108 
109  return version;
110  }
111 
112 
113  /**
114  * Set detector version.
115  *
116  * \param version version
117  */
118  static void setVersion(const JVersion& version)
119  {
120  getVersion() = JDetectorVersion(version);
121  }
122 
123 
124  /**
125  * Dot product.
126  *
127  * The dot product is evaluated for the PMT orientation.
128  *
129  * \param pmt PMT
130  * \return dot product
131  */
132  inline double getDot(const JPMT& pmt) const
133  {
134  return this->getDirection().getDot(pmt.getDirection());
135  }
136 
137 
138  /**
139  * Read PMT from input.
140  *
141  * \param in input stream
142  * \param pmt PMT
143  * \return input stream
144  */
145  friend inline std::istream& operator>>(std::istream& in, JPMT& pmt)
146  {
147  in >> static_cast<JObjectID&> (pmt);
148  in >> static_cast<JAxis3D&> (pmt);
149  in >> static_cast<JCalibration&>(pmt);
150 
152  in >> static_cast<JStatus&>(pmt);
153  }
154 
155  return in;
156  }
157 
158 
159  /**
160  * Write PMT to output.
161  *
162  * \param out output stream
163  * \param pmt PMT
164  * \return output stream
165  */
166  friend inline std::ostream& operator<<(std::ostream& out, const JPMT& pmt)
167  {
168  using namespace std;
169 
170  out << setw(8);
171  out << static_cast<const JObjectID&> (pmt);
172  out << ' ';
173  out << static_cast<const JAxis3D&> (pmt);
174  out << ' ';
175  out << static_cast<const JCalibration&>(pmt);
176 
178  out << ' ';
179  out << static_cast<const JStatus&>(pmt);
180  }
181 
182  return out;
183  }
184 
185 
186  /**
187  * Read PMT from input.
188  *
189  * \param in reader
190  * \param pmt PMT
191  * \return reader
192  */
193  friend inline JReader& operator>>(JReader& in, JPMT& pmt)
194  {
195  in >> static_cast<JObjectID&> (pmt);
196  in >> static_cast<JAxis3D&> (pmt);
197  in >> static_cast<JCalibration&>(pmt);
198 
200  in >> static_cast<JStatus&>(pmt);
201  }
202 
203  return in;
204  }
205 
206 
207  /**
208  * Write PMT to output.
209  *
210  * \param out writer
211  * \param pmt PMT
212  * \return writer
213  */
214  friend inline JWriter& operator<<(JWriter& out, const JPMT& pmt)
215  {
216  out << static_cast<const JObjectID&> (pmt);
217  out << static_cast<const JAxis3D&> (pmt);
218  out << static_cast<const JCalibration&>(pmt);
219 
221  out << static_cast<const JStatus&>(pmt);
222  }
223 
224  return out;
225  }
226  };
227 }
228 
229 #endif
Interface for binary output.
JStatus()
Default constructor.
Definition: JStatus.hh:48
Time calibration (including definition of sign of time offset).
const JDirection3D & getDirection() const
Get direction.
friend JReader & operator>>(JReader &in, JPMT &pmt)
Read PMT from input.
Definition: JPMT.hh:193
JPMT(const int id, const JAxis3D &axis, const JStatus &status=JStatus())
Constructor.
Definition: JPMT.hh:73
friend std::ostream & operator<<(std::ostream &out, const JPMT &pmt)
Write PMT to output.
Definition: JPMT.hh:166
Auxiliary class for controlling PMT status.
Definition: JStatus.hh:42
Data structure for time calibration.
Auxiliary class for a type holder.
Definition: JType.hh:19
JPMT()
Default constructor.
Definition: JPMT.hh:58
friend std::istream & operator>>(std::istream &in, JPMT &pmt)
Read PMT from input.
Definition: JPMT.hh:145
double getDot(const JAngle3D &angle) const
Get dot product.
Template definition of auxiliary base class for data structures composed of multiple base classes wit...
Definition: JMultiEquals.hh:32
JPMT(const int id, const JAxis3D &axis, const JCalibration &cal, const JStatus &status=JStatus())
Constructor.
Definition: JPMT.hh:91
Axis object.
Definition: JAxis3D.hh:38
Version with PMT status field and comments.
Auxiliary class for recursive type list generation.
Definition: JTypeList.hh:351
Auxiliary methods for handling file names, type names and environment.
Data structure for PMT geometry and calibration.
Definition: JPMT.hh:47
Data structure for detector version.
Interface for binary input.
static const JGetDetectorVersion getDetectorVersion
Function object to map detector variant to detector version.
static void setVersion(const JVersion &version)
Set detector version.
Definition: JPMT.hh:118
friend JWriter & operator<<(JWriter &out, const JPMT &pmt)
Write PMT to output.
Definition: JPMT.hh:214
Auxiliary class for object identification.
Definition: JObjectID.hh:22
Auxiliary class for version identifier.
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 CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:38
static JDetectorVersion & getVersion()
Get detector version.
Definition: JPMT.hh:105
version
Definition: JCalibratePMT.sh:7
double getDot(const JPMT &pmt) const
Dot product.
Definition: JPMT.hh:132