Commit b60fffca authored by Pawel Sznajder's avatar Pawel Sznajder
Browse files

New proposition for the organization of partons_example #28

parent 93c1b91d
#ifndef EXAMPLES_H_
#define EXAMPLES_H_
// ******************************************************
// GPD EXAMPLES *****************************************
// ******************************************************
/**
* This function demonstrates a simple task as the evaluation of GPD model in a single kinematic point.
* The result of this function is printed out to the standard output.
* These are the values for all defined in the model GPDs, including singlet and non-singlet combinations for quarks.
*/
void computeSingleKinematicsForGPD();
/**
* This function demonstrates the evaluation of GPD model for kinematics defined in a text file.
* In this file kinematic points are encoded in separate lines using the following format: "x|xi|t|MuF2|MuR2".
* The result of this function is printed out to the standard output.
* These are the values for all defined in the model GPDs, including singlet and non-singlet combinations for quarks.
*/
void computeManyKinematicsForGPD();
// ******************************************************
// CFF EXAMPLES *****************************************
// ******************************************************
/**
* This function demonstrates a simple task as the evaluation of DVCS Compton Form Factors (CFF) in a single kinematic point.
* The result of this function is printed out to the standard output.
* These are CFF values for all GPD types defined in the selected GPD model.
*/
void computeSingleKinematicsForDVCSComptonFormFactor();
/**
* This function demonstrates the evaluation of DVCS Compton Form Factors (CFF) for kinematics defined in a text file.
* In this file kinematic points are encoded in separate lines using the following format: "xi|t|MuF2|MuR2|Q2".
* The result of this function is printed out to the standard output.
* These are CFF values for all GPD types defined in the selected GPD model.
*/
void computeManyKinematicsForDVCSComptonFormFactor();
// ******************************************************
// OBSERVABLE EXAMPLES **********************************
// ******************************************************
/**
* This function demonstrates a simple task as the evaluation of DVCS observable in a single kinematic point.
* The result of this function is printed out to the standard output.
*/
void computeSingleKinematicsForDVCSObservable();
/**
* This function demonstrates the evaluation of DVCS observable for kinematics defined in a text file.
* In this file kinematic points are encoded in separate lines using the following format: "xB|t|Q2|phi|E".
* The result of this function is printed out to the standard output.
*/
void computeManyKinematicsForDVCSObservable();
// ******************************************************
// OTHER ************************************************
// ******************************************************
/**
* This function demonstrates how to change the integration routine in one of modules.
* To make it possible, the module must inherit from MathIntegratorModule class (our doxygen documentation will tell you that).
*
* Be careful when you perform this operation.
* Some integration routines may speed up computations, but at the same time they can be not accurate enough to be applied in some kinematic ranges (e.g. in low xB).
* The infinities are also treated differently by various integration routines (or they are not treated at all).
*
* This function is the demonstration for GPD module.
* Note however that the way of changing the integration routine that is presented here is applicable to any type of PARTONS module.
*/
void changeIntegrationRoutine();
#endif /* INCLUDE_EXAMPLES_H_ */
#include "../include/examples.h"
#include <ElementaryUtils/logger/LoggerManager.h>
#include <ElementaryUtils/parameters/Parameter.h>
#include <ElementaryUtils/parameters/Parameters.h>
......@@ -24,11 +26,6 @@
#include <partons/services/ObservableService.h>
#include <partons/ServiceObjectRegistry.h>
/*
* This function demonstrates a simple task as the evaluation of GPD model in a single kinematic point.
* The result of this function is printed out to the standard output.
* These are the values for all defined in the model GPDs, including singlet and non-singlet combinations for quarks.
*/
void computeSingleKinematicsForGPD() {
// Retrieve GPD service
......@@ -57,12 +54,6 @@ void computeSingleKinematicsForGPD() {
pGPDModel = 0;
}
/*
* This function demonstrates the evaluation of GPD model for kinematics defined in a text file.
* In this file kinematic points are encoded in separate lines using the following format: "x|xi|t|MuF2|MuR2".
* The result of this function is printed out to the standard output.
* These are the values for all defined in the model GPDs, including singlet and non-singlet combinations for quarks.
*/
void computeManyKinematicsForGPD() {
// Retrieve GPD service
......@@ -94,11 +85,6 @@ void computeManyKinematicsForGPD() {
pGPDModel = 0;
}
/*
* This function demonstrates a simple task as the evaluation of DVCS Compton Form Factors (CFF) in a single kinematic point.
* The result of this function is printed out to the standard output.
* These are CFF values for all GPD types defined in the selected GPD model.
*/
void computeSingleKinematicsForDVCSComptonFormFactor() {
// Retrieve service
......@@ -150,12 +136,6 @@ void computeSingleKinematicsForDVCSComptonFormFactor() {
pGPDModule = 0;
}
/*
* This function demonstrates the evaluation of DVCS Compton Form Factors (CFF) for kinematics defined in a text file.
* In this file kinematic points are encoded in separate lines using the following format: "xi|t|MuF2|MuR2|Q2".
* The result of this function is printed out to the standard output.
* These are CFF values for all GPD types defined in the selected GPD model.
*/
void computeManyKinematicsForDVCSComptonFormFactor() {
// Retrieve service
......@@ -208,10 +188,6 @@ void computeManyKinematicsForDVCSComptonFormFactor() {
pGPDModule = 0;
}
/*
* This function demonstrates a simple task as the evaluation of DVCS observable in a single kinematic point.
* The result of this function is printed out to the standard output.
*/
void computeSingleKinematicsForDVCSObservable() {
// Retrieve Observable service
......@@ -310,11 +286,6 @@ void computeSingleKinematicsForDVCSObservable() {
pGPDModule = 0;
}
/*
* This function demonstrates the evaluation of DVCS observable for kinematics defined in a text file.
* In this file kinematic points are encoded in separate lines using the following format: "xB|t|Q2|phi|E".
* The result of this function is printed out to the standard output.
*/
void computeManyKinematicsForDVCSObservable() {
// Retrieve Observable service
......@@ -414,17 +385,6 @@ void computeManyKinematicsForDVCSObservable() {
pGPDModule = 0;
}
/*
* This function demonstrates how to change the integration routine in one of modules.
* To make it possible, the module must inherit from MathIntegratorModule class (our doxygen documentation will tell you that).
*
* Be careful when you perform this operation.
* Some integration routines may speed up computations, but at the same time they can be not accurate enough to be applied in some kinematic ranges (e.g. in low xB).
* The infinities are also treated differently by various integration routines (or they are not treated at all).
*
* This function is the demonstration for GPD module.
* Note however that the way of changing the integration routine that is presented here is applicable to any type of PARTONS module.
*/
void changeIntegrationRoutine() {
// Retrieve GPD service
......
......@@ -7,17 +7,7 @@
#include <string>
#include <vector>
/*
* Some declarations from examples.cpp
* Uncomment the one you want to use.
*/
//void computeSingleKinematicsForGPD();
//void computeManyKinematicsForGPD();
//void computeSingleKinematicsForDVCSComptonFormFactor();
//void computeManyKinematicsForDVCSComptonFormFactor();
//void computeSingleKinematicsForDVCSObservable();
//void computeManyKinematicsForDVCSObservable();
//void changeIntegrationRoutine();
#include "../include/examples.h"
/*
* Parse XML scenarios.
......@@ -37,6 +27,7 @@ std::vector<std::string> parseArguments(int argc, char** argv) {
*/
int main(int argc, char** argv) {
// Init Qt4
QCoreApplication a(argc, argv);
PARTONS::Partons* pPartons = 0;
......@@ -46,22 +37,20 @@ int main(int argc, char** argv) {
pPartons = PARTONS::Partons::getInstance();
pPartons->init(argc, argv);
// ******************************************************
// RUN XML SCENARIO *************************************
// ******************************************************
// You need to provide at least one scenario via executable argument
if (argc <= 1) {
// If you want to run your C++ code based on PARTONS library, comment out this exception:
throw ElemUtils::CustomException("main", __func__,
"Missing argument, please provide one or more than one XML scenario file.");
// And include your code here, e.g. this function in examples.cpp:
// computeSingleKinematicsForGPD(); // It has to be declared before, uncomment the declaration too.
// The program will then run the code here when there are no XML scenarios in argument.
} else {
// You need this to run XML scenarios indicated in arguments of the executable.
}
// Parse arguments to retrieve xml file path list.
std::vector<std::string> xmlScenarioFilePathList = parseArguments(
argc, argv);
std::vector<std::string> xmlScenarioFilePathList = parseArguments(argc,
argv);
// Retrieve automation service parse scenario xml file and play it.
PARTONS::AutomationService* pAutomationService =
......@@ -72,17 +61,40 @@ int main(int argc, char** argv) {
xmlScenarioFilePathList[i]);
pAutomationService->playScenario(pScenario);
}
// ******************************************************
// RUN CPP CODE *****************************************
// ******************************************************
// You can put your own code here and build a stand-alone program based on PARTONS library.
// To learn how you can use PARTONS library study provided examples of functions to be found in
// include/examples.h (header) and src/examples.cpp (source) files.
// To run these examples just call them here, e.g.:
// computeSingleKinematicsForGPD();
// Note, that you may need to comment out the part responsible for the running of XML scenarios.
}
// Appropriate catching of exceptions is crucial for working of PARTONS.
// PARTONS defines its own type of exception, which allows to display class name and function name
// where the exception has occurred, but also a human readable explanation.
catch (const ElemUtils::CustomException &e) {
// If there is an exception
} catch (const ElemUtils::CustomException &e) {
// Display what happened
pPartons->getLoggerManager()->error(e);
// Close PARTONS application properly
if (pPartons) {
pPartons->close();
}
} catch (const std::exception &e) {
}
// In a case of standard exception.
catch (const std::exception &e) {
// Display what happened
pPartons->getLoggerManager()->error("main", __func__, e.what());
// Close PARTONS application properly
if (pPartons) {
pPartons->close();
......
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