Commit 3727763d authored by Valerio Bertone's avatar Valerio Bertone
Browse files

First implementation of the CollinearDistribution mother class

parent de235e02
......@@ -63,8 +63,11 @@ find_package(NumA++ REQUIRED)
# find libraries: GSL
find_package(GSL REQUIRED)
# find libraries: LHAPDF
find_package(LHAPDF REQUIRED)
# directories containing headers
include_directories(${QT_INCLUDE_DIRS} ${SFML_INCLUDE_DIR} ${CLN_INCLUDE_DIR} ${ElementaryUtils_INCLUDE_DIR} ${NumA++_INCLUDE_DIR})
include_directories(${QT_INCLUDE_DIRS} ${SFML_INCLUDE_DIR} ${CLN_INCLUDE_DIR} ${ElementaryUtils_INCLUDE_DIR} ${NumA++_INCLUDE_DIR} ${LHAPDF_INCLUDE_DIR})
include_directories(include)
# FINALIZE ==================================================================================
......@@ -108,6 +111,8 @@ target_link_libraries(
${GSL_LIBRARIES}
${LHAPDF_LIBRARIES}
Qt5::Core
Qt5::Sql
......
# LHAPDF
find_program(LHAPDF_CONFIG lhapdf-config REQUIRED)
if (LHAPDF_CONFIG)
exec_program(${LHAPDF_CONFIG}
ARGS --cppflags
OUTPUT_VARIABLE LHAPDF_CXX_FLAGS
)
set(LHAPDF_CXX_FLAGS ${LHAPDF_CXX_FLAGS} CACHE STRING INTERNAL)
exec_program(${LHAPDF_CONFIG}
ARGS --ldflags
OUTPUT_VARIABLE LHAPDF_LIBRARIES
)
set(LHAPDF_LIBRARIES ${LHAPDF_LIBRARIES} CACHE STRING INTERNAL)
endif(LHAPDF_CONFIG)
#ifndef PARTON_DISTRIBUTION_KINEMATIC_H
#define PARTON_DISTRIBUTION_KINEMATIC_H
/**
* @file PartonDistributionKinematic.h
* @author: Valerio BERTONE (CEA Saclay)
* @date July 17, 2020
* @version 1.0
*/
#include <ElementaryUtils/parameters/GenericType.h>
#include <ElementaryUtils/parameters/Parameters.h>
#include <string>
#include <vector>
#include "../../utils/type/PhysicalType.h"
#include "../../utils/type/PhysicalUnit.h"
#include "../Kinematic.h"
namespace ElemUtils {
class Packet;
} /* namespace ElemUtils */
namespace PARTONS {
/**
* @class PartonDistributionKinematic
*
* @brief Class representing a single collinear-distribution kinematics.
*
* This class represents a single collinear-distribution kinematics (x, \f$\mu_{F}^{2}\f$, \f$\mu_{F}^{2}\f$).
*/
class PartonDistributionKinematic: public Kinematic {
public:
static const std::string PARTON_DISTRIBUTION_KNEMATIC_CLASS_NAME; ///< Type of the kinematic in XML automation.
/**
* Parameter name to set variable \f$x\f$ via configuration methods.
*/
static const std::string KINEMATIC_PARAMETER_NAME_X;
/**
* Parameter name to set variable \f$\mu_{F}^{2}\f$ via configuration methods.
*/
static const std::string KINEMATIC_PARAMETER_NAME_MUF2;
/**
* Parameter name to set variable \f$\mu_{R}^{2}\f$ via configuration methods.
*/
static const std::string KINEMATIC_PARAMETER_NAME_MUR2;
/**
* Parameter name to set unit of variable \f$x\f$ via configuration methods.
*/
static const std::string KINEMATIC_PARAMETER_NAME_X_UNIT;
/**
* Parameter name to set unit of variable \f$\mu_{F}^{2}\f$ via configuration methods.
*/
static const std::string KINEMATIC_PARAMETER_NAME_MUF2_UNIT;
/**
* Parameter name to set unit of variable \f$\mu_{R}^{2}\f$ via configuration methods.
*/
static const std::string KINEMATIC_PARAMETER_NAME_MUR2_UNIT;
/**
* Default constructor.
*/
PartonDistributionKinematic();
/**
* Assignment constructor.
*
* @param x Longitudinal momentum fraction of active parton.
* @param MuF2 Factorization scale squared (in \f$GeV^{2}\f$).
* @param MuR2 Renormalization scale squared (in \f$GeV^{2}\f$).
*/
PartonDistributionKinematic(double x, double MuF2, double MuR2);
/**
* Assignment constructor.
*
* @param x Longitudinal momentum fraction of active parton.
* @param MuF2 Factorization scale squared (in \f$GeV^{2}\f$).
* @param MuR2 Renormalization scale squared (in \f$GeV^{2}\f$).
*/
PartonDistributionKinematic(const PhysicalType<double> &x, const PhysicalType<double> &MuF2, const PhysicalType<double> &MuR2);
/**
* Assignment constructor.
*
* @param x Longitudinal momentum fraction of active parton.
* @param MuF2 Factorization scale squared (in \f$GeV^{2}\f$).
* @param MuR2 Renormalization scale squared (in \f$GeV^{2}\f$).
*/
PartonDistributionKinematic(const ElemUtils::GenericType &x, const ElemUtils::GenericType &MuF2, const ElemUtils::GenericType &MuR2);
/**
* Copy constructor.
* @param other Object to be copied.
*/
PartonDistributionKinematic(const PartonDistributionKinematic &other);
/**
* Destructor.
*/
virtual ~PartonDistributionKinematic();
virtual void configure(const ElemUtils::Parameters &parameters);
virtual std::string toString() const;
/**
* Serialize into given Packet.
* @param packet Target Packet.
*/
void serialize(ElemUtils::Packet &packet) const;
/**
* Retrieve data from given Packet.
* @param packet Input Packet.
*/
void unserialize(ElemUtils::Packet &packet);
/**
* Serialize to std::vector<double>.
*/
void serializeIntoStdVector(std::vector<double>& vec) const;
/**
* Unserialize from std::vector<double>.
*/
void unserializeFromStdVector(std::vector<double>::const_iterator& it,
const std::vector<double>::const_iterator& end);
/**
* Is equal operator. Checks if values of kinematic variables are the same.
*/
bool operator ==(const PartonDistributionKinematic& other) const;
/**
* Is different operator. Checks of values of kinematic variables are different.
*/
bool operator !=(const PartonDistributionKinematic& other) const;
//********************************************************
//*** SETTERS AND GETTERS ********************************
//********************************************************
/**
* Get longitudinal momentum fraction of active parton.
*/
const PhysicalType<double>& getX() const;
/**
* Set longitudinal momentum fraction of active parton.
*/
void setX(const PhysicalType<double>& x);
/**
* Set longitudinal momentum fraction of active parton.
*/
void setX(double x, PhysicalUnit::Type unit = PhysicalUnit::NONE);
/**
* Get factorization scale squared.
*/
const PhysicalType<double>& getMuF2() const;
/**
* Set factorization scale squared.
*/
void setMuF2(const PhysicalType<double>& muF2);
/**
* Set factorization scale squared.
*/
void setMuF2(double muF2, PhysicalUnit::Type unit = PhysicalUnit::GEV2);
/**
* Get renormalization scale squared.
*/
const PhysicalType<double>& getMuR2() const;
/**
* Set renormalization scale squared.
*/
void setMuR2(const PhysicalType<double>& muR2);
/**
* Set renormalization scale squared.
*/
void setMuR2(double muR2, PhysicalUnit::Type unit = PhysicalUnit::GEV2);
protected:
virtual void updateHashSum() const;
private:
/**
* Longitudinal momentum fraction of active parton.
*/
PhysicalType<double> m_x;
/**
* Factorization scale squared (in \f$GeV^{2}\f$).
*/
PhysicalType<double> m_MuF2;
/**
* Renormalization scale squared (in \f$GeV^{2}\f$).
*/
PhysicalType<double> m_MuR2;
};
/**
* Stream operator to serialize class into Packet. See also PartonDistributionType::serialize().
*/
ElemUtils::Packet& operator <<(ElemUtils::Packet& packet, PartonDistributionKinematic& kinematic);
/**
* Stream operator to retrieve class from Packet. See also PartonDistributionType::unserialize().
*/
ElemUtils::Packet& operator >>(ElemUtils::Packet& packet, PartonDistributionKinematic& kinematic);
} /* namespace PARTONS */
#endif /* PARTON_DISTRIBUTION_KINEMATIC_H */
#ifndef COLLINEAR_DISTRIBUTION_MODULE_H
#define COLLINEAR_DISTRIBUTION_MODULE_H
/**
* @file CollinearDistributionModule.h
* @author Valerio BERTONE (CEA Saclay)
* @date July 17, 2020
* @version 1.0
*/
#include <ElementaryUtils/parameters/Parameters.h>
#include <map>
#include <string>
#include "../../beans/automation/BaseObjectData.h"
#include "../../beans/List.h"
#include "../../beans/parton_distribution/PartonDistribution.h"
#include "../../beans/parton_distribution/PartonDistributionKinematic.h"
#include "../../ModuleObject.h"
namespace PARTONS {
class PartonDistributionKinematic;
} /* namespace PARTONS */
namespace PARTONS {
/**
* @class CollinearDistributionModule @brief Abstract class that
* provides a skeleton to implement a collinear-distribution module
* (such as polarised and unpolarise PDFs and FFs).
*/
class CollinearDistributionModule: public ModuleObject {
public:
static const std::string COLLINEAR_DISTRIBUTION_MODULE_CLASS_NAME; ///< Type of the module in XML automation.
/**
* Destructor.
*/
virtual ~CollinearDistributionModule();
virtual CollinearDistributionModule* clone() const = 0;
virtual std::string toString() const;
virtual void resolveObjectDependencies();
virtual void configure(const ElemUtils::Parameters &parameters);
/**
* Virtual method, computes CollinearDistribution with some input parameters.
*
* @param kinematic CollinearDistribution kinematics object.
*
* @return PartonDistribution object.
* Contains results for each flavor of partons.
*/
virtual PartonDistribution compute(const PartonDistributionKinematic &kinematic);
protected:
/**
* Default constructor.
*/
CollinearDistributionModule(const std::string &className);
/**
* Copy constructor.
* @param other Object to be copied.
*/
CollinearDistributionModule(const CollinearDistributionModule &other);
/**
* Set internal kinematics.
* @param kinematic Kinematics to be set.
*/
virtual void setKinematics(const PartonDistributionKinematic& kinematic);
virtual void initModule();
virtual void isModuleWellConfigured();
/**
* Fuctions to be implemented in the child class that actually
* returs the set of collinear distributions in the form of a
* PartonDistribution object.
*/
virtual PartonDistribution compute() const = 0;
double m_x; ///< Longitudinal momentum fraction of the active parton.
double m_MuF2; ///< Factorization scale squared.
double m_MuR2; ///< Renormalization scale squared.
};
} /* namespace PARTONS */
#endif /* COLLINEAR_DISTRIBUTION_MODULE_H */
#include "../../../../include/partons/beans/parton_distribution/PartonDistributionKinematic.h"
#include <ElementaryUtils/string_utils/Formatter.h>
#include "../../../../include/partons/beans/channel/ChannelType.h"
#include "../../../../include/partons/Partons.h"
#include "../../../../include/partons/services/hash_sum/CryptographicHashService.h"
#include "../../../../include/partons/ServiceObjectRegistry.h"
namespace PARTONS {
const std::string PartonDistributionKinematic::PARTON_DISTRIBUTION_KNEMATIC_CLASS_NAME = "PartonDistributionKinematic";
const std::string PartonDistributionKinematic::KINEMATIC_PARAMETER_NAME_X = "x";
const std::string PartonDistributionKinematic::KINEMATIC_PARAMETER_NAME_MUF2 = "MuF2";
const std::string PartonDistributionKinematic::KINEMATIC_PARAMETER_NAME_MUR2 = "MuR2";
const std::string PartonDistributionKinematic::KINEMATIC_PARAMETER_NAME_X_UNIT = "x_unit";
const std::string PartonDistributionKinematic::KINEMATIC_PARAMETER_NAME_MUF2_UNIT = "MuF2_unit";
const std::string PartonDistributionKinematic::KINEMATIC_PARAMETER_NAME_MUR2_UNIT = "MuR2_unit";
PartonDistributionKinematic::PartonDistributionKinematic() :
Kinematic("PartonDistributionKinematic", ChannelType::UNDEFINED), m_x(
PhysicalType<double>(PhysicalUnit::NONE)), m_MuF2(
PhysicalType<double>(PhysicalUnit::GEV2)), m_MuR2(
PhysicalType<double>(PhysicalUnit::GEV2)) {
}
PartonDistributionKinematic::PartonDistributionKinematic(double x, double MuF2, double MuR2) :
Kinematic("PartonDistributionKinematic", ChannelType::UNDEFINED), m_x(
PhysicalType<double>(x, PhysicalUnit::NONE)), m_MuF2(
PhysicalType<double>(MuF2, PhysicalUnit::GEV2)), m_MuR2(
PhysicalType<double>(MuR2, PhysicalUnit::GEV2)) {
}
PartonDistributionKinematic::PartonDistributionKinematic(const PhysicalType<double> &x,
const PhysicalType<double> &MuF2, const PhysicalType<double> &MuR2) :
Kinematic("PartonDistributionKinematic", ChannelType::UNDEFINED), m_x(
PhysicalType<double>(PhysicalUnit::NONE)), m_MuF2(
PhysicalType<double>(PhysicalUnit::GEV2)), m_MuR2(
PhysicalType<double>(PhysicalUnit::GEV2)) {
m_x.checkIfSameUnitCategoryAs(x);
m_MuF2.checkIfSameUnitCategoryAs(MuF2);
m_MuR2.checkIfSameUnitCategoryAs(MuR2);
m_x = x;
m_MuF2 = MuF2;
m_MuR2 = MuR2;
}
PartonDistributionKinematic::PartonDistributionKinematic(const ElemUtils::GenericType& x,
const ElemUtils::GenericType& MuF2, const ElemUtils::GenericType& MuR2) :
Kinematic("PartonDistributionKinematic", ChannelType::UNDEFINED), m_x(
PhysicalType<double>(x, PhysicalUnit::NONE)), m_MuF2(
PhysicalType<double>(MuF2, PhysicalUnit::GEV2)), m_MuR2(
PhysicalType<double>(MuR2, PhysicalUnit::GEV2)) {
}
PartonDistributionKinematic::PartonDistributionKinematic(const PartonDistributionKinematic& other) :
Kinematic(other), m_x(other.m_x), m_MuF2(other.m_MuF2), m_MuR2(other.m_MuR2) {
}
PartonDistributionKinematic::~PartonDistributionKinematic() {
}
void PartonDistributionKinematic::configure(const ElemUtils::Parameters &parameters) {
//run for mother
Kinematic::configure(parameters);
double value;
PhysicalUnit::Type unit;
//x
if (parameters.isAvailable(PartonDistributionKinematic::KINEMATIC_PARAMETER_NAME_X)) {
value = parameters.getLastAvailable().toDouble();
if (parameters.isAvailable(
PartonDistributionKinematic::KINEMATIC_PARAMETER_NAME_X_UNIT)) {
unit =
PhysicalUnit(parameters.getLastAvailable().getString()).getType();
setX(value, unit);
} else {
setX(value, PhysicalUnit::NONE);
}
} else {
errorMissingParameter(PartonDistributionKinematic::KINEMATIC_PARAMETER_NAME_X);
}
//muF2
if (parameters.isAvailable(PartonDistributionKinematic::KINEMATIC_PARAMETER_NAME_MUF2)) {
value = parameters.getLastAvailable().toDouble();
if (parameters.isAvailable(
PartonDistributionKinematic::KINEMATIC_PARAMETER_NAME_MUF2_UNIT)) {
unit =
PhysicalUnit(parameters.getLastAvailable().getString()).getType();
setMuF2(value, unit);
} else {
setMuF2(value, PhysicalUnit::GEV2);
}
} else {
errorMissingParameter(PartonDistributionKinematic::KINEMATIC_PARAMETER_NAME_MUF2);
}
//muR2
if (parameters.isAvailable(PartonDistributionKinematic::KINEMATIC_PARAMETER_NAME_MUR2)) {
value = parameters.getLastAvailable().toDouble();
if (parameters.isAvailable(
PartonDistributionKinematic::KINEMATIC_PARAMETER_NAME_MUR2_UNIT)) {
unit =
PhysicalUnit(parameters.getLastAvailable().getString()).getType();
setMuR2(value, unit);
} else {
setMuR2(value, PhysicalUnit::GEV2);
}
} else {
errorMissingParameter(PartonDistributionKinematic::KINEMATIC_PARAMETER_NAME_MUR2);
}
}
std::string PartonDistributionKinematic::toString() const {
ElemUtils::Formatter formatter;
formatter << Kinematic::toString() << '\n';
if (m_x.isInitialized())
formatter << "x: " << m_x.toString() << ' ';
if (m_MuF2.isInitialized())
formatter << "muF2: " << m_MuF2.toString() << ' ';
if (m_MuR2.isInitialized())
formatter << "muR2: " << m_MuR2.toString() << ' ';
return formatter.str();
}
void PartonDistributionKinematic::serialize(ElemUtils::Packet &packet) const {
Kinematic::serialize(packet);
packet << m_x << m_MuF2 << m_MuR2;
}
void PartonDistributionKinematic::unserialize(ElemUtils::Packet &packet) {
Kinematic::unserialize(packet);
packet >> m_x;
packet >> m_MuF2;
packet >> m_MuR2;
updateHashSum();
}
void PartonDistributionKinematic::serializeIntoStdVector(std::vector<double>& vec) const {
Kinematic::serializeIntoStdVector(vec);
m_x.serializeIntoStdVector(vec);
m_MuF2.serializeIntoStdVector(vec);
m_MuR2.serializeIntoStdVector(vec);
}
void PartonDistributionKinematic::unserializeFromStdVector(
std::vector<double>::const_iterator& it,
const std::vector<double>::const_iterator& end) {
Kinematic::unserializeFromStdVector(it, end);
m_x.unserializeFromStdVector(it, end);
m_MuF2.unserializeFromStdVector(it, end);
m_MuR2.unserializeFromStdVector(it, end);
updateHashSum();
}
bool PartonDistributionKinematic::operator ==(const PartonDistributionKinematic& other) const {
return m_x == other.getX() && m_MuF2 == other.getMuF2() && m_MuR2 == other.getMuR2();
}
bool PartonDistributionKinematic::operator !=(const PartonDistributionKinematic& other) const {
return !((*this) == other);
}
void PartonDistributionKinematic::updateHashSum() const {
setHashSum(
Partons::getInstance()->getServiceObjectRegistry()->getCryptographicHashService()->generateSHA1HashSum(
ElemUtils::Formatter() << m_x.toStdString()
<< m_MuF2.toStdString() << m_MuR2.toStdString()));
}
const PhysicalType<double>& PartonDistributionKinematic::getX() const {
return m_x;
}
const PhysicalType<double>& PartonDistributionKinematic::getMuF2() const {
return m_MuF2;
}
const PhysicalType<double>& PartonDistributionKinematic::getMuR2() const {
return m_MuR2;
}
void PartonDistributionKinematic::setX(const PhysicalType<double>& x) {
m_x.checkIfSameUnitCategoryAs(x);
m_x = x;
updateHashSum();
}
void PartonDistributionKinematic::setMuF2(const PhysicalType<double>& muF2) {
m_MuF2.checkIfSameUnitCategoryAs(muF2);
m_MuF2 = muF2;
updateHashSum();
}
void PartonDistributionKinematic::setMuR2(const PhysicalType<double>& muR2) {
m_MuR2.checkIfSameUnitCategoryAs(muR2);