Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
GIDI_sums.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 <stdlib.h>
11#include "GIDI.hpp"
12#include <HAPI.hpp>
13
14namespace GIDI {
15
16namespace Sums {
17
18/*! \class Sums
19 * This class represents the **GNDS** <**sums**> node.
20 */
21
22/* *********************************************************************************************************//**
23 ***********************************************************************************************************/
24
27 m_crossSectionSums( GIDI_sumsCrossSectionsChars, GIDI_labelChars ),
28 m_multiplicitySums( GIDI_sumsMultiplicitiesChars, GIDI_labelChars ) {
29
30}
31
32/* *********************************************************************************************************//**
33 ***********************************************************************************************************/
34
36
37}
38
39/* *********************************************************************************************************//**
40 * The Sums method to parse its sub-nodes.
41 *
42 * @param a_construction [in] Used to pass user options to the constructor.
43 * @param a_node [in] The **HAPI::Node** to be parsed.
44 * @param a_setupInfo [in] Information create my the Protare constructor to help in parsing.
45 * @param a_pops [in] A PoPI::Database instance used to get particle indices and possibly other particle information.
46 * @param a_internalPoPs [in] The *internal* PoPI::Database instance used to get particle indices and possibly other particle information.
47 * This is the <**PoPs**> node under the <**reactionSuite**> node.
48 ***********************************************************************************************************/
49
50void Sums::parse( Construction::Settings const &a_construction, HAPI::Node const &a_node, SetupInfo &a_setupInfo,
51 PoPI::Database const &a_pops, PoPI::Database const &a_internalPoPs ) {
52
55 m_crossSectionSums.parse( a_construction, a_node.child( moniker ), a_setupInfo, a_pops, a_internalPoPs, parseSumsCrossSectionsSuite, nullptr );
56
59 m_multiplicitySums.parse( a_construction, a_node.child( moniker ), a_setupInfo, a_pops, a_internalPoPs, parseSumsMultiplicitiesSuite, nullptr );
60
61 m_crossSectionSums.setAncestor( this );
62 m_multiplicitySums.setAncestor( this );
63}
64
65/* *********************************************************************************************************//**
66 * Returns a pointer to the member whose moniker is *a_item*.
67 *
68 * @param a_item [in] The moniker of the member to return.
69 * @return Returns the pointer to the member of nullptr if it does not exists.
70 ***********************************************************************************************************/
71
72GUPI::Ancestry *Sums::findInAncestry3( std::string const &a_item ) {
73
74 if( a_item == GIDI_crossSectionSumsChars ) return( &m_crossSectionSums );
75 if( a_item == GIDI_multiplicitySumsChars ) return( &m_multiplicitySums );
76
77 if( a_item == GIDI_sumsCrossSectionsChars ) return( &m_crossSectionSums ); // GNDS 1.10.
78 if( a_item == GIDI_sumsMultiplicitiesChars ) return( &m_multiplicitySums ); // GNDS 1.10.
79
80 return( nullptr );
81}
82
83/* *********************************************************************************************************//**
84 * Returns a pointer to the member whose moniker is *a_item*.
85 *
86 * @param a_item [in] The moniker of the member to return.
87 * @return Returns the pointer to the member of nullptr if it does not exists.
88 ***********************************************************************************************************/
89
90GUPI::Ancestry const *Sums::findInAncestry3( std::string const &a_item ) const {
91
92 if( a_item == GIDI_crossSectionSumsChars ) return( &m_crossSectionSums );
93 if( a_item == GIDI_multiplicitySumsChars ) return( &m_multiplicitySums );
94
95 if( a_item == GIDI_sumsCrossSectionsChars ) return( &m_crossSectionSums ); // GNDS 1.10.
96 if( a_item == GIDI_sumsMultiplicitiesChars ) return( &m_multiplicitySums ); // GNDS 1.10.
97
98 return( nullptr );
99}
100
101/* *********************************************************************************************************//**
102 * Fills the argument *a_writeInfo* with the XML lines that represent *this*. Recursively enters each sub-node.
103 *
104 * @param a_writeInfo [in/out] Instance containing incremental indentation and other information and stores the appended lines.
105 * @param a_indent [in] The amount to indent *this* node.
106 ***********************************************************************************************************/
107
108void Sums::toXMLList( GUPI::WriteInfo &a_writeInfo, std::string const &a_indent ) const {
109
110 std::string indent2 = a_writeInfo.incrementalIndent( a_indent );
111
112 a_writeInfo.addNodeStarter( a_indent, moniker( ), "" );
113 m_crossSectionSums.toXMLList( a_writeInfo, indent2 );
114 m_multiplicitySums.toXMLList( a_writeInfo, indent2 );
115 a_writeInfo.addNodeEnder( moniker( ) );
116}
117
118/*! \class Base
119 * Base class for Sums sub-node.
120 */
121
122/* *********************************************************************************************************//**
123 * @param a_construction [in] Used to pass user options to the constructor.
124 * @param a_node [in] The **HAPI::Node** to be parsed.
125 * @param a_setupInfo [in] Information create my the Protare constructor to help in parsing.
126 * @param a_pops [in] A PoPI::Database instance used to get particle indices and possibly other particle information.
127 * @param a_internalPoPs [in] The *internal* PoPI::Database instance used to get particle indices and possibly other particle information.
128 * This is the <**PoPs**> node under the <**reactionSuite**> node.
129 * @param a_type [in] Type for the node.
130 ***********************************************************************************************************/
131
132Base::Base( Construction::Settings const &a_construction, HAPI::Node const &a_node, SetupInfo &a_setupInfo, LUPI_maybeUnused PoPI::Database const &a_pops,
133 LUPI_maybeUnused PoPI::Database const &a_internalPoPs, FormType a_type ) :
134 Form( a_node, a_setupInfo, a_type ),
135 m_ENDF_MT( a_node.attribute_as_int( GIDI_ENDF_MT_Chars ) ),
136 m_summands( a_construction, a_node.child( GIDI_sumsSummandsChars ), a_setupInfo ) {
137
138 m_summands.setAncestor( this );
139}
140
141/*! \class CrossSectionSum
142 * This class represents the **GNDS** <**crossSectionSum**> node.
143 */
144
145/* *********************************************************************************************************//**
146 * @param a_construction [in] Used to pass user options to the constructor.
147 * @param a_node [in] The **HAPI::Node** to be parsed.
148 * @param a_setupInfo [in] Information create my the Protare constructor to help in parsing.
149 * @param a_pops [in] A PoPI::Database instance used to get particle indices and possibly other particle information.
150 * @param a_internalPoPs [in] The *internal* PoPI::Database instance used to get particle indices and possibly other particle information.
151 * This is the <**PoPs**> node under the <**reactionSuite**> node.
152 ***********************************************************************************************************/
153
154CrossSectionSum::CrossSectionSum( Construction::Settings const &a_construction, HAPI::Node const &a_node, SetupInfo &a_setupInfo,
155 PoPI::Database const &a_pops, PoPI::Database const &a_internalPoPs ) :
156 Base( a_construction, a_node, a_setupInfo, a_pops, a_internalPoPs, FormType::crossSectionSum ),
157 m_Q( a_construction, GIDI_QChars, GIDI_labelChars, a_node, a_setupInfo, a_pops, a_internalPoPs, parseQSuite, nullptr ),
158 m_crossSection( a_construction, GIDI_crossSectionChars, GIDI_labelChars, a_node, a_setupInfo, a_pops, a_internalPoPs, parseCrossSectionSuite, nullptr ) {
159
160 m_Q.setAncestor( this );
161 m_crossSection.setAncestor( this );
162}
163
164/* *********************************************************************************************************//**
165 * Returns a pointer to the member whose moniker is *a_item*.
166 *
167 * @param a_item [in] The moniker of the member to return.
168 * @return Returns the pointer to the member of nullptr if it does not exists.
169 ***********************************************************************************************************/
170
172
173 if( a_item == GIDI_QChars ) return( &m_Q );
174 if( a_item == GIDI_crossSectionChars ) return( &m_crossSection );
175
176 return( nullptr );
177}
178
179/* *********************************************************************************************************//**
180 * Returns a pointer to the member whose moniker is *a_item*.
181 *
182 * @param a_item [in] The moniker of the member to return.
183 * @return Returns the pointer to the member of nullptr if it does not exists.
184 ***********************************************************************************************************/
185
186GUPI::Ancestry const *CrossSectionSum::findInAncestry3( std::string const &a_item ) const {
187
188 if( a_item == GIDI_QChars ) return( &m_Q );
189 if( a_item == GIDI_crossSectionChars ) return( &m_crossSection );
190
191 return( nullptr );
192}
193
194/* *********************************************************************************************************//**
195 * Fills the argument *a_writeInfo* with the XML lines that represent *this*. Recursively enters each sub-node.
196 *
197 * @param a_writeInfo [in/out] Instance containing incremental indentation and other information and stores the appended lines.
198 * @param a_indent [in] The amount to indent *this* node.
199 ***********************************************************************************************************/
200
201void CrossSectionSum::toXMLList( GUPI::WriteInfo &a_writeInfo, std::string const &a_indent ) const {
202
203 std::string indent2 = a_writeInfo.incrementalIndent( a_indent );
204 std::string attributes;
205
206 attributes = a_writeInfo.addAttribute( GIDI_labelChars, label( ) );
207 attributes += a_writeInfo.addAttribute( GIDI_ENDF_MT_Chars, intToString( ENDF_MT( ) ) );
208 a_writeInfo.addNodeStarter( a_indent, moniker( ), attributes );
209
210 summands( ).toXMLList( a_writeInfo, indent2 );
211
212 m_Q.toXMLList( a_writeInfo, indent2 );
213 m_crossSection.toXMLList( a_writeInfo, indent2 );
214
215 a_writeInfo.addNodeEnder( moniker( ) );
216}
217
218/*! \class MultiplicitySum
219 * This class represents the **GNDS** <**multiplicitySum**> node.
220 */
221
222/* *********************************************************************************************************//**
223 * @param a_construction [in] Used to pass user options to the constructor.
224 * @param a_node [in] The **HAPI::Node** to be parsed.
225 * @param a_setupInfo [in] Information create my the Protare constructor to help in parsing.
226 * @param a_pops [in] A PoPI::Database instance used to get particle indices and possibly other particle information.
227 * @param a_internalPoPs [in] The *internal* PoPI::Database instance used to get particle indices and possibly other particle information.
228 * This is the <**PoPs**> node under the <**reactionSuite**> node.
229 ***********************************************************************************************************/
230
231MultiplicitySum::MultiplicitySum( Construction::Settings const &a_construction, HAPI::Node const &a_node, SetupInfo &a_setupInfo,
232 PoPI::Database const &a_pops, PoPI::Database const &a_internalPoPs ) :
233 Base( a_construction, a_node, a_setupInfo, a_pops, a_internalPoPs, FormType::multiplicitySum ),
234 m_multiplicity( a_construction, GIDI_multiplicityChars, GIDI_labelChars, a_node, a_setupInfo, a_pops, a_internalPoPs, parseMultiplicitySuite, nullptr ) {
235
236 m_multiplicity.setAncestor( this );
237}
238
239/* *********************************************************************************************************//**
240 * Fills the argument *a_writeInfo* with the XML lines that represent *this*. Recursively enters each sub-node.
241 *
242 * @param a_writeInfo [in/out] Instance containing incremental indentation and other information and stores the appended lines.
243 * @param a_indent [in] The amount to indent *this* node.
244 ***********************************************************************************************************/
245
246void MultiplicitySum::toXMLList( GUPI::WriteInfo &a_writeInfo, std::string const &a_indent ) const {
247
248 std::string indent2 = a_writeInfo.incrementalIndent( a_indent );
249 std::string attributes;
250
251 attributes = a_writeInfo.addAttribute( GIDI_labelChars, label( ) );
252 attributes += a_writeInfo.addAttribute( GIDI_ENDF_MT_Chars, intToString( ENDF_MT( ) ) );
253 a_writeInfo.addNodeStarter( a_indent, moniker( ), attributes );
254
255 summands( ).toXMLList( a_writeInfo, indent2 );
256
257 m_multiplicity.toXMLList( a_writeInfo, indent2 );
258
259 a_writeInfo.addNodeEnder( moniker( ) );
260}
261
262/*! \class Summands
263 * This class represents the **GNDS** <**summands**> node.
264 */
265
266/* *********************************************************************************************************//**
267 * @param a_construction [in] Used to pass user options to the constructor.
268 * @param a_node [in] The **HAPI::Node** to be parsed.
269 * @param a_setupInfo [in] Information create my the Protare constructor to help in parsing.
270 ***********************************************************************************************************/
271
272Summands::Summands( Construction::Settings const &a_construction, HAPI::Node const &a_node, SetupInfo &a_setupInfo ) :
273 Form( a_node, a_setupInfo, FormType::summands ) {
274
275 for( HAPI::Node child = a_node.first_child( ); !child.empty( ); child.to_next_sibling( ) ) {
276 std::string name( child.name( ) );
277
278 if( name == GIDI_sumsAddChars ) {
279 Summand::Add *add = new Summand::Add( a_construction, child, a_setupInfo );
280
281 add->setAncestor( this );
282 m_summands.push_back( add ); }
283 else {
284 std::cout << "Sums::Summand::Base: Ignoring unsupported Form '" << name << "'." << std::endl;
285 }
286 }
287}
288
289/* *********************************************************************************************************//**
290 ***********************************************************************************************************/
291
293
294 for( std::vector<Summand::Base *>::iterator iter = m_summands.begin( ); iter < m_summands.end( ); ++iter ) delete *iter;
295}
296
297/* *********************************************************************************************************//**
298 * Fills the argument *a_writeInfo* with the XML lines that represent *this*. Recursively enters each sub-node.
299 *
300 * @param a_writeInfo [in/out] Instance containing incremental indentation and other information and stores the appended lines.
301 * @param a_indent [in] The amount to indent *this* node.
302 ***********************************************************************************************************/
303
304void Summands::toXMLList( GUPI::WriteInfo &a_writeInfo, std::string const &a_indent ) const {
305
306 std::string indent2 = a_writeInfo.incrementalIndent( a_indent );
307
308 a_writeInfo.addNodeStarter( a_indent, moniker( ), "" );
309 for( std::vector<Summand::Base *>::const_iterator iter = m_summands.begin( ); iter != m_summands.end( ); ++iter ) (*iter)->toXMLList( a_writeInfo, indent2 );
310 a_writeInfo.addNodeEnder( moniker( ) );
311}
312
313namespace Summand {
314
315/*! \class Base
316 * Base class inherited by sub-nodes of Summands.
317 */
318
319/* *********************************************************************************************************//**
320 * @param a_construction [in] Used to pass user options to the constructor.
321 * @param a_node [in] The **HAPI::Node** to be parsed.
322 * @param a_setupInfo [in] Information create my the Protare constructor to help in parsing.
323 ***********************************************************************************************************/
324
325Base::Base( LUPI_maybeUnused Construction::Settings const &a_construction, HAPI::Node const &a_node, LUPI_maybeUnused SetupInfo &a_setupInfo ) :
326 GUPI::Ancestry( a_node.name( ) ),
327 m_href( a_node.attribute_as_string( GIDI_hrefChars ) ) {
328
329}
330/*
331=========================================================
332 *
333 * @return
334 */
336
337}
338
339/* *********************************************************************************************************//**
340 * Fills the argument *a_writeInfo* with the XML lines that represent *this*. Recursively enters each sub-node.
341 *
342 * @param a_writeInfo [in/out] Instance containing incremental indentation and other information and stores the appended lines.
343 * @param a_indent [in] The amount to indent *this* node.
344 ***********************************************************************************************************/
345
346void Base::toXMLList( GUPI::WriteInfo &a_writeInfo, std::string const &a_indent ) const {
347
348 std::string attributes = a_writeInfo.addAttribute( GIDI_hrefChars, href( ) );
349
350 a_writeInfo.addNodeStarterEnder( a_indent, moniker( ), attributes );
351}
352
353
354/*! \class Add
355 * This class represents the **GNDS** <**add**> node.
356 */
357
358/* *********************************************************************************************************//**
359 * @param a_construction [in] Used to pass user options to the constructor.
360 * @param a_node [in] The **HAPI::Node** to be parsed.
361 * @param a_setupInfo [in] Information create my the Protare constructor to help in parsing.
362 ***********************************************************************************************************/
363
364Add::Add( Construction::Settings const &a_construction, HAPI::Node const &a_node, SetupInfo &a_setupInfo ) :
365 Base( a_construction, a_node, a_setupInfo ) {
366
367}
368
369} // End of namespace Summand.
370
371} // End of namespace Sums.
372
373} // End of namespace GIDI.
#define GIDI_sumsMultiplicitiesChars
Definition GIDI.hpp:206
#define GIDI_crossSectionChars
Definition GIDI.hpp:215
#define GIDI_ENDF_MT_Chars
Definition GIDI.hpp:420
#define GIDI_multiplicitySumsChars
Definition GIDI.hpp:211
#define GIDI_sumsSummandsChars
Definition GIDI.hpp:208
#define GIDI_QChars
Definition GIDI.hpp:219
#define GIDI_hrefChars
Definition GIDI.hpp:440
#define GIDI_labelChars
Definition GIDI.hpp:438
#define GIDI_sumsChars
Definition GIDI.hpp:204
#define GIDI_crossSectionSumsChars
Definition GIDI.hpp:209
#define GIDI_multiplicityChars
Definition GIDI.hpp:223
#define GIDI_sumsCrossSectionsChars
Definition GIDI.hpp:205
#define LUPI_maybeUnused
std::string const & label() const
Definition GIDI.hpp:658
Form(FormType a_type)
Definition GIDI_form.cc:25
Base(Construction::Settings const &a_construction, HAPI::Node const &a_node, SetupInfo &a_setupInfo, PoPI::Database const &a_pops, PoPI::Database const &a_internalPoPs, FormType a_type)
int ENDF_MT() const
Definition GIDI.hpp:4448
Summands const & summands() const
Definition GIDI.hpp:4449
GUPI::Ancestry * findInAncestry3(std::string const &a_item)
Definition GIDI_sums.cc:171
CrossSectionSum(Construction::Settings const &a_construction, HAPI::Node const &a_node, SetupInfo &a_setupInfo, PoPI::Database const &a_pops, PoPI::Database const &a_internalPoPs)
Definition GIDI_sums.cc:154
void toXMLList(GUPI::WriteInfo &a_writeInfo, std::string const &a_indent="") const
Definition GIDI_sums.cc:201
void toXMLList(GUPI::WriteInfo &a_writeInfo, std::string const &a_indent="") const
Definition GIDI_sums.cc:246
MultiplicitySum(Construction::Settings const &a_construction, HAPI::Node const &a_node, SetupInfo &a_setupInfo, PoPI::Database const &a_pops, PoPI::Database const &a_internalPoPs)
Definition GIDI_sums.cc:231
Add(Construction::Settings const &a_construction, HAPI::Node const &a_node, SetupInfo &a_setupInfo)
Definition GIDI_sums.cc:364
std::string const & href() const
Definition GIDI.hpp:4393
Base(Construction::Settings const &a_construction, HAPI::Node const &a_node, SetupInfo &a_setupInfo)
Summands(Construction::Settings const &a_construction, HAPI::Node const &a_node, SetupInfo &a_setupInfo)
Definition GIDI_sums.cc:272
void toXMLList(GUPI::WriteInfo &a_writeInfo, std::string const &a_indent="") const
Definition GIDI_sums.cc:304
void toXMLList(GUPI::WriteInfo &a_writeInfo, std::string const &a_indent="") const
Definition GIDI_sums.cc:108
GUPI::Ancestry * findInAncestry3(std::string const &a_item)
Definition GIDI_sums.cc:72
void parse(Construction::Settings const &a_construction, HAPI::Node const &a_node, SetupInfo &a_setupInfo, PoPI::Database const &a_pops, PoPI::Database const &a_internalPoPs)
Definition GIDI_sums.cc:50
void setAncestor(Ancestry *a_ancestor)
Definition GUPI.hpp:106
std::string const & moniker() const
Definition GUPI.hpp:102
Ancestry(std::string const &a_moniker, std::string const &a_attribute="")
virtual void toXMLList(WriteInfo &a_writeInfo, std::string const &a_indent="") const
void addNodeStarterEnder(std::string const &indent, std::string const &a_moniker, std::string const &a_attributes="")
Definition GUPI.hpp:57
void addNodeEnder(std::string const &a_moniker)
Definition GUPI.hpp:59
std::string incrementalIndent(std::string const &indent)
Definition GUPI.hpp:52
void addNodeStarter(std::string const &indent, std::string const &a_moniker, std::string const &a_attributes="")
Definition GUPI.hpp:55
std::string addAttribute(std::string const &a_name, std::string const &a_value) const
Definition GUPI.hpp:60
bool empty() const
Definition HAPI_Node.cc:150
Node first_child() const
Definition HAPI_Node.cc:82
Node child(const char *name) const
Definition HAPI_Node.cc:72
Definition GIDI.hpp:32
Form * parseCrossSectionSuite(Construction::Settings const &a_construction, Suite *parent, HAPI::Node const &a_node, SetupInfo &a_setupInfo, PoPI::Database const &a_pop, PoPI::Database const &a_internalPoPs, std::string const &a_name, Styles::Suite const *a_styles)
FormType
Definition GIDI.hpp:118
Form * parseQSuite(Construction::Settings const &a_construction, Suite *parent, HAPI::Node const &a_node, SetupInfo &a_setupInfo, PoPI::Database const &a_pop, PoPI::Database const &a_internalPoPs, std::string const &a_name, Styles::Suite const *a_styles)
Form * parseSumsMultiplicitiesSuite(Construction::Settings const &a_construction, Suite *a_parent, HAPI::Node const &a_node, SetupInfo &a_setupInfo, PoPI::Database const &a_pops, PoPI::Database const &a_internalPoPs, std::string const &a_name, Styles::Suite const *a_styles)
Form * parseMultiplicitySuite(Construction::Settings const &a_construction, Suite *parent, HAPI::Node const &a_node, SetupInfo &a_setupInfo, PoPI::Database const &a_pop, PoPI::Database const &a_internalPoPs, std::string const &a_name, Styles::Suite const *a_styles)
Form * parseSumsCrossSectionsSuite(Construction::Settings const &a_construction, Suite *a_parent, HAPI::Node const &a_node, SetupInfo &a_setupInfo, PoPI::Database const &a_pops, PoPI::Database const &a_internalPoPs, std::string const &a_name, Styles::Suite const *a_styles)
std::string intToString(int a_value)
Definition GIDI_misc.cc:415
Definition GUPI.hpp:20