Jpp  19.1.0-rc.1
the software that should make you happy
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 = 1.0; // [unit]
45  this->gainSpread = 0.4; // [unit]
46  this->riseTime_ns = 7.24; // [ns]
47  this->TTS_ns = -1.0; // [ns]
48  this->threshold = 0.24; // [npe]
49  this->PunderAmplified = 0.05; //
50  this->thresholdBand = 0.12; // [npe]
51  this->mean_ns = 4.5; // [ns]
52  this->sigma_ns = 1.5; // [ns]
53  this->slope = 7.0; // [ns/npe]
54  this->saturation = 210; // [ns]
55  this->slewing = true; //
56  }
57 
58 
59  /**
60  * Constructor.
61  *
62  * \param QE relative quantum efficiency
63  * \param gain gain [unit]
64  * \param gainSpread gain spread [unit]
65  * \param riseTime_ns rise time of analogue pulse [ns]
66  * \param TTS_ns transition time spread [ns]
67  * \param threshold threshold [npe]
68  * \param thresholdBand threshold-band [npe]
69  * \param mean_ns mean time-over-threshold of threshold-band hits [ns]
70  * \param sigma_ns time-over-threshold standard deviation of threshold-band hits [ns]
71  * \param PunderAmplified probability of underamplified hit
72  * \param slope slope [ns/npe]
73  * \param saturation saturation [ns]
74  * \param slewing time slewing of analogue signal
75  */
76  JPMTParameters(const double QE,
77  const double gain,
78  const double gainSpread,
79  const double riseTime_ns,
80  const double TTS_ns,
81  const double threshold,
82  const double PunderAmplified,
83  const double thresholdBand,
84  const double mean_ns,
85  const double sigma_ns,
86  const double slope,
87  const double saturation,
88  const bool slewing = true)
89  {
90  this->QE = QE;
91  this->gain = gain;
92  this->gainSpread = gainSpread;
93  this->riseTime_ns = riseTime_ns;
94  this->TTS_ns = TTS_ns;
95  this->threshold = threshold;
96  this->PunderAmplified = PunderAmplified;
97  this->thresholdBand = thresholdBand;
98  this->mean_ns = mean_ns;
99  this->sigma_ns = sigma_ns;
100  this->slope = slope;
101  this->saturation = saturation;
102  this->slewing = slewing;
103  }
104 
105 
106  /**
107  * Get PMT parameters.
108  *
109  * \return PMT parameters
110  */
112  {
113  return static_cast<const JPMTParameters&>(*this);
114  }
115 
116 
117  /**
118  * Set PMT parameters.
119  *
120  * \param parameters PMT parameters
121  */
122  void setPMTParameters(const JPMTParameters& parameters)
123  {
124  static_cast<JPMTParameters&>(*this) = parameters;
125  }
126 
127 
128  /**
129  * Check validity of PMT parameters.
130  *
131  * \return true if valid; else false
132  */
133  bool is_valid() const
134  {
135  if (this->QE < 0.0 ||
136  this->gain < 0.0 ||
137  this->gainSpread < 0.0 ||
138  this->threshold < 0.0 ||
139  this->thresholdBand < 0.0) {
140  return false;
141  }
142 
143  return true;
144  }
145 
146 
147  /**
148  * Stream input of PMT parameters.
149  *
150  * \param in input stream
151  * \param object PMT parameters
152  * \return input stream
153  */
154  friend inline std::istream& operator>>(std::istream& in, JPMTParameters& object)
155  {
156  return in >> object.QE
157  >> object.gain
158  >> object.gainSpread
159  >> object.riseTime_ns
160  >> object.TTS_ns
161  >> object.threshold;
162  }
163 
164 
165  /**
166  * Stream output of PMT parameters.
167  *
168  * \param out output stream
169  * \param object PMT parameters
170  * \return output stream
171  */
172  friend inline std::ostream& operator<<(std::ostream& out, const JPMTParameters& object)
173  {
174  const JFormat format(out);
175 
176  out << FIXED(5,3) << object.QE << ' '
177  << FIXED(5,3) << object.gain << ' '
178  << FIXED(5,3) << object.gainSpread << ' '
179  << FIXED(5,2) << object.riseTime_ns << ' '
180  << FIXED(5,2) << object.TTS_ns << ' '
181  << FIXED(5,3) << object.threshold;
182 
183  return out;
184  }
185 
186 
187  /**
188  * Get equation parameters.
189  *
190  * \return equation parameters
191  */
193  {
194  static JEquationParameters equation("=", ",", "./", "#");
195 
196  return equation;
197  }
198 
199 
200  /**
201  * Set equation parameters.
202  *
203  * \param equation equation parameters
204  */
205  static inline void setEquationParameters(const JEquationParameters& equation)
206  {
207  getEquationParameters() = equation;
208  }
209 
210 
211  /**
212  * Get properties of this class.
213  *
214  * \param equation equation parameters
215  */
217  {
218  return JPMTParametersHelper(*this, equation);
219  }
220 
221 
222  /**
223  * Get properties of this class.
224  *
225  * \param equation equation parameters
226  */
228  {
229  return JPMTParametersHelper(*this, equation);
230  }
231 
232 
233  double QE; //!< relative quantum efficiency
234  double gain; //!< gain [unit]
235  double gainSpread; //!< gain spread [unit]
236  double riseTime_ns; //!< rise time of analogue pulse [ns]
237  double TTS_ns; //!< transition time spread [ns]
238  double threshold; //!< threshold [npe]
239  double PunderAmplified; //!< probability of underamplified hit
240  double thresholdBand; //!< threshold-band [npe]
241  double mean_ns; //!< mean time-over-threshold of threshold-band hits [ns]
242  double sigma_ns; //!< time-over-threshold standard deviation of threshold-band hits [ns]
243  double slope; //!< slope [ns/npe]
244  double saturation; //!< saturation [ns]
245  bool slewing; //!< time slewing of analogue signal
246 
247  private:
248  /**
249  * Auxiliary class for I/O of PMT parameters.
250  */
252  public JProperties
253  {
254  public:
255  /**
256  * Constructor.
257  *
258  * \param object PMT parameters
259  * \param equation equation parameters
260  */
261  template<class JPMTParameters_t>
262  JPMTParametersHelper(JPMTParameters_t& object,
263  const JEquationParameters& equation) :
264  JProperties(equation, 1)
265  {
266  insert(gmake_property(object.QE));
267  insert(gmake_property(object.gain));
268  insert(gmake_property(object.gainSpread));
269  insert(gmake_property(object.riseTime_ns));
270  insert(gmake_property(object.TTS_ns));
271  insert(gmake_property(object.threshold));
272  insert(gmake_property(object.PunderAmplified));
273  insert(gmake_property(object.thresholdBand));
274  insert(gmake_property(object.mean_ns));
275  insert(gmake_property(object.sigma_ns));
276  insert(gmake_property(object.slope));
277  insert(gmake_property(object.saturation));
278  insert(gmake_property(object.slewing));
279  }
280  };
281  };
282 }
283 
284 #endif
I/O formatting auxiliaries.
Utility class to parse parameter values.
#define gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
Auxiliary class for I/O of PMT parameters.
JPMTParametersHelper(JPMTParameters_t &object, const JEquationParameters &equation)
Constructor.
Data structure for PMT parameters.
JProperties getProperties(const JEquationParameters &equation=JPMTParameters::getEquationParameters()) const
Get properties of this class.
bool is_valid() const
Check validity of PMT parameters.
double sigma_ns
time-over-threshold standard deviation of threshold-band hits [ns]
double QE
relative quantum efficiency
double thresholdBand
threshold-band [npe]
friend std::istream & operator>>(std::istream &in, JPMTParameters &object)
Stream input of PMT parameters.
double gainSpread
gain spread [unit]
JPMTParameters()
Default constructor.
double riseTime_ns
rise time of analogue pulse [ns]
double TTS_ns
transition time spread [ns]
double threshold
threshold [npe]
double mean_ns
mean time-over-threshold of threshold-band hits [ns]
static void setEquationParameters(const JEquationParameters &equation)
Set equation parameters.
JProperties getProperties(const JEquationParameters &equation=JPMTParameters::getEquationParameters())
Get properties of this class.
void setPMTParameters(const JPMTParameters &parameters)
Set PMT parameters.
const JPMTParameters & getPMTParameters() const
Get PMT parameters.
double slope
slope [ns/npe]
double PunderAmplified
probability of underamplified hit
bool slewing
time slewing of analogue signal
double saturation
saturation [ns]
friend std::ostream & operator<<(std::ostream &out, const JPMTParameters &object)
Stream output of PMT parameters.
JPMTParameters(const double QE, const double gain, const double gainSpread, const double riseTime_ns, const double TTS_ns, const double threshold, const double PunderAmplified, const double thresholdBand, const double mean_ns, const double sigma_ns, const double slope, const double saturation, const bool slewing=true)
Constructor.
static JEquationParameters & getEquationParameters()
Get equation parameters.
Utility class to parse parameter values.
Definition: JProperties.hh:501
Simple data structure to support I/O of equations (see class JLANG::JEquation).
file Auxiliary data structures and methods for detector calibration.
Definition: JAnchor.hh:12
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:448
Auxiliary class to temporarily define format specifications.
Definition: JManip.hh:636