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/logger/LoggerManager.h>
#include <ElementaryUtils/parameters/Parameter.h> #include <ElementaryUtils/parameters/Parameter.h>
#include <ElementaryUtils/parameters/Parameters.h> #include <ElementaryUtils/parameters/Parameters.h>
...@@ -24,11 +26,6 @@ ...@@ -24,11 +26,6 @@
#include <partons/services/ObservableService.h> #include <partons/services/ObservableService.h>
#include <partons/ServiceObjectRegistry.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() { void computeSingleKinematicsForGPD() {
// Retrieve GPD service // Retrieve GPD service
...@@ -57,12 +54,6 @@ void computeSingleKinematicsForGPD() { ...@@ -57,12 +54,6 @@ void computeSingleKinematicsForGPD() {
pGPDModel = 0; 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() { void computeManyKinematicsForGPD() {
// Retrieve GPD service // Retrieve GPD service
...@@ -94,11 +85,6 @@ void computeManyKinematicsForGPD() { ...@@ -94,11 +85,6 @@ void computeManyKinematicsForGPD() {
pGPDModel = 0; 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() { void computeSingleKinematicsForDVCSComptonFormFactor() {
// Retrieve service // Retrieve service
...@@ -150,12 +136,6 @@ void computeSingleKinematicsForDVCSComptonFormFactor() { ...@@ -150,12 +136,6 @@ void computeSingleKinematicsForDVCSComptonFormFactor() {
pGPDModule = 0; 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() { void computeManyKinematicsForDVCSComptonFormFactor() {
// Retrieve service // Retrieve service
...@@ -208,10 +188,6 @@ void computeManyKinematicsForDVCSComptonFormFactor() { ...@@ -208,10 +188,6 @@ void computeManyKinematicsForDVCSComptonFormFactor() {
pGPDModule = 0; 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() { void computeSingleKinematicsForDVCSObservable() {
// Retrieve Observable service // Retrieve Observable service
...@@ -310,11 +286,6 @@ void computeSingleKinematicsForDVCSObservable() { ...@@ -310,11 +286,6 @@ void computeSingleKinematicsForDVCSObservable() {
pGPDModule = 0; 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() { void computeManyKinematicsForDVCSObservable() {
// Retrieve Observable service // Retrieve Observable service
...@@ -414,17 +385,6 @@ void computeManyKinematicsForDVCSObservable() { ...@@ -414,17 +385,6 @@ void computeManyKinematicsForDVCSObservable() {
pGPDModule = 0; 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() { void changeIntegrationRoutine() {
// Retrieve GPD service // Retrieve GPD service
......
...@@ -7,17 +7,7 @@ ...@@ -7,17 +7,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
/* #include "../include/examples.h"
* 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();
/* /*
* Parse XML scenarios. * Parse XML scenarios.
...@@ -37,6 +27,7 @@ std::vector<std::string> parseArguments(int argc, char** argv) { ...@@ -37,6 +27,7 @@ std::vector<std::string> parseArguments(int argc, char** argv) {
*/ */
int main(int argc, char** argv) { int main(int argc, char** argv) {
// Init Qt4
QCoreApplication a(argc, argv); QCoreApplication a(argc, argv);
PARTONS::Partons* pPartons = 0; PARTONS::Partons* pPartons = 0;
...@@ -46,43 +37,64 @@ int main(int argc, char** argv) { ...@@ -46,43 +37,64 @@ int main(int argc, char** argv) {
pPartons = PARTONS::Partons::getInstance(); pPartons = PARTONS::Partons::getInstance();
pPartons->init(argc, argv); pPartons->init(argc, argv);
// ******************************************************
// RUN XML SCENARIO *************************************
// ******************************************************
// You need to provide at least one scenario via executable argument
if (argc <= 1) { if (argc <= 1) {
// If you want to run your C++ code based on PARTONS library, comment out this exception:
throw ElemUtils::CustomException("main", __func__, throw ElemUtils::CustomException("main", __func__,
"Missing argument, please provide one or more than one XML scenario file."); "Missing argument, please provide one or more than one XML scenario file.");
}
// And include your code here, e.g. this function in examples.cpp: // Parse arguments to retrieve xml file path list.
// computeSingleKinematicsForGPD(); // It has to be declared before, uncomment the declaration too. std::vector<std::string> xmlScenarioFilePathList = parseArguments(argc,
argv);
// The program will then run the code here when there are no XML scenarios in argument. // Retrieve automation service parse scenario xml file and play it.
PARTONS::AutomationService* pAutomationService =
pPartons->getServiceObjectRegistry()->getAutomationService();
} else { for (unsigned int i = 0; i < xmlScenarioFilePathList.size(); i++) {
// You need this to run XML scenarios indicated in arguments of the executable. PARTONS::Scenario* pScenario = pAutomationService->parseXMLFile(
xmlScenarioFilePathList[i]);
pAutomationService->playScenario(pScenario);
}
// Parse arguments to retrieve xml file path list. // ******************************************************
std::vector<std::string> xmlScenarioFilePathList = parseArguments( // RUN CPP CODE *****************************************
argc, argv); // ******************************************************
// Retrieve automation service parse scenario xml file and play it. // You can put your own code here and build a stand-alone program based on PARTONS library.
PARTONS::AutomationService* pAutomationService = // To learn how you can use PARTONS library study provided examples of functions to be found in
pPartons->getServiceObjectRegistry()->getAutomationService(); // include/examples.h (header) and src/examples.cpp (source) files.
// To run these examples just call them here, e.g.:
for (unsigned int i = 0; i < xmlScenarioFilePathList.size(); i++) { // computeSingleKinematicsForGPD();
PARTONS::Scenario* pScenario = pAutomationService->parseXMLFile(
xmlScenarioFilePathList[i]);
pAutomationService->playScenario(pScenario);
}
}
// If there is an exception // Note, that you may need to comment out the part responsible for the running of XML scenarios.
} catch (const ElemUtils::CustomException &e) {
}
// 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) {
// Display what happened
pPartons->getLoggerManager()->error(e); pPartons->getLoggerManager()->error(e);
// Close PARTONS application properly // Close PARTONS application properly
if (pPartons) { if (pPartons) {
pPartons->close(); 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()); pPartons->getLoggerManager()->error("main", __func__, e.what());
// Close PARTONS application properly // Close PARTONS application properly
if (pPartons) { if (pPartons) {
pPartons->close(); 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