File indexing completed on 2026-06-02 08:51:44
0001 #ifndef CONVOL_COEFF_FUNCTION_MODULE_H
0002 #define CONVOL_COEFF_FUNCTION_MODULE_H
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include <ElementaryUtils/logger/CustomException.h>
0012 #include <ElementaryUtils/parameters/Parameters.h>
0013 #include <ElementaryUtils/string_utils/Formatter.h>
0014 #include <map>
0015 #include <string>
0016 #include <utility>
0017
0018 #include "../../beans/automation/BaseObjectData.h"
0019 #include "../../beans/channel/ChannelType.h"
0020 #include "../../beans/gpd/GPDType.h"
0021 #include "../../beans/List.h"
0022 #include "../../ModuleObjectFactory.h"
0023 #include "../../Partons.h"
0024 #include "../../utils/type/PhysicalUnit.h"
0025 #include "../gpd/GPDModule.h"
0026 #include "../MathIntegratorModule.h"
0027
0028 namespace PARTONS {
0029
0030
0031
0032
0033
0034
0035 template<typename KinematicType, typename ResultType>
0036 class ConvolCoeffFunctionModule: public ModuleObject,
0037 public MathIntegratorModule {
0038
0039 public:
0040
0041
0042
0043
0044 virtual ~ConvolCoeffFunctionModule() {
0045
0046 if (m_pGPDModule != 0) {
0047 setGPDModule(0);
0048 m_pGPDModule = 0;
0049 }
0050 }
0051
0052 virtual ConvolCoeffFunctionModule* clone() const = 0;
0053
0054 virtual std::string toString() const {
0055 return ModuleObject::toString();
0056 }
0057
0058 virtual void resolveObjectDependencies() {
0059 ModuleObject::resolveObjectDependencies();
0060 }
0061
0062 virtual void run() {
0063 throw ElemUtils::CustomException("Thread", __func__,
0064 "This must be implemented in daughter class");
0065 }
0066
0067 virtual void configure(const ElemUtils::Parameters ¶meters) {
0068
0069 ModuleObject::configure(parameters);
0070 configureIntegrator(parameters);
0071 }
0072
0073 virtual void prepareSubModules(
0074 const std::map<std::string, BaseObjectData>& subModulesData) {
0075
0076
0077 ModuleObject::prepareSubModules(subModulesData);
0078
0079
0080 std::map<std::string, BaseObjectData>::const_iterator it;
0081
0082
0083 if (isGPDModuleDependent()) {
0084
0085
0086 it = subModulesData.find(GPDModule::GPD_MODULE_CLASS_NAME);
0087
0088
0089 if (it != subModulesData.end()) {
0090
0091
0092 if (m_pGPDModule != 0) {
0093
0094 setGPDModule(0);
0095 m_pGPDModule = 0;
0096 }
0097
0098
0099 if (m_pGPDModule == 0) {
0100
0101 m_pGPDModule =
0102 Partons::getInstance()->getModuleObjectFactory()->newGPDModule(
0103 (it->second).getModuleClassName());
0104
0105 info(__func__,
0106 ElemUtils::Formatter()
0107 << "Configured with GPDModule = "
0108 << m_pGPDModule->getClassName());
0109
0110 m_pGPDModule->configure((it->second).getParameters());
0111 m_pGPDModule->prepareSubModules(
0112 (it->second).getSubModules());
0113 }
0114
0115 } else {
0116
0117
0118 throw ElemUtils::CustomException(getClassName(), __func__,
0119 ElemUtils::Formatter() << getClassName()
0120 << " is GPDModule dependent and you have not provided one");
0121 }
0122 }
0123 }
0124
0125
0126
0127
0128
0129
0130
0131 virtual ResultType compute(const KinematicType& kinematic,
0132 const List<GPDType>& gpdType) = 0;
0133
0134
0135
0136
0137
0138 virtual List<GPDType> getListOfAvailableGPDTypeForComputation() const = 0;
0139
0140
0141
0142
0143
0144
0145 GPDModule* getGPDModule() const {
0146 return m_pGPDModule;
0147 }
0148
0149
0150
0151
0152 void setGPDModule(GPDModule* gpdModule) {
0153
0154 m_pModuleObjectFactory->updateModulePointerReference(m_pGPDModule,
0155 gpdModule);
0156 m_pGPDModule = gpdModule;
0157 }
0158
0159
0160
0161
0162 bool isGPDModuleDependent() const {
0163 return m_isGPDModuleDependent;
0164 }
0165
0166
0167
0168
0169 void setIsGPDModuleDependent(bool isGPDModuleDependent) {
0170 m_isGPDModuleDependent = isGPDModuleDependent;
0171 }
0172
0173 protected:
0174
0175
0176
0177
0178
0179
0180
0181
0182 ConvolCoeffFunctionModule(const std::string &className,
0183 ChannelType::Type channelType) :
0184 ModuleObject(className, channelType), MathIntegratorModule(), m_xi(
0185 0.), m_t(0.), m_MuF2(0.), m_MuR2(0.), m_currentGPDComputeType(
0186 GPDType::UNDEFINED), m_pGPDModule(0), m_isGPDModuleDependent(
0187 true) {
0188 }
0189
0190
0191
0192
0193
0194 ConvolCoeffFunctionModule(const ConvolCoeffFunctionModule &other) :
0195 ModuleObject(other), MathIntegratorModule(other), m_xi(other.m_xi), m_t(
0196 other.m_t), m_MuF2(other.m_MuF2), m_MuR2(other.m_MuR2), m_currentGPDComputeType(
0197 other.m_currentGPDComputeType), m_pGPDModule(0), m_isGPDModuleDependent(
0198 other.m_isGPDModuleDependent) {
0199
0200 if (other.m_pGPDModule != 0) {
0201 m_pGPDModule = m_pModuleObjectFactory->cloneModuleObject(
0202 other.m_pGPDModule);
0203 }
0204 }
0205
0206
0207
0208
0209
0210 virtual void setKinematics(const KinematicType& kinematic) {
0211
0212 m_xi = kinematic.getXi().makeSameUnitAs(PhysicalUnit::NONE).getValue();
0213 m_t = kinematic.getT().makeSameUnitAs(PhysicalUnit::GEV2).getValue();
0214 m_MuF2 =
0215 kinematic.getMuF2().makeSameUnitAs(PhysicalUnit::GEV2).getValue();
0216 m_MuR2 =
0217 kinematic.getMuR2().makeSameUnitAs(PhysicalUnit::GEV2).getValue();
0218 }
0219
0220
0221
0222
0223 void setCurrentGPDType(GPDType::Type gpdType) {
0224 m_currentGPDComputeType = gpdType;
0225 }
0226
0227 virtual void initModule() {
0228 }
0229
0230 virtual void isModuleWellConfigured() {
0231
0232 if (m_xi < 0. || m_xi > 1.) {
0233 warn(__func__,
0234 ElemUtils::Formatter() << "Input value of Xi = " << m_xi
0235 << " do not lay between 0 and 1.");
0236 }
0237
0238 if (m_t > 0) {
0239 warn(__func__,
0240 ElemUtils::Formatter() << " Input value of t = " << m_t
0241 << " is not <= 0.");
0242 }
0243
0244 if (m_MuF2 < 0) {
0245 warn(__func__,
0246 ElemUtils::Formatter() << "Input value of muF2 = " << m_MuF2
0247 << " is not > 0.");
0248 }
0249
0250 if (m_MuR2 < 0) {
0251 warn(__func__,
0252 ElemUtils::Formatter() << "Input value of muR2 = " << m_MuR2
0253 << " is not > 0.");
0254 }
0255
0256 if (isGPDModuleDependent() && m_pGPDModule == 0) {
0257 throw ElemUtils::CustomException(this->getClassName(), __func__,
0258 "m_pGPDModule is NULL");
0259 }
0260 }
0261
0262
0263
0264
0265 void convolCoeffFunctionResultToStdVector(const ResultType& r, std::vector<double>& v) const {
0266
0267 std::vector<GPDType> gpds = r.listGPDTypeComputed();
0268
0269 for (std::vector<GPDType>::const_iterator it = gpds.begin(); it != gpds.end(); it++) {
0270
0271 const std::complex<double>& e = r.getResult(*it);
0272
0273 v.push_back(e.real());
0274 v.push_back(e.imag());
0275 }
0276 }
0277
0278 double m_xi;
0279 double m_t;
0280 double m_MuF2;
0281 double m_MuR2;
0282
0283 GPDType::Type m_currentGPDComputeType;
0284
0285 GPDModule* m_pGPDModule;
0286
0287 bool m_isGPDModuleDependent;
0288 };
0289
0290 }
0291
0292 #endif