Jpp
JPMTParameters.hh
Go to the documentation of this file.
1 #ifndef __JDETECTOR__JPMTPARAMETERS__
2 #define __JDETECTOR__JPMTPARAMETERS__
3 
4 #include <istream>
5 #include <ostream>
6 #include <iomanip>
7 
8 #include "Jeep/JPrint.hh"
9 #include "Jeep/JProperties.hh"
10 
11 
12 /**
13  * \author mdejong
14  * \file
15  * PMT parameters and auxiliary methods.
16  */
17 
18 namespace JDETECTOR {}
19 namespace JPP { using namespace JDETECTOR; }
20 
21 namespace JDETECTOR {
22 
24 
25 
26  /**
27  * Data structure for PMT parameters.
28  */
30  public:
31  /**
32  * Default constructor.
33  *
34  * This constuctor provides for default values of all PMT parameters.
35  * Note that only when the value of <tt>TTS_ns</tt> is positive, it will be used to generate the PMT transition times.
36  * In this case, a normal distribution is used with a sigma equal to the specified value.
37  * By default, the value is negative.
38  * As a consequence, the PMT transition times will be generated according
39  * the measured distribution (see <tt>JPMTTransitTimeGenerator.hh</tt>).
40  */
42  {
43  this->QE = 1.0; // [unit]
44  this->gain = 0.9; // [unit]
45  this->gainSpread = 0.3; // [unit]
46  this->riseTime_ns = 8.5; // [ns]
47  this->TTS_ns = -1.0; // [ns]
48  this->threshold = 0.33; // [npe]
49  this->slope = 7.0; // [ns/npe]
50  this->saturation = 210; // [ns]
51  this->slewing = true; //
52  }
53 
54 
55  /**
56  * Constructor.
57  *
58  * \param QE relative quantum efficiency
59  * \param gain gain [unit]
60  * \param gainSpread gain spread [unit]
61  * \param riseTime_ns rise time of analogue pulse [ns]
62  * \param TTS_ns; transition time spread [ns]
63  * \param threshold threshold [npe]
64  * \param slope slope [ns/npe]
65  * \param saturation saturation [ns]
66  * \param slewing time slewing of analogue signal
67  */
68  JPMTParameters(const double QE,
69  const double gain,
70  const double gainSpread,
71  const double riseTime_ns,
72  const double TTS_ns,
73  const double threshold,
74  const double slope,
75  const double saturation,
76  const bool slewing = true)
77  {
78  this->QE = QE;
79  this->gain = gain;
80  this->gainSpread = gainSpread;
81  this->riseTime_ns = riseTime_ns;
82  this->TTS_ns = TTS_ns;
83  this->threshold = threshold;
84  this->slope = slope;
85  this->saturation = saturation;
86  this->slewing = slewing;
87  }
88 
89 
90  /**
91  * Get PMT parameters.
92  *
93  * \return PMT parameters
94  */
96  {
97  return static_cast<const JPMTParameters&>(*this);
98  }
99 
100 
101  /**
102  * Set PMT parameters.
103  *
104  * \param parameters PMT parameters
105  */
106  void setPMTParameters(const JPMTParameters& parameters)
107  {
108  static_cast<JPMTParameters&>(*this) = parameters;
109  }
110 
111 
112  /**
113  * Check validity of PMT parameters.
114  *
115  * \return true if valid; else false
116  */
117  bool is_valid() const
118  {
119  if (this->QE < 0.0 ||
120  this->gain < 0.0 ||
121  this->gainSpread < 0.0 ||
122  this->threshold < 0.0) {
123  return false;
124  }
125 
126  return true;
127  }
128 
129 
130  /**
131  * Stream input of PMT parameters.
132  *
133  * \param in input stream
134  * \param object PMT parameters
135  * \return input stream
136  */
137  friend inline std::istream& operator>>(std::istream& in, JPMTParameters& object)
138  {
139  return in >> object.QE
140  >> object.gain
141  >> object.gainSpread
142  >> object.riseTime_ns
143  >> object.TTS_ns
144  >> object.threshold;
145  }
146 
147 
148  /**
149  * Stream output of PMT parameters.
150  *
151  * \param out output stream
152  * \param object PMT parameters
153  * \return output stream
154  */
155  friend inline std::ostream& operator<<(std::ostream& out, const JPMTParameters& object)
156  {
157  JFlags flags(out);
158 
159  out << FIXED(5,3) << object.QE << ' '
160  << FIXED(5,3) << object.gain << ' '
161  << FIXED(5,3) << object.gainSpread << ' '
162  << FIXED(5,2) << object.riseTime_ns << ' '
163  << FIXED(5,2) << object.TTS_ns << ' '
164  << FIXED(5,3) << object.threshold;
165 
166  return out;
167  }
168 
169 
170  /**
171  * Get equation parameters.
172  *
173  * \return equation parameters
174  */
176  {
177  static JEquationParameters equation("=", ",", "./", "#");
178 
179  return equation;
180  }
181 
182 
183  /**
184  * Set equation parameters.
185  *
186  * \param equation equation parameters
187  */
188  static inline void setEquationParameters(const JEquationParameters& equation)
189  {
190  getEquationParameters() = equation;
191  }
192 
193 
194  /**
195  * Get properties of this class.
196  *
197  * \param equation equation parameters
198  */
200  {
201  return JPMTParametersHelper(*this, equation);
202  }
203 
204 
205  /**
206  * Get properties of this class.
207  *
208  * \param equation equation parameters
209  */
211  {
212  return JPMTParametersHelper(*this, equation);
213  }
214 
215 
216  double QE; //!< relative quantum efficiency
217  double gain; //!< gain [unit]
218  double gainSpread; //!< gain spread [unit]
219  double riseTime_ns; //!< rise time of analogue pulse [ns]
220  double TTS_ns; //!< transition time spread [ns]
221  double threshold; //!< threshold [npe]
222  double slope; //!< slope [ns/npe]
223  double saturation; //!< saturation [ns]
224  bool slewing; //!< time slewing of analogue signal
225 
226  private:
227  /**
228  * Auxiliary class for I/O of PMT parameters.
229  */
231  public JProperties
232  {
233  public:
234  /**
235  * Constructor.
236  *
237  * \param object PMT parameters
238  * \param equation equation parameters
239  */
240  template<class JPMTParameters_t>
241  JPMTParametersHelper(JPMTParameters_t& object,
242  const JEquationParameters& equation) :
243  JProperties(equation, 1)
244  {
245  insert(gmake_property(object.QE));
246  insert(gmake_property(object.gain));
247  insert(gmake_property(object.gainSpread));
248  insert(gmake_property(object.riseTime_ns));
249  insert(gmake_property(object.TTS_ns));
250  insert(gmake_property(object.threshold));
251  insert(gmake_property(object.slope));
252  insert(gmake_property(object.saturation));
253  insert(gmake_property(object.slewing));
254  }
255  };
256  };
257 }
258 
259 #endif
JDETECTOR::JPMTParameters::saturation
double saturation
saturation [ns]
Definition: JPMTParameters.hh:223
JDETECTOR::JPMTParameters::setEquationParameters
static void setEquationParameters(const JEquationParameters &equation)
Set equation parameters.
Definition: JPMTParameters.hh:188
JDETECTOR::JPMTParameters::threshold
double threshold
threshold [npe]
Definition: JPMTParameters.hh:221
FIXED
Auxiliary data structure for floating point format specification.
Definition: JPrint.hh:481
JDETECTOR::JPMTParameters::JPMTParametersHelper
Auxiliary class for I/O of PMT parameters.
Definition: JPMTParameters.hh:230
JDETECTOR::JPMTParameters::operator>>
friend std::istream & operator>>(std::istream &in, JPMTParameters &object)
Stream input of PMT parameters.
Definition: JPMTParameters.hh:137
JPrint.hh
JDETECTOR::JPMTParameters::TTS_ns
double TTS_ns
transition time spread [ns]
Definition: JPMTParameters.hh:220
JDETECTOR::JPMTParameters::is_valid
bool is_valid() const
Check validity of PMT parameters.
Definition: JPMTParameters.hh:117
JDETECTOR::JPMTParameters::gainSpread
double gainSpread
gain spread [unit]
Definition: JPMTParameters.hh:218
JDETECTOR::JPMTParameters::setPMTParameters
void setPMTParameters(const JPMTParameters &parameters)
Set PMT parameters.
Definition: JPMTParameters.hh:106
JDETECTOR::JPMTParameters::getPMTParameters
const JPMTParameters & getPMTParameters() const
Get PMT parameters.
Definition: JPMTParameters.hh:95
JDETECTOR::JPMTParameters::operator<<
friend std::ostream & operator<<(std::ostream &out, const JPMTParameters &object)
Stream output of PMT parameters.
Definition: JPMTParameters.hh:155
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
JDETECTOR::JPMTParameters::slewing
bool slewing
time slewing of analogue signal
Definition: JPMTParameters.hh:224
JDETECTOR::JPMTParameters::getProperties
JProperties getProperties(const JEquationParameters &equation=JPMTParameters::getEquationParameters())
Get properties of this class.
Definition: JPMTParameters.hh:199
JDETECTOR::JPMTParameters::getEquationParameters
static JEquationParameters & getEquationParameters()
Get equation parameters.
Definition: JPMTParameters.hh:175
JDETECTOR::JPMTParameters::gain
double gain
gain [unit]
Definition: JPMTParameters.hh:217
JDETECTOR::JPMTParameters::JPMTParameters
JPMTParameters(const double QE, const double gain, const double gainSpread, const double riseTime_ns, const double TTS_ns, const double threshold, const double slope, const double saturation, const bool slewing=true)
Constructor.
Definition: JPMTParameters.hh:68
JFlags
Auxiliary class to temporarily modify format specifications.
Definition: JPrint.hh:617
JLANG::JEquationParameters
Simple data structure to support I/O of equations (see class JLANG::JEquation).
Definition: JEquationParameters.hh:20
gmake_property
#define gmake_property(A)
macro to convert (template) parameter to JPropertiesElement object
Definition: JProperties.hh:1319
JEEP::JProperties
Utility class to parse parameter values.
Definition: JProperties.hh:496
JDETECTOR::JPMTParameters::slope
double slope
slope [ns/npe]
Definition: JPMTParameters.hh:222
JProperties.hh
JDETECTOR::JPMTParameters::JPMTParametersHelper::JPMTParametersHelper
JPMTParametersHelper(JPMTParameters_t &object, const JEquationParameters &equation)
Constructor.
Definition: JPMTParameters.hh:241
JDETECTOR::JPMTParameters::getProperties
JProperties getProperties(const JEquationParameters &equation=JPMTParameters::getEquationParameters()) const
Get properties of this class.
Definition: JPMTParameters.hh:210
JDETECTOR::JPMTParameters::QE
double QE
relative quantum efficiency
Definition: JPMTParameters.hh:216
JDETECTOR::JPMTParameters
Data structure for PMT parameters.
Definition: JPMTParameters.hh:29
JDETECTOR
Auxiliary classes and methods for detector calibration.
Definition: JAnchor.hh:12
JDETECTOR::JPMTParameters::riseTime_ns
double riseTime_ns
rise time of analogue pulse [ns]
Definition: JPMTParameters.hh:219
JDETECTOR::JPMTParameters::JPMTParameters
JPMTParameters()
Default constructor.
Definition: JPMTParameters.hh:41