Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #ifndef OBSERVABLE_RESULT_H
0002 #define OBSERVABLE_RESULT_H
0003 
0004 /**
0005  * @file ObservableResult.h
0006  * @author: Bryan BERTHOU (SPhN / CEA Saclay)
0007  * @date September 21, 2015
0008  * @version 1.0
0009  */
0010 
0011 #include <ElementaryUtils/logger/CustomException.h>
0012 #include <ElementaryUtils/string_utils/Formatter.h>
0013 #include <ElementaryUtils/string_utils/StringUtils.h>
0014 #include <string>
0015 
0016 #include "../../utils/type/PhysicalType.h"
0017 #include "../channel/ChannelType.h"
0018 #include "../Result.h"
0019 
0020 namespace PARTONS {
0021 
0022 /**
0023  * @class ObservableResult
0024  *
0025  * @brief Abstract class representing single observable result.
0026  *
0027  * This abstract class is used to store results of a single observable computation.
0028  */
0029 template<typename KinematicType>
0030 class ObservableResult: public Result<KinematicType> {
0031 
0032 public:
0033 
0034     /**
0035      * Destructor.
0036      */
0037     virtual ~ObservableResult() {
0038     }
0039 
0040     virtual std::string toString() const {
0041 
0042         ElemUtils::Formatter formatter;
0043 
0044         formatter << "\n" << Result<KinematicType>::toString() << "\n\n";
0045         formatter << "Result: " << m_value.toString();
0046         formatter << '\n';
0047 
0048         return formatter.str();
0049     }
0050 
0051     //********************************************************
0052     //*** SETTERS AND GETTERS ********************************
0053     //********************************************************
0054 
0055     /**
0056      * Get value of result.
0057      */
0058     const PhysicalType<double>& getValue() const {
0059         return m_value;
0060     }
0061 
0062     /**
0063      * Set value of result.
0064      */
0065     void setValue(const PhysicalType<double>& value) {
0066         m_value = value;
0067     }
0068 
0069 protected:
0070 
0071     /**
0072      * Default constructor.
0073      */
0074     ObservableResult(const std::string &className,
0075             ChannelType::Type channelType) :
0076             Result<KinematicType>(className, channelType) {
0077     }
0078 
0079     /**
0080      * Assignment constructor.
0081      * @param value Value to be assigned.
0082      */
0083     ObservableResult(const std::string &className,
0084             ChannelType::Type channelType, const PhysicalType<double>& value) :
0085             Result<KinematicType>(className, channelType), m_value(value) {
0086     }
0087 
0088     /**
0089      * Assignment constructor.
0090      * @param kinematic Observable kinematics to be assigned.
0091      */
0092     ObservableResult(const std::string &className,
0093             ChannelType::Type channelType, const KinematicType& kinematic) :
0094             Result<KinematicType>(className, channelType, kinematic) {
0095     }
0096 
0097     /**
0098      * Assignment constructor.
0099      * @param value Value to be assigned.
0100      * @param kinematic Observable kinematics to be assigned.
0101      */
0102     ObservableResult(const std::string &className,
0103             ChannelType::Type channelType, const PhysicalType<double>& value,
0104             const KinematicType& kinematic) :
0105             Result<KinematicType>(className, channelType, kinematic), m_value(
0106                     value) {
0107     }
0108 
0109     /**
0110      * Copy constructor.
0111      * @param other Object to be copied.
0112      */
0113     ObservableResult(const ObservableResult& other) :
0114             Result<KinematicType>(other), m_value(other.m_value) {
0115     }
0116 
0117     /**
0118      * Value of result.
0119      */
0120     PhysicalType<double> m_value;
0121 };
0122 
0123 } /* namespace PARTONS */
0124 
0125 #endif /* OBSERVABLE_RESULT_H */