Skip to content

TMVA Pythonization#21

Closed
harshal0815 wants to merge 293 commits intolmoneta:masterfrom
harshal0815:tmva-python-tutorials
Closed

TMVA Pythonization#21
harshal0815 wants to merge 293 commits intolmoneta:masterfrom
harshal0815:tmva-python-tutorials

Conversation

@harshal0815
Copy link
Copy Markdown

This Pull request:

  • Pythonizations for TMVA
  • Translated TMVA tutorial files

Changes or fixes:

Checklist:

  • tested changes locally
  • updated the docs (if necessary)

This PR fixes #

guitargeek and others added 30 commits June 28, 2022 16:43
The HistoToWorkspaceFactoryFast has three unused private member
functions that can be removed:

  * AddMultiVarGaussConstraint
  * AddPoissonTerms
  * EditSyst

Removing this code makes it easier to figure out where the systematic
constraint terms are actually created.
Some functions in RooRealSumFunc and RooRealSumPdf are overloaded in
exactly the same way, for example `evaluate` and `checkObservables`.

To avoid code duplication, they are implemented also as private static
functions in RooRealSumPdf, which the friend class RooRealSumFunc can
also use. This pattern might be used also to avoid further code
duplication, also with the other addition classes like RooAddition and
RooAddPdf.
This continues the work from the previous commit and should be squashed
with it on merge.
Fix the following compilation error of `ntuple_types` on Windows:
```
ntuple_types.obj : error LNK2019: unresolved external symbol "const ROOT::Experimental::RRecordField::`vftable'" (??_7RRecordField@Experimental@ROOT@@6b@) referenced in function "private: virtual void __thiscall RNTuple_CreateField_Test::TestBody(void)" (?TestBody@RNTuple_CreateField_Test@@EAEXXZ) [C:\Users\bellenot\build\release\tree\ntuple\v7\test\ntuple_types.vcxproj]
C:\Users\bellenot\build\release\tree\ntuple\v7\test\Release\ntuple_types.exe : fatal error LNK1120: 1 unresolved externals [C:\Users\bellenot\build\release\tree\ntuple\v7\test\ntuple_types.vcxproj]
```
This commit reverts root-project/root@69568116cd

The CtorsConstants variable is not used. The commit log has a simple tests which
now works without this patch.

Thanks to Jonas Hahnfeld (@hahnjo) for pointing this out!
Added new main block because this was mentioned in the meta issue
list (root-project#406 in cling) as one of the rewrite steps. This also allows for
the main code to be run as opposed to running the main code plus the
function defintions.
Replace plain Form by TString form; form.Form(...)
Ensure proper allocation, destroy, copy of this data
Had problems in copy and assign operators
One cannot copy pointers on pie slices, but have to copy values.
Implement TPieSlice::Copy function for that
Probably, is very rare use-case
Simplify cleanup, no need to call `goto L210` only for cleanup.
Use nullptr
When custom labels for TGaxis was configured, they were never deleted.
Situation is complicated, while fModLabs can point on modified
labels from TAxis object. Need to be improved.
Replace `if (flag == kTRUE)` just by `if (flag)` where flag is Bool_t
It is the only workaround to support I/O of TGaxis.
If TGaxis was configured from histogram axis and stored,
it may store `fModLabs` list from TAxis. After reading back such
object from the file one has no information about ownership.

Therefore now only lists with configured ownership are deleted -
making no crash with old ROOT files.
As per C++ core guidelines.
Before this patch, we were iterating until the end of the map
rather than until the end of the equal_range (this was not a
problem in practice because program logic guaranteed that we would
find what we were looking for and break out of the loop early).
saisoma123 and others added 26 commits July 16, 2022 19:43
well as llvm_tar and llvm_url. I added these dependent arguments
because they were listed as a rewrite step for the argument parser in
the meta-issue list. Also, it wouldn't make sense to download both the
LLVM binary and tar. I also added the tar and url dependency because
there was a binary and url dependency.
This will make code more flake8 compliant.
This makes the code more flake8 compliant.
Makes the code more flake8 compliant.
…e-dev-env [skip-ci] (root-project#10960)

Added skip-cleanup flags for create-dev-env.
This would instruct the cpt to build cling, clang, and llvm, without
deleting the build area, as the cpt normally would delete the build
area due to the use of memory running out when linking, because
of too many build subprocesses.
Header was badly formatted which resulted in only part of
it being displayed.
Also, fixed some typos.
The RooWorkspace sometimes stores some RooArgSet prefixed with `CACHE_`
in itself to cache for example parameters or constraint sets.

These cache sets are invalidated when elements are removed from them by
`RooWorkspace::RecursiveRemove()`. In this case, they should be removed
from the workspace such that they can be correctly recomputed later.

This change fixes problems like this one reported on the forum:
https://root-forum.cern.ch/t/how-to-properly-redefine-pdf-in-rooworkspace/50757

In that usecase, the following sequence of events happened:

1. Create pdf in workspace
2. Fit this pdf (triggering the caching of the set of parameters)
3. Recursively remove everything from the workspace, but not the cache
   sets as they are hidden from the user. The cached parameter sets are
   now empty, as all parameters got removed from the workspace
4. The same pdf from step 1 is recreated
5. Fitting of this new pdf will now fail, because RooFit thinks it has
   zero free parameters, as the call to `getParameters()` now returns
   the cleared cache set!
Some modernization of the RooWorkspace code:

  * use less `0` to represent null pointers and booleans
  * use more `!empty()` instead of `size()>0`
  * replace `MakeIterator` with range-based loops
  * remove some dead code that was commented out for over a decade
So far, one had to remove string attributes of a RooAbsArg with the
`RooAbsArg::removeStringAttribute(const char* key, const char* value)`
method, passing `nullptr` as a value. Passing a `nullptr` to a function
that takes a `const char*` is not supported in PyROOT, as explained in
GitHub issue root-project#10954. Therefore, a new function is added to RooAbsArg to
remove a string attribute without having to use `nullptr`.

This new function called `removeStringAttribute()` is now used in all
the ROOT code to remove string attributes from RooAbsArgs, and also
mentioned in the warnings that tell the user that they might want to
remove the `fitrange` attribute.

The verb `remove` was chosen instead of `delete`, `clear`, or `erase`,
because there was already a `RooAbsArg::removeServer()` method.
This is necessary for getting the code to be flake8 compliant.
Some of the quotes are causing issues in some `autoconf` macros for two packages in the LCG stack
Generalizes `RPageSourceDaos::LoadClusters()` to batch up the fetch requests for all pages in the cluster bunch before calling `RDaosContainer::ReadV`.

Async fetch requests for pages from different clusters may now share queue and flight time; thus, remote storage can parallelize them and improve read throughput.
Last year, with commit 3657e7c, the parameter index calculation was
changed to be on the fly instead of using a look-up map, which is much
faster.

However, the implemented formula was not correct for two or three
dimensions, which is fixed by this commit.

To make sure that the index computation is correct this time, the new
code was tested in this code snippet with various inputs:

```C++
void runTest(int nx = 42, int ny = 42, int nz = 42) {
  const int nxy = nx * ny;
  const int nyz = ny * nz;

  for (int i = 0; i < nx; ++i) {
    for (int j = 0; j < ny; ++j) {
      for (int k = 0; k < nz; ++k) {
        const int index = k + j * nz + i * ny * nz;
        const int gammaIndex = i + j * nx + k * nx * ny;

        const int i2 = index / nyz;
        const int tmp = index % nyz;
        const int j2 = tmp / nz;
        const int k2 = tmp % nz;

        const int gammaIndex2 = i2 + j2 * nx + k2 * nxy;

        if (gammaIndex2 != gammaIndex) {
          std::cout << "The unraveled indices were not correct!"
                    << std::endl;
          return;
        }
      }
    }
  }
}
```

Needs to be backported to the 6.26 branch to get into the 6.26.06 patch
release.

This commit the following problem reported on the forum:
https://root-forum.cern.ch/t/cpycppyy-segfault-on-mac-m1/50822
Enables Barlow-Beeston in multidimensional fits.

This patch was extensively tested and used by P. Hamilton et al. in LHCb.

Loop over all entries, not just the x-axis of a histogram.
When the normalization range for coefficient determination of a
RooAddPdf is changed, the AddPdf's projection cache needs to be reset,
just like it is already done in `RooAddPdf::fixCoefNormalization`.
Otherwise, there will be problems in the pdf evaluation and integration
because the projection cache is invalid.

A unit test based on the GitHub issue that reported this problem is also
implemented.

Closes root-project#10988.
It should be avoided to have RooAbsArgs with the same object name as
part of the same computation graph.

This has happened in RooAddPdf when using internally defined recursive
coefficients, which is changed with this commit.
TMVA DataSetInfo incorrectly handles array of variables
Fixed formatting issues
Fixed formatting issues
@harshal0815 harshal0815 requested a review from lmoneta as a code owner July 21, 2022 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.