Logo

PARTONS: PARtonic Tomography Of Nucleon Software

This page:
about
instalation
usage
development
license
acknowledgements
contact

View GitHub repository:
link

View Docker repository:
link

View reference article:
doi   arXiv   inspire

Development of a new module

Introduction

PARTONS was designed with the philosophy that users should be able to “plug in” their own models at any level of the computation chain. This is achieved without modifying the core PARTONS library. A developer simply needs to create a class (direcly in PARTONS or within their own project) that inherits from an abstract class of a given type and implements the required virtual functions.

This tutorial provides guidance on creating these new modules and includes templates that illustrate the structures developers must understand and complete.

General remarks

How to use a new module

Once your project is compiled, you can use your new module just like any other in PARTONS. For more details, see this tutorial. To instantiate a clone of your new GPD module, use the following:

// Clone GPD module using the ModuleObjectFactory with your custom module's classId
PARTONS::GPDModule* pGPDModel = PARTONS::Partons::getInstance()->getModuleObjectFactory()->newGPDModule(MyGPDModel::classId);

Template for a new GPD module

Header File Template

class MyGPDModel : public PARTONS::GPDModule {

public:

    /** * Unique ID assigned by the BaseObjectRegistry.
     */
    static const unsigned int classId;

    /** * Default constructor.
     * @param className Name of the class.
     */
    MyGPDModel(const std::string& className);

    /** * Destructor.
     */
    virtual ~MyGPDModel();

    virtual MyGPDModel* clone() const;
    virtual void resolveObjectDependencies();
    virtual void configure(const ElemUtils::Parameters &parameters);

protected:

    /** * Copy constructor.
     * @param other Object to be copied.
     */
    MyGPDModel(const MyGPDModel& other);

    virtual void isModuleWellConfigured();
    virtual void initModule();

    // Specific GPD implementations
    virtual PARTONS::PartonDistribution computeH();
    virtual PARTONS::PartonDistribution computeE();
};

Source Code File Template

// Register the module in the PARTONS Registry
const unsigned int MyGPDModel::classId = 
    PARTONS::BaseObjectRegistry::getInstance()->registerBaseObject(new MyGPDModel("MyGPDModel"));

MyGPDModel::MyGPDModel(const std::string &className) : PARTONS::GPDModule(className) {

    // Map specific GPD types to their corresponding calculation functions
    m_listGPDComputeTypeAvailable.insert(
            std::make_pair(PARTONS::GPDType::H, &PARTONS::GPDModule::computeH));

    m_listGPDComputeTypeAvailable.insert(
            std::make_pair(PARTONS::GPDType::E, &PARTONS::GPDModule::computeE));
}

MyGPDModel::MyGPDModel(const MyGPDModel& other) : PARTONS::GPDModule(other) {
}

MyGPDModel::~MyGPDModel() {
}

MyGPDModel* MyGPDModel::clone() const {
    return new MyGPDModel(*this);
}

void MyGPDModel::resolveObjectDependencies() {
    // Initialize sub-modules here if necessary
}

void MyGPDModel::configure(const ElemUtils::Parameters &parameters) {
    PARTONS::GPDModule::configure(parameters);
}

void MyGPDModel::isModuleWellConfigured() {
    PARTONS::GPDModule::isModuleWellConfigured();
}

void MyGPDModel::initModule() {
    PARTONS::GPDModule::initModule();
}

PARTONS::PartonDistribution MyGPDModel::computeH() {

    // Initialize result container
    PARTONS::PartonDistribution result;

    // TODO: Your model implementation comes here
    // Use kinematics variables (m_x, m_xi, etc.) to perform calculations

    return result;
}

PARTONS::PartonDistribution MyGPDModel::computeE() {
    // Implementation follows the same logic as computeH()
    PARTONS::PartonDistribution result;
    return result;
}

Useful Variables

The following variables are defined in the parent abstract classes and are essential for implementing your GPD calculations. They store the current kinematic state for the evaluation: