#ifndef __JDETECTOR__JDETECTORPARAMETERS__ #define __JDETECTOR__JDETECTORPARAMETERS__ #include "JLang/JParameter.hh" #include "JLang/JException.hh" #include "JLang/JComparable.hh" #include "Jeep/JProperties.hh" /** * \author mdejong */ namespace JDETECTOR {} namespace JPP { using namespace JDETECTOR; } namespace JDETECTOR { using JLANG::JParameter; using JLANG::JException; using JLANG::JComparable; /** * Data structure for parameters for detector geometry. */ class JDetectorParameters : public JComparable { public: /** * Default constructor. */ JDetectorParameters() : detectorType (), floorDistance_m(), numberOfFloors (), lineDistance_m (), numberOfLines () {} JParameter detectorType; JParameter floorDistance_m; JParameter numberOfFloors; JParameter lineDistance_m; JParameter numberOfLines; /** * Get status of parameters. * * \return true if all parameters have been defined; else false */ const bool isDefined() const { return (detectorType .isDefined() && floorDistance_m.isDefined() && numberOfFloors .isDefined() && lineDistance_m .isDefined() && numberOfLines .isDefined()); } /** * Compare detector parameters. * * The hierarchy is: * 1) detector type; * 2) number of lines; * 3) number of floors; * 4) line distance; * 5) floor distance; * * \param detector detector parameters * \return true is first is less than second; else false */ bool less(const JDetectorParameters& detector) const { if (detectorType == detector.detectorType) if (numberOfLines == detector.numberOfLines) if (numberOfFloors == detector.numberOfFloors) if (lineDistance_m == detector.lineDistance_m) return floorDistance_m < detector.floorDistance_m; else return lineDistance_m < detector.lineDistance_m; else return numberOfFloors < detector.numberOfFloors; else return numberOfLines < detector.numberOfLines; else return detectorType < detector.detectorType; } }; /** * Auxiliary class for I/O of JDetectorParameters data structure. */ class JDetectorParametersHelper : public JProperties { public: /** * Constructor. * * \param detector detector parameters */ JDetectorParametersHelper(JDetectorParameters& detector) : JProperties(JEquationParameters("= ", "\n;", "", ""), 2) { insert(gmake_property(detector.detectorType)); insert(gmake_property(detector.floorDistance_m)); insert(gmake_property(detector.numberOfFloors)); insert(gmake_property(detector.lineDistance_m)); insert(gmake_property(detector.numberOfLines)); } }; } #endif