TTTT Analysis  0.1
api.hpp
1 #ifndef ROOT_API_HPP
2 #define ROOT_API_HPP
3 #include <string>
4 #include <vector>
5 #include <tuple>
6 #include "filval/api.hpp"
7 #include "filval_root/value.hpp"
8 namespace fv::root{
9 
10  decltype(auto)
11  lorentz_vectors(Value<std::vector<float>>* pt, Value<std::vector<float>>* eta,
12  Value<std::vector<float>>* phi, Value<std::vector<float>>* mass,
13  const std::string& alias=""){
14  typedef std::vector<TLorentzVector> type;
15  const std::string& name = root::LorentzVectors::fmt_name(pt, eta, phi, mass);
16  if (check_exists<type>(name))
17  return lookup<type>(name);
18  else
19  return (Value<type>*)new root::LorentzVectors(pt, eta, phi, mass, alias);
20  }
21 
22  decltype(auto)
23  lorentz_vectors(const std::string& pt_name, const std::string& eta_name,
24  const std::string& phi_name, const std::string& mass_name,
25  const std::string& alias=""){
26  return lorentz_vectors(lookup<std::vector<float>>(pt_name), lookup<std::vector<float>>(eta_name),
27  lookup<std::vector<float>>(phi_name), lookup<std::vector<float>>(mass_name),
28  alias);
29  }
30 
31  decltype(auto)
32  energies(Value<std::vector<TLorentzVector>>* vectors, const std::string& alias="") {
33  typedef std::vector<float> type;
34  const std::string& name = root::Energies::fmt_name(vectors);
35  if (check_exists<type>(name))
36  return lookup<type>(name);
37  else
38  return (Value<type>*)new root::Energies(vectors, alias);
39  }
40 
41  decltype(auto)
42  energies(const std::string& vectors_name, const std::string& alias="") {
43  return energies(lookup<std::vector<TLorentzVector>>(vectors_name), alias);
44  }
45 
46  template<typename... DataTypes>
47  decltype(auto)
48  mva_data(Value<bool>* is_training, Value<bool>* is_signal, Value<double>* weight,
49  const std::pair<std::string, Value<DataTypes>*>&&... data_vals) {
50  typedef typename root::MVAData<DataTypes...> mva_type;
51  typedef typename mva_type::type type;
52  std::string alias="";
53  const std::string& name = mva_type::fmt_name(is_training, is_signal, weight,
54  std::forward<const std::pair<std::string,Value<DataTypes>*>>(data_vals)...);
55  if (check_exists<type>(name))
56  return lookup<type>(name);
57  else
58  return (Value<type>*)new mva_type(is_training, is_signal, weight,
59  std::forward<const std::pair<std::string,Value<DataTypes>*>>(data_vals)...);
60  }
61 
62 }
63 #endif // ROOT_API_HPP
STL namespace.
Definition: api.hpp:8