Commit e3a64cd6 authored by Wouter Deconinck's avatar Wouter Deconinck
Browse files

Dataframe example

parent 9dec2512
Pipeline #14223 passed with stage
in 1 minute and 37 seconds
......@@ -250,6 +250,35 @@ TNetXNGFile** root://sci-xrootd.jlab.org//osgpool/eic/ATHENA/RECO/SING
KEY: TTree events;1 Events tree
KEY: TTree metadata;1 Metadata tree
events->Draw("ReconstructedParticlesInitFromTruth.p.px")
events->Draw("EcalBarrelClusters.energy")
events->Draw("EcalBarrelClusters.polar.theta:EcalBarrelClusters.polar.phi")
events->Draw("EcalBarrelClusters.polar.phi:EcalBarrelClusters.polar.theta", "EcalBarrelClusters.edep", "colz")
```
## Analysis of full simulation reconstruction output with RDataFrame commands
```console
auto momenta_from_reconstruction(const std::vector<eic::ReconstructedParticleData>& parts) {
std::vector<ROOT::Math::PxPyPzEVector> momenta{parts.size()};
std::transform(parts.begin(), parts.end(), momenta.begin(), [](const auto& part) {
return ROOT::Math::PxPyPzEVector{part.p.x, part.p.y, part.p.z, part.energy};
});
return momenta;
}
auto Q2(const std::vector<ROOT::Math::PxPyPzEVector>& mom) {
std::vector<double> Q2Vec(mom.size() );
ROOT::Math::PxPyPzEVector beamMom = {0, 0, 18, 18};
std::transform(mom.begin(), mom.end(), Q2Vec.begin(), [beamMom](const auto& part) {
return -(part - beamMom).M2();
});
return Q2Vec;
}
ROOT::RDataFrame d("events", "s3https://dtn01.sdcc.bnl.gov:9000/eictest/ATHENA/RECO/SINGLE/e-/1GeV/45to135deg/e-_1GeV_45to135deg.0001.root");
auto d0 = d.Define("p", momenta_from_reconstruction, {"ReconstructedParticles"}).Define("Q2", Q2, {"p"});
auto h_Q2_sim = d0.Histo1D({"h_Q2_sim", "; GeV; counts", 100, -5, 25}, "Q2");
auto& h1_Q2_sim = *h_Q2_sim;
h1_Q2_sim.DrawClone("hist");
```
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment