Skip to content

Multi-weight handling overhaul

Christian Gutschow requested to merge allow_weight_subsets into release-3-1-x

So I started this as a feature development and then ended up heading down a rabbit hole, I'm afraid, so now it covers a few things:

New features

  1. The rivet executable now supports the flags --match-weights and --unmatch-weights to select/veto a subset of the weights in analogy to the plotting scripts:
rivet -a MC_JETS --match-weights="Weight1,Weight2,MUR.*MUF.*PDF123456" input.hepmc
rivet -a MC_JETS --unmatch-weights="NTrial,MUR1_MUF1_PDF987654" input.hepmc

Notice the support of regular expressions. These flags map onto functions selectWeightNames(patterns) and deselectWeightNames(patterns) defined in the AnalysisHandler.

Bugs

  1. While implementing this, I noticed that the existing --skip-weights flag was still not working properly and required more sophisticated book-keeping of what is the index of the nominal weight in the weight matrix vs. the index of the nominal histogram. They aren't necessarily the same, especially when you only book histograms for a subset of the available weights. Fixed now.
  2. Fixing the one above made me think that there is probably a bug in the EventMixingFinalState projection, specifically in L159 of the header file where it selects e.weights()[0]: It's not guaranteed that the 0th position corresponds to the nominal weight or even a physically meaningful weight at all. This could be a scale variation or some MC-internal debugging value. I haven't touched this yet and leave it to @lonnblad and/or @bierlich to review this. (Also happy to fix this if you tell me what this should be doing.)
  3. Speaking of which, now that we allow the user to only run with a subset of the available events, I wonder whether there should be some sort of check that, when doing a re-entrant run, the number of multiweights found in the input YODA file is equal to the number of selected weights for the re-entrant run. I'm not actually sure what would happen if they don't match, but maybe @lonnblad can comment.

Code improvements

  1. Given that we now require C++14, I could finally get rid off the ugly hack to extract the weight names in RivetHepMC_2.cc and put the original implementation based on regex back in that wasn't supported by gcc4.8.
  2. I realised we could avoid the odd loop in the AnalysisHandler, so I re-structured a couple of things, particularly around the nominal weight identification.
  3. Tightened up a few loose ends that had ToDos next to them.

Closes #53 (closed)

Edited by Christian Gutschow

Merge request reports