Neutron generator updates#1878
Conversation
|
Hi @michaelmackenzie,
which require these tests: build. @Mu2e/write, @Mu2e/fnalbuild-users have access to CI actions on main. ⌛ The following tests have been triggered for fd5c2a7: build (Build queue - API unavailable) |
Core changeNew helper in the base class centralizes what double calculateBinnedSpectrumEnergyFraction(fhicl::ParameterSet pset,
std::string var_low = "elow",
std::string var_high = "ehi",
double full_var_low = 0.,
double full_var_high = 0.) const {
BinnedSpectrum spectrum(pset);
pset.erase(var_low);
pset.erase(var_high);
pset.put(var_low, full_var_low);
pset.put(var_high, full_var_high);
BinnedSpectrum fullSpectrum(pset);
...
const double fraction = (fullIntegral > 0.) ? integral / fullIntegral : 0.;
return fraction;
}
Issues / concerns1. Behavior change in DIO: dropped threshold correction (medium). The old DIO code added a near-threshold correction before computing the fraction; the new shared helper omits it: // removed in DIOGenerator_tool.cc
double pmin = _spectrum.getAbscissa(0);
double pdfmin = _spectrum.getPDF(0);
double binsize = _spectrum.getBinWidth();
fullintegral += 0.5*pdfmin*pmin/binsize;This changes the DIO 2. 3. Debug 4. |
|
☀️ The build tests passed at fd5c2a7.
N.B. These results were obtained from a build of this Pull Request at fd5c2a7 after being merged into the base branch at 20895af. For more information, please check the job page here. |
|
Responding to the AI comments, after discussion with Dave about the integral calculation:
|
| } | ||
| // The "full" integral may be missing the lowest tail component in some cases (e.g. DIO) | ||
| // --> apply a linear interpolation correction if requested | ||
| if(correct_full_integral) { |
There was a problem hiding this comment.
What is the use case for making this correction optional?
There was a problem hiding this comment.
Is this correction needed in general? Should the proton/neutron KE spectra also include it? In the case that a different variable was given (perhaps one, like cos(theta), that doesn't go 0 - x) would we need to instead provide the x-value for the absolute edge that isn't included in the BinnedSpectrum PDF?
I only made it optional as I didn't understand if all BinnedSpectrum PDFs are missing a component that can be approximated with a linear interpolation to 0 or not.
|
I suggest taking 1 step at a time:
- fix the bug in the integral calculation of DIO spectrum, where it's use
is unambiguous.
-factorize it out with proper control for the general case (if possible)
simply relying on the user to understand how the spectra are being used and
configure this correctly seems error prone.
…On Sat, Jul 11, 2026 at 10:46 AM Michael MacKenzie ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In EventGenerator/inc/ParticleGeneratorTool.hh
<#1878 (comment)>:
> + pset.put(var_low, full_var_low);
+ pset.put(var_high, full_var_high);
+ BinnedSpectrum fullSpectrum(pset);
+
+ // Calculate the integrals
+ double integral = 0.;
+ double fullIntegral = 0.;
+ for(size_t ibin=0;ibin < spectrum.getNbins();++ibin){
+ integral += spectrum.getPDF(ibin);
+ }
+ for(size_t ibin=0;ibin < fullSpectrum.getNbins();++ibin){
+ fullIntegral += fullSpectrum.getPDF(ibin);
+ }
+ // The "full" integral may be missing the lowest tail component in some cases (e.g. DIO)
+ // --> apply a linear interpolation correction if requested
+ if(correct_full_integral) {
Is this correction needed in general? Should the proton/neutron KE spectra
also include it? In the case that a different variable was given (perhaps
one, like cos(theta), that doesn't go 0 - x) would we need to instead
provide the x-value for the absolute edge that isn't included in the
BinnedSpectrum PDF?
I only made it optional as I didn't understand if all BinnedSpectrum PDFs
are missing a component that can be approximated with a linear
interpolation to 0 or not.
—
Reply to this email directly, view it on GitHub
<#1878?email_source=notifications&email_token=ABAH57YATQ3T7JCETXUQNGT5EJ4PJA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTINRXHA2DMOBUGI42M4TFMFZW63VMORSWC3K7NVSW45DJN5XKKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#discussion_r3564725389>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABAH57Y2EYPQYV4TEZJJMKL5EJ4PJAVCNFSNUABFKJSXA33TNF2G64TZHMZDAMRYGA2DMOJSHNEXG43VMU5TIOBVG44DGNJTGQ22C5QC>
.
You are receiving this because you are on a team that was mentioned.Message
ID: ***@***.***>
--
David Brown ***@***.***
Office Phone (510) 486-7261
Lawrence Berkeley National Lab
M/S 50R5008 (50-6026C) Berkeley, CA 94720
|
Is the current implementation following this or do you want the linear interpolation from 0 to bin 0 on by default? I can also update to use |
|
I just pushed an update to by default correct the low edge of the full PDF integral if |
This is so we can simulate the high energy neutron tail component for calo cluster background studies