Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
GIDI_xs_pdf_cdf1d.cc
Go to the documentation of this file.
1/*
2# <<BEGIN-copyright>>
3# Copyright 2019, Lawrence Livermore National Security, LLC.
4# This file is part of the gidiplus package (https://github.com/LLNL/gidiplus).
5# gidiplus is licensed under the MIT license (see https://opensource.org/licenses/MIT).
6# SPDX-License-Identifier: MIT
7# <<END-copyright>>
8*/
9
10#include "GIDI.hpp"
11#include <HAPI.hpp>
12
13namespace GIDI {
14
15namespace Functions {
16
17#define GIDI_xsChars "xs"
18#define GIDI_pdfChars "pdf"
19#define GIDI_cdfChars "cdf"
20
21/*! \class Xs_pdf_cdf1d
22 * Class for the GNDS <**xs_pdf_cdf1d**> node.
23 */
24
25/* *********************************************************************************************************//**
26 ***********************************************************************************************************/
27
32
33/* *********************************************************************************************************//**
34 *
35 * @param a_axes [in] The axes to copy for *this*.
36 * @param a_interpolation [in] The interpolation flag.
37 * @param a_index [in] If imbedded in a two dimensional function, the index of this instance.
38 * @param a_outerDomainValue [in] If imbedded in a two dimensional function, the domain value for *x2*.
39 * @param a_Xs [in] List of x1 values.
40 * @param a_pdf [in] The pdf evaluated at the x1 values.
41 * @param a_cdf [in] The pdf evaluated at the x1 values.
42 ***********************************************************************************************************/
43
44Xs_pdf_cdf1d::Xs_pdf_cdf1d( Axes const &a_axes, ptwXY_interpolation a_interpolation, std::vector<double> const &a_Xs,
45 std::vector<double> const &a_pdf, std::vector<double> const &a_cdf, int a_index, double a_outerDomainValue ) :
46 Function1dForm( GIDI_xs_pdf_cdf1dChars, FormType::xs_pdf_cdf1d, a_axes, a_interpolation, a_index, a_outerDomainValue ),
47 m_xs( a_Xs ),
48 m_pdf( a_pdf ),
49 m_cdf( a_cdf ) {
50
51}
52
53/* *********************************************************************************************************//**
54 *
55 * @param a_construction [in] Used to pass user options to the constructor.
56 * @param a_node [in] The **HAPI::Node** to be parsed and used to construct the XYs2d.
57 * @param a_setupInfo [in] Information create my the Protare constructor to help in parsing.
58 * @param a_parent [in] The parent GIDI::Suite.
59 ***********************************************************************************************************/
60
61Xs_pdf_cdf1d::Xs_pdf_cdf1d( Construction::Settings const &a_construction, HAPI::Node const &a_node, SetupInfo &a_setupInfo, Suite *a_parent ) :
62 Function1dForm( a_construction, a_node, a_setupInfo, FormType::xs_pdf_cdf1d, a_parent ) {
63
64 nf_Buffer<double> buffer;
65 parseValuesOfDoubles( a_construction, a_node.child( GIDI_xsChars ).child( GIDI_valuesChars ), a_setupInfo, buffer );
66 m_xs = buffer.vector();
67 parseValuesOfDoubles( a_construction, a_node.child( GIDI_pdfChars ).child( GIDI_valuesChars ), a_setupInfo, buffer );
68 m_pdf = buffer.vector();
69 parseValuesOfDoubles( a_construction, a_node.child( GIDI_cdfChars ).child( GIDI_valuesChars ), a_setupInfo, buffer );
70 m_cdf = buffer.vector();
71}
72
73/* *********************************************************************************************************//**
74 * *********************************************************************************************************/
75
79
80/* *********************************************************************************************************//**
81 * The assignment operator. This method sets the members of *this* to those of *a_rhs* except for those
82 * not set by base classes.
83 *
84 * @param a_rhs [in] Instance whose member are used to set the members of *this*.
85 ***********************************************************************************************************/
86
88
89 if( this != &a_rhs ) {
91 m_xs = a_rhs.Xs( );
92 m_pdf = a_rhs.pdf( );
93 m_cdf = a_rhs.cdf( );
94 }
95
96 return( *this );
97}
98
99/* *********************************************************************************************************//**
100 * The value of *pdf* at the point *a_x1*.
101 * Currently not implemented.
102 *
103 * @param a_x1 [in] The point for the *x1* axis.
104 * @return The value of the function at the point *a_x1*.
105 ***********************************************************************************************************/
106
107double Xs_pdf_cdf1d::evaluate( LUPI_maybeUnused double a_x1 ) const {
108
109 throw Exception( "Xs_pdf_cdf1d::evaluate: not implemented." );
110}
111
112/* *********************************************************************************************************//**
113 * This methods returns an XYs1d representation of the pdf of *this*. The calling function owns the created instance and is responible
114 * for freeing it.
115 *
116 * @param a_asLinlin [in] This argument is not used but retained to make the methods API at same as other asXYs1d functions.
117 * @param a_accuracy [in] This argument is not used but retained to make the methods API at same as other asXYs1d functions.
118 * @param a_lowerEps [in] This argument is not used but retained to make the methods API at same as other asXYs1d functions.
119 * @param a_upperEps [in] This argument is not used but retained to make the methods API at same as other asXYs1d functions.
120 *
121 * @return A pointer to an XYs1d instance that must be freed by the calling function.
122 ***********************************************************************************************************/
123
124XYs1d *Xs_pdf_cdf1d::asXYs1d( LUPI_maybeUnused bool a_asLinlin, LUPI_maybeUnused double a_accuracy, LUPI_maybeUnused double a_lowerEps, LUPI_maybeUnused double a_upperEps ) const {
125
126 return( new XYs1d( axes( ), ptwXY_interpolationLinLin, m_xs, m_pdf ) );
127}
128
129/* *********************************************************************************************************//**
130 * Fills the argument *a_writeInfo* with the XML lines that represent *this*. Recursively enters each sub-node.
131 *
132 * @param a_writeInfo [in/out] Instance containing incremental indentation and other information and stores the appended lines.
133 * @param a_indent [in] The amount to indent *this* node.
134 * @param a_embedded [in] If *true*, *this* function is embedded in a higher dimensional function.
135 * @param a_inRegions [in] If *true*, *this* is in a Regions1d container.
136 ***********************************************************************************************************/
137
138void Xs_pdf_cdf1d::toXMLList_func( GUPI::WriteInfo &a_writeInfo, std::string const &a_indent, bool a_embedded, bool a_inRegions ) const {
139
140 std::string attributes;
141
142 if( a_embedded ) {
144 else {
145 if( a_inRegions ) {
146 attributes = a_writeInfo.addAttribute( GIDI_indexChars, intToString( index( ) ) ); }
147 else {
148 if( label( ) != "" ) attributes = a_writeInfo.addAttribute( GIDI_labelChars, label( ) );
149 }
150 }
151
153
154 std::string xml = a_writeInfo.nodeStarter( a_indent, moniker( ), attributes );
155 xml += nodeWithValuesToDoubles( a_writeInfo, GIDI_xsChars, m_xs );
156 xml += nodeWithValuesToDoubles( a_writeInfo, GIDI_pdfChars, m_pdf );
157 xml += nodeWithValuesToDoubles( a_writeInfo, GIDI_cdfChars, m_cdf );
158 xml += a_writeInfo.nodeEnder( moniker( ) );
159
160 a_writeInfo.push_back( xml );
161}
162
163} // End namespace Functions.
164
165} // End namespace GIDI.
#define GIDI_valuesChars
Definition GIDI.hpp:260
#define GIDI_outerDomainValueChars
Definition GIDI.hpp:436
#define GIDI_interpolationChars
Definition GIDI.hpp:434
#define GIDI_labelChars
Definition GIDI.hpp:438
#define GIDI_xs_pdf_cdf1dChars
Definition GIDI.hpp:295
#define GIDI_indexChars
Definition GIDI.hpp:437
#define GIDI_xsChars
#define GIDI_pdfChars
#define GIDI_cdfChars
#define LUPI_maybeUnused
std::string const & label() const
Definition GIDI.hpp:658
Function1dForm(std::string const &a_moniker, FormType a_type, ptwXY_interpolation a_interpolation, int a_index, double a_outerDomainValue)
Definition GIDI_form.cc:348
Function1dForm & operator=(Function1dForm const &a_rhs)
Definition GIDI_form.cc:405
std::string interpolationString() const
Definition GIDI.hpp:1017
Axes const & axes() const
Definition GIDI.hpp:1012
double outerDomainValue() const
Definition GIDI.hpp:1010
ptwXY_interpolation interpolation() const
Definition GIDI.hpp:1015
XYs1d * asXYs1d(bool a_asLinlin, double a_accuray, double a_lowerEps, double a_upperEps) const
Xs_pdf_cdf1d & operator=(Xs_pdf_cdf1d const &a_rhs)
std::vector< double > const & cdf() const
Definition GIDI.hpp:1313
void toXMLList_func(GUPI::WriteInfo &a_writeInfo, std::string const &a_indent, bool a_embedded, bool a_inRegions) const
std::vector< double > const & pdf() const
Definition GIDI.hpp:1312
double evaluate(double a_x1) const
std::vector< double > const & Xs() const
Definition GIDI.hpp:1311
std::string const & moniker() const
Definition GUPI.hpp:102
void push_back(std::string const &a_line)
Definition GUPI.hpp:53
std::string nodeEnder(std::string const &a_moniker)
Definition GUPI.hpp:64
std::string nodeStarter(std::string const &indent, std::string const &a_moniker, std::string const &a_attributes="")
Definition GUPI.hpp:62
std::string addAttribute(std::string const &a_name, std::string const &a_value) const
Definition GUPI.hpp:60
Node child(const char *name) const
Definition HAPI_Node.cc:72
Definition GIDI.hpp:32
void parseValuesOfDoubles(Construction::Settings const &a_construction, HAPI::Node const &a_node, SetupInfo &a_setupInfo, nf_Buffer< double > &a_vector)
Definition GIDI_misc.cc:88
FormType
Definition GIDI.hpp:118
std::string nodeWithValuesToDoubles(GUPI::WriteInfo &a_writeInfo, std::string const &a_nodeName, std::vector< double > const &a_values)
Definition GIDI_misc.cc:391
std::string intToString(int a_value)
Definition GIDI_misc.cc:415
std::string doubleToShortestString(double a_value, int a_significantDigits=15, int a_favorEFormBy=0)
Definition LUPI_misc.cc:349
enum ptwXY_interpolation_e ptwXY_interpolation
@ ptwXY_interpolationLinLin
Definition ptwXY.h:37