13using FourVectorVec = std::vector<FourVector>;
19void fill_tree(
const char *filename,
const char *treeName)
21 const double M = 0.13957;
24 auto genTracks = [&](){
26 const auto nPart =
R.Poisson(15);
28 for (
int j = 0; j < nPart; ++j) {
29 const auto px =
R.Gaus(0, 10);
30 const auto py =
R.Gaus(0, 10);
31 const auto pt =
sqrt(px * px + py * py);
32 const auto eta =
R.Uniform(-3, 3);
33 const auto phi =
R.Uniform(0.0, 2 *
TMath::Pi());
34 CylFourVector vcyl(
pt, eta, phi);
36 auto E =
sqrt(vcyl.R() * vcyl.R() + M * M);
38 tracks.emplace_back(vcyl.X(), vcyl.Y(), vcyl.Z(),
E);
44 d.Define(
"tracks", genTracks).Snapshot<FourVectorVec>(treeName, filename, {
"tracks"});
51 auto fileName =
"df002_dataModel.root";
52 auto treeName =
"myTree";
53 fill_tree(fileName, treeName);
62 auto n_cut = [](
const FourVectorRVec &
tracks) {
return tracks.size() > 8; };
63 auto nentries =
d.Filter(n_cut, {
"tracks"}).Count();
65 std::cout << *
nentries <<
" passed all filters" << std::endl;
71 auto getPt = [](
const FourVectorRVec &
tracks) {
76 auto getPtWeights = [](
const FourVectorRVec &
tracks) {
80 auto augmented_d =
d.Define(
"tracks_n", [](
const FourVectorRVec &
tracks) {
return (
int)
tracks.size(); })
81 .
Filter([](
int tracks_n) {
return tracks_n > 2; }, {
"tracks_n"})
82 .Define(
"tracks_pts", getPt)
83 .Define(
"tracks_pts_weights", getPtWeights);
85 auto trN = augmented_d.Histo1D({
"",
"", 40, -.5, 39.5},
"tracks_n");
86 auto trPts = augmented_d.Histo1D(
"tracks_pts");
87 auto trWPts = augmented_d.Histo1D(
"tracks_pts",
"tracks_pts_weights");
#define R(a, b, c, d, e, f, g, h, i)
ROOT's RDataFrame offers a high level interface for analyses of data stored in TTrees,...
A "std::vector"-like collection of values implementing handy operation to analyse them.
Random number generator class based on M.
DisplacementVector3D< CylindricalEta3D< double >, DefaultCoordinateSystemTag > RhoEtaPhiVector
3D Vector based on the eta based cylindrical coordinates rho, eta, phi in double precision.
LorentzVector< PxPyPzE4D< double > > XYZTVector
LorentzVector based on x,y,x,t (or px,py,pz,E) coordinates in double precision with metric (-,...
auto Map(Args &&... args) -> decltype(ROOT::Detail::VecOps::MapFromTuple(std::forward_as_tuple(args...), std::make_index_sequence< sizeof...(args) - 1 >()))
Create new collection applying a callable to the elements of the input collection.
RVec< T > Filter(const RVec< T > &v, F &&f)
Create a new collection with the elements passing the filter expressed by the predicate.
constexpr Double_t E()
Base of natural log: