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://sci-xrootd.jlab.org//osgpool/eic/ATHENA/RECO/SING
events->Draw("ReconstructedParticlesInitFromTruth.p.px")
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](https://eicweb.phy.anl.gov/EIC/benchmarks/physics_benchmarks/-/blob/master/benchmarks/dis/analysis/dis_electrons.cxx) is used in our CI system and determines DIS parameters for every change to the detector geometry, simulation, digitization, or reconstruction.
```console
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(), part.energy()};
});
return momenta;
}
bool sort_mom_bool(ROOT::Math::PxPyPzEVector &mom1, ROOT::Math::PxPyPzEVector &mom2) {
return mom1.energy() > mom2.energy();
}
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", "s3https://dtn01.sdcc.bnl.gov:9000/eictest/ATHENA/RECO/SINGLE/e-/1GeV/45to135deg/e-_1GeV_45to135deg.0001.root");
ROOT::RDataFrame d("events", "s3https://dtn01.sdcc.bnl.gov:9000/eictest/ATHENA/RECO//DIS/crossDivNrgCrab/DIS_NC_Q2gt10_crossDivNrgCrab_25mRad_5x41_v2.root");
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