diff --git a/include/partons/beans/convol_coeff_function/TCS/TCSConvolCoeffFunctionKinematic.h b/include/partons/beans/convol_coeff_function/TCS/TCSConvolCoeffFunctionKinematic.h new file mode 100644 index 0000000000000000000000000000000000000000..10d28b2ce549b7af4172e6b093c1df4bdc421a79 --- /dev/null +++ b/include/partons/beans/convol_coeff_function/TCS/TCSConvolCoeffFunctionKinematic.h @@ -0,0 +1,215 @@ +#ifndef TCS_CONVOL_COEFF_FUNCTION_KINEMATIC_H +#define TCS_CONVOL_COEFF_FUNCTION_KINEMATIC_H + +/** + * @file TCSConvolCoeffFunctionKinematic.h + * @author Pawel Sznajder (NCBJ) + * @date July 26, 2018 + * @version 1.0 + */ + +#include +#include +#include + +#include "../../Kinematic.h" + +namespace ElemUtils { +class Packet; +class Parameters; +} /* namespace ElemUtils */ + +namespace PARTONS { + +/** + * @class TCSConvolCoeffFunctionKinematic + * + * @brief Class representing single CFF kinematics for TCS process. + * TODO + */ +class TCSConvolCoeffFunctionKinematic: public Kinematic { +public: + + /** + * Default constructor. + */ + TCSConvolCoeffFunctionKinematic(); + + /** + * Assignment constructor. + * @param parameters Parameters object storing values to be set marked by TODO + */ + TCSConvolCoeffFunctionKinematic(const ElemUtils::Parameters ¶meters); + + /** + * Assignment constructor. + * @param xi Skewness variable. + * @param t Four-momentum transfer squared of hadron target (in \f$GeV^{2}\f$). + * @param Q2Prim Virtual-photon virtuality. + * @param MuF2 Factorization scale squared (in \f$GeV^{2}\f$). + * @param MuR2 Renormalization scale squared (in \f$GeV^{2}\f$). + */ + TCSConvolCoeffFunctionKinematic(double xi, double t, double Q2Prim, double MuF2, + double MuR2); + + /** + * Assignment constructor. + * @param binId Id of bin. + * @param xi Skewness variable. + * @param t Four-momentum transfer squared of hadron target (in \f$GeV^{2}\f$). + * @param Q2Prim Virtual-photon virtuality. + * @param MuF2 Factorization scale squared (in \f$GeV^{2}\f$). + * @param MuR2 Renormalization scale squared (in \f$GeV^{2}\f$). + */ + TCSConvolCoeffFunctionKinematic(unsigned int binId, double xi, double t, + double Q2Prim, double MuF2, double MuR2); + + /** + * Assignment constructor. + * @param xi Skewness variable. + * @param t Four-momentum transfer squared of hadron target (in \f$GeV^{2}\f$). + * @param Q2Prim Virtual-photon virtuality. + * @param MuF2 Factorization scale squared (in \f$GeV^{2}\f$). + * @param MuR2 Renormalization scale squared (in \f$GeV^{2}\f$). + */ + TCSConvolCoeffFunctionKinematic(const ElemUtils::GenericType &xi, + const ElemUtils::GenericType &t, const ElemUtils::GenericType &Q2Prim, + const ElemUtils::GenericType &MuF2, + const ElemUtils::GenericType &MuR2); + + /** + * Destructor. + */ + virtual ~TCSConvolCoeffFunctionKinematic(); + + virtual std::string toString() const; + + /** + * Serialize into given Packet. + * @param packet Target Packet. + */ + void serialize(ElemUtils::Packet &packet) const; + + /** + * Retrieve data from given Packet. + * @param packet Input Packet. + */ + void unserialize(ElemUtils::Packet &packet); + + //******************************************************** + //*** SETTERS AND GETTERS ******************************** + //******************************************************** + + /** + * Get id of bin. + * @return Retrieved value. + */ + unsigned int getBinId() const; + + /** + * Set id of bin. + */ + void setBinId(unsigned int binId); + + /** + * Get skewness variable. + */ + double getXi() const; + + /** + * Set skewness variable. + */ + void setXi(double xi); + + /** + * Get four-momentum transfer squared of hadron target. + */ + double getT() const; + + /** + * Set four-momentum transfer squared of hadron target. + */ + void setT(double t); + + /** + * Get virtual-photon virtuality. + */ + double getQ2Prim() const; + + /** + * Set virtual-photon virtuality. + */ + void setQ2Prim(double Q2Prim); + + /** + * Set factorization scale squared. + */ + void setMuF2(double muF2); + + /** + * Set renormalization scale squared. + */ + void setMuR2(double muR2); + + /** + * Get factorization scale squared. + */ + double getMuF2() const; + + /** + * Get renormalization scale squared. + */ + double getMuR2() const; + +protected: + virtual void updateHashSum() const; + +private: + + /** + * Id of bin. + * This information is not set and used by typical calculations performed in PARTONS. However, it can associated to experimental or pseudo data stored in the database. + */ + unsigned int m_binId; + + /** + * Skewness variable. + */ + double m_xi; + + /** + * Four-momentum transfer squared of hadron target (in \f$GeV^{2}\f$). + */ + double m_t; + + /** + * Virtual-photon virtuality (in \f$GeV^{2}\f$). + */ + double m_Q2Prim; + + /** + * Factorization scale squared (in \f$GeV^{2}\f$). + */ + double m_MuF2; + + /** + * Renormalization scale squared (in \f$GeV^{2}\f$). + */ + double m_MuR2; +}; + +/** + * Stream operator to serialize class into Packet. See also GPDType::serialize(). + */ +ElemUtils::Packet& operator <<(ElemUtils::Packet& packet, + TCSConvolCoeffFunctionKinematic& kinematic); + +/** + * Stream operator to retrieve class from Packet. See also GPDType::unserialize(). + */ +ElemUtils::Packet& operator >>(ElemUtils::Packet& packet, + TCSConvolCoeffFunctionKinematic& kinematic); + +} /* namespace PARTONS */ + +#endif /* TCS_CONVOL_COEFF_FUNCTION_KINEMATIC_H */ diff --git a/include/partons/beans/convol_coeff_function/TCS/TCSConvolCoeffFunctionResult.h b/include/partons/beans/convol_coeff_function/TCS/TCSConvolCoeffFunctionResult.h new file mode 100644 index 0000000000000000000000000000000000000000..24e72fdd82fb1cb2acf86ece71aae76c1e303935 --- /dev/null +++ b/include/partons/beans/convol_coeff_function/TCS/TCSConvolCoeffFunctionResult.h @@ -0,0 +1,175 @@ +#ifndef TCS_CONVOL_COEFF_FUNCTION_RESULT_H +#define TCS_CONVOL_COEFF_FUNCTION_RESULT_H + +/** + * @file TCSConvolCoeffFunctionResult.h + * @author Pawel Sznajder (NCBJ) + * @date 26 July 2018 + * @version 1.0 + */ + +#include +#include +#include +#include +#include + +#include "../../../utils/compare/ComparisonReport.h" +#include "../../gpd/GPDType.h" +#include "../../observable/ObservableChannel.h" +#include "../../Result.h" +#include "TCSConvolCoeffFunctionKinematic.h" + +namespace PARTONS { + +class ComparisonReport; + +/** + * @class TCSConvolCoeffFunctionResult + * + * @brief Class representing single result of TCS CFF computation. + * + * This class is used to store results of a single TCS Compton Form Factor (CFF) computation. TODO + */ +class TCSConvolCoeffFunctionResult: public Result { +public: + + /** + * Default constructor. + */ + TCSConvolCoeffFunctionResult(); + + /** + * Assignment constructor. + * @param kinematic TCS CFF kinematics to be assigned. + */ + TCSConvolCoeffFunctionResult(TCSConvolCoeffFunctionKinematic kinematic); + + /** + * Destructor. + */ + virtual ~TCSConvolCoeffFunctionResult(); + + /** + * Add result for given GPD type. + * @param gpdComputeType GPD type associated to given result. + * @param result Result to be added. + */ + void add(GPDType::Type gpdComputeType, std::complex result); + + /** + * Get result for given GPD type. + * @param gpdComputeType GPD type associated to requested result. + * @return Requested result. + */ + std::complex get(GPDType::Type gpdComputeType); + + /** + * Check if the object stores result associated to given GPD type. + * @param gpdType GPD type to be checked. + * @return True if the object stores result associated to given GPD type, otherwise false. + * @see TCSConvolCoeffFunctionResult::getLastAvailable() + */ + bool isAvailable(GPDType::Type gpdType); + + /** + * Get reference to result marked by the last call of TCSConvolCoeffFunctionResult::isAvailible() function. + * @return Reference to selected result. + * @see TCSConvolCoeffFunctionResult::isAvailible() + */ + std::complex getLastAvailable() const; + + /** + * Get reference to result for given GPD type. + * @param gpdType GPD type associated to requested result. + * @return Reference to requested result. + */ + const std::complex& getResult(GPDType::Type gpdType) const; + + /** + * Compare to other TCSConvolCoeffFunctionResult object and store comparison result in given comparison report. + * @param rootComparisonReport Reference to comparison report to be used to store comparison result. + * @param referenceObject Reference to object to be compared. + * @param parentObjectInfo Addition information coming from the parent object (if needed). + */ + void compare(ComparisonReport &rootComparisonReport, + const TCSConvolCoeffFunctionResult &referenceObject, + std::string parentObjectInfo = ElemUtils::StringUtils::EMPTY) const; + + virtual std::string toString() const; + + /** + * Relation operator that checks if the value of left operand is less than the value of right operand (in this case returned is this->m_kinematic < other.m_kinematic). + * Used by std::sort function. + * @param other Right hand value. + * @return True if the value of left operand is less than the value of right operand, otherwise false. + */ + bool operator <(const TCSConvolCoeffFunctionResult &other) const; + + /** + * Get list of GPD types associated to stored parton distributions. + * @return Vector of associated types. + */ + std::vector listGPDTypeComputed(); + + //******************************************************** + //*** SETTERS AND GETTERS ******************************** + //******************************************************** + + /** + * Get type of channel associated to this class. + */ + const ObservableChannel& getChannel() const; + + /** + * Set type of channel associated to this class. + */ + void setChannel(const ObservableChannel& channel); + + /** + * Get reference to TCS CFF kinematics associated to this result. + */ + const TCSConvolCoeffFunctionKinematic& getKinematic() const; + + /** + * Set TCS CFF kinematics associated to this result. + */ + void setKinematic(const TCSConvolCoeffFunctionKinematic& kinematic); + + /** + * Get reference to map containing stored results distinguished by associated GPD types. + */ + const std::map >& getResultsByGpdType() const; + + /** + * Set map containing stored results distinguished by associated GPD types. + */ + void setResultsByGpdType( + const std::map >& resultsByGpdType); + +private: + + /** + * Type of channel associated to this class. + */ + ObservableChannel m_channel; + + /** + * TCS CFF kinematics associated to this result. + */ + TCSConvolCoeffFunctionKinematic m_kinematic; + + /** + * Map containing stored results distinguished by associated GPD types. + */ + std::map > m_resultsByGPDType; + + /** + * Iterator used to mark a specific entry in TCSConvolCoeffFunctionResult::m_resultsByGPDType. + */ + std::map >::const_iterator m_it; +}; + +} /* namespace PARTONS */ + +#endif /* TCS_CONVOL_COEFF_FUNCTION_RESULT_H */ diff --git a/include/partons/modules/convol_coeff_function/DVCS/DVCSConvolCoeffFunctionModule.h b/include/partons/modules/convol_coeff_function/DVCS/DVCSConvolCoeffFunctionModule.h index cde0e414963717ab04c5ae9f76a279371f8ca749..704cf106cfc3c8cbf3de8e90a723362240891bad 100644 --- a/include/partons/modules/convol_coeff_function/DVCS/DVCSConvolCoeffFunctionModule.h +++ b/include/partons/modules/convol_coeff_function/DVCS/DVCSConvolCoeffFunctionModule.h @@ -28,12 +28,14 @@ class RunningAlphaStrongModule; /** * @class DVCSConvolCoeffFunctionModule * - * @brief Abstract class that provides a skeleton to implement a Compton Form Factor (CFF) module. + * @brief Abstract class that provides a skeleton to implement DVCS Compton Form Factor (CFF) module. * * It is best to use this module with the corresponding service: ConvolCoeffFunctionService (see examples therein), as explained in the [general tutorial](@ref usage). */ class DVCSConvolCoeffFunctionModule: public ConvolCoeffFunctionModule { + public: + /** * Constructor. * See BaseObject::BaseObject and ModuleObject::ModuleObject for more details. @@ -41,6 +43,7 @@ public: * @param className name of child class. */ DVCSConvolCoeffFunctionModule(const std::string &className); + /** * Default destructor. */ @@ -61,12 +64,14 @@ public: * @return Complex result. */ virtual std::complex computeUnpolarized(); + /** * Method to compute some CFFs. * Can be implemented and used in child class, if needed. * @return Complex result. */ virtual std::complex computePolarized(); + /** * Method to compute some CFFs. * Can be implemented and used in child class, if needed. @@ -82,19 +87,24 @@ public: // ##### GETTERS & SETTERS ##### /** - * - * @return Order of the perturbative QCD computation. + * Get the order of the perturbative QCD computation. */ PerturbativeQCDOrderType::Type getQCDOrderType() const; + /** * Defines the order of the perturbative QCD computation. - * @param qcdOrderType + * @param qcdOrderType Order of the perturbative QCD computation. */ void setQCDOrderType(PerturbativeQCDOrderType::Type qcdOrderType); + /** + * Set pointer to Nf module to be used. + * @param pNfConvolCoeffFunction Pointer to Nf module to be used. + */ void setNfConvolCoeffFunction(ActiveFlavorsThresholdsModule* pNfConvolCoeffFunction); + /** - * + * Set pointer to the running coupling module to be used. * @param pRunningAlphaStrongModule Pointer to the running coupling module to be used. */ void setRunningAlphaStrongModule( @@ -104,15 +114,14 @@ protected: /** * Copy constructor. - * - * @param other + * @param other Object to be copied. */ DVCSConvolCoeffFunctionModule(const DVCSConvolCoeffFunctionModule &other); std::map (DVCSConvolCoeffFunctionModule::*)()> m_listOfCFFComputeFunctionAvailable; ///< List of GPD/CFF types the child class can compute. std::map (DVCSConvolCoeffFunctionModule::*)()>::iterator m_it; + std::complex (DVCSConvolCoeffFunctionModule::*)()>::iterator m_it; ///< Iterator. double m_xi; ///< Skewness. double m_t; ///< Mandelstam variable, momentum transfer on the hadron target (in GeV^2). @@ -123,8 +132,7 @@ protected: unsigned int m_nf; ///< Number of flavors. RunningAlphaStrongModule* m_pRunningAlphaStrongModule; ///< Pointer to the running coupling module to be used. - - ActiveFlavorsThresholdsModule* m_pNfConvolCoeffFunction; + ActiveFlavorsThresholdsModule* m_pNfConvolCoeffFunction; ///> m_xi; @@ -156,6 +159,7 @@ void DVCSConvolCoeffFunctionKinematic::setXi(double xi) { ElemUtils::Packet& operator <<(ElemUtils::Packet& packet, DVCSConvolCoeffFunctionKinematic& kinematic) { + kinematic.serialize(packet); return packet; } diff --git a/src/partons/beans/convol_coeff_function/DVCS/DVCSConvolCoeffFunctionResult.cpp b/src/partons/beans/convol_coeff_function/DVCS/DVCSConvolCoeffFunctionResult.cpp index 7fc26fbc5805b89459c434cc31580345cfece106..7a3ada3ecd0818af99a57f515af770b1912e4e53 100644 --- a/src/partons/beans/convol_coeff_function/DVCS/DVCSConvolCoeffFunctionResult.cpp +++ b/src/partons/beans/convol_coeff_function/DVCS/DVCSConvolCoeffFunctionResult.cpp @@ -9,11 +9,9 @@ namespace PARTONS { - DVCSConvolCoeffFunctionResult::DVCSConvolCoeffFunctionResult() : Result("DVCSConvolCoeffFunctionResult"), m_channel( ObservableChannel::DVCS) { - } DVCSConvolCoeffFunctionResult::DVCSConvolCoeffFunctionResult( @@ -32,7 +30,9 @@ void DVCSConvolCoeffFunctionResult::add(GPDType::Type gpdComputeType, std::complex DVCSConvolCoeffFunctionResult::get( GPDType::Type gpdComputeType) { + m_it = m_resultsByGPDType.find(gpdComputeType); + if (m_it == m_resultsByGPDType.end()) { throw ElemUtils::CustomException(getClassName(), __func__, ElemUtils::Formatter() @@ -44,6 +44,7 @@ std::complex DVCSConvolCoeffFunctionResult::get( } std::string DVCSConvolCoeffFunctionResult::toString() const { + std::map >::const_iterator it; ElemUtils::Formatter formatter; @@ -61,6 +62,7 @@ std::string DVCSConvolCoeffFunctionResult::toString() const { } std::vector DVCSConvolCoeffFunctionResult::listGPDTypeComputed() { + std::vector list; std::map >::const_iterator it; @@ -86,6 +88,7 @@ void DVCSConvolCoeffFunctionResult::setKinematic( } bool DVCSConvolCoeffFunctionResult::isAvailable(GPDType::Type gpdType) { + m_it = m_resultsByGPDType.find(gpdType); return (m_it != m_resultsByGPDType.end()) ? true : false; @@ -126,6 +129,7 @@ void DVCSConvolCoeffFunctionResult::compare( const std::complex& DVCSConvolCoeffFunctionResult::getResult( GPDType::Type gpdType) const { + std::map >::const_iterator it = m_resultsByGPDType.find(gpdType); diff --git a/src/partons/beans/convol_coeff_function/TCS/TCSConvolCoeffFunctionKinematic.cpp b/src/partons/beans/convol_coeff_function/TCS/TCSConvolCoeffFunctionKinematic.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d54e098f7f0b330391858e50bd82dcd40b984370 --- /dev/null +++ b/src/partons/beans/convol_coeff_function/TCS/TCSConvolCoeffFunctionKinematic.cpp @@ -0,0 +1,172 @@ +#include "../../../../../include/partons/beans/convol_coeff_function/TCS/TCSConvolCoeffFunctionKinematic.h" + +#include +#include + +#include "../../../../../include/partons/beans/gpd/GPDKinematic.h" +#include "../../../../../include/partons/beans/observable/ObservableKinematic.h" +#include "../../../../../include/partons/Partons.h" +#include "../../../../../include/partons/services/hash_sum/CryptographicHashService.h" +#include "../../../../../include/partons/ServiceObjectRegistry.h" + +namespace PARTONS { + +TCSConvolCoeffFunctionKinematic::TCSConvolCoeffFunctionKinematic() : + Kinematic("TCSConvolCoeffFunctionKinematic"), m_binId(0), m_xi(0.), m_t( + 0.), m_Q2Prim(0.), m_MuF2(0.), m_MuR2(0.) { +} + +TCSConvolCoeffFunctionKinematic::TCSConvolCoeffFunctionKinematic( + const ElemUtils::Parameters ¶meters) : + Kinematic("TCSConvolCoeffFunctionKinematic"), m_binId(0), m_xi(0.), m_t( + 0.), m_Q2Prim(0.), m_MuF2(0.), m_MuR2(0.) { + + if (parameters.isAvailable(GPDKinematic::GPD_KINEMATIC_PARAMETER_NAME_XI)) { + m_xi = parameters.getLastAvailable().toDouble(); + } else { + errorMissingParameter(GPDKinematic::GPD_KINEMATIC_PARAMETER_NAME_XI); + } + if (parameters.isAvailable(ObservableKinematic::PARAMETER_NAME_T)) { + m_t = parameters.getLastAvailable().toDouble(); + } else { + errorMissingParameter(ObservableKinematic::PARAMETER_NAME_T); + } + if (parameters.isAvailable(ObservableKinematic::PARAMETER_NAME_Q2Prim)) { + m_Q2Prim = parameters.getLastAvailable().toDouble(); + } else { + errorMissingParameter(ObservableKinematic::PARAMETER_NAME_Q2Prim); + } + + //TODO remove from kinematic + m_MuF2 = + parameters.get(GPDKinematic::GPD_KINEMATIC_PARAMETER_NAME_MUF2).toDouble(); + m_MuR2 = + parameters.get(GPDKinematic::GPD_KINEMATIC_PARAMETER_NAME_MUR2).toDouble(); +} + +TCSConvolCoeffFunctionKinematic::TCSConvolCoeffFunctionKinematic(double xi, + double t, double Q2Prim, double MuF2, double MuR2) : + Kinematic("TCSConvolCoeffFunctionKinematic"), m_binId(0), m_xi(xi), m_t( + t), m_Q2Prim(Q2Prim), m_MuF2(MuF2), m_MuR2(MuR2) { +} + +TCSConvolCoeffFunctionKinematic::TCSConvolCoeffFunctionKinematic( + unsigned int binId, double xi, double t, double Q2Prim, double MuF2, + double MuR2) : + Kinematic("TCSConvolCoeffFunctionKinematic"), m_binId(binId), m_xi(xi), m_t( + t), m_Q2Prim(Q2Prim), m_MuF2(MuF2), m_MuR2(MuR2) { +} + +TCSConvolCoeffFunctionKinematic::TCSConvolCoeffFunctionKinematic( + const ElemUtils::GenericType &xi, const ElemUtils::GenericType &t, + const ElemUtils::GenericType &Q2Prim, + const ElemUtils::GenericType &MuF2, const ElemUtils::GenericType &MuR2) : + Kinematic("TCSConvolCoeffFunctionKinematic"), m_xi(xi.toDouble()), m_t( + t.toDouble()), m_Q2Prim(Q2Prim.toDouble()), m_MuF2( + MuF2.toDouble()), m_MuR2(MuR2.toDouble()) { + +} + +TCSConvolCoeffFunctionKinematic::~TCSConvolCoeffFunctionKinematic() { +} + +std::string TCSConvolCoeffFunctionKinematic::toString() const { + return ElemUtils::Formatter() << Kinematic::toString() << " m_binId = " + << m_binId << " m_xi = " << m_xi << " m_t = " << m_t + << " m_Q2Prim = " << m_Q2Prim << " m_MuF2 = " << m_MuF2 + << " m_MuR2 = " << m_MuR2; +} + +unsigned int TCSConvolCoeffFunctionKinematic::getBinId() const { + return m_binId; +} + +double TCSConvolCoeffFunctionKinematic::getMuF2() const { + return m_MuF2; +} + +double TCSConvolCoeffFunctionKinematic::getMuR2() const { + return m_MuR2; +} + +double TCSConvolCoeffFunctionKinematic::getQ2Prim() const { + return m_Q2Prim; +} + +double TCSConvolCoeffFunctionKinematic::getT() const { + return m_t; +} + +double TCSConvolCoeffFunctionKinematic::getXi() const { + return m_xi; +} + +void TCSConvolCoeffFunctionKinematic::updateHashSum() const { + setHashSum( + Partons::getInstance()->getServiceObjectRegistry()->getCryptographicHashService()->generateSHA1HashSum( + ElemUtils::Formatter() << m_xi << m_t << m_Q2Prim << m_MuF2 + << m_MuR2)); +} + +void TCSConvolCoeffFunctionKinematic::serialize( + ElemUtils::Packet& packet) const { + + Kinematic::serialize(packet); + + packet << m_xi << m_t << m_Q2Prim << m_MuF2 << m_MuR2; +} + +void TCSConvolCoeffFunctionKinematic::unserialize(ElemUtils::Packet& packet) { + + Kinematic::unserialize(packet); + + packet >> m_xi; + packet >> m_t; + packet >> m_Q2Prim; + packet >> m_MuF2; + packet >> m_MuR2; +} + +void TCSConvolCoeffFunctionKinematic::setBinId(unsigned int binId) { + m_binId = binId; +} + +void TCSConvolCoeffFunctionKinematic::setMuF2(double MuF2) { + m_MuF2 = MuF2; + updateHashSum(); +} + +void TCSConvolCoeffFunctionKinematic::setMuR2(double MuR2) { + m_MuR2 = MuR2; + updateHashSum(); +} + +void TCSConvolCoeffFunctionKinematic::setQ2Prim(double Q2Prim) { + m_Q2Prim = Q2Prim; + updateHashSum(); +} + +void TCSConvolCoeffFunctionKinematic::setT(double t) { + m_t = t; + updateHashSum(); +} + +void TCSConvolCoeffFunctionKinematic::setXi(double xi) { + m_xi = xi; + updateHashSum(); +} + +ElemUtils::Packet& operator <<(ElemUtils::Packet& packet, + TCSConvolCoeffFunctionKinematic& kinematic) { + + kinematic.serialize(packet); + return packet; +} +ElemUtils::Packet& operator >>(ElemUtils::Packet& packet, + TCSConvolCoeffFunctionKinematic& kinematic) { + + kinematic.unserialize(packet); + return packet; +} + +} /* namespace PARTONS */ diff --git a/src/partons/beans/convol_coeff_function/TCS/TCSConvolCoeffFunctionResult.cpp b/src/partons/beans/convol_coeff_function/TCS/TCSConvolCoeffFunctionResult.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c6d0b2732c515164151827153b58bc08d54124d6 --- /dev/null +++ b/src/partons/beans/convol_coeff_function/TCS/TCSConvolCoeffFunctionResult.cpp @@ -0,0 +1,160 @@ +#include "../../../../../include/partons/beans/convol_coeff_function/TCS/TCSConvolCoeffFunctionResult.h" + +#include +#include +#include + +#include "../../../../../include/partons/utils/compare/CompareUtils.h" +#include "../../../../../include/partons/utils/compare/ComparisonData.h" + +namespace PARTONS { + +TCSConvolCoeffFunctionResult::TCSConvolCoeffFunctionResult() : + Result("TCSConvolCoeffFunctionResult"), m_channel( + ObservableChannel::TCS) { +} + +TCSConvolCoeffFunctionResult::TCSConvolCoeffFunctionResult( + TCSConvolCoeffFunctionKinematic kinematic) : + Result("TCSConvolCoeffFunctionResult"), m_channel( + ObservableChannel::TCS), m_kinematic(kinematic) { +} + +TCSConvolCoeffFunctionResult::~TCSConvolCoeffFunctionResult() { +} + +void TCSConvolCoeffFunctionResult::add(GPDType::Type gpdComputeType, + std::complex result) { + m_resultsByGPDType.insert(std::make_pair(gpdComputeType, result)); +} + +std::complex TCSConvolCoeffFunctionResult::get( + GPDType::Type gpdComputeType) { + + m_it = m_resultsByGPDType.find(gpdComputeType); + + if (m_it == m_resultsByGPDType.end()) { + throw ElemUtils::CustomException(getClassName(), __func__, + ElemUtils::Formatter() + << "Cannot find result for GPDComputeType = " + << GPDType(gpdComputeType).toString()); + } + + return m_it->second; +} + +std::string TCSConvolCoeffFunctionResult::toString() const { + + std::map >::const_iterator it; + + ElemUtils::Formatter formatter; + formatter << "[" << getClassName() << "] computed by " + << getComputationModuleName() << '\n'; + formatter << "kinematic(" << m_kinematic.toString() << ") \n"; + + for (it = m_resultsByGPDType.begin(); it != m_resultsByGPDType.end(); + it++) { + formatter << " CFF_" << GPDType(it->first).toString() << " = " + << (it->second).real() << " ; " << (it->second).imag() << "\n"; + } + + return formatter.str(); +} + +std::vector TCSConvolCoeffFunctionResult::listGPDTypeComputed() { + + std::vector list; + + std::map >::const_iterator it; + + if (m_resultsByGPDType.size() != 0) { + + for (it = m_resultsByGPDType.begin(); it != m_resultsByGPDType.end(); + ++it) { + list.push_back(it->first); + } + } + + return list; +} + +const TCSConvolCoeffFunctionKinematic& TCSConvolCoeffFunctionResult::getKinematic() const { + return m_kinematic; +} + +void TCSConvolCoeffFunctionResult::setKinematic( + const TCSConvolCoeffFunctionKinematic& kinematic) { + m_kinematic = kinematic; +} + +bool TCSConvolCoeffFunctionResult::isAvailable(GPDType::Type gpdType) { + + m_it = m_resultsByGPDType.find(gpdType); + + return (m_it != m_resultsByGPDType.end()) ? true : false; +} + +std::complex TCSConvolCoeffFunctionResult::getLastAvailable() const { + return m_it->second; +} + +const std::map >& TCSConvolCoeffFunctionResult::getResultsByGpdType() const { + return m_resultsByGPDType; +} + +void TCSConvolCoeffFunctionResult::setResultsByGpdType( + const std::map >& resultsByGpdType) { + m_resultsByGPDType = resultsByGpdType; +} + +void TCSConvolCoeffFunctionResult::compare( + ComparisonReport &rootComparisonReport, + const TCSConvolCoeffFunctionResult &referenceObject, + std::string parentObjectInfo) const { + + //TODO faire un test pour valider la cinématique associée + + //TODO tester la taille des listes avant de faire le test + for (std::map >::const_iterator it = + m_resultsByGPDType.begin(); it != m_resultsByGPDType.end(); it++) { + + ComparisonData comparisonData = CompareUtils::compareComplex("", + it->second, referenceObject.getResult(it->first), + rootComparisonReport.getTolerances(), + ElemUtils::Formatter() << parentObjectInfo << " " + << GPDType(it->first).toString()); + rootComparisonReport.addComparisonData(comparisonData); + } +} + +const std::complex& TCSConvolCoeffFunctionResult::getResult( + GPDType::Type gpdType) const { + + std::map >::const_iterator it = + m_resultsByGPDType.find(gpdType); + + if (it == m_resultsByGPDType.end()) { + throw ElemUtils::CustomException(getClassName(), __func__, + ElemUtils::Formatter() + << "Cannot find complex value from GPDType = " + << GPDType(gpdType).toString()); + } + + return (it->second); +} + +const ObservableChannel& TCSConvolCoeffFunctionResult::getChannel() const { + return m_channel; +} + +void TCSConvolCoeffFunctionResult::setChannel( + const ObservableChannel& channel) { + m_channel = channel; +} + +bool TCSConvolCoeffFunctionResult::operator <( + const TCSConvolCoeffFunctionResult& other) const { + return (m_kinematic < other.m_kinematic); +} + +} /* namespace PARTONS */