Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #ifndef DVCS_CFF_NN_H
0002 #define DVCS_CFF_NN_H
0003 
0004 #include <ElementaryUtils/parameters/Parameters.h>
0005 #include <NumA/neural_network/neural_network/NeuralNetwork.h>
0006 #include <stddef.h>
0007 #include <complex>
0008 #include <map>
0009 #include <string>
0010 #include <utility>
0011 #include <vector>
0012 
0013 #include "../../../beans/automation/BaseObjectData.h"
0014 #include "../../../beans/gpd/GPDType.h"
0015 #include "DVCSConvolCoeffFunctionModule.h"
0016 
0017 namespace PARTONS {
0018 
0019 /**
0020  * @class DVCSCFFNN
0021  *
0022  * @brief DVCS CFFs based on neural network analysis.
0023  *
0024  * This module returns CFFs as estimated from this fit to world data: Eur.Phys.J. C79 (2019) no.7, 614
0025  *
0026  * Mean values and uncertainties should be estimated from a set of values returned by 101 replicas. To run the evaluation for
0027  * a given replica one should use either DVCSCFFNN::loadParameters() function, or DVCSCFFNN::configure() with
0028  * DVCSCFFNN::PARAMETER_NAME_REPLICA parameter (to be used also in xml).
0029  *
0030  * Mean values and uncertainties can be evaluated from a set of values using DVCSCFFNN::getMeanAndUncertainty().
0031  * Please note the procedure to remove the outliers.
0032  */
0033 class DVCSCFFNN: public DVCSConvolCoeffFunctionModule {
0034 
0035 public:
0036 
0037     static const std::string PARAMETER_NAME_REPLICA; ///< Name of parameter to set replica index via xml file.
0038 
0039     static const unsigned int classId; ///< Unique ID to automatically register the class in the registry.
0040 
0041     /**
0042      * Constructor.
0043      * See BaseObject::BaseObject and ModuleObject::ModuleObject for more details.
0044      * @param className Name of last child class.
0045      */
0046     DVCSCFFNN(const std::string &className);
0047 
0048     /**
0049      * Destructor.
0050      */
0051     virtual ~DVCSCFFNN();
0052 
0053     virtual DVCSCFFNN* clone() const;
0054 
0055     virtual void configure(const ElemUtils::Parameters &parameters);
0056     virtual void resolveObjectDependencies();
0057 
0058     virtual void prepareSubModules(
0059             const std::map<std::string, PARTONS::BaseObjectData>& subModulesData);
0060 
0061     virtual std::complex<double> computeCFF();
0062 
0063     /**
0064      * Load parameters for a given replica index.
0065      */
0066     void loadParameters(size_t replica, bool printInfo = true);
0067 
0068     /**
0069     * Set parameters.
0070     */
0071     void setParameters(const std::vector<double>& params);
0072 
0073     /**
0074      * Get neural networks.
0075      */
0076     const std::map<PARTONS::GPDType::Type,
0077             std::pair<NumA::NeuralNetwork*, NumA::NeuralNetwork*> >& getNeuralNetworks() const;
0078 
0079     /**
0080      * Evaluate mean and uncertainty for a given vector of numbers. The procedure include removing of outliers.
0081      */
0082     void getMeanAndUncertainty(const std::vector<double>& v, double& mean,
0083             double& unc) const;
0084 
0085 protected:
0086 
0087     /**
0088      * Copy constructor.
0089      * @param other Object to be copied.
0090      */
0091     DVCSCFFNN(const DVCSCFFNN &other);
0092 
0093     virtual void initModule();
0094     virtual void isModuleWellConfigured();
0095 
0096 private:
0097 
0098     /**
0099      * Build all neural networks.
0100      */
0101     void buildNeuralNetworks();
0102 
0103     /**
0104      * Build single neural network for a given GPD type and CFF RE or Im.
0105      */
0106     NumA::NeuralNetwork* buildAndConfigureSingleNeuralNetwork(
0107             PARTONS::GPDType::Type gpdType, bool isReal);
0108 
0109     /**
0110      * Evaluate mean from a given vector.
0111      */
0112     double getMean(const std::vector<double>& v) const;
0113 
0114     /**
0115      * Evaluate sigma from a given vector.
0116      */
0117     double getSigma(const std::vector<double>& v) const;
0118 
0119     /**
0120      * Remove outliers from a given vector using 3sigma rule.
0121      */
0122     size_t removeOutliers(std::vector<double>& v) const;
0123 
0124     std::map<PARTONS::GPDType::Type,
0125             std::pair<NumA::NeuralNetwork*, NumA::NeuralNetwork*> > m_neuralNetworks; ///< Neural networks
0126 
0127     std::pair<double, double> m_rangeLog10Xi; ///< Normalization range: log10xi
0128     std::pair<double, double> m_rangeT; ///< Normalization range: t
0129     std::pair<double, double> m_rangeLog10Q2; ///< Normalization range: log10Q2
0130     std::map<PARTONS::GPDType::Type, std::pair<double, double> > m_rangeXiReCFF; ///< Normalization range: xi*ReCFF
0131     std::map<PARTONS::GPDType::Type, std::pair<double, double> > m_rangeXiImCFF; ///< Normalization range: xi*ImCFF
0132 
0133     size_t m_replica; ///< Replica index.
0134 };
0135 
0136 }
0137 
0138 #endif /* DVCS_CFF_NN_H */