73 auto hf_vtx_vec = marley_hepmc3::get_vertices_with_status(
74 marley_hepmc3::NUHEPMC_HF_DECAY_VERTEX, ev );
77 for (
const auto& vtx : hf_vtx_vec ) {
81 bool decayed_to_continuum =
false;
83 const auto& in_vec = vtx->particles_in();
84 const auto& out_vec = vtx->particles_out();
87 if ( in_vec.size() != 1u || out_vec.size() != 2u ) {
88 throw marley::Error(
"Hauser-Feshbach vertex encountered that"
89 " is not a binary decay" );
95 double width_tot = width_tot_attr->
value();
99 double width_ec = width_ec_attr->
value();
104 double width_sp = 0.;
105 if ( width_sp_attr ) {
106 decayed_to_continuum =
true;
107 width_sp = width_sp_attr->value();
111 const auto& mother = in_vec.front();
116 double Exi = Exi_attr->
value();
119 int twoJi = twoJi_attr->
value();
127 const auto& emitted_particle = out_vec.front();
128 const auto& daughter = out_vec.back();
130 int emitted_pdg = emitted_particle->pid();
135 double Exf = Exf_attr->
value();
138 int twoJf = twoJf_attr->
value();
147 double width_tot_alt = hf_alt.total_width();
152 auto ec_iter = std::find_if( ec_vec.cbegin(), ec_vec.cend(),
153 [ emitted_pdg, decayed_to_continuum, Exf ](
154 const std::unique_ptr< marley::ExitChannel >& test_ec ) ->
bool
156 if ( emitted_pdg != test_ec->emitted_particle_pdg() ) return false;
158 if ( decayed_to_continuum ) {
159 if ( !test_ec->is_continuum() ) return false;
166 const auto* dec =
dynamic_cast<
168 if ( !dec )
return false;
173 double Ex_level = lev.
energy();
177 if ( std::abs(Exf - Ex_level) > PRETTY_SMALL )
return false;
182 if ( ec_iter == ec_vec.cend() ) {
183 MARLEY_LOG( WARN,
"physics.opticalmodel" )
184 <<
"Could not find ExitChannel during reweighting";
191 double width_ec_alt = ( *ec_iter )->width();
195 double width_sp_alt = 0.;
196 if ( decayed_to_continuum ) {
200 const auto& cec =
dynamic_cast<
202 cec.differential_width( Exf,
true );
205 int mpol = 0, two_j_frag = 0, orb_l = 0;
206 bool emitted_gamma =
false;
210 emitted_gamma =
true;
211 mpol = mpol_attr->value();
220 two_j_frag = two_j_frag_attr->
value();
221 orb_l = orb_l_attr->
value();
226 const auto& spw_vec = cec.get_spw_table();
227 auto spw_iter = std::find_if( spw_vec.cbegin(), spw_vec.cend(),
228 [ twoJf, Pf, emitted_gamma, mpol, two_j_frag, orb_l ](
230 ::SpinParityWidth >& spw ) ->
bool
232 if ( Pf != spw->Pf ) return false;
233 if ( twoJf != spw->twoJf ) return false;
234 if ( emitted_gamma ) {
235 const auto* g_spw = static_cast< const marley
236 ::GammaContinuumExitChannel::GammaSpinParityWidth* >(
238 if ( !g_spw ) return false;
239 if ( mpol != g_spw->multipolarity ) return false;
243 const auto* f_spw = static_cast< const marley
244 ::FragmentContinuumExitChannel::FragmentSpinParityWidth* >(
246 if ( !f_spw ) return false;
247 if ( two_j_frag != f_spw->two_j_frag ) return false;
248 if ( orb_l != f_spw->orb_l ) return false;
254 if ( spw_iter == spw_vec.cend() ) {
255 MARLEY_LOG( WARN,
"physics.opticalmodel" )
256 <<
"Could not find SpinParityWidth during reweighting";
263 width_sp_alt = spw_iter->get()->diff_width;
268 std::string bad_width_name;
269 if ( width_tot_alt <= 0. ) {
270 bad_width_name =
"Alternate total_width";
272 else if ( width_tot <= 0. ) {
273 bad_width_name =
"Original total width";
275 else if ( width_ec <= 0. ) {
276 bad_width_name =
"Original exit channel";
278 else if ( width_ec_alt <= 0. ) {
279 bad_width_name =
"Alternate exit channel";
281 else if ( decayed_to_continuum ) {
282 if ( width_sp_alt <= 0. ) bad_width_name =
"Alternate spin-parity";
283 else if ( width_sp <= 0. ) bad_width_name =
"Original spin-parity";
286 if ( !bad_width_name.empty() ) {
287 MARLEY_LOG( WARN,
"physics.opticalmodel" ) << bad_width_name <<
" is non-positive";
295 double w = width_tot / width_tot_alt;
296 if ( decayed_to_continuum ) {
297 w *= width_sp_alt / width_sp;
300 w *= width_ec_alt / width_ec;
303 MARLEY_LOG( DEBUG,
"physics.opticalmodel" ) <<
"OMP reweight: vertex"
304 " weight w = " << w <<
" (tot_width_alt/tot_width = "
305 << width_tot_alt <<
"/" << width_tot <<
")";
313 MARLEY_LOG( DEBUG,
"physics.opticalmodel" ) <<
"OMP reweight: final event"
314 " weight = " << weight;