How to find and save a smallest number among three numbers

Hi,

alternatively, you can modify the working example I delivered to you here How to check conditions entry by entry in a nested loop with this one, which prints the minimum z per entry in your tree:

void analyse() {

ROOT::Experimental::TDataFrame d("mytree","myfile.root");
using floats = std::vector<float>;
using ints = std::vector<int>;

auto retMinZ = [](floats& x, floats& y, floats& z, floats& t, ints& c){
   std::vector<TLorentzVector> tmp = {{x[0], y[0], z[0], t[0]},
                                     {x[1], y[1], z[1], t[1]},
                                     {x[2], y[2], z[2], t[2]}};
   return std::min({(tmp[1] + tmp[2]).M(), (tmp[2] + tmp[3]).M(), (tmp[1] + tmp[3]).M()});

};

d.Define("minZmass",retMinZ,{"VetoMu_px","VetoMu_py","VetoMu_pz","VetoMu_en","VetoMu_charge"})
 .Foreach([](double m){std::cout << "Min z mass is " << m << std::endl;}, {"minZmass"});

}