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

Finalized RDataFrame example

parent e3a64cd6
Pipeline #14240 passed with stage
in 1 minute and 38 seconds
......@@ -252,9 +252,11 @@ TNetXNGFile** root://
events->Draw("EcalBarrelClusters.polar.phi:EcalBarrelClusters.polar.theta", "EcalBarrelClusters.edep", "colz")
These types of plots will likely be limited to simple data inspection.
## Analysis of full simulation reconstruction output with RDataFrame commands
For a more advanced analysis, you can take advantage of the RDataFrame features, such as in this (shortened) DIS example. The [original]( is used in our CI system and determines DIS parameters for every change to the detector geometry, simulation, digitization, or reconstruction.
auto momenta_from_reconstruction(const std::vector<eic::ReconstructedParticleData>& parts) {
std::vector<ROOT::Math::PxPyPzEVector> momenta{parts.size()};
......@@ -264,16 +266,34 @@ auto momenta_from_reconstruction(const std::vector<eic::ReconstructedParticleDat
return momenta;
auto convertMtoE(const std::vector<ROOT::Math::PxPyPzMVector>& mom) {
std::vector<ROOT::Math::PxPyPzEVector> momenta{mom.size()};
std::transform(mom.begin(), mom.end(), momenta.begin(), [](const auto& part) {
return ROOT::Math::PxPyPzEVector{part.Px(), part.Py(), part.Pz(),};
return momenta;
bool sort_mom_bool(ROOT::Math::PxPyPzEVector &mom1, ROOT::Math::PxPyPzEVector &mom2) {
return >;
auto sort_momenta(const std::vector<ROOT::Math::PxPyPzEVector>& mom) {
std::vector <ROOT::Math::PxPyPzEVector> sort_mom = mom;
sort(sort_mom.begin(), sort_mom.end(), sort_mom_bool);
return sort_mom;
auto Q2(const std::vector<ROOT::Math::PxPyPzEVector>& mom) {
std::vector<double> Q2Vec(mom.size() );
ROOT::Math::PxPyPzEVector beamMom = {0, 0, 18, 18};
ROOT::Math::PxPyPzEVector beamMom = {0, 0, 5, 5};
std::transform(mom.begin(), mom.end(), Q2Vec.begin(), [beamMom](const auto& part) {
return -(part - beamMom).M2();
return Q2Vec;
ROOT::RDataFrame d("events", "s3");
ROOT::RDataFrame d("events", "s3");
auto d0 = d.Define("p", momenta_from_reconstruction, {"ReconstructedParticles"}).Define("Q2", Q2, {"p"});
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