**This feature will come with Pluto 5.41**

## What?

The Pluto functions (at the moment only for the 2-dimensional case) offer an extension to the ROOT functions TF1/TF2/TF3. They combine the classical ROOT functions with the Pluto batch scripting which itself connects with objects like TH1/TH2/TH3 and TGraph/TGraph2D. It therefore allows to combine histogram(s) with graphs and calculations. The number of combinations which are possible by these features is almost endless. Therefore the following examples can only sketch the possibilites.

## The problem

The Pluto functions should serve as a general interface for Pluto models whereever 2rd party data should be included. One common example is the class PAngularDistributions, where one can add TF1/TF2, or a TGraph. While keeping this methods to ensure backward compatibility, the aim is to provide a more general interface.

## The solution

The Pluto functions are costructed like the ROOT functions with the difference that no pointer to a function or a TFormula is used. The latter feature is already included in the Pluto script language, which is based on TFormula. The function is replaced by one (or more) methods which can be optionally extended with the histogram of graph objects. The axes of the function can be read via the variables _x, _y and _z, and the output _f as the function value must be provided. The access to the histogram/graph object is done via the Eval command.

All examples are based on this macro which contains some dummy histograms and TGraphs.

### Interface to a TGraph2D

```
PF2 * only_tgraph = new PF2("Only TGraph2D", 0, 0.8, 0, 0.8);
only_tgraph->Add(gra, "_f = Eval(_x,_y)");
```

### Mixing a histogram with a graph

```
PF2 * tgraph_and_hist1 = new PF2("TGraph2D mixed with a TH1", 0, 0.8, 0, 0.8);
tgraph_and_hist1->Add(gra, "_f = Eval(_x,_y)");
tgraph_and_hist1->Add(hist1, "if (_x < 0.3) _f = Eval(_y)");
```

### Mixing a histogram with a graph and some dummy calculations (here a rotation)

```
PF2 * tgraph_and_hist1a = new PF2("TGraph2D mixed with a TH1 and some dummy calculations", 0, 0.8, 0, 0.8);
tgraph_and_hist1a->Add(gra, "_f = Eval(_x,_y)");
tgraph_and_hist1a->Add("my_x = _x - _y; my_y = (_x + _y) * 0.5; ");
tgraph_and_hist1a->Add(hist1, "if (my_x > 0.1 && my_x < 0.35) _f = Eval(my_y)");
```

### Merger of a histogram with a graph (here a multiplication)

```
PF2 * tgraph_and_hist2 = new PF2("TGraph2D merged with a TH2", 0, 0.8, 0, 0.8);
tgraph_and_hist2->Add(gra, "_f = Eval(_x,_y)");
tgraph_and_hist2->Add(hist2, "_f = _f * Eval(_x, _y)");
```