Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-02 08:51:43

0001 #ifndef RESULT_H
0002 #define RESULT_H
0003 
0004 /**
0005  * @file Result.h
0006  * @author: Bryan BERTHOU (SPhN / CEA Saclay)
0007  * @date 12 November 2015
0008  * @version 1.0
0009  */
0010 
0011 #include <ElementaryUtils/string_utils/Formatter.h>
0012 #include <string>
0013 
0014 #include "channel/ChannelType.h"
0015 #include "system/ResultInfo.h"
0016 
0017 namespace PARTONS {
0018 
0019 /**
0020  * @class Result
0021  *
0022  * @brief Base class for all result-like classes.
0023  *
0024  * This class is used as a base (abstract) class for all classes storing result information, like e.g. GPDResult or ObservableResult.
0025  */
0026 template<typename KinematicType>
0027 class Result: public BaseObject {
0028 
0029 public:
0030 
0031     /**
0032      * Destructor.
0033      */
0034     virtual ~Result() {
0035     }
0036 
0037     virtual std::string toString() const {
0038 
0039         ElemUtils::Formatter formatter;
0040 
0041         formatter << BaseObject::toString() << " ChannelType: "
0042                 << ChannelType(m_channelType).toString()
0043                 << " ComputationModuleName: " << m_computationModuleName
0044                 << " IndexId: " << getIndexId() << "\n\n";
0045         formatter << "Kinematics: " << m_kinematic.toString();
0046 
0047         return formatter.str();
0048     }
0049 
0050     /**
0051      * Relation operator that checks if the value of left operand is less than the value of right operand (in this case returned is this->m_kinematic < other.m_kinematic).
0052      * Used by std::sort function.
0053      * @param other Right hand value.
0054      * @return True if the value of left operand is less than the value of right operand, otherwise false.
0055      */
0056     bool operator <(const Result<KinematicType> &other) const {
0057         return (m_kinematic < other.m_kinematic);
0058     }
0059 
0060     //********************************************************
0061     //*** SETTERS AND GETTERS ********************************
0062     //********************************************************
0063 
0064     /**
0065      * Get channel type.
0066      */
0067     ChannelType::Type getChannelType() const {
0068         return m_channelType;
0069     }
0070 
0071     /**
0072      * Set name of module used to evaluate this result.
0073      */
0074     void setComputationModuleName(const std::string& moduleName) {
0075         m_computationModuleName = moduleName;
0076     }
0077 
0078     /**
0079      * Get name of module used to evaluate this result.
0080      */
0081     const std::string& getComputationModuleName() const {
0082         return m_computationModuleName;
0083     }
0084 
0085     /**
0086      * Set information on this result.
0087      */
0088     void setResultInfo(const ResultInfo& resultInfo) {
0089         m_resultInfo = resultInfo;
0090     }
0091 
0092     /**
0093      * Get information on this result.
0094      */
0095     const ResultInfo& getResultInfo() const {
0096         return m_resultInfo;
0097     }
0098 
0099     /**
0100      * Set kinematics associated to this result.
0101      */
0102     void setKinematic(const KinematicType& kinematic) {
0103         m_kinematic = kinematic;
0104     }
0105 
0106     /**
0107      * Get reference to kinematics associated to this result.
0108      */
0109     const KinematicType& getKinematic() const {
0110         return m_kinematic;
0111     }
0112 
0113 protected:
0114 
0115     /**
0116      * Default constructor.
0117      * @param className Name of class to be associated to BaseObject (see BaseObject::m_className variable).
0118      * @param channelType Channel type.
0119      */
0120     Result(const std::string &className, ChannelType::Type channelType) :
0121             BaseObject(className), m_channelType(channelType), m_computationModuleName(
0122                     "UNDEFINED") {
0123     }
0124 
0125     /**
0126      * Assignment constructor.
0127      * @param kinematic Kinematics to be assigned.
0128      */
0129     Result(const std::string &className, ChannelType::Type channelType,
0130             const KinematicType& kinematic) :
0131             BaseObject(className), m_channelType(channelType), m_computationModuleName(
0132                     "UNDEFINED"), m_kinematic(kinematic) {
0133     }
0134 
0135     /**
0136      * Copy constructor.
0137      * @param other Object to be copied.
0138      */
0139     Result(const Result &other) :
0140             BaseObject(other), m_channelType(other.m_channelType), m_computationModuleName(
0141                     other.m_computationModuleName), m_resultInfo(
0142                     other.m_resultInfo), m_kinematic(other.m_kinematic) {
0143     }
0144 
0145     /**
0146      * Channel type.
0147      */
0148     ChannelType::Type m_channelType;
0149 
0150     /**
0151      * Name of module used to evaluate this result.
0152      */
0153     std::string m_computationModuleName;
0154 
0155     /**
0156      * Information on this result.
0157      */
0158     ResultInfo m_resultInfo;
0159 
0160     /**
0161      * Kinematics associated to this result.
0162      */
0163     KinematicType m_kinematic;
0164 };
0165 
0166 } /* namespace PARTONS */
0167 
0168 #endif /* RESULT_H */