Commit 4932b8fc authored by Arkadiusz P. Trawinski's avatar Arkadiusz P. Trawinski
Browse files

Splitting MellinMoment class into abstract class MellinMomentModule and

MellinMomentFromGPD class.
parent 8774d43c
#ifndef MELLIN_MOMENT_H
#define MELLIN_MOMENT_H
/**
* @file MellinMomentFromGPD.h
* @author: Arkadiusz P. Trawiński (DPhN/CEA-Saclay & CPHT/École polytechnique)
* @date 22 March 2019
* @version 1.0
*/
#include <partons/beans/gpd/GPDType.h>
#include <partons/modules/gpd/GPDModule.h>
#include <partons/beans/List.h>
#include <partons/beans/QuarkFlavor.h>
#include <partons/modules/MathIntegratorModule.h>
#include <partons/ModuleObject.h>
#include <vector>
#include "MellinMomentKinematic.h"
#include "MellinMomentModule.h"
#include "../parton_value/QuarkValue.h"
#include "../parton_value/GluonValue.h"
#include "../parton_value/PartonValues.h"
namespace PARTONS {
/**
* @class MellinMomentFromGPD
*
* @brief Class representing single computation of Mellin Moment from GPD.
*
* This class is used to compute Mellin Moment for a specific n, GPD type, GPD model and for both quarks and gluons.
*/
class MellinMomentFromGPD: public MellinMomentModule, public MathIntegratorModule {
public:
static const std::string MELLIN_MOMENT_MODULE_CLASS_NAME; ///< Type of the module in XML automation.
static const std::string MELLIN_MOMENT_MODULE_GPD_TYPE; ///< Parameter used in configure() or XML automation to set the type of the GPD to compute.
/**
* ID assigned by BaseObjectRegistry.
*/
static const unsigned int classId;
/**
* Default constructor.
* @param className Name of class.
*/
MellinMomentFromGPD(const std::string &className);
virtual MellinMomentFromGPD* clone() const;
void virtual configure(const ElemUtils::Parameters &parameters);
GPDModule* getGPDModule() const;
void setGPDModule(GPDModule* pGPDModel);
protected:
virtual void isModuleWellConfigured();
virtual void initModule();
MellinMomentFromGPD(const MellinMomentFromGPD &other);
private:
GPDModule* m_pGPDModel; ///< Pointer to GPD model to use.
NumA::FunctionType1D* m_pint; ///< Functor related to integrant.
virtual double compute(MellinMomentKinematic mKinematic);
double integrant(double x, std::vector<double> par);
virtual List<QuarkFlavor> getQuarkFlavorList(MellinMomentKinematic mKinematic, const GPDType &gpdType);
}
;
} /* namespace PARTONS */
#endif /* MELLIN_MOMENT_H */
#ifndef MELLIN_MOMENT_H
#define MELLIN_MOMENT_H
#ifndef MELLIN_MOMENT_MODULE_H
#define MELLIN_MOMENT_MODULE_H
/**
* @file MellinMomentResult.h
* @author: Arkadiusz P. Trawiński (DPhN/CEA-Saclay & CPHT/École polytechnique)
* @file MellinMomentModule.h
* @author: Arkadiusz P. Trawiński (DPhN/CEA-Saclay & CPHT/École polytechnique)
* @date 22 March 2019
* @version 1.0
*/
......@@ -24,86 +24,83 @@
namespace PARTONS {
/**
* @class MellinMoment
* @class MellinMomentModule
*
* @brief Class representing single computation of Mellin Moment.
* @brief Abstract class representing single computation of Mellin Moment.
*
* This class is used to compute Mellin Moment for a specific n, GPD type, GPD model and for both quarks and gluons.
*/
class MellinMoment: public ModuleObject, public MathIntegratorModule {
class MellinMomentModule: public ModuleObject {
public:
static const std::string MELLIN_MOMENT_MODULE_CLASS_NAME; ///< Type of the module in XML automation.
static const std::string MELLIN_MOMENT_MODULE_GPD_TYPE; ///< Parameter used in configure() or XML automation to set the type of the GPD to compute.
static const std::string MELLIN_MOMENT_MODULE_CLASS_NAME; ///< Type of the module in XML automation.
static const std::string PARAMETER_NAME_MELLIN_MODEL_MODULE_N; ///< Index of the Mellin Model in XML automation.
/**
* ID assigned by BaseObjectRegistry.
*/
static const unsigned int classId;
/**
* Default constructor.
* @param className Name of class.
*/
MellinMomentModule(const std::string &className);
/**
* ID assigned by BaseObjectRegistry.
*/
static const unsigned int classId;
/**
* Default constructor.
* @param className Name of class.
* Default destructor.
*/
MellinMoment(const std::string &className);
virtual ~MellinMomentModule();
virtual MellinMoment* clone() const;
virtual MellinMomentModule* clone() const = 0;
void configure(const ElemUtils::Parameters &parameters);
/*
* @param n index of Mellin Moment.
* @param mKinematic Mellin Moment kinematic.
* @param pGPDModel GPD model to use.
* @param mtype Type of GPD to compute.
* @return Result of \f$n\f$-th Mellin Moment computation for all avaible quark flavors and gluon.
*/
PartonValues compute(int n, MellinMomentKinematic mKinematic,
GPDModule* pGPDModel, GPDType mtype);
PartonValues computeAll(MellinMomentKinematic mKinematic,GPDType mGPDtype);
/*
* @param n index of Mellin Moment.
* @param mKinematic Mellin Moment kinematic.
* @param pGPDModel GPD model to use.
* @param mtype Type of GPD to compute.
* @return \f$n\f$-th gluon Mellin Moment, where \f$n\f$-th means \f$f_n^g = \int dx x^{n-2} f^g(x) \f$-th
*/
GluonValue computeGluonValue(int n, MellinMomentKinematic mKinematic,
GPDModule* pGPDModel, GPDType mtype);
GluonValue computeGluonValue(MellinMomentKinematic mKinematic,GPDType mtype);
/*
* @param n index of Mellin Moment.
* @param mKinematic Mellin Moment kinematic.
* @param pGPDModel GPD model to use.
* @param mtype Type of GPD to compute.
* @param mflavor Flavor of quark.
* @return \f$n\f$-th quark Mellin Moment of flavor \f$mflavor\f$, where \f$n\f$-th means \f$f_n^1 = \int dx x^{n-1} f^g(x) \f$-th
*/
QuarkValue computeQuarkValue(int n, MellinMomentKinematic mKinematic,
GPDModule* pGPDModel, GPDType mtype, QuarkFlavor mflavor);
QuarkValue computeQuarkValue(MellinMomentKinematic mKinematic,GPDType mtype, QuarkFlavor mflavor);
int getN();
void setN(int n);
protected:
virtual void isModuleWellConfigured();
virtual void initModule();
MellinMoment(const MellinMoment &other);
MellinMomentModule(const MellinMomentModule &other);
private:
int m_n; ///< Mellin Moment index
bool m_gluon; ///< If compute for gluon.
QuarkFlavor m_flavor; ///< For witch quark flavor compute.
GPDType m_type; ///< Witch type of GPD compute.
GPDModule* m_pGPDModel; ///< Pointer to GPD model to use.
NumA::FunctionType1D* m_pint; ///< Functor related to integrant.
double compute(int n, MellinMomentKinematic mKinematic,
GPDModule* pGPDModel);
virtual List<QuarkFlavor> getQuarkFlavorList(MellinMomentKinematic mKinematic, const GPDType &gpdType) = 0;
double integrant(double x, std::vector<double> par);
private:
virtual double compute(MellinMomentKinematic mKinematic) = 0;
List<QuarkFlavor> getQuarkFlavorList(MellinMomentKinematic mKinematic, GPDModule* pGPDModule,
const GPDType &gpdType);
}
;
} /* namespace PARTONS */
#endif /* MELLIN_MOMENT_H */
#endif /* MELLIN_MOMENT_MODULE_H */
......@@ -16,6 +16,7 @@
#include "MellinMomentKinematic.h"
#include "MellinMomentResult.h"
#include "MellinMomentModule.h"
namespace PARTONS {
class MellinMoment;
......@@ -60,32 +61,28 @@ public:
virtual void resolveObjectDependencies();
/**
* Computes n-th Mellin moment of GPD model at specific kinematic.
* Computes n-th Mellin moment of list GPD types at specific kinematic.
*
* @param n index of Mellin Moment.
* @param kinematic Mellin Moment kinematic.
* @param pGPDModule GPDModule to use.
* @param gpdType List of GPDType to compute. Default: all the GPDTypes available with the GPDModule.
* @return GPDResult
* @param pMellinModule MellinMomentModule to use.
* @param gpdType List of GPDType to compute. Default: all the GPDTypes available with the MellinMomentModule.
* @return MellinMomentResult
*/
MellinMomentResult compute(int n, const MellinMomentKinematic &kinematic,
GPDModule* pGPDModule, const List<GPDType> & gpdType =
List<GPDType>()) const;
MellinMomentResult compute(const MellinMomentKinematic &kinematic, MellinMomentModule* pMellinModule,
const List<GPDType> & gpdType = List<GPDType>()) const;
/**
* Computes n-th Mellin moments of GPD model for a list of kinematics.
*
* @param n index of Mellin Moment.
* @param kinematicList List of GPDKinematics.
* @param pGPDModule GPDModule to use for the computation.
* @param gpdTypeList List of GPDType to compute. Default: all the GPDTypes available with the GPDModule.
* @param kinematicList List of MellinMomentKinematic.
* @param pMellinModule MellinMomentModule to use.
* @param gpdTypeList List of GPDType to compute. Default: all the GPDTypes available with the MellinMomentModule.
* @param storeInDB Boolean to store the results and kinematics on the database. Default: false.
* @return List of GPDResults.
*/
List<MellinMomentResult> computeManyKinematic(int n,
const List<MellinMomentKinematic> &kinematicList, GPDModule* pGPDModule,
List<MellinMomentResult> computeManyKinematic(const List<MellinMomentKinematic> &kinematicList, MellinMomentModule* pMellinModule,
const List<GPDType> &gpdTypeList = List<GPDType>(),
const bool storeInDB = 0);
const bool storeInDB = false);
/**
* Method used in automation to compute given tasks.
......@@ -147,13 +144,13 @@ private:
* @param gpdTypeList List of desired GPD types to compute.
* @return List of GPD types.
*/
List<GPDType> getFinalGPDTypeList(GPDModule* pGPDModule,
List<GPDType> getFinalGPDTypeList(MellinMomentModule* pMellinModule,
const List<GPDType> &gpdTypeList) const;
List<GPDType> getGPDTypeList(GPDModule* pGPDModule,
List<GPDType> getGPDTypeList(MellinMomentModule* pMellinModule,
const List<GPDType> &gpdTypeList) const;
List<QuarkFlavor> getQuarkFlavorList(GPDModule* pGPDModule,
List<QuarkFlavor> getQuarkFlavorList(MellinMomentModule* pMellinModule,
const GPDType &gpdType) const;
};
......
......@@ -41,13 +41,15 @@
#include <vector>
#include "../include/mellin_moment/MellinMomentKinematic.h"
#include "../include/mellin_moment/MellinMoment.h"
#include "../include/mellin_moment/MellinMomentModule.h"
#include "../include/mellin_moment/MellinMomentFromGPD.h"
#include "../include/mellin_moment/MellinMomentService.h"
void computeSingleKinematicsForMellinMoment() {
// Create a GPDKinematic(x, xi, t, MuF2, MuR2) to compute
// Create a MellinMomentKinematic(xi, t, MuF2, MuR2) to compute
PARTONS::MellinMomentKinematic mkinematic(0.2, -0.1, 2., 2.);
// Create GPD module with the BaseModuleFactory
......@@ -59,14 +61,36 @@ void computeSingleKinematicsForMellinMoment() {
formatter << '\n';
PARTONS::MellinMoment moment;
// Create Mellin Moment Module module with the BaseModuleFactory
PARTONS::MellinMomentFromGPD* pMoment = static_cast<PARTONS::MellinMomentFromGPD*>(
PARTONS::Partons::getInstance()->getModuleObjectFactory()->newModuleObject(
PARTONS::MellinMomentFromGPD::classId));
pMoment->setGPDModule(pGPDModel);
pMoment->setN(2);
formatter << "Mellin Moments: " << '\n' << pMoment->computeGluonValue(mkinematic, PARTONS::GPDType::H).toString();
formatter << pMoment->computeQuarkValue(mkinematic, PARTONS::GPDType::H,PARTONS::QuarkFlavor::UNDEFINED).toString() << '\n';
formatter << pMoment->computeAll(mkinematic, PARTONS::GPDType::H).toString() << '\n';
// Retrieve Mellin Moment service
//PARTONS::MellinMomentService* pMellinService = static_cast<PARTONS::MellinMomentService*>(PARTONS::Partons::getInstance()->getServiceObjectRegistry()->get(PARTONS::MellinMomentService::classId));
// Run computation
PARTONS::List<PARTONS::GPDType> gpdTypeList;
//gpdTypeList.add(PARTONS::GPDType::H);
gpdTypeList.add(PARTONS::GPDType::E);
gpdTypeList.add(PARTONS::GPDType::Et);
gpdTypeList.add(PARTONS::GPDType::Ht);
//PARTONS::MellinMomentResult result = pMellinService->compute(mkinematic,pGPDModel,gpdTypeList);
// Print results
//PARTONS::Partons::getInstance()->getLoggerManager()->info("main", __func__, result.toString());
formatter << "Mellin Moments: " << '\n'
<< moment.computeGluonValue(2, mkinematic, pGPDModel, PARTONS::GPDType::H).toString()
<< '\n';
formatter << moment.computeQuarkValue(1, mkinematic, pGPDModel, PARTONS::GPDType::H,
PARTONS::QuarkFlavor::UNDEFINED).toString() << '\n';
// Print results
PARTONS::Partons::getInstance()->getLoggerManager()->info("main", __func__,
formatter.str());
......@@ -77,6 +101,12 @@ void computeSingleKinematicsForMellinMoment() {
pGPDModel, 0);
pGPDModel = 0;
// Remove pointer references
// Module pointers are managed by PARTONS
PARTONS::Partons::getInstance()->getModuleObjectFactory()->updateModulePointerReference(
pMoment, 0);
pMoment = 0;
}
void computeSingleKinematicsForGPD() {
......
#include "../../include/mellin_moment/MellinMoment.h"
#include "../../include/mellin_moment/MellinMomentFromGPD.h"
#include <ElementaryUtils/parameters/Parameters.h>
#include <ElementaryUtils/string_utils/Formatter.h>
#include <NumA/functor/one_dimension/Functor1D.h>
#include <NumA/integration/one_dimension/Integrator1D.h>
......@@ -9,105 +10,61 @@
#include <partons/beans/parton_distribution/PartonDistribution.h>
#include <partons/beans/parton_distribution/QuarkDistribution.h>
#include <partons/BaseObjectRegistry.h>
#include <partons/ModuleObjectFactory.h>
#include <cmath>
#include <iostream>
#include <string>
namespace PARTONS {
const unsigned int MellinMoment::classId = BaseObjectRegistry::getInstance()->registerBaseObject(new MellinMoment("MellinMomentModule"));
const unsigned int MellinMomentFromGPD::classId =
BaseObjectRegistry::getInstance()->registerBaseObject(
new MellinMomentFromGPD("MellinMomentFromGPD"));
const std::string MellinMoment::MELLIN_MOMENT_MODULE_CLASS_NAME =
"MellinMomentModule";
const std::string MellinMoment::MELLIN_MOMENT_MODULE_GPD_TYPE =
const std::string MellinMomentFromGPD::MELLIN_MOMENT_MODULE_CLASS_NAME =
"MellinMomentFromGPD";
const std::string MellinMomentFromGPD::MELLIN_MOMENT_MODULE_GPD_TYPE =
"GPD_MODULE_GPD_TYPE";
MellinMoment::MellinMoment(const std::string &className) :
ModuleObject(className) {
m_n = 0;
m_gluon = false;
MellinMomentFromGPD::MellinMomentFromGPD(const std::string &className) :
MellinMomentModule(className) {
m_pGPDModel = 0;
m_pint = NumA::Integrator1D::newIntegrationFunctor(this,
&MellinMoment::integrant);
&MellinMomentFromGPD::integrant);
NumA::IntegratorType1D::Type integratorType = NumA::IntegratorType1D::DEXP;
setIntegrator(integratorType);
}
MellinMoment::MellinMoment(const MellinMoment& other) :
ModuleObject(other), MathIntegratorModule(other) {
MellinMomentFromGPD::MellinMomentFromGPD(const MellinMomentFromGPD& other) :
MellinMomentModule(other), MathIntegratorModule(other) {
m_n = other.m_n;
m_gluon = other.m_gluon;
m_flavor = other.m_flavor;
m_type = other.m_type;
m_pGPDModel = 0;
m_pint = NumA::Integrator1D::newIntegrationFunctor(this,
&MellinMoment::integrant);
&MellinMomentFromGPD::integrant);
}
MellinMoment* MellinMoment::clone() const {
return new MellinMoment(*this);
MellinMomentFromGPD* MellinMomentFromGPD::clone() const {
return new MellinMomentFromGPD(*this);
}
void MellinMoment::isModuleWellConfigured() {
void MellinMomentFromGPD::isModuleWellConfigured() {
debug(__func__, ElemUtils::Formatter() << "executed");
}
void MellinMoment::initModule() {
void MellinMomentFromGPD::initModule() {
debug(__func__, ElemUtils::Formatter() << "executed");
}
GluonValue MellinMoment::computeGluonValue(int n,
MellinMomentKinematic mKinematic, GPDModule* pGPDModel, GPDType mGPDtype) {
m_type = mGPDtype;
m_gluon = true;
GluonValue result;
result.setGluonValue(MellinMoment::compute(n, mKinematic, pGPDModel));
return result;
}
QuarkValue MellinMoment::computeQuarkValue(int n,
MellinMomentKinematic mKinematic, GPDModule* pGPDModel, GPDType mGPDtype,
QuarkFlavor mflavor) {
m_type = mGPDtype;
m_gluon = false;
m_flavor = mflavor;
QuarkValue result;
result.setQuarkFlavor(mflavor);
result.setQuarkValue(MellinMoment::compute(n, mKinematic, pGPDModel));
return result;
}
PartonValues MellinMoment::compute(int n, MellinMomentKinematic mKinematic,
GPDModule* pGPDModel, GPDType mGPDtype) {
PartonValues result;
GluonValue gluon = MellinMoment::computeGluonValue(n, mKinematic, pGPDModel, mGPDtype);
result.setGluonValue(gluon);
List<QuarkFlavor> flavorList = MellinMoment::getQuarkFlavorList(mKinematic, pGPDModel, mGPDtype);
for (unsigned int i = 0; i != flavorList.size(); i++) {
result.addQuarkValue(MellinMoment::computeQuarkValue(n, mKinematic, pGPDModel, mGPDtype,flavorList[i]));
}
return result;
void MellinMomentFromGPD::configure(const ElemUtils::Parameters &parameters) {
MathIntegratorModule::configureIntegrator(parameters);
MellinMomentModule::configure(parameters);
}
double MellinMoment::compute(int n, MellinMomentKinematic mKinematic,
GPDModule* pGPDModel) ///< Compute when everything is set.
double MellinMomentFromGPD::compute(MellinMomentKinematic mKinematic) ///< Compute when everything is set.
{
m_n = n;
m_pGPDModel = pGPDModel;
std::vector<double> parameters;
parameters.push_back(mKinematic.getXi());
parameters.push_back(mKinematic.getT());
......@@ -118,7 +75,7 @@ double MellinMoment::compute(int n, MellinMomentKinematic mKinematic,
}
double MellinMoment::integrant(double x, std::vector<double> par) ///< Integrand
double MellinMomentFromGPD::integrant(double x, std::vector<double> par) ///< Integrand
{
// Create a GPDKinematic(x, xi, t, MuF2, MuR2) to compute
......@@ -134,13 +91,12 @@ double MellinMoment::integrant(double x, std::vector<double> par) ///< Integrand
}
}
List<QuarkFlavor> MellinMoment::getQuarkFlavorList(
MellinMomentKinematic mKinematic, GPDModule* pGPDModule,
const GPDType &gpdType) {
List<QuarkFlavor> MellinMomentFromGPD::getQuarkFlavorList(
MellinMomentKinematic mKinematic, const GPDType &gpdType) {
List<QuarkFlavor> result;
List<GPDType> gpdTypeList =
pGPDModule->getListOfAvailableGPDTypeForComputation();
m_pGPDModel->getListOfAvailableGPDTypeForComputation();
bool isGPDType = false;
for (unsigned int i = 0; i != gpdTypeList.size(); i++) {
......@@ -152,7 +108,7 @@ List<QuarkFlavor> MellinMoment::getQuarkFlavorList(
GPDKinematic kinematic(1, mKinematic.getXi, mKinematic.getT,
mKinematic.getMuF2, mKinematic.getMuR2);
List<QuarkDistribution> list =
pGPDModule->compute(kinematic, gpdType).getListOfQuarkDistribution();
m_pGPDModel->compute(kinematic, gpdType).getListOfQuarkDistribution();
for (unsigned int i = 0; i != list.size(); i++) {
QuarkFlavor flavor = list[i].getQuarkFlavor();
result.add(flavor);
......@@ -162,4 +118,22 @@ List<QuarkFlavor> MellinMoment::getQuarkFlavorList(
return result;
}
GPDModule* MellinMomentFromGPD::getGPDModule() const {
return m_pGPDModel;
}
void MellinMomentFromGPD::setGPDModule(GPDModule* pGPDModel) {
m_pModuleObjectFactory->updateModulePointerReference(m_pGPDModel,
pGPDModel);
m_pGPDModel = pGPDModel;
if (m_pGPDModel != 0) {
info(__func__,
ElemUtils::Formatter() << "GPD Module is set to : "
<< m_pGPDModel->getClassName());
} else {
info(__func__, "GPDModule is set to : 0");
}
}
} /* namespace PARTONS */
......@@ -64,9 +64,9 @@ MellinMomentKinematic::~MellinMomentKinematic() {
}
std::string MellinMomentKinematic::toString() const {
return ElemUtils::Formatter() << Kinematic::toString() << "\n" << "m_n = "
<< " m_xi = " << m_xi << " m_t = " << m_t << " m_MuF2 = "
<< m_MuF2 << "(Gev2) m_MuR2 = " << m_MuR2 << "(Gev2)";
return ElemUtils::Formatter() << Kinematic::toString() << "\n"
<< " m_xi = " << m_xi << ", m_t = " << m_t << ", m_MuF2 = "
<< m_MuF2 << "(Gev2), m_MuR2 = " << m_MuR2 << "(Gev2)";
}
......
#include <ElementaryUtils/string_utils/Formatter.h>
#include <NumA/functor/one_dimension/Functor1D.h>
#include <NumA/integration/one_dimension/Integrator1D.h>
#include <NumA/integration/one_dimension/IntegratorType1D.h>
#include <partons/beans/gpd/GPDKinematic.h>
#include <partons/beans/parton_distribution/GluonDistribution.h>
#include <partons/beans/parton_distribution/PartonDistribution.h>
#include <partons/beans/parton_distribution/QuarkDistribution.h>
#include <partons/BaseObjectRegistry.h>
#include <cmath>
#include <iostream>
#include <string>
#include "../../include/mellin_moment/MellinMomentModule.h"
namespace PARTONS {
const std::string MellinMomentModule::MELLIN_MOMENT_MODULE_CLASS_NAME =
"MellinMomentModule";
const std::string MellinMomentModule::PARAMETER_NAME_MELLIN_MODEL_MODULE_N = "MELLIN_INDEX_N";
MellinMomentModule::MellinMomentModule(const std::string &className) :
ModuleObject(className) {
m_n = 0;
m_gluon = false;
}
MellinMomentModule::MellinMomentModule(const MellinMomentModule& other) :
ModuleObject(other) {
m_n = other.m_n;
m_gluon = other.m_gluon;
m_flavor = other.m_flavor;
m_type = other.m_type;
}
MellinMomentModule::~MellinMomentModule(){
}
void MellinMomentModule::isModuleWellConfigured() {
debug(__func__, ElemUtils::Formatter() << "executed");
}
void MellinMomentModule::initModule() {
debug(__func__, ElemUtils::Formatter() << "executed");
}
void MellinMomentModule::configure(const ElemUtils::Parameters &parameters) {
if (parameters.isAvailable(MellinMomentModule::PARAMETER_NAME_MELLIN_MODEL_MODULE_N)) {
m_n = parameters.getLastAvailable().toDouble();