Commit 94e8fc84 authored by Valerio Bertone's avatar Valerio Bertone
Browse files

Adjusting CMakeLists.txt to make sure the code compiles also when using clang...

Adjusting CMakeLists.txt to make sure the code compiles also when using clang + work towards a reorganisation of the evolution and collinear distribution modules according to the discussion that Herve', Pawel and I had one week ago
parent 1c627678
......@@ -7,7 +7,11 @@ cmake_minimum_required(VERSION 3.2)
project(PARTONS CXX)
# define c++ standard and issue all the warning demanded by this standard
add_definitions(-std=c++11 -pedantic -Wno-vla-extension -fext-numeric-literals)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_definitions(-std=c++11 -pedantic -Wno-vla-extension)
else()
add_definitions(-std=c++11 -pedantic -Wno-vla-extension -fext-numeric-literals)
endif()
set(CMAKE_CXX_STANDARD 11)
if (NOT DEFINED CMAKE_MACOSX_RPATH)
......
......@@ -67,8 +67,12 @@ public:
* @param Mu2Max Factorization scale squared maximum value.
* @return If lowerBound > upperBound a single interval with the number of active flavors corresponding to lowerBound is returned. Otherwise, a vector containing intervals for the requested range of factorization scale.
*/
std::vector<ActiveFlavorsThresholds> getNfIntervals(double Mu2Min,
double Mu2Max) const;
std::vector<ActiveFlavorsThresholds> getNfIntervals(double Mu2Min, double Mu2Max) const;
/**
* Get intervals for the entire range of the factorization scale squared.
*/
std::vector<ActiveFlavorsThresholds> getNfIntervals() const { return m_nfFunctionOfMu2; }
protected:
......@@ -87,8 +91,7 @@ protected:
* @param lowerBound Lower bound of the new interval.
* @param upperBound Upper bound of the new interval.
*/
void addNfInterval(unsigned short nfValue, double lowerBound,
double upperBound);
void addNfInterval(unsigned short nfValue, double lowerBound, double upperBound);
/**
* Reset vector containing defined integrals.
......
#ifndef ACTIVE_FLAVORS_THRESHOLDS_VARIABLE_H
#define ACTIVE_FLAVORS_THRESHOLDS_VARIABLE_H
/**
* @file ActiveFlavorsThresholdsVariable.h
* @author Bryan BERTHOU (SPhN / CEA Saclay)
* @date 26 October 2020
* @version 1.0
*/
#include <ElementaryUtils/parameters/Parameters.h>
#include <stddef.h>
#include <string>
#include "ActiveFlavorsThresholdsModule.h"
namespace PARTONS {
/**
* @class ActiveFlavorsThresholdsVariable
*
* @brief Variable number of active quark flavors.
*/
class ActiveFlavorsThresholdsVariable: public ActiveFlavorsThresholdsModule {
public:
static const std::string PARAM_NAME_THRESHOLDS;
/**
* Unique ID to automatically register the class in the registry.
*/
static const unsigned int classId;
/**
* Constructor.
* @param className Name of this class.
*/
ActiveFlavorsThresholdsVariable(const std::string &className);
/**
* Destructor.
*/
virtual ~ActiveFlavorsThresholdsVariable();
virtual ActiveFlavorsThresholdsVariable* clone() const;
virtual void configure(const ElemUtils::Parameters &parameters);
virtual void resolveObjectDependencies();
/**
* Set Thresholds.
*/
void setThresholds(std::vector<double> thresholds);
/**
* Get number of quark flavors.
*/
std::vector<double> getThresholds() const;
protected:
/**
* Copy constructor.
* @param other Object to be copied.
*/
ActiveFlavorsThresholdsVariable(const ActiveFlavorsThresholdsVariable &other);
virtual void initModule();
virtual void isModuleWellConfigured();
private:
/**
* Thresholds
*/
std::vector<double> m_thresholds;
};
} /* namespace PARTONS */
#endif /* ACTIVE_FLAVORS_THRESHOLDS_VARIABLE_H */
......@@ -95,6 +95,11 @@ public:
// ##### GETTERS & SETTERS #####
/**
* Get reference factorization scale used by the collinear distribution model before evolution.
*/
double getMuF2Ref() const;
/**
* Set underlying collinear distribution Evolution module.
*/
......@@ -126,11 +131,6 @@ protected:
virtual void initModule();
virtual void isModuleWellConfigured();
/**
* Set current collinear distribution type to be computed.
*/
void setCurrentCollinearDistributionType(CollinearDistributionType::Type colldistType);
/**
* List of collinear distribution types that can be computed by the child class.
* Needs to be set in the constructor of the child class, with the corresponding methods to be used.
......@@ -140,7 +140,7 @@ protected:
double m_x; ///< Longitudinal momentum fraction of the active parton.
double m_MuF2; ///< Factorization scale squared.
double m_MuR2; ///< Renormalization scale squared.
CollinearDistributionType::Type m_currentCollinearDistributionComputeType; ///< Current collinear distribution type.
double m_MuF2_ref; ///< Reference factorization scale used by the collinear model before evolution.
CollinearDistributionEvolutionModule* m_pCollinearDistributionEvolutionModule; ///< Pointer to the underlying collinear distribution Evolution module.
};
......
......@@ -10,6 +10,7 @@
#include "CollinearDistributionEvolutionModule.h"
#include "../../../../../include/partons/modules/collinear_distribution/CollinearDistributionModule.h"
#include "../../active_flavors_thresholds/ActiveFlavorsThresholdsModule.h"
#include <apfel/apfelxx.h>
......@@ -27,18 +28,10 @@ public:
/**
* Settable parameters
*/
static const std::string PARAM_NAME_THRESHOLDS;
static const std::string PARAM_NAME_MASSES;
static const std::string PARAM_NAME_SUBGRID_NODES;
static const std::string PARAM_NAME_SUBGRID_LOWER_BOUNDS;
static const std::string PARAM_NAME_SUBGRID_INTER_DEGREES;
static const std::string PARAM_NAME_TAB_NODES;
static const std::string PARAM_NAME_TAB_LOWER_BOUND;
static const std::string PARAM_NAME_TAB_UPPER_BOUND;
static const std::string PARAM_NAME_TAB_INTER_DEGREE;
/**
* Unique ID to automatically register the class in the registry.
*/
......@@ -63,30 +56,14 @@ public:
// ##### GETTERS & SETTERS #####
void setThresholds(const std::vector<double>& thresholds);
void setMasses(const std::vector<double>& masses);
void setSubgridNodes(const std::vector<int>& subgridNodes);
void setSubgridLowerBounds(const std::vector<double>& subgridLowerBounds);
void setSubgridInterDegrees(const std::vector<int>& subgridInterDegrees);
void setTabNodes(const int& tabNodes);
void setTabLowerBound(const double& tabLowerBound);
void setTabUpperBound(const double& tabUpperBound);
void setTabInterDegree(const int& tabInterDegree);
std::vector<double> getThresholds() const;
std::vector<double> getMasses() const;
std::vector<int> getSubgridNodes() const;
std::vector<double> getSubgridLowerBounds() const;
std::vector<int> getSubgridInterDegrees() const;
int getTabNodes() const;
double getTabLowerBound() const;
double getTabUpperBound() const;
int getTabInterDegree() const;
protected:
/**
......@@ -100,22 +77,16 @@ protected:
virtual PartonDistribution compute(CollinearDistributionModule* pCollinearDistributionModule);
std::function<std::map<int, double>(double const&)> initialScaleDistributions(CollinearDistributionModule* pCollinearDistributionModule);
std::function<std::map<int, double>(double const&, double const&)> initialScaleDistributions(CollinearDistributionModule* pCollinearDistributionModule);
private:
std::vector<double> m_thresholds;
std::vector<double> m_masses;
std::vector<int> m_subgridNodes;
std::vector<double> m_subgridLowerBounds;
std::vector<int> m_subgridInterDegrees;
int m_tabNodes;
double m_tabLowerBound;
double m_tabUpperBound;
int m_tabInterDegree;
std::unique_ptr<apfel::Grid> m_g;
std::unique_ptr<apfel::TabulateObject<apfel::Set<apfel::Operator>>> m_tabulatedOps;
std::map<int, apfel::DglapObjects> m_dglapobj;
};
} /* namespace PARTONS */
......
......@@ -18,6 +18,7 @@ namespace PARTONS {
class CollinearDistributionModule;
class RunningAlphaStrongModule;
class ActiveFlavorsThresholdsModule;
/**
* @class CollinearDistributionEvolutionModule
......@@ -30,11 +31,6 @@ class CollinearDistributionEvolutionModule: public ModuleObject {
public:
/**
* Settable parameters
*/
static const std::string PARAM_NAME_MUF2_REF;
/**
* Type of module name used by the automatization.
*/
......@@ -64,16 +60,15 @@ public:
// ##### GETTERS & SETTERS #####
void setMuF2_ref(const double& MuF2_ref);
void setPertOrder(const PerturbativeQCDOrderType::Type& pertOrder);
void setCollinearDistributionType(CollinearDistributionType::Type type);
void setRunningAlphaStrongModule(RunningAlphaStrongModule* runningAlphaStrongModule);
void setActiveFlavorsModule(ActiveFlavorsThresholdsModule* activeFlavorsModule);
double getMuF2_ref() const;
double getMuF_ref() const;
PerturbativeQCDOrderType::Type getPertOrder() const;
CollinearDistributionType::Type getCollinearDistributionType() const;
RunningAlphaStrongModule* getRunningAlphaStrongModule() const;
ActiveFlavorsThresholdsModule* getActiveFlavorsModule() const;
protected:
......@@ -94,11 +89,11 @@ protected:
/**
* Attributes
*/
double m_MuF2_ref; ///< Reference factorization scale squared (in \f$GeV^{2}\f$).
PerturbativeQCDOrderType::Type m_pertOrder; ///< pQCD order assumed in the calculation.
CollinearDistributionType::Type m_type; ///< collinear distribution type.
RunningAlphaStrongModule* m_pRunningAlphaStrongModule; ///< Pointer to RunningAlphaStrongModule object being used.
ActiveFlavorsThresholdsModule* m_pActiveFlavorsModule; ///< Pointer to ActiveFlavorsThresholdsModule object being used.
/**
* Kinematics
......
......@@ -39,7 +39,6 @@ public:
static const std::string PARAM_NAME_MU_REF;
static const std::string PARAM_NAME_THRESHOLDS;
static const std::string PARAM_NAME_MASSES;
static const std::string PARAM_NAME_TAB_NODES;
static const std::string PARAM_NAME_TAB_LOWER_BOUND;
......@@ -72,7 +71,6 @@ public:
void setMuRef(const double& muRef);
void setThresholds(const std::vector<double>& thresholds);
void setMasses(const std::vector<double>& masses);
void setTabNodes(const int& tabNodes);
void setTabLowerBound(const double& tabLowerBound);
......@@ -84,7 +82,6 @@ public:
double getMuRef() const;
std::vector<double> getThresholds() const;
std::vector<double> getMasses() const;
int getTabNodes() const;
double getTabLowerBound() const;
......@@ -108,7 +105,6 @@ private:
double m_alphasRef;
double m_muRef;
std::vector<double> m_thresholds;
std::vector<double> m_masses;
int m_tabNodes;
double m_tabLowerBound;
double m_tabUpperBound;
......
......@@ -94,7 +94,7 @@ ActiveFlavorsThresholds ActiveFlavorsThresholdsModule::getNfInterval(
warn(__func__,
ElemUtils::Formatter() << "Mu2 " << Mu2
<< " grater than the last interval. The last interval is returned with the modified upper bound equal "
<< " greater than the last interval. The last interval is returned with the modified upper bound equal "
<< Mu2);
}
// case first interval <= Mu2 < last threshold
......
#include "../../../../include/partons/modules/active_flavors_thresholds/ActiveFlavorsThresholdsVariable.h"
#include <ElementaryUtils/parameters/GenericType.h>
#include <ElementaryUtils/string_utils/Formatter.h>
#include <ElementaryUtils/logger/CustomException.h>
#include <limits>
#include "../../../../include/partons/BaseObjectRegistry.h"
namespace PARTONS {
const std::string ActiveFlavorsThresholdsVariable::PARAM_NAME_THRESHOLDS = "thresholds";
const unsigned int ActiveFlavorsThresholdsVariable::classId = BaseObjectRegistry::getInstance()->registerBaseObject(new ActiveFlavorsThresholdsVariable("ActiveFlavorsThresholdsVariable"));
ActiveFlavorsThresholdsVariable::ActiveFlavorsThresholdsVariable(const std::string &className) :
ActiveFlavorsThresholdsModule(className), m_thresholds({}) {
}
ActiveFlavorsThresholdsVariable::~ActiveFlavorsThresholdsVariable() {
}
ActiveFlavorsThresholdsVariable::ActiveFlavorsThresholdsVariable(
const ActiveFlavorsThresholdsVariable& other) :
ActiveFlavorsThresholdsModule(other), m_thresholds(other.m_thresholds) {
}
ActiveFlavorsThresholdsVariable* ActiveFlavorsThresholdsVariable::clone() const {
return new ActiveFlavorsThresholdsVariable(*this);
}
void ActiveFlavorsThresholdsVariable::configure(const ElemUtils::Parameters &parameters) {
ActiveFlavorsThresholdsModule::configure(parameters);
//check and set
if (parameters.isAvailable(ActiveFlavorsThresholdsVariable::PARAM_NAME_THRESHOLDS)) {
setThresholds(parameters.getLastAvailable().toVectorDouble());
std::ostringstream oss;
std::copy(m_thresholds.begin(), m_thresholds.end(), std::ostream_iterator<double>(oss, " "));
info(__func__, ElemUtils::Formatter() << ActiveFlavorsThresholdsVariable::PARAM_NAME_THRESHOLDS << " configured with value = [ " << oss.str() << "] GeV");
}
}
void ActiveFlavorsThresholdsVariable::resolveObjectDependencies() {
ActiveFlavorsThresholdsModule::resolveObjectDependencies();
}
void ActiveFlavorsThresholdsVariable::initModule() {
ActiveFlavorsThresholdsModule::initModule();
}
void ActiveFlavorsThresholdsVariable::isModuleWellConfigured() {
ActiveFlavorsThresholdsModule::isModuleWellConfigured();
//check that the vector of thresholds is not empty
if (m_thresholds.size() == 0) {
throw ElemUtils::CustomException(getClassName(), __func__, ElemUtils::Formatter() << "The vector of thresholds is empty");
}
//check if the vector of thresholds is ordered
if (!std::is_sorted(m_thresholds.begin(), m_thresholds.end())) {
throw ElemUtils::CustomException(getClassName(), __func__, ElemUtils::Formatter() << "The vector of thresholds is not ordered");
}
}
void ActiveFlavorsThresholdsVariable::setThresholds(std::vector<double> thresholds) {
m_thresholds = thresholds;
reset();
for (int i = 1; i < (int) thresholds.size(); i++)
addNfInterval(i, std::max(pow(thresholds[i-1], 2), i*1e-6), std::max(pow(thresholds[i], 2), (i+1)*1e-6));
addNfInterval(thresholds.size(), pow(thresholds.back(), 2), 1e12);
}
std::vector<double> ActiveFlavorsThresholdsVariable::getThresholds() const {
// Now check if the module is well-configured
return m_thresholds;
}
} /* namespace PARTONS */
......@@ -9,20 +9,16 @@ namespace PARTONS {
const std::string CollinearDistributionLHAPDF::PARAM_NAME_SET_NAME = "setName";
const std::string CollinearDistributionLHAPDF::PARAM_NAME_SET_TYPE = "setType";
const std::string CollinearDistributionLHAPDF::PARAM_NAME_SET_MEMBER =
"setMember";
const std::string CollinearDistributionLHAPDF::PARAM_NAME_SET_MEMBER = "setMember";
const unsigned int CollinearDistributionLHAPDF::classId =
BaseObjectRegistry::getInstance()->registerBaseObject(
new CollinearDistributionLHAPDF("CollinearDistributionLHAPDF"));
const unsigned int CollinearDistributionLHAPDF::classId = BaseObjectRegistry::getInstance()->registerBaseObject(new CollinearDistributionLHAPDF("CollinearDistributionLHAPDF"));
//TODO initialise missing members
CollinearDistributionLHAPDF::CollinearDistributionLHAPDF(
const std::string &className) :
CollinearDistributionModule(className), m_setName("UNDEFINED"), m_member(
0), m_type(CollinearDistributionType::Type::UNDEFINED), m_set(
0), m_type(CollinearDistributionType::Type::UnpolPDF), m_set(
{ }) {
}
CollinearDistributionLHAPDF::CollinearDistributionLHAPDF(
......@@ -83,7 +79,6 @@ void CollinearDistributionLHAPDF::configure(
}
void CollinearDistributionLHAPDF::isModuleWellConfigured() {
CollinearDistributionModule::isModuleWellConfigured();
//check that the set name in no UNDEFINED
......@@ -112,6 +107,8 @@ void CollinearDistributionLHAPDF::initModule() {
if (m_set.empty()) {
m_set = LHAPDF::mkPDFs(m_setName);
}
m_MuF2_ref = m_set[0]->q2Min();
}
PartonDistribution CollinearDistributionLHAPDF::computeUnpolPDF() {
......
......@@ -24,14 +24,12 @@ namespace PARTONS {
const std::string CollinearDistributionModule::COLLINEAR_DISTRIBUTION_MODULE_CLASS_NAME = "CollinearDistributionModule";
CollinearDistributionModule::CollinearDistributionModule(const std::string &className) :
ModuleObject(className, ChannelType::UNDEFINED), m_x(0.), m_MuF2(0.), m_MuR2(0.), m_currentCollinearDistributionComputeType(
CollinearDistributionType::ALL), m_pCollinearDistributionEvolutionModule(0) {
ModuleObject(className, ChannelType::UNDEFINED), m_x(0.), m_MuF2(0.), m_MuR2(0.), m_MuF2_ref(0.), m_pCollinearDistributionEvolutionModule(0) {
}
CollinearDistributionModule::CollinearDistributionModule(const CollinearDistributionModule &other) :
ModuleObject(other), m_x(other.m_x), m_MuF2(
other.m_MuF2), m_MuR2(other.m_MuR2), m_currentCollinearDistributionComputeType(
other.m_currentCollinearDistributionComputeType) {
other.m_MuF2), m_MuR2(other.m_MuR2), m_MuF2_ref(other.m_MuF2_ref) {
if (other.m_pCollinearDistributionEvolutionModule != 0) {
m_pCollinearDistributionEvolutionModule = m_pModuleObjectFactory->cloneModuleObject(
......@@ -163,13 +161,9 @@ CollinearDistributionResult CollinearDistributionModule::compute(const Collinear
//check if found
if (m_it != m_listCollinearDistributionComputeTypeAvailable.end()) {
//set collinear distribution type
setCurrentCollinearDistributionType(colldistType[i]);
//evaluate
PartonDistribution partonDistribution;
if (m_pCollinearDistributionEvolutionModule != 0 && (m_MuF2 != m_pCollinearDistributionEvolutionModule->getMuF2_ref())) {
if (m_pCollinearDistributionEvolutionModule != 0 && m_MuF2 != m_MuF2_ref) {
CollinearDistributionModule* collDistModule = m_pModuleObjectFactory->cloneModuleObject(this);
partonDistribution = m_pCollinearDistributionEvolutionModule->compute(kinematic, collDistModule);
m_pModuleObjectFactory->updateModulePointerReference(collDistModule, 0);
......@@ -215,6 +209,10 @@ List<CollinearDistributionType> CollinearDistributionModule::getListOfAvailableC
return listOfAvailableCollinearDistributionTypeForComputation;
}
double CollinearDistributionModule::getMuF2Ref() const {
return m_MuF2_ref;
}
const CollinearDistributionEvolutionModule* CollinearDistributionModule::getEvolQcdModule() const {
return m_pCollinearDistributionEvolutionModule;
}
......@@ -271,10 +269,10 @@ void CollinearDistributionModule::isModuleWellConfigured() {
if (m_MuR2 <= 0.) {
warn(__func__, "Square of renormalization scale should be > 0.");
}
}
void CollinearDistributionModule::setCurrentCollinearDistributionType(CollinearDistributionType::Type colldistType) {
m_currentCollinearDistributionComputeType = colldistType;
if (m_MuF2_ref <= 0.) {
warn(__func__, "Square of reference factorization scale should be > 0.");
}
}
} /* namespace PARTONS */
......@@ -5,38 +5,18 @@
namespace PARTONS {
const std::string CollinearDistributionEvolutionApfel::PARAM_NAME_THRESHOLDS =
"thresholds";
const std::string CollinearDistributionEvolutionApfel::PARAM_NAME_MASSES =
"masses";
const std::string CollinearDistributionEvolutionApfel::PARAM_NAME_SUBGRID_NODES =
"subgridNodes";
const std::string CollinearDistributionEvolutionApfel::PARAM_NAME_SUBGRID_LOWER_BOUNDS =
"subgridLowerBounds";
const std::string CollinearDistributionEvolutionApfel::PARAM_NAME_SUBGRID_INTER_DEGREES =
"subgridInterDegrees";
const std::string CollinearDistributionEvolutionApfel::PARAM_NAME_TAB_NODES =
"tabNodes";
const std::string CollinearDistributionEvolutionApfel::PARAM_NAME_TAB_LOWER_BOUND =
"tabLowerBound";
const std::string CollinearDistributionEvolutionApfel::PARAM_NAME_TAB_UPPER_BOUND =
"tabUpperBound";
const std::string CollinearDistributionEvolutionApfel::PARAM_NAME_TAB_INTER_DEGREE =
"tabInterDegree";
const unsigned int CollinearDistributionEvolutionApfel::classId =
BaseObjectRegistry::getInstance()->registerBaseObject(
new CollinearDistributionEvolutionApfel(
"CollinearDistributionEvolutionApfel"));
const std::string CollinearDistributionEvolutionApfel::PARAM_NAME_SUBGRID_NODES = "subgridNodes";
const std::string CollinearDistributionEvolutionApfel::PARAM_NAME_SUBGRID_LOWER_BOUNDS = "subgridLowerBounds";
const std::string CollinearDistributionEvolutionApfel::PARAM_NAME_SUBGRID_INTER_DEGREES = "subgridInterDegrees";
const unsigned int CollinearDistributionEvolutionApfel::classId = BaseObjectRegistry::getInstance()->registerBaseObject(new CollinearDistributionEvolutionApfel("CollinearDistributionEvolutionApfel"));
CollinearDistributionEvolutionApfel::CollinearDistributionEvolutionApfel(
const std::string &className) :
CollinearDistributionEvolutionModule(className), m_thresholds( { }), m_masses(
{ }), m_subgridNodes( { }), m_subgridLowerBounds( { }), m_subgridInterDegrees(
{ }), m_tabNodes(0), m_tabLowerBound(0), m_tabUpperBound(0), m_tabInterDegree(
0) {
CollinearDistributionEvolutionModule(className),
m_subgridNodes({100, 60, 50, 50}),
m_subgridLowerBounds({0.0001, 0.1, 0.6, 0.8}),
m_subgridInterDegrees({3, 3, 3, 3}) {
}
CollinearDistributionEvolutionApfel::~CollinearDistributionEvolutionApfel() {
......@@ -58,32 +38,6 @@ void CollinearDistributionEvolutionApfel::configure(
const ElemUtils::Parameters &parameters) {
CollinearDistributionEvolutionModule::configure(parameters);
if (parameters.isAvailable(
CollinearDistributionEvolutionApfel::PARAM_NAME_THRESHOLDS)) {
setThresholds(parameters.getLastAvailable().toVectorDouble());
std::ostringstream oss;
std::copy(m_thresholds.begin(), m_thresholds.end(),
std::ostream_iterator<double>(oss, " "));
info(__func__,
ElemUtils::Formatter()
<< CollinearDistributionEvolutionApfel::PARAM_NAME_THRESHOLDS
<< " configured with value = [ " << oss.str()
<< "] GeV");
}
if (parameters.isAvailable(
CollinearDistributionEvolutionApfel::PARAM_NAME_MASSES)) {
setMasses(parameters.getLastAvailable().toVectorDouble());
std::ostringstream oss;
std::copy(m_masses.begin(), m_masses.end(),