Skip to content

Conversation

@VCLanNguyen
Copy link
Contributor

@VCLanNguyen VCLanNguyen commented Jan 9, 2026

  1. Fix a bug in MeVPrtl: BNBKaonGen incorrectly label boone ntuple as dk2nu format. Updated to it simple flux format. This would prevent Flux Weight tools to to crash when inputting MeVPrtl files.
  2. Add a feature in Flux Weight tools: to pick up neutrino energy from MCTruth instead if flux.nenergyn == -1.
    In MeVPrtl, by default, MCFlux neutrino energy is filled as -1 since not every meson in flux file would result in a neutrino. It instead computes an equivalent neutrino energy and saves it as MCTruth.
    This change should not impact the neutrino workflow since every meson results in a neutrino, and MCFlux flux.nenergyn should always be filled.

Description

Please provide a detailed description of the changes this pull request introduces. If available, also link to a docdb link where the issue/change have been presented on/discussed.

  • Have you added a label? (bug/enhancement/physics etc.)
  • Have you assigned at least 1 reviewer?
  • Is this PR related to an open issue / project?
  • Does this PR affect CAF data format? If so, please assign a CAF maintainer as additional reviewer.
  • Does this PR require merging another PR in a different repository (such as sbnanobj/sbnobj etc.)? If so, please link it in the description.
  • Are you submitting this PR on behalf of someone else who made the code changes? If so, please mention them in the description.

… fix flux weight calculator to pick neutrino energy from MCTruth if MCFlux energy is -1
@VCLanNguyen VCLanNguyen self-assigned this Jan 9, 2026
@VCLanNguyen VCLanNguyen added the bugfix Addresses one or more bugs label Jan 9, 2026
@kjplows kjplows moved this to Open pull requests in SBN software development Jan 15, 2026
@kjplows kjplows moved this from Open pull requests to Partially reviewed in SBN software development Jan 26, 2026
Copy link
Member

@jicrespo jicrespo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see the comments below.

}

flux.fFluxType = simb::kDk2Nu;
flux.fFluxType = simb::kSimple_Flux;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the flux type is "kSimple_Flux"? According to the MCFlux documentation, that item corresponds to "A simplified flux ntuple for quick running." It seems "kNtuple" (Full flux simulation ntuple) is more appropriate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked with Marco for which flux type to use and he suggested kSimple_Flux. Although it doesn't really matter which one of the two it is. Happy to switch to kNtuple.

// Collect neutrino energy; mclist is replaced with fluxlist.
// double enu= mclist[inu].GetNeutrino().Nu().E();
double enu= fluxlist[inu].fnenergyn;
if ( enu == -1 ) enu= mclist[inu].GetNeutrino().Nu().E(); //For MeVPrtl generator, not all MCFlux result in a neutrino, so equivalent neutrino energy is computed and saved as MCTruth
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If MCFlux does not contain a neutrino, it seems unnecessary to add a fake neutrino energy different from -1. I think it is safer to keep neutrino energy = -1 and handle the exception downstream.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The flux SBND weight module needs the neutrino energy to compute the systematic, see line: https://github.com/SBNSoftware/sbncode/blob/develop/sbncode/SBNEventWeight/Calculators/BNBFlux/FluxCalcPrep.cxx#L276

The equivalent neutrino energy is computed by MeVPrtl here:

// Compute the equivalent neutrino energy for a given parent meson position / momentum
double EnuLab(double enucm, TLorentzVector meson_mom, TLorentzVector meson_pos) { // all in detector coordinates
// Assume neutrino travels to center of detector
double costh = meson_mom.Vect().Unit().Dot(-meson_pos.Vect().Unit());
// Scale factor
double M = 1. / (meson_mom.Gamma() * (1 - meson_mom.Beta() * costh));
return M * enucm;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the time being, the flux module would seg fault when the neutrino energy is missing or -1. So this fix is neccessary for at least the flux module to work with MeVPrtl inputs.

See @grayputnam 's comments from a while ago: https://github.com/SBNSoftware/sbncode/blob/develop/sbncode/EventGenerator/MeVPrtl/MeVPrtlGen_module.cc#L363-L371


//or do the above 3 lines in one line
// auto const& mclist = *e.getValidHandle<std::vector<simb::MCTruth>>(fGeneratorModuleLabel);
auto const& mclist = *e.getValidHandle<std::vector<simb::MCTruth>>(fGeneratorModuleLabel);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this line is only uncommented for the neutrino energy fix when MCFlux does not have a neutrino, I would move it to a block under if ( enu == -1 ). However, see my other comment about not fixing the energy in that case.

Copy link
Contributor Author

@VCLanNguyen VCLanNguyen Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are several lines after this where mclist was commented out. So I'd like to keep at the same line for bookkeeping sake.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Addresses one or more bugs

Projects

Status: Partially reviewed
Status: Waiting on Reviewer

Development

Successfully merging this pull request may close these issues.

5 participants