28 using FourVectors = std::vector<FourVector>;
33 void fill_tree(
const char *filename,
const char *treeName)
35 TFile f(filename,
"RECREATE");
36 TTree t(treeName, treeName);
38 t.Branch(
"tracks", &tracks);
40 const double M = 0.13957;
43 for (
int i = 0; i < 50; ++i) {
46 tracks.reserve(nPart);
47 for (
int j = 0; j < nPart; ++j) {
48 double px =
R.
Gaus(0, 10);
49 double py =
R.
Gaus(0, 10);
50 double pt =
sqrt(px * px + py * py);
53 CylFourVector vcyl(pt, eta, phi);
55 double E =
sqrt(vcyl.R() * vcyl.R() + M * M);
56 FourVector
q(vcyl.X(), vcyl.Y(), vcyl.Z(),
E);
58 tracks.emplace_back(
q);
72 auto fileName =
"tdf002_dataModel.root";
73 auto treeName =
"myTree";
74 fill_tree(fileName, treeName);
83 auto n_cut = [](
const FourVectors &tracks) {
return tracks.size() > 8; };
84 auto nentries = d.Filter(n_cut, {
"tracks"}).Count();
86 std::cout << *
nentries <<
" passed all filters" << std::endl;
92 auto getPt = [](
const FourVectors &tracks) {
93 std::vector<double> pts;
94 pts.reserve(tracks.size());
95 for (
auto &t : tracks) pts.emplace_back(t.Pt());
100 auto getPtWeights = [](
const FourVectors &tracks) {
101 std::vector<double> ptsw;
102 ptsw.reserve(tracks.size());
103 for (
auto &t : tracks) ptsw.emplace_back(1. / t.Pt());
107 auto augmented_d = d.Define(
"tracks_n", [](
const FourVectors &tracks) {
return (
int)tracks.size(); })
108 .Filter([](
int tracks_n) {
return tracks_n > 2; }, {
"tracks_n"})
109 .Define(
"tracks_pts", getPt)
110 .Define(
"tracks_pts_weights", getPtWeights);
112 auto trN = augmented_d.Histo1D(
TH1F{
"",
"", 40, -.5, 39.5},
"tracks_n");
113 auto trPts = augmented_d.Histo1D(
"tracks_pts");
114 auto trWPts = augmented_d.Histo1D(
"tracks_pts",
"tracks_pts_weights");
118 c1.
Print(
"tracks_n.png");
122 c2.
Print(
"tracks_pt.png");
126 c3.
Print(
"tracks_Wpt.png");
Random number generator class based on M.
virtual Double_t Gaus(Double_t mean=0, Double_t sigma=1)
Samples a random number from the standard Normal (Gaussian) Distribution with the given mean and sigm...
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
tomato 1-D histogram with a float per channel (see TH1 documentation)}
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 (-...
virtual void Print(const char *filename="") const
Save Pad contents in a file in one of various formats.
virtual Double_t Uniform(Double_t x1=1)
Returns a uniform deviate on the interval (0, x1).
ROOT's TDataFrame offers a high level interface for analyses of data stored in TTrees.
A TTree object has a header with a name and a title.
virtual Int_t Poisson(Double_t mean)
Generates a random integer N according to a Poisson law.
int main(int argc, char **argv)