Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR extends the framework to support simultaneous fits of multiple hadrons by generalizing the neural network and LHAPDF interfaces. Key changes include:
- Updates to NNADparameterisation to handle multiple hadrons (via mapping output splits, rotations, and derivatives).
- Modifications to LHAPDFparameterisation and associated chi² routines to retrieve the appropriate distributions based on the hadron type.
- Changes in test and run utilities to remove redundant command‐line options and support hadron‐specific configurations.
Reviewed Changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Reweighting.cc | Added a warning message regarding unsupported multiple hadrons and adjusted LHAPDF initialization. |
| tests/PredsComparison.cc, ClosureTests.cc | Updated to call distribution functions with the hadron argument. |
| src/parameterisations/NNADparameterisation.cc | Refactored to split outputs and rotations by hadron; now uses maps for derivative sets and hadron output sizes. |
| src/parameterisations/LHAPDFparameterisation.cc | Adjusted constructors and distribution function definitions to use hadron-dependent maps. |
| run/* (Predictions.cc, Optimize.cc, LHAPDFGrid.cc, ComputeChi2s.cc) | Updated run utilities to work with the new multiple-hadron configuration and simplified usage. |
| inc/MontBlanc/*.h | Header updates reflecting new function signatures and internal data structures for multi-hadron support. |
Files not reviewed (1)
- src/CMakeLists.txt: Language not supported
Comments suppressed due to low confidence (1)
tests/Reweighting.cc:38
- The warning message indicates 'undefined behaviour' when multiple hadrons are provided; consider rephrasing to clearly advise users on the limitations or required input format.
std::cout << "WARNING: this module does not handle multiple hadrons. If the more than one hadrons are "
Comment on lines
+103
to
+108
| for(size_t i=1; access((ResultFolder+ "/" + SetNamesMap[0] + "/" + SetNamesMap[0] + "_" + i_to_fixed_length_str(i,4) + ".dat").c_str(), F_OK) != -1; i++) | ||
| { | ||
| //std::cout<<(ResultFolder+"/LHAPDFSet/" + std::to_string(i)); | ||
| compute_chi2s(ResultFolder, i, LHAPDFSet, "IndivChi2s/Chi2sReplica" + std::to_string(i)); | ||
| for (auto const& map : config["NNAD"]["flavour maps"]) | ||
| MembersMap.insert({map["hadron"].as<std::string>(), i}); | ||
| compute_chi2s(ResultFolder, MembersMap, SetNamesMap, "IndivChi2s/Chi2sReplica" + std::to_string(i)); |
There was a problem hiding this comment.
Indexing the unordered_map 'SetNamesMap' with the key 0 is likely incorrect since it is keyed by string; consider iterating over the map or using a valid string key for file path construction.
…_MINUS_B.yaml to avoid a singular covariance matrix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements the possibility of performing simultaneous fits of multiple hadrons.
Implementation detail
NNADparameterisation
We use the same neural network to parametrise multiple hadrons. This means that the outputs of the network needs to be split into flavours belonging to different hadrons. Hence, for each hadron we define a split matrix which is stored in the class attribute
_SplitMatricesthat is defined in the constructor ofNNADparameterisation._SplitMatricesis astd::mapthat maps astd::string(the name of the hadron) to thennad:Matrixthat encodes the filtering layer for the network outputs. Hence, given a neural network that parametrises KA and PI, we can select the flavours of the PI as followsThen, one can apply flavour rotations to
SplitOutput. Note that flavour rotations also need to be coupled with the hadron. Hence, we also include the map_Rotations, which is similar to_SplitMatricesbut for flavour rotations.Both
_Rotationsand_SplitMatricesare constructed in the constructor ofNNADparameterisation. The reason is that both require runtime information taken from the runcard. For instance, the split matrices have to account for the number of flavours in each hadron and the total size of the network outputs, both specified in the runcard.On the other hand, flavour rotations require the flavour map specified for each hadron (see "Runcard Example" to learn how to specify maps for different hadrons).
The data structure of
_NNderivativeSetsis also modified. Now it isso that each hadron has its own
apfelset. This requires changes inEvaluateOnGridandDeriveOnGrid, which will loop over hadrons (see source code).Chi2 and predictions
Since we have to handle predictions with different hadrons in the same fit, we need to ensure that convolutions are computed with the correct hadron
apfel::Set. This is achieved by matching the hadron name from theDataHandlerwith the correctapfel::SetinNNADparameterisationwhen setting the FF inNangaParbat::ConvolutionTable. For instance, inAnalyticChiSquarewe haveLHAPDFgrid
The script that creates the LHAPDF grids is also modified to handle multiple hadrons. Specifically,
LHAPDFgridwill generate a grid for each hadron. The names of the sets are specified in the runcard for each hadron, under the keySetName(see runcard below).Other improvements
Using multiple cores in
ceres-solver(see Optimize.cc)It is possible to specify the number of cores to use as a command-line argument
TODO
Compatibility with scripts in the Tests folderMany scripts in theTestsfolder were already deprecated or outdated.Check that the implementation gives sensible resultsTest performed fitting KA and PI without sum rules. The two hadrons are compatible with previous separate fits (see ...)Backwards compatibilitylegacy version is tagged and the user is asked to use the old version of the code with legacy runcardRuncard example