Custom scales¶
HEJ 2 comes with a small selection of built-in renormalisation and factorisation scales, as described in the scales setting. In addition to this, user-defined scales can be imported from custom libraries.
Writing the library¶
Custom scales are defined through C++ functions that take an event and
compute the corresponding scale. As an example, let’s consider a
function returning the transverse momentum of the softest jet in an
event. To make it accessible from HEJ 2, we have to prevent C++
name mangling with extern "C"
:
#include "HEJ/Event.hh"
extern "C"
double softest_jet_pt(HEJ::Event const & ev){
const auto softest_jet = sorted_by_pt(ev.jets()).back();
return softest_jet.perp();
}
After saving this code to some file myscales.cc
, we can compile
it to a shared library. With the g++
compiler this can be done
with the command
g++ $(HEJ-config --cxxflags) -fPIC -shared -Wl,-soname,libmyscales.so -o libmyscales.so myscales.cc
If g++
is used and the library also contains other definitions,
it is recommended to add -fvisibility=hidden
to the compiler
flags and __attribute__((visibility("default")))
after
extern "C"
for each exported function in order to avoid possible
name clashes.
Importing the scale into HEJ 2¶
Our custom scale can now be imported into HEJ 2 by adding the following lines to the YAML configuration file
import scales:
/path/to/libmyscales.so: softest_jet_pt
It is also possible to import several scales from one or more libraries:
import scales:
/path/to/libmyscales1.so: [first_scale, second_scale]
/path/to/libmyscales2.so: [another_scale, yet_another_scale]
The custom scales can then be used as usual in the scales setting, for example
scales: [H_T, softest_jet_pt, 2*softest_jet_pt]