You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/getting-started.md
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,7 +40,8 @@ The following options are available when configuring the build (when running `cm
40
40
*`-DBOOST_ROOT=(path)`: Use specific Boost version (path to its install directory)
41
41
*`-DTESTS=ON`: Also compile the test executables
42
42
*`-DEXAMPLES=OFF`: Do not compile the example executables
43
-
43
+
*`-DPYTHON_BINDINGS=ON|OFF` (`OFF` by default). Builds python bindings for MoMEMta. Requires python and boost::python.
44
+
*`-DDEBUG_TIMING=ON|OFF` (`OFF` by default). If `ON`, a summary of how long each module ran is printed at the end of the integration. Can be useful to see which module to optimize.
44
45
45
46
## Usage: Lua & MoMEMta
46
47
@@ -50,23 +51,22 @@ Computing weights in your analysis code is then a matter of only a few lines of
@@ -82,10 +82,10 @@ We ship a few example configuration files, along with short scripts computing a
82
82
./WW_fullyleptonic.exe
83
83
```
84
84
85
-
A set of more comprehensive examples on how to run MoMEMta can be found in our [Tutorials repository](https://github.com/MoMEMta/Tutorials). Each of these examples includes a matrix element generated by our exporter, a ROOT file containing a few events, a Lua configuration file and a small source code showing how to compute weights for the events in the sample.
85
+
A set of more comprehensive examples on how to run MoMEMta can be found in our [Tutorials repository](https://github.com/MoMEMta/Tutorials). Each of these examples includes a matrix element generated by our [exporter](https://github.com/MoMEMta/MoMEMta-MaGMEE) (see below), a ROOT file containing a few events, a Lua configuration file and a small source code showing how to compute weights for the events in the sample.
86
86
87
87
## Matrix elements
88
88
89
89
MoMEMta includes matrix elements for a few processes, but you might soon want to compute weights for other processes. It is possible to include matrix elements for any process by using our [Matrix Element Exporter](https://github.com/MoMEMta/MoMEMta-MaGMEE), a plugin for [MadGraph5_aMC@NLO](https://launchpad.net/mg5amcnlo) (MG5). The plugin takes a leading-order matrix element generated by MG5 and exports it in a format suitable for use in MoMEMta. More information on how to use the plugin and the resulting matrix elements is provided in the plugin’s [README file](https://github.com/MoMEMta/MoMEMta-MaGMEE/blob/master/README.md).
90
90
91
-
Support for other matrix element generators is planned for futures releases.
91
+
Support for other matrix element generators is planned for futures releases, however nothing prevents plugging in any code returning the matrix element provided it is wrapped properly for MoMEMta.
In MoMEMta, the integration is defined by linking modules together in a Lua script. MoMEMta is shipped with a set of modules covering the most common needs and whose parameters, inputs and outputs are documented [here](https://momemta.github.io/MoMEMta/dev/group__modules.html). For more information on how to write the configuration file, see [here](configuration-file.md).
2
2
3
-
> *A module is just a C++ class deriving from the `Module` virtual class. How to write a new module and make it available for the calculation is described (here).*
3
+
> *A module is just a C++ class deriving from the `Module` virtual class.*
4
+
5
+
[//]: # ( How to write a new module and make it available for the calculation is described (here). )
4
6
5
7
Once the configuration file is defined, it can be loaded by MoMEMta’s configuration reader:
At this point, the user might wish to modify some parameters defined in the file from the code itself:
12
+
At this point, the user might wish to modify some parameters defined in the file from the code itself (see also [here](configuration-file#parameters)):
> *MoMEMta is instantiated using a `Configuration` object, describing a fixed configuration: parameters cannot be modified at this stage. Parameters can be changed in the ConfigurationReader, and a new `MoMEMta` instance must then be constructed by calling `ConfigurationReader::freeze()` again.*
23
+
> *MoMEMta is instantiated using a `Configuration` object, describing a fixed configuration: parameters cannot be modified at this stage, the execution flow of the computation is fully fixed. Parameters can be changed in the ConfigurationReader, and a new `MoMEMta` instance must then be constructed by calling `ConfigurationReader::freeze()` again.*
22
24
23
-
The weight can finally be computed by calling the computeWeights() method of the MoMEMta object, passing the observed particles as a set of LorentzVectors:
25
+
The weight can finally be computed by calling the computeWeights() method of the MoMEMta object, passing the observed particles as arguments:
> *The `momemta::Particle` type consists of tree parts: a name (string) allowing to identify the particle in the configuration file, a 4-vector object, and a type (int). The type is not used by MoMEMta but can help the user configure the computation. It could be a PDG ID code, or any other code defined by the user.*
34
+
35
+
> *The MET is an optional argument (defaults to a null vector)*
29
36
30
-
> *The MET is an optional argument*
37
+
> *MoMEMta provides the useful typedef `LorentzVector` for Lorentz Vectors in the file `momemta/Types.h`*
31
38
32
-
> *The LorentzVectors are expected to be expressed in the `PxPyPzE<double>` basis*
39
+
> **Note**: MoMEMta checks that your inputs are physical, i.e. have non-negative energy and mass. Due e.g. to machine precision issues, it is possible your inputs have slightly negative masses without you noticing it. However, MoMEMta can produce nonsensical output or even crash in this case (*garbage in, garbage out*). It's up to the user to correct the inputs in those cases.
33
40
34
-
The function starts the Monte-Carlo integration: the integrand function is called a large number of times, each time passing as input a phase-space point vector (where the length of the vector is the dimensionality of the integrated phase-space) with elements lying between 0 and 1, and returning as output the integrated function evaluated on this point.
41
+
The function `computeWeights()`starts the Monte-Carlo integration: the integrand function is called a large number of times, each time passing as input a phase-space point vector (where the length of the vector is the dimensionality of the integrated phase-space) with elements lying between 0 and 1, and returning as output the integrated function evaluated on this point.
35
42
36
-
`computeWeights()` returns a vector of pairs (weight, uncertainty) (at the moment, this vector only has one entry) which can then be stored by the user.
43
+
`computeWeights()` returns a vector of pairs (weight, uncertainty). In most cases, this vector will contain only one entry, but MoMEMta allows the possibility to define *vector* integrands, i.e. integrate multi-valued functions, and return a weight and uncertainty for each component.
37
44
38
-
> *The phase-space points are associated with a weight, given that they are not distributed uniformly in the phase-space, but according to the importance function defined by Vegas. In most use cases this weight is not needed by the user since Cuba automatically takes it into account when computing the integral, however it can still be retrieved through the `cuba::ps_weight` input tag (see [here](configuration-file.md#defaults)).*
45
+
[//]: # (> *The phase-space points are associated with a weight, given that they are not distributed uniformly in the phase-space, but according to the importance function defined by Vegas. In most use cases this weight is not needed by the user since Cuba automatically takes it into account when computing the integral, however it can still be retrieved through the `cuba::ps_weight` input tag (see [here](configuration-file.md#defaults)).*)
Copy file name to clipboardExpand all lines: docs/in-depth/configuration-file.md
+97-18Lines changed: 97 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,9 @@
1
1
# The configuration file
2
2
3
-
## Configuring modules
3
+
## Configure modules
4
4
5
-
Declaring a module named `karl` of type `Gaussian` in Lua is simple:
5
+
Different *types* of modules are available on MoMEMta, each designed to perform a specific task.
6
+
Declaring an instance of a module named `karl` of type `Gaussian` in Lua is simple:
6
7
7
8
```
8
9
Gaussian.karl = {}
@@ -23,11 +24,11 @@ Gaussian.friedrich = {
23
24
}
24
25
```
25
26
26
-
A **parameter** can be an integer (eg.: `2`), a floating point number, (eg.: `172.5`, `13000.` - note the decimal point *must* be present), a boolean (`true` or `false`) or a string (eg.: `hello`). Parameters might have default values and be optional, or be mandatory.
27
+
A **parameter**is strongly typed and can be an integer (eg.: `2`), a floating point number, (eg.: `172.5`, `13000.` - note the decimal point *must* be present), a boolean (`true` or `false`) or a string (eg.: `hello`). Parameters might have default values and be optional, or be mandatory.
27
28
28
29
An **input** is set through a so-called "**input tag**" of the form `other_module::its_output[/i]`, where `other_module` is the name of another module responsible for producing the quantity `its_output`, and `/i` has to be used when the produced quantity in question is a vector and only a specific entry of that vector is needed as input.
29
30
30
-
Some modules expect **vectors** of input tags, where the order of the entries may or nor matter. Vectors in Lua are easily declared:
31
+
Some modules expect **vectors** of input tags, where the order of the entries may or may not matter. Vectors in Lua are easily declared:
31
32
32
33
```Lua
33
34
-- Take first and third entry of vector output `output` of module `that_module`
**NB**: The indexing of Lua vectors or input tags starts at **1, not 0**.
44
45
45
-
When declared, a module tells MoMEMta how many dimensions it adds to the integration (for instance, adding a transfer function on the energy of a jet means integrating over the energy of the corresponding parton). If a module adds a dimension, it also means it requires a component of the phase-space point to be specified as input (see below). MoMEMta keeps track of the total number of dimensions needed for the integration.
46
+
The use of some modules requires adding a dimension to the volume that is being integrated over. In other words, those modules need a component of the phase-space point to be specified as input. This is done using the function `add_dimension()`, which returns an input tag linking to a component of the phase-space point, and notifies MoMEMta to add an integration dimension.
46
47
47
-
The order in which the modules are declared in the script does not matter: MoMEMta automatically executes the module in an order such that inputs are always well-defined (obviously, circular dependencies are forbidden). By default, modules whose outputs are not used by any other module, and modules whose inputs are not produced by any other modules are not executed.
48
+
The order in which the modules are declared in the script does not matter: MoMEMta automatically executes the modules in an order such that inputs are always well-defined (obviously, circular dependencies are forbidden). By default, modules whose outputs are not used by any other module, and modules whose inputs are not produced by any other modules are not executed.
48
49
49
-
## Default inputs, outputs and parameters <aname=defaults></a>
50
+
A full list of modules available out-of-the-box, along with documentation about the modules' inputs, outputs and parameters, is available at MoMEMta's [technical documentation](https://momemta.github.io/MoMEMta/dev/group__modules.html).
50
51
51
-
Some inputs and outputs are not defined by any module *per se* but are used by MoMEMta to pass and retrieve important quantities:
52
+
## Declare input particles
52
53
53
-
Inputs:
54
+
Particles passed as input to the `computeWeights()` function (see [Calling MoMEMta](calling-momemta)) can be linked with the modules by registering them in the Lua configuration. For instance, for a particle declared in C++ as `momemta::Particle m_part1 { "part1", p1, 0 }`, one would do:
55
+
```Lua
56
+
locall_part1=declare_input("part1") -- Pass as argument the name string of m_part1
57
+
```
58
+
The Lua object `l_part1` now contains the input tag needed to access the particle's 4-vector. For instance, defining a transfer function on the energy of `part1` can be done as:
59
+
```Lua
60
+
GaussianTransferFunctionOnEnergy.tf_part1= {
61
+
ps_point=add_dimension(), -- A transfer function integrates over a variable (the particle's energy), so we need a new dimension in the integrated volume
62
+
reco_particle=l_part1.reco_p4, -- Pass the input tag corresponding to the experimentally reconstructed 4-vector of the particle, passed to 'computeWeights()'
63
+
sigma=0.10-- Take 10% resolution on the energy
64
+
}
65
+
```
66
+
Since the transfer function integrates over the particle's energy, it generates new values for its energy. This defines a new, 'parton'-level 4-vector for `part1`, which can now be passed e.g. to a matrix element. In this example, the parton-level 4-vector can be accessed directly through the `tf_part1::output` input tag. It is also possible to register it with the `l_part1` object:
67
+
```Lua
68
+
l_part1.set_gen_p4("tf_part1::output")
69
+
```
70
+
When declaring further modules, instead of using `tf_part1::output`, it is now possible to use `l_part1.gen_p4` to access the parton-level 4-vector, i.e. these are equivalent:
71
+
```Lua
72
+
P4Printer.printer1= { input="tf_part1::output" }
73
+
P4Printer.printer2= { input=l_part1.gen_p4 }
74
+
```
54
75
55
-
*`input::particles`: Vector of LorentzVectors passed as argument to `computeWeights()`
76
+
Finally, the missing transverse energy 4-vector (passed optionally to `computeWeights()`) can either be accessed directly through the `met::p4` input tag, or declared as a Lua object as above:
77
+
```Lua
78
+
localmet=declare_input("met")
79
+
```
56
80
57
-
*`input::met`: LorentzVector of the observed MET (optional argument to `computeWeights()`)
81
+
## Declare the integrand
58
82
59
-
*`cuba::ps_points`: Vector of doubles between 0 and 1. Phase-space point, ie. set of random numbers launched by Cuba to perform the integration. The length of the vector is the total number of integration dimensions declared by the modules. Instead of manually specifying the `cuba::ps_points/i` input tags, it is possible to use to `getpspoint()` function (which automatically increases “i” each time it is called).
83
+
When the integration is fully configured, i.e. all the final module defining the integrand value is defined, the integrand has to be registered with MoMEMta to be able to compute the integral.
84
+
For instance, if the module called `final_module` with output `output` defines the integrand, one has to call:
85
+
```Lua
86
+
integrand("final_module::output")
87
+
```
60
88
61
-
*`cuba::ps_weight`: (double) Weight associated with the phase-space point
89
+
It is possible in MoMEMta to integrate multi-valued functions (caution: is only efficient if the components of the function are not too different). For two components, the integrand would then be declared as:
*`integrands`: Vector of doubles. This is the value taken to be the integrand, returned to Cuba to compute the integral. Exactly **one** declared module **must** produce this quantity.
96
+
In MoMEMta, once the `ConfigurationReader` has been "frozen" to give a `Configuration` object, it is not possible anymore to modify anything in the integration. However, some parameters can be modified in the `ConfigurationReader` from the C++ code (allowing e.g. to carry out mass scans easily). In order to do that, the parameters have to be put in the `parameters` table in Lua:
97
+
```Lua
98
+
parameters= {
99
+
my_mass=173.,
100
+
my_width=2.5
101
+
}
102
+
```
103
+
These parameters can then be linked with the modules' parameters using the `parameter()` Lua function:
104
+
```Lua
105
+
BreitWignerGenerator.m_prop= {
106
+
ps_point=add_dimension(),
107
+
mass=parameter('my_mass'), -- Access the value through the "parameter" function, allowing it to be modified from the C++ code
108
+
width=parameter.my_width-- Access the value as a regular Lua table. It will NOT be possible to modify it later on
109
+
}
110
+
```
111
+
Changing `my_mass` from C++ before freezing the configuration is now possible using `ConfigurationReader::getGlobalParameters()`, see [calling momemta](calling-momemta).
66
112
67
-
Parameters:
113
+
## Configure the integration algorithm
68
114
69
-
*`cuba`
115
+
The integration algorithm can be configured from within Lua using the `cuba` table, for instance:
116
+
```Lua
117
+
cuba= {
118
+
integration_algorithm="divonne", -- default is "vegas"
119
+
relative_accuracy=0.01
120
+
}
121
+
```
122
+
Four different integration algorithms are available, and each has several parameters than can be tweaked to adjust the precision and convergence speed of the calculations.
123
+
For a full list of the available methods and corresponding options, please consult the documentation of the numerical integration library used in MoMEMta: Cuba[^1].
124
+
125
+
The integration parameters can be changed from the C++ in a manner similar to the parameters in the previous section, using the method `ConfigurationReader::getCubaConfiguration()`.
126
+
127
+
## Pass arguments to the configuration
128
+
129
+
Once the `ConfigurationReader` has parsed the Lua configuration file, it is not possible anymore to change the resulting computation flow (the only changes possible are the above parameters).
130
+
It is however possible to pass arguments from C++ to the Lua script when it is read by the `ConfigurationReader`, to influence its execution.
131
+
132
+
Defining the arguments in C++:
133
+
```cpp
134
+
ParameterSet lua_parameters;
135
+
lua_parameters.set("text1", "hello, world!");
136
+
lua_parameters.set("text2", "always look on the bright side of life!");
0 commit comments