[Rivet] Rivet 2.5.2 magic

Andy Buckley andy.buckley at cern.ch
Thu Oct 13 15:32:23 BST 2016


Hi Chris, (+ others)

The slides are attached to the agenda at 
https://indico.cern.ch/event/549001/

But the overlap removal stuff that I showed was just browsing the code. 
Try 
https://rivet.hepforge.org/hg/rivet/file/tip/src/Analyses/ATLAS_2016_I1458270.cc 
where the filtering starts at line 88.

A few quick comments about the new routines, in lieu for now of actual 
documentation *shame*:

---

There are quite a few variants of filter function.

   - Let's start with filter_select(objs, fn): this is a function that 
takes a (maybe const) container of Particles or Jets and a classifier 
function, and discards the entries for which the function returns false. 
It filters on a *copy* of the passed container, and returns the result.

   - Now the variations: there is also a filter_discard(), which inverts 
the classification function behaviour, to discard entries for which 
fn(obj) returns true; there are also ifilter_*() variants, which only 
accept non-const containers and modify "in-place" (hence the "i" 
prefix); and there are versions of all these where fn is a Cut, and 
others where it is a templated "function-like thing" or "functor".

   - The Cut application should be clear by now, but functors? This is a 
fancy way of saying that you can pass any object which effectively has 
one of these methods: "bool operator() (const Particle&) const" (or the 
same for Jet). This includes a genuine C++ function with that signature, 
but can also be an object: the latter is useful because an object can 
have *state*. A fairly large collection of built-in functions and 
functors for both boolean classification and more general "mapped 
calculations" can be found in the 
include/Rivet/Tools/{ParticleBase,Particle,Jet}Utils.hh headers. A good 
example of state is the deltaRLess functor: this calculates dR with 
respect to a reference vector/Particle/Jet provided at construction 
time, and returns true if a Particle/Jet passed to its operator() method 
is within a given radius -- also given at construction time: 
deltaRLess(myjet, 0.2), for example. There are lots of these "built-in", 
to save you writing your own. Advanced tip: if there's no standard 
functor to do what you want, a C++11 inline ("lambda") function can also 
be used as a functor.

Hope that's enough to get you started / help to read that example 
analysis code. Let me know if not -- if we're lucky, a dialogue on this 
stuff could serve as the basis for a wiki page documenting this stuff. 
CC to the Rivet dev list for that reason...

Andy


On 13/10/16 11:59, Christian Gutschow wrote:
> Hi Andy,
>
> could you email me the slides and/or routine that you’ve shown at the
> Rivet workshop (where you do all the fancy new 2.5.2 magic with the
> overlap removal and what not)? :-)
>
> Ta,
> Chris
>
>
>>
>  Dr. Christian Gütschow
>
>  Department of Physics and Astronomy
>  University College London
>  Gower Street
>  London WC1E 6BT
>
>  > D10 Physics Building
>  > +44 (0)20 7679 3775
>  > chris.g at cern.ch <mailto:chris.g at cern.ch>
>
>
>
>


-- 
Dr Andy Buckley, Lecturer / Royal Society University Research Fellow
Particle Physics Expt Group, University of Glasgow


More information about the Rivet mailing list