File indexing completed on 2026-06-02 08:51:42
0001 #ifndef CONVOL_COEFF_FUNCTION_RESULT_H
0002 #define CONVOL_COEFF_FUNCTION_RESULT_H
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include <ElementaryUtils/logger/CustomException.h>
0012 #include <ElementaryUtils/string_utils/Formatter.h>
0013 #include <ElementaryUtils/string_utils/StringUtils.h>
0014 #include <complex>
0015 #include <map>
0016 #include <string>
0017 #include <utility>
0018 #include <vector>
0019
0020 #include "../channel/ChannelType.h"
0021 #include "../gpd/GPDType.h"
0022 #include "../Result.h"
0023
0024 namespace PARTONS {
0025
0026
0027
0028
0029
0030
0031
0032
0033 template<typename KinematicType>
0034 class ConvolCoeffFunctionResult: public Result<KinematicType> {
0035
0036 public:
0037
0038
0039
0040
0041 virtual ~ConvolCoeffFunctionResult() {
0042 }
0043
0044 virtual std::string toString() const {
0045
0046 ElemUtils::Formatter formatter;
0047
0048 formatter << "\n" << Result<KinematicType>::toString() << "\n\n";
0049 formatter << "Result: " << '\n';
0050
0051 std::map<GPDType::Type, std::complex<double> >::const_iterator it;
0052
0053 for (it = m_resultsByGPDType.begin(); it != m_resultsByGPDType.end();
0054 it++) {
0055 formatter << "CFF " << GPDType(it->first).toString() << ": Re: "
0056 << (it->second).real() << " Im: " << (it->second).imag()
0057 << '\n';
0058 }
0059
0060 return formatter.str();
0061 }
0062
0063
0064
0065
0066
0067
0068 void addResult(GPDType::Type gpdType, const std::complex<double>& result) {
0069
0070
0071 std::map<GPDType::Type, std::complex<double> >::const_iterator it =
0072 m_resultsByGPDType.find(gpdType);
0073
0074
0075 if (it != m_resultsByGPDType.end()) {
0076 throw ElemUtils::CustomException(this->getClassName(), __func__,
0077 ElemUtils::Formatter() << "Result for GPDType = "
0078 << GPDType(gpdType).toString() << " exists");
0079 }
0080
0081
0082 m_resultsByGPDType.insert(std::make_pair(gpdType, result));
0083 }
0084
0085
0086
0087
0088
0089
0090 const std::complex<double>& getResult(GPDType::Type gpdType) const {
0091
0092
0093 std::map<GPDType::Type, std::complex<double> >::const_iterator it =
0094 m_resultsByGPDType.find(gpdType);
0095
0096
0097 if (it == m_resultsByGPDType.end()) {
0098 throw ElemUtils::CustomException(this->getClassName(), __func__,
0099 ElemUtils::Formatter()
0100 << "Cannot find result for GPDType = "
0101 << GPDType(gpdType).toString());
0102 }
0103
0104
0105 return (it->second);
0106 }
0107
0108
0109
0110
0111
0112
0113
0114 bool isAvailable(GPDType::Type gpdType) {
0115
0116
0117 m_it = m_resultsByGPDType.find(gpdType);
0118
0119
0120 return (m_it != m_resultsByGPDType.end());
0121 }
0122
0123
0124
0125
0126
0127
0128 std::complex<double> getLastAvailable() const {
0129 return m_it->second;
0130 }
0131
0132
0133
0134
0135
0136 std::vector<GPDType> listGPDTypeComputed() const {
0137
0138
0139 std::vector<GPDType> list;
0140
0141
0142 std::map<GPDType::Type, std::complex<double> >::const_iterator it;
0143
0144
0145 if (m_resultsByGPDType.size() != 0) {
0146
0147 for (it = m_resultsByGPDType.begin();
0148 it != m_resultsByGPDType.end(); ++it) {
0149 list.push_back(it->first);
0150 }
0151 }
0152
0153
0154 return list;
0155 }
0156
0157
0158
0159
0160
0161
0162
0163
0164 const std::map<GPDType::Type, std::complex<double> >& getResultsByGpdType() const {
0165 return m_resultsByGPDType;
0166 }
0167
0168
0169
0170
0171 void setResultsByGpdType(
0172 const std::map<GPDType::Type, std::complex<double> >& resultsByGpdType) {
0173 m_resultsByGPDType = resultsByGpdType;
0174 }
0175
0176 protected:
0177
0178
0179
0180
0181 ConvolCoeffFunctionResult(const std::string &className,
0182 ChannelType::Type channelType) :
0183 Result<KinematicType>(className, channelType) {
0184 }
0185
0186
0187
0188
0189
0190 ConvolCoeffFunctionResult(const std::string &className,
0191 ChannelType::Type channelType, const KinematicType& kinematic) :
0192 Result<KinematicType>(className, channelType, kinematic) {
0193 }
0194
0195
0196
0197
0198
0199 ConvolCoeffFunctionResult(const ConvolCoeffFunctionResult& other) :
0200 Result<KinematicType>(other) {
0201 m_resultsByGPDType = other.m_resultsByGPDType;
0202 }
0203
0204
0205
0206
0207 std::map<GPDType::Type, std::complex<double> > m_resultsByGPDType;
0208
0209
0210
0211
0212 std::map<GPDType::Type, std::complex<double> >::const_iterator m_it;
0213 };
0214
0215 }
0216
0217 #endif