Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sbncode/EventGenerator/MeVPrtl/Tools/BNBKaonGen_tool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ simb::MCFlux BNBKaonGen::MakeMCFlux(const bsim::BooNe &boone) {
<< std::endl;
}

flux.fFluxType = simb::kDk2Nu;
flux.fFluxType = simb::kNtuple;
flux.fnimpwt = fBooneNtp.beamwgt;
flux.fvx = fBooneNtp.ini_pos[0][0]; //0
flux.fvy = fBooneNtp.ini_pos[0][1]; //0
Expand Down
4 changes: 2 additions & 2 deletions sbncode/SBNEventWeight/Calculators/BNBFlux/FluxCalcPrep.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ namespace sbn {
}

//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.


// If no neutrinos in this event, gives 0 weight;
int NUni = fParameterSet.fNuniverses;
Expand Down Expand Up @@ -264,8 +264,8 @@ namespace sbn {
}

// 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


//Let's make a weights based on the calculator you have requested

Expand Down