Commit 6862a574 authored by Pawel Sznajder's avatar Pawel Sznajder
Browse files

add ANN parameters

parent e9d101d7
This diff is collapsed.
#include <ElementaryUtils/logger/CustomException.h>
#include <ElementaryUtils/logger/LoggerManager.h>
#include <partons/beans/gpd/GPDKinematic.h>
#include <partons/beans/gpd/GPDType.h>
#include <partons/beans/parton_distribution/PartonDistribution.h>
#include <partons/beans/parton_distribution/QuarkDistribution.h>
#include <partons/beans/QuarkFlavor.h>
#include <partons/modules/gpd/GPDGK16.h>
#include <partons/ModuleObjectFactory.h>
#include <partons/Partons.h>
#include <partons/services/GPDService.h>
#include <partons/ServiceObjectRegistry.h>
#include <QtCore/qcoreapplication.h>
#include <stddef.h>
#include <cstdlib>
#include <iostream>
#include <vector>
#include "../include/gpd/GPDANNDD.h"
#include "../include/gpd/xEqXi_with_pos_replicas.h"
using namespace PARTONS;
......@@ -30,31 +41,62 @@ int main(int argc, char** argv) {
Partons::getInstance()->getServiceObjectRegistry()->getGPDService();
// Create GPD module with the BaseModuleFactory
GPDModule* pGPDModel =
GPDModule* pGPDModelGK =
Partons::getInstance()->getModuleObjectFactory()->newGPDModule(
GPDGK16::classId);
GPDModule* pGPDModelANN =
Partons::getInstance()->getModuleObjectFactory()->newGPDModule(
GPDANNDD::classId);
// Create a GPDKinematic(x, xi, t, MuF2, MuR2) to compute
GPDKinematic gpdKinematic(0.1, 0.2, -0.1, 2., 2.);
// Run computation
GPDResult gpdResult = pGPDService->computeSingleKinematic(gpdKinematic,
pGPDModel);
GPDResult gpdResultGK = pGPDService->computeSingleKinematic(
gpdKinematic, pGPDModelGK);
// Print results
Partons::getInstance()->getLoggerManager()->info("main", __func__,
gpdResult.toString());
gpdResultGK.toString());
// Print something more specific
// Print something specific
std::cout << "GPD H for up quarks is: "
<< gpdResult.getPartonDistribution(GPDType::H).getQuarkDistribution(
<< gpdResultGK.getPartonDistribution(GPDType::H).getQuarkDistribution(
QuarkFlavor::UP).getQuarkDistribution() << std::endl;
// Set replica for ANN
size_t iReplica = 0;
std::vector<double> parameters(c_nPar_x_eq_xi_with_pos);
if (!(iReplica < c_nRep_x_eq_xi_with_pos)) {
std::cout << "error: " << __func__ << ": wrong replica index, "
<< iReplica << " (must be smaller than "
<< c_nRep_x_eq_xi_with_pos << ")" << std::endl;
exit(0);
}
for (size_t i = 0; i < c_nPar_x_eq_xi_with_pos; i++) {
parameters.at(i) = c_par_x_eq_xi_with_pos[iReplica][i];
}
static_cast<GPDANNDD*>(pGPDModelANN)->setParameters(parameters);
// Run computation
GPDResult gpdResultANN = pGPDService->computeSingleKinematic(
gpdKinematic, pGPDModelANN);
// Print results
Partons::getInstance()->getLoggerManager()->info("main", __func__,
gpdResultANN.toString());
// Remove pointer references
// Module pointers are managed by PARTONS
Partons::getInstance()->getModuleObjectFactory()->updateModulePointerReference(
pGPDModel, 0);
pGPDModel = 0;
pGPDModelGK, 0);
pGPDModelGK = 0;
}
// Appropriate catching of exceptions is crucial for working of PARTONS.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment