#ifndef __JDETECTOR__JPMTPARAMETERS__ #define __JDETECTOR__JPMTPARAMETERS__ #include #include #include #include "Jeep/JPrint.hh" #include "Jeep/JProperties.hh" /** * \author mdejong * \file * PMT parameters and auxiliary methods. */ namespace JDETECTOR {} namespace JPP { using namespace JDETECTOR; } namespace JDETECTOR { using JLANG::JEquationParameters; /** * Data structure for PMT parameters. */ class JPMTParameters { public: /** * Default constructor. * * This constuctor provides for default values of all PMT parameters. * Note that only when the value of TTS_ns is positive, it will be used to generate the PMT transition times. * In this case, a normal distribution is used with a sigma equal to the specified value. * By default, the value is negative. * As a consequence, the PMT transition times will be generated according * the measured distribution (see JPMTTransitTimeGenerator.hh). */ JPMTParameters() { this->QE = 1.0; // [unit] this->gain = 1.0; // [unit] this->gainSpread = 0.4; // [unit] this->riseTime_ns = 7.24; // [ns] this->TTS_ns = -1.0; // [ns] this->threshold = 0.24; // [npe] this->PunderAmplified = 0.05; // this->thresholdBand = 0.12; // [npe] this->mean_ns = 4.5; // [ns] this->sigma_ns = 1.5; // [ns] this->slope = 7.0; // [ns/npe] this->saturation = 210; // [ns] this->slewing = true; // } /** * Constructor. * * \param QE relative quantum efficiency * \param gain gain [unit] * \param gainSpread gain spread [unit] * \param riseTime_ns rise time of analogue pulse [ns] * \param TTS_ns transition time spread [ns] * \param threshold threshold [npe] * \param thresholdBand threshold-band [npe] * \param mean_ns mean time-over-threshold of threshold-band hits [ns] * \param sigma_ns time-over-threshold standard deviation of threshold-band hits [ns] * \param PunderAmplified probability of underamplified hit * \param slope slope [ns/npe] * \param saturation saturation [ns] * \param slewing time slewing of analogue signal */ 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) { this->QE = QE; this->gain = gain; this->gainSpread = gainSpread; this->riseTime_ns = riseTime_ns; this->TTS_ns = TTS_ns; this->threshold = threshold; this->PunderAmplified = PunderAmplified; this->thresholdBand = thresholdBand; this->mean_ns = mean_ns; this->sigma_ns = sigma_ns; this->slope = slope; this->saturation = saturation; this->slewing = slewing; } /** * Get PMT parameters. * * \return PMT parameters */ const JPMTParameters& getPMTParameters() const { return static_cast(*this); } /** * Set PMT parameters. * * \param parameters PMT parameters */ void setPMTParameters(const JPMTParameters& parameters) { static_cast(*this) = parameters; } /** * Check validity of PMT parameters. * * \return true if valid; else false */ bool is_valid() const { if (this->QE < 0.0 || this->gain < 0.0 || this->gainSpread < 0.0 || this->threshold < 0.0 || this->thresholdBand < 0.0) { return false; } return true; } /** * Stream input of PMT parameters. * * \param in input stream * \param object PMT parameters * \return input stream */ friend inline std::istream& operator>>(std::istream& in, JPMTParameters& object) { return in >> object.QE >> object.gain >> object.gainSpread >> object.riseTime_ns >> object.TTS_ns >> object.threshold; } /** * Stream output of PMT parameters. * * \param out output stream * \param object PMT parameters * \return output stream */ friend inline std::ostream& operator<<(std::ostream& out, const JPMTParameters& object) { const JFormat format(out); out << FIXED(5,3) << object.QE << ' ' << FIXED(5,3) << object.gain << ' ' << FIXED(5,3) << object.gainSpread << ' ' << FIXED(5,2) << object.riseTime_ns << ' ' << FIXED(5,2) << object.TTS_ns << ' ' << FIXED(5,3) << object.threshold; return out; } /** * Get equation parameters. * * \return equation parameters */ static inline JEquationParameters& getEquationParameters() { static JEquationParameters equation("=", ",", "./", "#"); return equation; } /** * Set equation parameters. * * \param equation equation parameters */ static inline void setEquationParameters(const JEquationParameters& equation) { getEquationParameters() = equation; } /** * Get properties of this class. * * \param equation equation parameters */ JProperties getProperties(const JEquationParameters& equation = JPMTParameters::getEquationParameters()) { return JPMTParametersHelper(*this, equation); } /** * Get properties of this class. * * \param equation equation parameters */ JProperties getProperties(const JEquationParameters& equation = JPMTParameters::getEquationParameters()) const { return JPMTParametersHelper(*this, equation); } double QE; //!< relative quantum efficiency double gain; //!< gain [unit] double gainSpread; //!< gain spread [unit] double riseTime_ns; //!< rise time of analogue pulse [ns] double TTS_ns; //!< transition time spread [ns] double threshold; //!< threshold [npe] double PunderAmplified; //!< probability of underamplified hit double thresholdBand; //!< threshold-band [npe] double mean_ns; //!< mean time-over-threshold of threshold-band hits [ns] double sigma_ns; //!< time-over-threshold standard deviation of threshold-band hits [ns] double slope; //!< slope [ns/npe] double saturation; //!< saturation [ns] bool slewing; //!< time slewing of analogue signal private: /** * Auxiliary class for I/O of PMT parameters. */ class JPMTParametersHelper : public JProperties { public: /** * Constructor. * * \param object PMT parameters * \param equation equation parameters */ template JPMTParametersHelper(JPMTParameters_t& object, const JEquationParameters& equation) : JProperties(equation, 1) { insert(gmake_property(object.QE)); insert(gmake_property(object.gain)); insert(gmake_property(object.gainSpread)); insert(gmake_property(object.riseTime_ns)); insert(gmake_property(object.TTS_ns)); insert(gmake_property(object.threshold)); insert(gmake_property(object.PunderAmplified)); insert(gmake_property(object.thresholdBand)); insert(gmake_property(object.mean_ns)); insert(gmake_property(object.sigma_ns)); insert(gmake_property(object.slope)); insert(gmake_property(object.saturation)); insert(gmake_property(object.slewing)); } }; }; } #endif