1010#include " njoy/dryad/resonances/Channel.hpp"
1111#include " njoy/dryad/format/createVector.hpp"
1212#include " njoy/dryad/format/endf/resonances/lrf7/createParticlePairs.hpp"
13+ #include " njoy/dryad/format/endf/resonances/lrf7/createFrohnerBackground.hpp"
14+ #include " njoy/dryad/format/endf/resonances/lrf7/createSammyBackground.hpp"
15+ #include " njoy/dryad/format/endf/resonances/lrf7/createTabulatedBackground.hpp"
1316#include " ENDFtk/section/2/151.hpp"
1417
1518namespace njoy {
@@ -35,7 +38,8 @@ namespace lrf7 {
3538 const dryad::resonances::BoundaryCondition& boundary_condition,
3639 const dryad::resonances::Kinematics& kinematics,
3740 const ENDFtk::section::Type< 2 , 151 >::RMatrixLimited::ParticlePairs& endfPairs,
38- const ENDFtk::section::Type< 2 , 151 >::RMatrixLimited::ResonanceChannels& endfChannels ) {
41+ const ENDFtk::section::Type< 2 , 151 >::RMatrixLimited::ResonanceChannels& endfChannels,
42+ const ENDFtk::section::Type< 2 , 151 >::RMatrixLimited::BackgroundChannels& endfBackground ) {
3943
4044 std::vector< dryad::resonances::Channel > channels;
4145
@@ -114,6 +118,41 @@ namespace lrf7 {
114118 dryad::resonances::ChannelRadii radii ( endfChannels.trueChannelRadii ()[i] * constants::deca,
115119 endfChannels.effectiveChannelRadii ()[i] * constants::deca );
116120
121+ using Background = dryad::resonances::Channel::Background;
122+ std::optional< Background > background = std::nullopt ;
123+ if ( endfBackground.KBK () > 0 ) {
124+
125+ if ( endfBackground.backgroundRMatrices ()[i].has_value () ) {
126+
127+ using NoBackgroundRMatrix = ENDFtk::section::Type< 2 , 151 >::RMatrixLimited::NoBackgroundRMatrix;
128+ using TabulatedBackgroundRMatrix = ENDFtk::section::Type< 2 , 151 >::RMatrixLimited::TabulatedBackgroundRMatrix;
129+ using SammyBackgroundRMatrix = ENDFtk::section::Type< 2 , 151 >::RMatrixLimited::SammyBackgroundRMatrix;
130+ using FrohnerBackgroundRMatrix = ENDFtk::section::Type< 2 , 151 >::RMatrixLimited::FrohnerBackgroundRMatrix;
131+
132+ auto getBackground = tools::overload{
133+
134+ [&] ( const NoBackgroundRMatrix& ) -> std::optional< Background > {
135+
136+ return std::nullopt ;
137+ },
138+ [&] ( const FrohnerBackgroundRMatrix& data ) -> std::optional< Background > {
139+
140+ return createFrohnerBackground ( data );
141+ },
142+ [&] ( const SammyBackgroundRMatrix& data ) -> std::optional< Background > {
143+
144+ return createSammyBackground ( data );
145+ },
146+ [&] ( const TabulatedBackgroundRMatrix& data ) -> std::optional< Background > {
147+
148+ return createTabulatedBackground ( data );
149+ }
150+ };
151+
152+ background = std::visit ( getBackground, endfBackground.backgroundRMatrices ()[i].value () );
153+ }
154+ }
155+
117156 channels.emplace_back ( id::ChannelID ( id::ReactionID ( projectile, target, endfPairs.MT ()[index] ),
118157 dryad::resonances::ChannelQuantumNumbers ( endfChannels.orbitalMomentumValues ()[i],
119158 endfChannels.channelSpinValues ()[i],
@@ -124,7 +163,8 @@ namespace lrf7 {
124163 qvalues[index],
125164 std::move ( boundary ),
126165 std::move ( radii ),
127- kinematics );
166+ kinematics,
167+ std::move ( background ) );
128168 }
129169
130170 return channels;
0 commit comments