using FourVectorVec = std::vector<FourVector>;
void fill_tree(const char *filename, const char *treeName)
{
const double M = 0.13957;
auto genTracks = [&](){
FourVectorVec tracks;
const auto nPart =
R.Poisson(15);
tracks.reserve(nPart);
for (int j = 0; j < nPart; ++j) {
const auto px =
R.Gaus(0, 10);
const auto py =
R.Gaus(0, 10);
const auto pt =
sqrt(px * px + py * py);
const auto eta =
R.Uniform(-3, 3);
CylFourVector vcyl(pt, eta, phi);
auto E =
sqrt(vcyl.R() * vcyl.R() + M * M);
tracks.emplace_back(vcyl.X(), vcyl.Y(), vcyl.Z(),
E);
}
return tracks;
};
d.Define(
"tracks", genTracks).Snapshot<FourVectorVec>(treeName, filename, {
"tracks"});
}
{
auto fileName = "df002_dataModel.root";
auto treeName = "myTree";
fill_tree(fileName, treeName);
auto n_cut = [](const FourVectorRVec &tracks) { return tracks.size() > 8; };
auto nentries =
d.Filter(n_cut, {
"tracks"}).Count();
std::cout << *
nentries <<
" passed all filters" << std::endl;
auto getPt = [](const FourVectorRVec &tracks) {
};
auto getPtWeights = [](const FourVectorRVec &tracks) {
};
auto augmented_d =
d.Define(
"tracks_n", [](
const FourVectorRVec &tracks) {
return (
int)tracks.size(); })
.
Filter([](
int tracks_n) {
return tracks_n > 2; }, {
"tracks_n"})
.Define("tracks_pts", getPt)
.Define("tracks_pts_weights", getPtWeights);
auto trN = augmented_d.Histo1D({"", "", 40, -.5, 39.5}, "tracks_n");
auto trPts = augmented_d.Histo1D("tracks_pts");
auto trWPts = augmented_d.Histo1D("tracks_pts", "tracks_pts_weights");
trN->Draw();
c1.
Print(
"tracks_n.png");
trPts->Draw();
c2.
Print(
"tracks_pt.png");
trWPts->Draw();
c3.
Print(
"tracks_Wpt.png");
return 0;
}