From 3de821ca8c81a291dc5b6f50c3a6522fd1303450 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck <wdconinc@gmail.com> Date: Fri, 18 Feb 2022 22:06:44 -0600 Subject: [PATCH] Modifications to scripts --- .../clustering/scripts/cluster_plots.py | 4 +- .../scripts/deprecated/barrel_clusters.cxx | 26 +++++----- .../analysis/analysis_zdc_neutrons.cxx | 29 +++++------ .../analysis/analysis_zdc_photons.cxx | 29 +++++------ .../analysis/hits_far_forward_protons.cxx | 22 ++++----- .../analysis/print_far_forward_protons.cxx | 2 +- .../analysis/rec_far_forward_protons.cxx | 14 +++--- .../emcal_barrel_pion_rejection_analysis.cxx | 48 +++++++++---------- .../imaging_ecal/scripts/draw_cluster.py | 4 +- .../scripts/draw_cluster_layers.py | 2 +- benchmarks/imaging_ecal/scripts/utils.py | 6 +-- .../scripts/check_edep_dists.py | 4 +- .../scripts/prepare_tf_dataset.py | 6 +-- .../scripts/rec_multiple_tracks.cxx | 14 +++--- .../scripts/rec_multiple_tracks.cxx | 14 +++--- .../scripts/rec_single_tracks.cxx | 14 +++--- .../tracking/run_tracking_benchmarks.py | 2 +- .../scripts/hits_central_electrons.cxx | 24 +++++----- .../tracking/scripts/hits_central_pions.cxx | 22 ++++----- .../scripts/rec_central_electrons.cxx | 14 +++--- .../tracking/scripts/rec_central_pions.cxx | 14 +++--- .../tracking/scripts/rec_multiple_tracks.cxx | 14 +++--- .../tracking/scripts/tracking_performance.py | 4 +- 23 files changed, 166 insertions(+), 166 deletions(-) diff --git a/benchmarks/clustering/scripts/cluster_plots.py b/benchmarks/clustering/scripts/cluster_plots.py index 567c5151..5210fe25 100644 --- a/benchmarks/clustering/scripts/cluster_plots.py +++ b/benchmarks/clustering/scripts/cluster_plots.py @@ -48,7 +48,7 @@ def flatten_collection(rdf, collection, cols=None): return dfp -def thrown_particles_figure(rdf, save, mcbranch="mcparticles"): +def thrown_particles_figure(rdf, save, mcbranch="MCParticles"): # define truth particle info dft = flatten_collection(rdf, mcbranch, ['genStatus', 'pdgID', 'ps.x', 'ps.y', 'ps.z', 'mass']) dft.rename(columns={c: c.replace(mcbranch + '.', '') for c in dft.columns}, inplace=True) @@ -109,7 +109,7 @@ if __name__ == '__main__': parser.add_argument('-o', dest='outdir', default='.', help='Output directory.') parser.add_argument('-m', '--macros', dest='macros', default='rootlogon.C', help='Macro files to be loaded by root, separated by \",\".') - parser.add_argument('--mc-branch', dest='mc', default='mcparticles', + parser.add_argument('--mc-branch', dest='mc', default='MCParticles', help='Branch name of MC particles truth info.') parser.add_argument('--collections', dest='coll', default='', help='Collection name of clusters to plot') diff --git a/benchmarks/clustering/scripts/deprecated/barrel_clusters.cxx b/benchmarks/clustering/scripts/deprecated/barrel_clusters.cxx index 5720c7ea..efc82914 100644 --- a/benchmarks/clustering/scripts/deprecated/barrel_clusters.cxx +++ b/benchmarks/clustering/scripts/deprecated/barrel_clusters.cxx @@ -1,10 +1,8 @@ #include <iostream> #include "ROOT/RDataFrame.hxx" -#include "dd4pod/Geant4ParticleCollection.h" +#include "edm4hep/MCParticleCollection.h" #include "eicd/ClusterCollection.h" #include "eicd/ClusterData.h" -// If root cannot find a dd4pod header make sure to add the include dir to ROOT_INCLUDE_PATH: -// export ROOT_INCLUDE_PATH=$HOME/include:$ROOT_INCLUDE_PATH using ROOT::RDataFrame; using namespace ROOT::VecOps; @@ -23,34 +21,34 @@ auto theta = [](std::vector<ROOT::Math::PxPyPzMVector> const& in) { } return result; }; -auto fourvec = [](ROOT::VecOps::RVec<dd4pod::Geant4ParticleData> const& in) { +auto fourvec = [](ROOT::VecOps::RVec<edm4hep::MCParticleData> const& in) { std::vector<ROOT::Math::PxPyPzMVector> result; ROOT::Math::PxPyPzMVector lv; for (size_t i = 0; i < in.size(); ++i) { - lv.SetCoordinates(in[i].psx, in[i].psy, in[i].psz, in[i].mass); + lv.SetCoordinates(in[i].momentum.x, in[i].momentum.y, in[i].momentum.z, in[i].mass); result.push_back(lv); } return result; }; -auto pt = [](std::vector<dd4pod::Geant4ParticleData> const& in) { +auto pt = [](std::vector<edm4hep::MCParticleData> const& in) { std::vector<float> result; for (size_t i = 0; i < in.size(); ++i) { - result.push_back(std::sqrt(in[i].psx * in[i].psx + in[i].psy * in[i].psy)); + result.push_back(std::sqrt(in[i].momentum.x * in[i].momentum.x + in[i].momentum.y * in[i].momentum.y)); } return result; }; -auto pid = [](ROOT::VecOps::RVec<dd4pod::Geant4ParticleData> const& in) { +auto pid = [](ROOT::VecOps::RVec<edm4hep::MCParticleData> const& in) { std::vector<int> result; for (size_t i = 0; i < in.size(); ++i) { - result.push_back(in[i].pdgID); + result.push_back(in[i].PDG); } return result; }; -auto eta = [](ROOT::VecOps::RVec<dd4pod::Geant4ParticleData> const& in) { +auto eta = [](ROOT::VecOps::RVec<edm4hep::MCParticleData> const& in) { std::vector<float> result; ROOT::Math::PxPyPzMVector lv; for (size_t i = 0; i < in.size(); ++i) { - lv.SetCoordinates(in[i].psx, in[i].psy, in[i].psz, in[i].mass); + lv.SetCoordinates(in[i].momentum.x, in[i].momentum.y, in[i].momentum.z, in[i].mass); result.push_back(lv.Eta()); } return result; @@ -91,8 +89,8 @@ int barrel_clusters(const char* in_fname = "topside/rec_barrel_clusters.root") ROOT::EnableImplicitMT(); ROOT::RDataFrame df("events", in_fname); - auto d0 = df.Define("isThrown", "mcparticles.genStatus == 1") - .Define("thrownParticles", "mcparticles[isThrown]") + auto d0 = df.Define("isThrown", "MCParticles.generatorStatus == 1") + .Define("thrownParticles", "MCParticles[isThrown]") .Define("thrownP", fourvec, {"thrownParticles"}) .Define("thrownEta", eta, {"thrownParticles"}) .Define("thrownTheta", theta, {"thrownP"}) @@ -159,6 +157,6 @@ int barrel_clusters(const char* in_fname = "topside/rec_barrel_clusters.root") //c->SaveAs("results/crystal_cal_electrons_Ecluster.png"); //std::string outfilename = "rdf_test.root"; - //df2.Snapshot("events", outfilename, {"MCParticles_pt", "mcparticles"}); + //df2.Snapshot("events", outfilename, {"MCParticles_pt", "MCParticles"}); return 0; } diff --git a/benchmarks/far_forward/analysis/analysis_zdc_neutrons.cxx b/benchmarks/far_forward/analysis/analysis_zdc_neutrons.cxx index 07ec683b..5ac4ecaa 100644 --- a/benchmarks/far_forward/analysis/analysis_zdc_neutrons.cxx +++ b/benchmarks/far_forward/analysis/analysis_zdc_neutrons.cxx @@ -8,8 +8,8 @@ #include <iostream> #include <vector> -#include "dd4pod/Geant4ParticleCollection.h" -#include "dd4pod/CalorimeterHitCollection.h" +#include "edm4hep/MCParticleCollection.h" +#include "edm4hep/SimCalorimeterHitCollection.h" #include "TCanvas.h" #include "TStyle.h" @@ -67,38 +67,39 @@ void analysis_zdc_neutrons(const char* input_fname = "sim_zdc_uniform_neutron.ed ROOT::RDataFrame d0("events", input_fname); // Thrown Energy [GeV] - auto Ethr = [](const std::vector<dd4pod::Geant4ParticleData> & input) { + auto Ethr = [](const std::vector<edm4hep::MCParticleData> & input) { auto p = input[2]; - auto energy = TMath::Sqrt(p.ps.x * p.ps.x + p.ps.y * p.ps.y + p.ps.z * p.ps.z + p.mass * p.mass); + auto energy = TMath::Sqrt(p.momentum.x * p.momentum.x + p.momentum.y * p.momentum.y + p.momentum.z * p.momentum.z + p.mass * p.mass); return energy; }; // Theta [mrad] - auto Thetathr = [](const std::vector<dd4pod::Geant4ParticleData> & input) { + auto Thetathr = [](const std::vector<edm4hep::MCParticleData> & input) { auto p = input[2]; - auto theta = p.ps.theta(); + auto theta = std::atan2(std::hypot(p.momentum.x, p.momentum.y), p.momentum.z); return theta*1000.0; }; // Phi [rad] - auto Phithr = [](const std::vector<dd4pod::Geant4ParticleData> & input) { + auto Phithr = [](const std::vector<edm4hep::MCParticleData> & input) { auto p = input[2]; - auto phi = p.ps.phi(); + auto phi = std::atan2(p.momentum.y, p.momentum.x); return phi; }; // Eta - auto Etathr = [](const std::vector<dd4pod::Geant4ParticleData> & input) { + auto Etathr = [](const std::vector<edm4hep::MCParticleData> & input) { auto p = input[2]; - auto eta = p.ps.eta(); + auto theta = std::atan2(std::hypot(p.momentum.x, p.momentum.y), p.momentum.z); + auto eta = -std::log(std::tan(theta/2)); return eta; }; // Define variables - auto d1 = d0.Define("Ethr", Ethr, {"mcparticles"}) - .Define("Thetathr", Thetathr, {"mcparticles"}) - .Define("Phithr", Phithr, {"mcparticles"}) - .Define("Etathr", Etathr, {"mcparticles"}) + auto d1 = d0.Define("Ethr", Ethr, {"MCParticles"}) + .Define("Thetathr", Thetathr, {"MCParticles"}) + .Define("Phithr", Phithr, {"MCParticles"}) + .Define("Etathr", Etathr, {"MCParticles"}) ; // Define Histograms diff --git a/benchmarks/far_forward/analysis/analysis_zdc_photons.cxx b/benchmarks/far_forward/analysis/analysis_zdc_photons.cxx index 3c88182b..4f2ae18e 100644 --- a/benchmarks/far_forward/analysis/analysis_zdc_photons.cxx +++ b/benchmarks/far_forward/analysis/analysis_zdc_photons.cxx @@ -8,8 +8,8 @@ #include <iostream> #include <vector> -#include "dd4pod/Geant4ParticleCollection.h" -#include "dd4pod/CalorimeterHitCollection.h" +#include "edm4hep/MCParticleCollection.h" +#include "edm4hep/CalorimeterHitCollection.h" #include "TCanvas.h" #include "TStyle.h" @@ -67,38 +67,39 @@ void analysis_zdc_photons(const char* input_fname = "sim_zdc_uniform_photon.edm4 ROOT::RDataFrame d0("events", input_fname); // Thrown Energy [GeV] - auto Ethr = [](const std::vector<dd4pod::Geant4ParticleData> & input) { + auto Ethr = [](const std::vector<edm4hep::MCParticleData> & input) { auto p = input[2]; - auto energy = TMath::Sqrt(p.ps.x * p.ps.x + p.ps.y * p.ps.y + p.ps.z * p.ps.z + p.mass * p.mass); + auto energy = TMath::Sqrt(p.momentum.x * p.momentum.x + p.momentum.y * p.momentum.y + p.momentum.z * p.momentum.z + p.mass * p.mass); return energy; }; // Theta [mrad] - auto Thetathr = [](const std::vector<dd4pod::Geant4ParticleData> & input) { + auto Thetathr = [](const std::vector<edm4hep::MCParticleData> & input) { auto p = input[2]; - auto theta = p.ps.theta(); + auto theta = std::atan2(std::hypot(p.momentum.x, p.momentum.y), p.momentum.z); return theta*1000.0; }; // Phi [rad] - auto Phithr = [](const std::vector<dd4pod::Geant4ParticleData> & input) { + auto Phithr = [](const std::vector<edm4hep::MCParticleData> & input) { auto p = input[2]; - auto phi = p.ps.phi(); + auto phi = std::atan2(p.momentum.y, p.momentum.x); return phi; }; // Eta - auto Etathr = [](const std::vector<dd4pod::Geant4ParticleData> & input) { + auto Etathr = [](const std::vector<edm4hep::MCParticleData> & input) { auto p = input[2]; - auto eta = p.ps.eta(); + auto theta = std::atan2(std::hypot(p.momentum.x, p.momentum.y), p.momentum.z); + auto eta = -std::log(std::tan(theta/2)); return eta; }; // Define variables - auto d1 = d0.Define("Ethr", Ethr, {"mcparticles"}) - .Define("Thetathr", Thetathr, {"mcparticles"}) - .Define("Phithr", Phithr, {"mcparticles"}) - .Define("Etathr", Etathr, {"mcparticles"}) + auto d1 = d0.Define("Ethr", Ethr, {"MCParticles"}) + .Define("Thetathr", Thetathr, {"MCParticles"}) + .Define("Phithr", Phithr, {"MCParticles"}) + .Define("Etathr", Etathr, {"MCParticles"}) ; // Define Histograms diff --git a/benchmarks/far_forward/analysis/hits_far_forward_protons.cxx b/benchmarks/far_forward/analysis/hits_far_forward_protons.cxx index 986bf36e..374f5861 100644 --- a/benchmarks/far_forward/analysis/hits_far_forward_protons.cxx +++ b/benchmarks/far_forward/analysis/hits_far_forward_protons.cxx @@ -10,9 +10,9 @@ R__LOAD_LIBRARY(libeicd.so) R__LOAD_LIBRARY(libDD4pod.so) -#include "dd4pod/TrackerHitCollection.h" -#include "dd4pod/TrackerHitData.h" -#include "dd4pod/Geant4ParticleCollection.h" +#include "edm4hep/SimTrackerHitCollection.h" +#include "edm4hep/SimTrackerHitData.h" +#include "edm4hep/MCParticleCollection.h" #include "eicd/TrackParametersCollection.h" #include "eicd/ClusterCollection.h" #include "eicd/ClusterData.h" @@ -30,10 +30,10 @@ auto p_track = [](std::vector<eic::TrackParametersData> const& in) { }; -std::vector<float> pt (std::vector<dd4pod::Geant4ParticleData> const& in){ +std::vector<float> pt (std::vector<edm4hep::MCParticleData> const& in){ std::vector<float> result; for (size_t i = 0; i < in.size(); ++i) { - result.push_back(std::sqrt(in[i].ps.x * in[i].ps.x + in[i].ps.y * in[i].ps.y)); + result.push_back(std::sqrt(in[i].momentum.x * in[i].momentum.x + in[i].momentum.y * in[i].momentum.y)); } return result; } @@ -52,11 +52,11 @@ auto theta = [](std::vector<ROOT::Math::PxPyPzMVector> const& in) { } return result; }; -auto fourvec = [](ROOT::VecOps::RVec<dd4pod::Geant4ParticleData> const& in) { +auto fourvec = [](ROOT::VecOps::RVec<edm4hep::MCParticleData> const& in) { std::vector<ROOT::Math::PxPyPzMVector> result; ROOT::Math::PxPyPzMVector lv; for (size_t i = 0; i < in.size(); ++i) { - lv.SetCoordinates(in[i].ps.x, in[i].ps.y, in[i].ps.z, in[i].mass); + lv.SetCoordinates(in[i].momentum.x, in[i].momentum.y, in[i].momentum.z, in[i].mass); result.push_back(lv); } return result; @@ -88,8 +88,8 @@ int hits_far_forward_protons(const char* fname = "sim_far_forward_protons.edm4he ROOT::EnableImplicitMT(); ROOT::RDataFrame df("events", fname); - auto df0 = df.Define("isThrown", "mcparticles.genStatus == 1") - .Define("thrownParticles", "mcparticles[isThrown]") + auto df0 = df.Define("isThrown", "MCParticles.generatorStatus == 1") + .Define("thrownParticles", "MCParticles[isThrown]") .Define("thrownP", fourvec, {"thrownParticles"}) .Define("p_thrown", momentum, {"thrownP"}) .Define("theta_thrown", theta, {"thrownP"}) @@ -105,8 +105,8 @@ int hits_far_forward_protons(const char* fname = "sim_far_forward_protons.edm4he //.Define("delta_p_over_p1",delta_p_over_p, {"p_track1", "p_thrown"}) //.Define("delta_p_over_p2",delta_p_over_p, {"p_track2", "p_thrown"}) //.Define("N_VtxBarrelHits",[](std::vector<eic::TrackerHitData> hits) { return hits.size();},{"VertexBarrelRecHits"}) - .Define("N_BarrelHits", [](std::vector<dd4pod::TrackerHitData> hits) { return hits.size();}, {"TrackerBarrelHits"}) - .Define("N_EndcapHits", [](std::vector<dd4pod::TrackerHitData> hits) { return hits.size();}, {"TrackerEndcapHits"}) + .Define("N_BarrelHits", [](std::vector<edm4hep::SimTrackerHitData> hits) { return hits.size();}, {"TrackerBarrelHits"}) + .Define("N_EndcapHits", [](std::vector<edm4hep::SimTrackerHitData> hits) { return hits.size();}, {"TrackerEndcapHits"}) ; auto hBarrel_x_vs_y = df0.Histo2D({"hBarrel_x_vs_y", "; x ; y ", 100, -900, 900,100, -900, 900 }, "TrackerBarrelHits.position.x", "TrackerBarrelHits.position.y"); diff --git a/benchmarks/far_forward/analysis/print_far_forward_protons.cxx b/benchmarks/far_forward/analysis/print_far_forward_protons.cxx index 0fbbf60f..841c0bf8 100644 --- a/benchmarks/far_forward/analysis/print_far_forward_protons.cxx +++ b/benchmarks/far_forward/analysis/print_far_forward_protons.cxx @@ -8,7 +8,7 @@ R__LOAD_LIBRARY(libeicd.so) R__LOAD_LIBRARY(libDD4pod.so) -#include "dd4pod/Geant4ParticleCollection.h" +#include "edm4hep/MCParticleCollection.h" #include "eicd/TrackParametersCollection.h" #include "eicd/ClusterCollection.h" #include "eicd/ClusterData.h" diff --git a/benchmarks/far_forward/analysis/rec_far_forward_protons.cxx b/benchmarks/far_forward/analysis/rec_far_forward_protons.cxx index 9e0ae6b8..8a84c11c 100644 --- a/benchmarks/far_forward/analysis/rec_far_forward_protons.cxx +++ b/benchmarks/far_forward/analysis/rec_far_forward_protons.cxx @@ -10,7 +10,7 @@ R__LOAD_LIBRARY(libeicd.so) R__LOAD_LIBRARY(libDD4pod.so) -#include "dd4pod/Geant4ParticleCollection.h" +#include "edm4hep/MCParticleCollection.h" #include "eicd/TrackParametersCollection.h" #include "eicd/ClusterCollection.h" #include "eicd/ClusterData.h" @@ -28,10 +28,10 @@ auto p_track = [](std::vector<eic::TrackParametersData> const& in) { }; -std::vector<float> pt (std::vector<dd4pod::Geant4ParticleData> const& in){ +std::vector<float> pt (std::vector<edm4hep::MCParticleData> const& in){ std::vector<float> result; for (size_t i = 0; i < in.size(); ++i) { - result.push_back(std::sqrt(in[i].ps.x * in[i].ps.x + in[i].ps.y * in[i].ps.y)); + result.push_back(std::sqrt(in[i].momentum.x * in[i].momentum.x + in[i].momentum.y * in[i].momentum.y)); } return result; } @@ -50,11 +50,11 @@ auto theta = [](std::vector<ROOT::Math::PxPyPzMVector> const& in) { } return result; }; -auto fourvec = [](ROOT::VecOps::RVec<dd4pod::Geant4ParticleData> const& in) { +auto fourvec = [](ROOT::VecOps::RVec<edm4hep::MCParticleData> const& in) { std::vector<ROOT::Math::PxPyPzMVector> result; ROOT::Math::PxPyPzMVector lv; for (size_t i = 0; i < in.size(); ++i) { - lv.SetCoordinates(in[i].ps.x, in[i].ps.y, in[i].ps.z, in[i].mass); + lv.SetCoordinates(in[i].momentum.x, in[i].momentum.y, in[i].momentum.z, in[i].mass); result.push_back(lv); } return result; @@ -86,8 +86,8 @@ int rec_far_forward_protons(const char* fname = "topside/rec_far_forward_protons ROOT::EnableImplicitMT(); ROOT::RDataFrame df("events", fname); - auto df0 = df.Define("isThrown", "mcparticles.genStatus == 1") - .Define("thrownParticles", "mcparticles[isThrown]") + auto df0 = df.Define("isThrown", "MCParticles.generatorStatus == 1") + .Define("thrownParticles", "MCParticles[isThrown]") .Define("thrownP", fourvec, {"thrownParticles"}) .Define("p_thrown", momentum, {"thrownP"}) .Define("theta_thrown", theta, {"thrownP"}) diff --git a/benchmarks/imaging_ecal/analysis/emcal_barrel_pion_rejection_analysis.cxx b/benchmarks/imaging_ecal/analysis/emcal_barrel_pion_rejection_analysis.cxx index b07f5728..288c59c5 100644 --- a/benchmarks/imaging_ecal/analysis/emcal_barrel_pion_rejection_analysis.cxx +++ b/benchmarks/imaging_ecal/analysis/emcal_barrel_pion_rejection_analysis.cxx @@ -8,8 +8,8 @@ #include <algorithm> #include <string> -#include "dd4pod/CalorimeterHitCollection.h" -#include "dd4pod/Geant4ParticleCollection.h" +#include "edm4hep/SimCalorimeterHitCollection.h" +#include "edm4hep/MCParticleCollection.h" #include "eicd/CalorimeterHitCollection.h" #include "eicd/CalorimeterHitData.h" @@ -104,34 +104,34 @@ void emcal_barrel_pion_rejection_analysis( // MCParticles Functions///////////////////////////////////////////////////////////////////////////////////// // Filter function to get electrons - auto is_electron = [](std::vector<dd4pod::Geant4ParticleData> const& input){ - return (input[2].pdgID == 11 ? true : false); + auto is_electron = [](std::vector<edm4hep::MCParticleData> const& input){ + return (input[2].PDG == 11 ? true : false); }; // Filter function to get just negative pions - auto is_piMinus = [](std::vector<dd4pod::Geant4ParticleData> const& input){ - return (input[2].pdgID == -211 ? true : false); + auto is_piMinus = [](std::vector<edm4hep::MCParticleData> const& input){ + return (input[2].PDG == -211 ? true : false); }; // Thrown Energy [GeV] - auto Ethr = [](std::vector<dd4pod::Geant4ParticleData> const& input) { - return TMath::Sqrt(input[2].ps.x*input[2].ps.x + input[2].ps.y*input[2].ps.y + input[2].ps.z*input[2].ps.z + input[2].mass*input[2].mass); + auto Ethr = [](std::vector<edm4hep::MCParticleData> const& input) { + return TMath::Sqrt(input[2].momentum.x*input[2].momentum.x + input[2].momentum.y*input[2].momentum.y + input[2].momentum.z*input[2].momentum.z + input[2].mass*input[2].mass); }; // Thrown Momentum [GeV] - auto Pthr = [](std::vector<dd4pod::Geant4ParticleData> const& input) { - return TMath::Sqrt(input[2].ps.x*input[2].ps.x + input[2].ps.y*input[2].ps.y + input[2].ps.z*input[2].ps.z); + auto Pthr = [](std::vector<edm4hep::MCParticleData> const& input) { + return TMath::Sqrt(input[2].momentum.x*input[2].momentum.x + input[2].momentum.y*input[2].momentum.y + input[2].momentum.z*input[2].momentum.z); }; // Thrown Eta - auto Eta = [](std::vector<dd4pod::Geant4ParticleData> const& input) { - double E = TMath::Sqrt(input[2].ps.x*input[2].ps.x + input[2].ps.y*input[2].ps.y + input[2].ps.z*input[2].ps.z + input[2].mass*input[2].mass); - return 0.5*TMath::Log((E + input[2].ps.z) / (E - input[2].ps.z)); + auto Eta = [](std::vector<edm4hep::MCParticleData> const& input) { + double E = TMath::Sqrt(input[2].momentum.x*input[2].momentum.x + input[2].momentum.y*input[2].momentum.y + input[2].momentum.z*input[2].momentum.z + input[2].mass*input[2].mass); + return 0.5*TMath::Log((E + input[2].momentum.z) / (E - input[2].momentum.z)); }; // Thrown pT [GeV] - auto pT = [](std::vector<dd4pod::Geant4ParticleData> const& input) { - return TMath::Sqrt(input[2].ps.x*input[2].ps.x + input[2].ps.y*input[2].ps.y); + auto pT = [](std::vector<edm4hep::MCParticleData> const& input) { + return TMath::Sqrt(input[2].momentum.x*input[2].momentum.x + input[2].momentum.y*input[2].momentum.y); }; // RecoEcalBarrelImagingHits Functions///////////////////////////////////////////////////////////////////////////////////// @@ -475,10 +475,10 @@ void emcal_barrel_pion_rejection_analysis( // Define variables auto d1 = d0 - .Define("Ethr", Ethr, {"mcparticles"}) - .Define("Pthr", Pthr, {"mcparticles"}) - .Define("Eta", Eta, {"mcparticles"}) - .Define("pT", pT, {"mcparticles"}) + .Define("Ethr", Ethr, {"MCParticles"}) + .Define("Pthr", Pthr, {"MCParticles"}) + .Define("Eta", Eta, {"MCParticles"}) + .Define("pT", pT, {"MCParticles"}) .Define("ERecoImg", ERecoImg, {"RecoEcalBarrelImagingHits"}) .Define("nhitsImgLayer", nhitsImgLayer, {"RecoEcalBarrelImagingHits"}) @@ -552,8 +552,8 @@ void emcal_barrel_pion_rejection_analysis( "ERecoScFiLayer3OverP", "ERecoScFiLayer4OverP", "ERecoScFiLayer5OverP","ERecoScFiLayer6OverP"}; std::vector<std::vector<double>> colRange = {{0,23},{0,19},{0,570},{-300,300},{0,280},{0.065,0.45},{-0.5,1},{0,1.5},{0,1.5},{0,2.5e-2},{0,2.5e-2},{0,2.5e-2},{0,2.5e-2},}; - auto d_temp_ele = d1.Filter(is_electron, {"mcparticles"}); - auto d_temp_pim = d1.Filter(is_piMinus, {"mcparticles"}); + auto d_temp_ele = d1.Filter(is_electron, {"MCParticles"}); + auto d_temp_pim = d1.Filter(is_piMinus, {"MCParticles"}); int rangeCount = 0; for (auto && name : colList){ @@ -792,12 +792,12 @@ void emcal_barrel_pion_rejection_analysis( double effPim[7]; double rejRatios[7]; - auto he_uncut = d1.Filter(is_electron, {"mcparticles"}).Histo1D({"he_uncut", "P", 7, &binEdges[0]}, "Pthr"); + auto he_uncut = d1.Filter(is_electron, {"MCParticles"}).Histo1D({"he_uncut", "P", 7, &binEdges[0]}, "Pthr"); auto he_cut = d_ele.Histo1D({"he_cut", "P", 7, &binEdges[0]}, "Pthr"); - auto hp_uncut = d1.Filter(is_piMinus, {"mcparticles"}).Histo1D({"hp_uncut", "P", 7, &binEdges[0]}, "Pthr"); + auto hp_uncut = d1.Filter(is_piMinus, {"MCParticles"}).Histo1D({"hp_uncut", "P", 7, &binEdges[0]}, "Pthr"); auto hp_cut = d_pim.Histo1D({"hp_cut", "P", 7, &binEdges[0]}, "Pthr"); - double ele_eff_total = (double)*d_ele.Count() / (double)*d1.Filter(is_electron, {"mcparticles"}).Count(); + double ele_eff_total = (double)*d_ele.Count() / (double)*d1.Filter(is_electron, {"MCParticles"}).Count(); he_cut->Divide(he_uncut.GetPtr());//Effienciency hp_uncut->Divide(hp_cut.GetPtr());//Rejection power diff --git a/benchmarks/imaging_ecal/scripts/draw_cluster.py b/benchmarks/imaging_ecal/scripts/draw_cluster.py index 02cc7683..faeac4be 100755 --- a/benchmarks/imaging_ecal/scripts/draw_cluster.py +++ b/benchmarks/imaging_ecal/scripts/draw_cluster.py @@ -148,7 +148,7 @@ if __name__ == '__main__': df['eta'] = -np.log(np.tan(df['theta'].values/1000./2.)) # Read all mc particles - dfallmcp = get_all_mcp(args.file, args.iev, 'mcparticles') + dfallmcp = get_all_mcp(args.file, args.iev, 'MCParticles') pdgbase = ROOT.TDatabasePDG() # Select decaying particles dftemp = dfallmcp[dfallmcp['g4Parent'] == 1.0] @@ -169,7 +169,7 @@ if __name__ == '__main__': dfdecaymcp['eta'] = -np.log(np.tan(dfdecaymcp['theta'].values/1000./2.)) # truth - dfmcp = get_mcp_simple(args.file, args.iev, 'mcparticles').iloc[0] + dfmcp = get_mcp_simple(args.file, args.iev, 'MCParticles').iloc[0] #pdgbase = ROOT.TDatabasePDG() inpart = pdgbase.GetParticle(int(dfmcp['pid'])) if inpart: diff --git a/benchmarks/imaging_ecal/scripts/draw_cluster_layers.py b/benchmarks/imaging_ecal/scripts/draw_cluster_layers.py index 42b80d43..0a37a522 100644 --- a/benchmarks/imaging_ecal/scripts/draw_cluster_layers.py +++ b/benchmarks/imaging_ecal/scripts/draw_cluster_layers.py @@ -98,7 +98,7 @@ if __name__ == '__main__': df['eta'] = -np.log(np.tan(df['theta'].values/1000./2.)) # truth - dfmcp = get_mcp_simple(args.file, args.iev, 'mcparticles').iloc[0] + dfmcp = get_mcp_simple(args.file, args.iev, 'MCParticles').iloc[0] pdgbase = ROOT.TDatabasePDG() inpart = pdgbase.GetParticle(int(dfmcp['pid'])) print("Incoming particle = {}, pdgcode = {}, charge = {}, mass = {}"\ diff --git a/benchmarks/imaging_ecal/scripts/utils.py b/benchmarks/imaging_ecal/scripts/utils.py index 0f4e40a2..452a9334 100644 --- a/benchmarks/imaging_ecal/scripts/utils.py +++ b/benchmarks/imaging_ecal/scripts/utils.py @@ -37,7 +37,7 @@ def load_root_macros(arg_macros): # read mc particles from root file -def get_mcp_data(path, evnums=None, branch='mcparticles'): +def get_mcp_data(path, evnums=None, branch='MCParticles'): f = ROOT.TFile(path) events = f.events if evnums is None: @@ -61,7 +61,7 @@ def get_mcp_data(path, evnums=None, branch='mcparticles'): # read mc particles from root file -def get_mcp_simple(path, evnums=None, branch='mcparticles'): +def get_mcp_simple(path, evnums=None, branch='MCParticles'): f = ROOT.TFile(path) events = f.events if evnums is None: @@ -86,7 +86,7 @@ def get_mcp_simple(path, evnums=None, branch='mcparticles'): ####################################### # read all mc particles from root file ####################################### -def get_all_mcp(path, evnums=None, branch='mcparticles'): +def get_all_mcp(path, evnums=None, branch='MCParticles'): f = ROOT.TFile(path) events = f.events if evnums is None: diff --git a/benchmarks/imaging_shower_ML/scripts/check_edep_dists.py b/benchmarks/imaging_shower_ML/scripts/check_edep_dists.py index 404855b1..c865af89 100644 --- a/benchmarks/imaging_shower_ML/scripts/check_edep_dists.py +++ b/benchmarks/imaging_shower_ML/scripts/check_edep_dists.py @@ -63,7 +63,7 @@ if __name__ == '__main__': parser.add_argument('-m', '--macros', type=str, default='rootlogon.C', dest='macros', help='root macros to load (accept multiple paths separated by \",\")') parser.add_argument('--branch', type=str, default='EcalBarrelImagingHitsReco', help='name of data branch (eic::CalorimeterHitCollection)') - parser.add_argument('--truth-branch', type=str, default='mcparticles', help='name of truth mc branch') + parser.add_argument('--truth-branch', type=str, default='MCParticles', help='name of truth mc branch') parser.add_argument('--edep-max', type=float, default=0., help='maximum edep (GeV) to plot') parser.add_argument('--edep-nbins', type=int, default=200, help='number of bins') parser.add_argument('--name-tag', type=str, default='test', help='name tag to save the file') @@ -73,7 +73,7 @@ if __name__ == '__main__': os.makedirs(args.outdir, exist_ok=True) load_root_macros(args.macros) - # read data and mcparticles + # read data and MCParticles rdf = ROOT.RDataFrame("events", args.file) mc_branch = args.truth_branch diff --git a/benchmarks/imaging_shower_ML/scripts/prepare_tf_dataset.py b/benchmarks/imaging_shower_ML/scripts/prepare_tf_dataset.py index d94d1cb6..88477d56 100644 --- a/benchmarks/imaging_shower_ML/scripts/prepare_tf_dataset.py +++ b/benchmarks/imaging_shower_ML/scripts/prepare_tf_dataset.py @@ -73,7 +73,7 @@ if __name__ == '__main__': os.makedirs(args.outdir, exist_ok=True) load_root_macros(args.macros) - # read data and mcparticles + # read data and MCParticles rdf = ROOT.RDataFrame("events", args.file) df = flatten_collection(rdf, args.branch, ['layer', 'energy', 'position.x', 'position.y', 'position.z']) df.rename(columns={c: c.replace(args.branch + '.', '') for c in df.columns}, inplace=True) @@ -85,8 +85,8 @@ if __name__ == '__main__': df.loc[:, 'rc'] = rc df.loc[:, 'eta'] = eta - dfm = flatten_collection(rdf, 'mcparticles', ['genStatus', 'pdgID', 'ps.x', 'ps.y', 'ps.z', 'mass']) - dfm.rename(columns={c: c.replace('mcparticles.', '') for c in dfm.columns}, inplace=True) + dfm = flatten_collection(rdf, 'MCParticles', ['generatorStatus', 'PDG', 'momentum.x', 'momentum.y', 'momentum.z', 'mass']) + dfm.rename(columns={c: c.replace('MCParticles.', '') for c in dfm.columns}, inplace=True) # selete incident particles dfm = dfm[dfm['genStatus'].isin([0, 1])] # NOTE: assumed single particles diff --git a/benchmarks/track_finding/scripts/rec_multiple_tracks.cxx b/benchmarks/track_finding/scripts/rec_multiple_tracks.cxx index 9b3e5512..8026faee 100644 --- a/benchmarks/track_finding/scripts/rec_multiple_tracks.cxx +++ b/benchmarks/track_finding/scripts/rec_multiple_tracks.cxx @@ -8,7 +8,7 @@ R__LOAD_LIBRARY(libJugBase.so) R__LOAD_LIBRARY(libeicd.so) R__LOAD_LIBRARY(libDD4pod.so) -#include "dd4pod/Geant4ParticleCollection.h" +#include "edm4hep/MCParticleCollection.h" #include "eicd/TrackParametersCollection.h" #include "eicd/ClusterCollection.h" #include "eicd/ClusterData.h" @@ -26,10 +26,10 @@ auto p_track = [](std::vector<eic::TrackParametersData> const& in) { }; -std::vector<float> pt (std::vector<dd4pod::Geant4ParticleData> const& in){ +std::vector<float> pt (std::vector<edm4hep::MCParticleData> const& in){ std::vector<float> result; for (size_t i = 0; i < in.size(); ++i) { - result.push_back(std::sqrt(in[i].ps.x * in[i].ps.x + in[i].ps.y * in[i].ps.y)); + result.push_back(std::sqrt(in[i].momentum.x * in[i].momentum.x + in[i].momentum.y * in[i].momentum.y)); } return result; } @@ -48,11 +48,11 @@ auto theta = [](std::vector<ROOT::Math::PxPyPzMVector> const& in) { } return result; }; -auto fourvec = [](ROOT::VecOps::RVec<dd4pod::Geant4ParticleData> const& in) { +auto fourvec = [](ROOT::VecOps::RVec<edm4hep::MCParticleData> const& in) { std::vector<ROOT::Math::PxPyPzMVector> result; ROOT::Math::PxPyPzMVector lv; for (size_t i = 0; i < in.size(); ++i) { - lv.SetCoordinates(in[i].ps.x, in[i].ps.y, in[i].ps.z, in[i].mass); + lv.SetCoordinates(in[i].momentum.x, in[i].momentum.y, in[i].momentum.z, in[i].mass); result.push_back(lv); } return result; @@ -87,8 +87,8 @@ int rec_multiple_tracks(const char* fname = "topside/rec_multiple_tracks.root") ROOT::EnableImplicitMT(); ROOT::RDataFrame df("events", fname); - auto df0 = df.Define("isThrown", "mcparticles.genStatus == 1") - .Define("thrownParticles", "mcparticles[isThrown]") + auto df0 = df.Define("isThrown", "MCParticles.generatorStatus == 1") + .Define("thrownParticles", "MCParticles[isThrown]") .Define("thrownP", fourvec, {"thrownParticles"}) .Define("nThrown", "thrownParticles.size()") .Define("nProto", "outputProtoTracks.size()") diff --git a/benchmarks/track_fitting/scripts/rec_multiple_tracks.cxx b/benchmarks/track_fitting/scripts/rec_multiple_tracks.cxx index ada976a3..81904762 100644 --- a/benchmarks/track_fitting/scripts/rec_multiple_tracks.cxx +++ b/benchmarks/track_fitting/scripts/rec_multiple_tracks.cxx @@ -8,7 +8,7 @@ R__LOAD_LIBRARY(libeicd.so) R__LOAD_LIBRARY(libDD4pod.so) -#include "dd4pod/Geant4ParticleCollection.h" +#include "edm4hep/MCParticleCollection.h" #include "eicd/TrackParametersCollection.h" #include "eicd/ClusterCollection.h" #include "eicd/ClusterData.h" @@ -26,10 +26,10 @@ auto p_track = [](std::vector<eic::TrackParametersData> const& in) { }; -std::vector<float> pt (std::vector<dd4pod::Geant4ParticleData> const& in){ +std::vector<float> pt (std::vector<edm4hep::MCParticleData> const& in){ std::vector<float> result; for (size_t i = 0; i < in.size(); ++i) { - result.push_back(std::sqrt(in[i].ps.x * in[i].ps.x + in[i].ps.y * in[i].ps.y)); + result.push_back(std::sqrt(in[i].momentum.x * in[i].momentum.x + in[i].momentum.y * in[i].momentum.y)); } return result; } @@ -48,11 +48,11 @@ auto theta = [](std::vector<ROOT::Math::PxPyPzMVector> const& in) { } return result; }; -auto fourvec = [](ROOT::VecOps::RVec<dd4pod::Geant4ParticleData> const& in) { +auto fourvec = [](ROOT::VecOps::RVec<edm4hep::MCParticleData> const& in) { std::vector<ROOT::Math::PxPyPzMVector> result; ROOT::Math::PxPyPzMVector lv; for (size_t i = 0; i < in.size(); ++i) { - lv.SetCoordinates(in[i].ps.x, in[i].ps.y, in[i].ps.z, in[i].mass); + lv.SetCoordinates(in[i].momentum.x, in[i].momentum.y, in[i].momentum.z, in[i].mass); result.push_back(lv); } return result; @@ -84,8 +84,8 @@ int rec_multiple_tracks(const char* fname = "topside/rec_multiple_tracks.root") ROOT::EnableImplicitMT(); ROOT::RDataFrame df("events", fname); - auto df0 = df.Define("isThrown", "mcparticles.genStatus == 1") - .Define("thrownParticles", "mcparticles[isThrown]") + auto df0 = df.Define("isThrown", "MCParticles.generatorStatus == 1") + .Define("thrownParticles", "MCParticles[isThrown]") .Define("thrownP", fourvec, {"thrownParticles"}) .Define("p_thrown", momentum, {"thrownP"}) .Define("theta_thrown", theta, {"thrownP"}) diff --git a/benchmarks/track_fitting/scripts/rec_single_tracks.cxx b/benchmarks/track_fitting/scripts/rec_single_tracks.cxx index 9aad6734..f6492685 100644 --- a/benchmarks/track_fitting/scripts/rec_single_tracks.cxx +++ b/benchmarks/track_fitting/scripts/rec_single_tracks.cxx @@ -8,7 +8,7 @@ R__LOAD_LIBRARY(libeicd.so) R__LOAD_LIBRARY(libDD4pod.so) -#include "dd4pod/Geant4ParticleCollection.h" +#include "edm4hep/MCParticleCollection.h" #include "eicd/TrackParametersCollection.h" #include "eicd/ClusterCollection.h" #include "eicd/ClusterData.h" @@ -29,10 +29,10 @@ auto p_track = [](std::vector<eic::TrackParametersData> const& in) { }; -std::vector<float> pt (std::vector<dd4pod::Geant4ParticleData> const& in){ +std::vector<float> pt (std::vector<edm4hep::MCParticleData> const& in){ std::vector<float> result; for (size_t i = 0; i < in.size(); ++i) { - result.push_back(std::sqrt(in[i].ps.x * in[i].ps.x + in[i].ps.y * in[i].ps.y)); + result.push_back(std::sqrt(in[i].momentum.x * in[i].momentum.x + in[i].momentum.y * in[i].momentum.y)); } return result; } @@ -51,11 +51,11 @@ auto theta = [](std::vector<ROOT::Math::PxPyPzMVector> const& in) { } return result; }; -auto fourvec = [](ROOT::VecOps::RVec<dd4pod::Geant4ParticleData> const& in) { +auto fourvec = [](ROOT::VecOps::RVec<edm4hep::MCParticleData> const& in) { std::vector<ROOT::Math::PxPyPzMVector> result; ROOT::Math::PxPyPzMVector lv; for (size_t i = 0; i < in.size(); ++i) { - lv.SetCoordinates(in[i].ps.x, in[i].ps.y, in[i].ps.z, in[i].mass); + lv.SetCoordinates(in[i].momentum.x, in[i].momentum.y, in[i].momentum.z, in[i].mass); result.push_back(lv); } return result; @@ -87,8 +87,8 @@ int rec_single_tracks(const char* fname = "topside/rec_single_tracks.root") ROOT::EnableImplicitMT(); ROOT::RDataFrame df("events", fname); - auto df0 = df.Define("isThrown", "mcparticles.genStatus == 1") - .Define("thrownParticles", "mcparticles[isThrown]") + auto df0 = df.Define("isThrown", "MCParticles.generatorStatus == 1") + .Define("thrownParticles", "MCParticles[isThrown]") .Define("thrownP", fourvec, {"thrownParticles"}) .Define("p_thrown", momentum, {"thrownP"}) .Define("theta_thrown", theta, {"thrownP"}) diff --git a/benchmarks/tracking/run_tracking_benchmarks.py b/benchmarks/tracking/run_tracking_benchmarks.py index b6da02f9..93c00577 100755 --- a/benchmarks/tracking/run_tracking_benchmarks.py +++ b/benchmarks/tracking/run_tracking_benchmarks.py @@ -91,7 +91,7 @@ if 'rec' in procs: if 'ana' in procs: os.makedirs('results', exist_ok=True) ana_cmd = ['python', analysis_script, rec_file, - '--mc-collection', 'mcparticles', + '--mc-collection', 'MCParticles', '--tracking-collection', 'outputTrackParameters', '-o', 'results', '-t', args.nametag] return_code = subprocess.run(ana_cmd).returncode diff --git a/benchmarks/tracking/scripts/hits_central_electrons.cxx b/benchmarks/tracking/scripts/hits_central_electrons.cxx index d76cacdf..493a35a4 100644 --- a/benchmarks/tracking/scripts/hits_central_electrons.cxx +++ b/benchmarks/tracking/scripts/hits_central_electrons.cxx @@ -8,9 +8,9 @@ R__LOAD_LIBRARY(libeicd.so) R__LOAD_LIBRARY(libDD4pod.so) -#include "dd4pod/TrackerHitCollection.h" -#include "dd4pod/TrackerHitData.h" -#include "dd4pod/Geant4ParticleCollection.h" +#include "edm4hep/SimTrackerHitCollection.h" +#include "edm4hep/SimTrackerHitData.h" +#include "edm4hep/MCParticleCollection.h" #include "eicd/TrackParametersCollection.h" #include "eicd/ClusterCollection.h" #include "eicd/ClusterData.h" @@ -28,10 +28,10 @@ auto p_track = [](std::vector<eic::TrackParametersData> const& in) { }; -std::vector<float> pt (std::vector<dd4pod::Geant4ParticleData> const& in){ +std::vector<float> pt (std::vector<edm4hep::MCParticleData> const& in){ std::vector<float> result; for (size_t i = 0; i < in.size(); ++i) { - result.push_back(std::sqrt(in[i].ps.x * in[i].ps.x + in[i].ps.y * in[i].ps.y)); + result.push_back(std::sqrt(in[i].momentum.x * in[i].momentum.x + in[i].momentum.y * in[i].momentum.y)); } return result; } @@ -50,11 +50,11 @@ auto theta = [](std::vector<ROOT::Math::PxPyPzMVector> const& in) { } return result; }; -auto fourvec = [](ROOT::VecOps::RVec<dd4pod::Geant4ParticleData> const& in) { +auto fourvec = [](ROOT::VecOps::RVec<edm4hep::MCParticleData> const& in) { std::vector<ROOT::Math::PxPyPzMVector> result; ROOT::Math::PxPyPzMVector lv; for (size_t i = 0; i < in.size(); ++i) { - lv.SetCoordinates(in[i].ps.x, in[i].ps.y, in[i].ps.z, in[i].mass); + lv.SetCoordinates(in[i].momentum.x, in[i].momentum.y, in[i].momentum.z, in[i].mass); result.push_back(lv); } return result; @@ -86,8 +86,8 @@ int hits_central_electrons(const char* fname = "sim_central_electrons.edm4hep.ro ROOT::EnableImplicitMT(); ROOT::RDataFrame df("events", fname); - auto df0 = df.Define("isThrown", "mcparticles.genStatus == 1") - .Define("thrownParticles", "mcparticles[isThrown]") + auto df0 = df.Define("isThrown", "MCParticles.generatorStatus == 1") + .Define("thrownParticles", "MCParticles[isThrown]") .Define("thrownP", fourvec, {"thrownParticles"}) .Define("p_thrown", momentum, {"thrownP"}) .Define("theta_thrown", theta, {"thrownP"}) @@ -103,9 +103,9 @@ int hits_central_electrons(const char* fname = "sim_central_electrons.edm4hep.ro //.Define("delta_p_over_p1",delta_p_over_p, {"p_track1", "p_thrown"}) //.Define("delta_p_over_p2",delta_p_over_p, {"p_track2", "p_thrown"}) //.Define("N_VtxBarrelHits",[](std::vector<eic::TrackerHitData> hits) { return hits.size();},{"VertexBarrelRecHits"}) - //.Define("N_Hits", [](std::vector<dd4pod::TrackerHitData> hits) { return hits.size();}, {"trackingHits"}) - .Define("N_BarrelHits", [](std::vector<dd4pod::TrackerHitData> hits) { return hits.size();}, {"TrackerBarrelHits"}) - .Define("N_EndcapHits", [](std::vector<dd4pod::TrackerHitData> hits) { return hits.size();}, {"TrackerEndcapHits"}) + //.Define("N_Hits", [](std::vector<edm4hep::SimTrackerHitData> hits) { return hits.size();}, {"trackingHits"}) + .Define("N_BarrelHits", [](std::vector<edm4hep::SimTrackerHitData> hits) { return hits.size();}, {"TrackerBarrelHits"}) + .Define("N_EndcapHits", [](std::vector<edm4hep::SimTrackerHitData> hits) { return hits.size();}, {"TrackerEndcapHits"}) ; auto hBarrel_x_vs_y = df0.Histo2D({"hBarrel_x_vs_y", "; x ; y ", 100, -900, 900,100, -900, 900 }, "TrackerBarrelHits.position.x", "TrackerBarrelHits.position.y"); diff --git a/benchmarks/tracking/scripts/hits_central_pions.cxx b/benchmarks/tracking/scripts/hits_central_pions.cxx index 74a20915..ef7d3fef 100644 --- a/benchmarks/tracking/scripts/hits_central_pions.cxx +++ b/benchmarks/tracking/scripts/hits_central_pions.cxx @@ -8,9 +8,9 @@ R__LOAD_LIBRARY(libeicd.so) R__LOAD_LIBRARY(libDD4pod.so) -#include "dd4pod/TrackerHitCollection.h" -#include "dd4pod/TrackerHitData.h" -#include "dd4pod/Geant4ParticleCollection.h" +#include "edm4hep/SimTrackerHitCollection.h" +#include "edm4hep/SimTrackerHitData.h" +#include "edm4hep/MCParticleCollection.h" #include "eicd/TrackParametersCollection.h" #include "eicd/ClusterCollection.h" #include "eicd/ClusterData.h" @@ -28,10 +28,10 @@ auto p_track = [](std::vector<eic::TrackParametersData> const& in) { }; -std::vector<float> pt (std::vector<dd4pod::Geant4ParticleData> const& in){ +std::vector<float> pt (std::vector<edm4hep::MCParticleData> const& in){ std::vector<float> result; for (size_t i = 0; i < in.size(); ++i) { - result.push_back(std::sqrt(in[i].ps.x * in[i].ps.x + in[i].ps.y * in[i].ps.y)); + result.push_back(std::sqrt(in[i].momentum.x * in[i].momentum.x + in[i].momentum.y * in[i].momentum.y)); } return result; } @@ -50,11 +50,11 @@ auto theta = [](std::vector<ROOT::Math::PxPyPzMVector> const& in) { } return result; }; -auto fourvec = [](ROOT::VecOps::RVec<dd4pod::Geant4ParticleData> const& in) { +auto fourvec = [](ROOT::VecOps::RVec<edm4hep::MCParticleData> const& in) { std::vector<ROOT::Math::PxPyPzMVector> result; ROOT::Math::PxPyPzMVector lv; for (size_t i = 0; i < in.size(); ++i) { - lv.SetCoordinates(in[i].ps.x, in[i].ps.y, in[i].ps.z, in[i].mass); + lv.SetCoordinates(in[i].momentum.x, in[i].momentum.y, in[i].momentum.z, in[i].mass); result.push_back(lv); } return result; @@ -86,8 +86,8 @@ int hits_central_pions(const char* fname = "sim_central_pions.edm4hep.root") ROOT::EnableImplicitMT(); ROOT::RDataFrame df("events", fname); - auto df0 = df.Define("isThrown", "mcparticles.genStatus == 1") - .Define("thrownParticles", "mcparticles[isThrown]") + auto df0 = df.Define("isThrown", "MCParticles.generatorStatus == 1") + .Define("thrownParticles", "MCParticles[isThrown]") .Define("thrownP", fourvec, {"thrownParticles"}) .Define("p_thrown", momentum, {"thrownP"}) .Define("theta_thrown", theta, {"thrownP"}) @@ -103,8 +103,8 @@ int hits_central_pions(const char* fname = "sim_central_pions.edm4hep.root") //.Define("delta_p_over_p1",delta_p_over_p, {"p_track1", "p_thrown"}) //.Define("delta_p_over_p2",delta_p_over_p, {"p_track2", "p_thrown"}) //.Define("N_VtxBarrelHits",[](std::vector<eic::TrackerHitData> hits) { return hits.size();},{"VertexBarrelRecHits"}) - .Define("N_BarrelHits", [](std::vector<dd4pod::TrackerHitData> hits) { return hits.size();}, {"TrackerBarrelHits"}) - .Define("N_EndcapHits", [](std::vector<dd4pod::TrackerHitData> hits) { return hits.size();}, {"TrackerEndcapHits"}) + .Define("N_BarrelHits", [](std::vector<edm4hep::SimTrackerHitData> hits) { return hits.size();}, {"TrackerBarrelHits"}) + .Define("N_EndcapHits", [](std::vector<edm4hep::SimTrackerHitData> hits) { return hits.size();}, {"TrackerEndcapHits"}) ; auto hBarrel_x_vs_y = df0.Histo2D({"hBarrel_x_vs_y", "; x ; y ", 100, -900, 900,100, -900, 900 }, "TrackerBarrelHits.position.x", "TrackerBarrelHits.position.y"); diff --git a/benchmarks/tracking/scripts/rec_central_electrons.cxx b/benchmarks/tracking/scripts/rec_central_electrons.cxx index 8c3708f1..4c7a76b6 100644 --- a/benchmarks/tracking/scripts/rec_central_electrons.cxx +++ b/benchmarks/tracking/scripts/rec_central_electrons.cxx @@ -8,7 +8,7 @@ R__LOAD_LIBRARY(libeicd.so) R__LOAD_LIBRARY(libDD4pod.so) -#include "dd4pod/Geant4ParticleCollection.h" +#include "edm4hep/MCParticleCollection.h" #include "eicd/TrackParametersCollection.h" #include "eicd/ClusterCollection.h" #include "eicd/ClusterData.h" @@ -26,10 +26,10 @@ auto p_track = [](std::vector<eic::TrackParametersData> const& in) { }; -std::vector<float> pt (std::vector<dd4pod::Geant4ParticleData> const& in){ +std::vector<float> pt (std::vector<edm4hep::MCParticleData> const& in){ std::vector<float> result; for (size_t i = 0; i < in.size(); ++i) { - result.push_back(std::sqrt(in[i].ps.x * in[i].ps.x + in[i].ps.y * in[i].ps.y)); + result.push_back(std::sqrt(in[i].momentum.x * in[i].momentum.x + in[i].momentum.y * in[i].momentum.y)); } return result; } @@ -48,11 +48,11 @@ auto theta = [](std::vector<ROOT::Math::PxPyPzMVector> const& in) { } return result; }; -auto fourvec = [](ROOT::VecOps::RVec<dd4pod::Geant4ParticleData> const& in) { +auto fourvec = [](ROOT::VecOps::RVec<edm4hep::MCParticleData> const& in) { std::vector<ROOT::Math::PxPyPzMVector> result; ROOT::Math::PxPyPzMVector lv; for (size_t i = 0; i < in.size(); ++i) { - lv.SetCoordinates(in[i].ps.x, in[i].ps.y, in[i].ps.z, in[i].mass); + lv.SetCoordinates(in[i].momentum.x, in[i].momentum.y, in[i].momentum.z, in[i].mass); result.push_back(lv); } return result; @@ -84,8 +84,8 @@ int rec_central_electrons(const char* fname = "topside/rec_central_electrons.roo ROOT::EnableImplicitMT(); ROOT::RDataFrame df("events", fname); - auto df0 = df.Define("isThrown", "mcparticles.genStatus == 1") - .Define("thrownParticles", "mcparticles[isThrown]") + auto df0 = df.Define("isThrown", "MCParticles.generatorStatus == 1") + .Define("thrownParticles", "MCParticles[isThrown]") .Define("thrownP", fourvec, {"thrownParticles"}) .Define("p_thrown", momentum, {"thrownP"}) .Define("theta_thrown", theta, {"thrownP"}) diff --git a/benchmarks/tracking/scripts/rec_central_pions.cxx b/benchmarks/tracking/scripts/rec_central_pions.cxx index 516ecb2b..102c7900 100644 --- a/benchmarks/tracking/scripts/rec_central_pions.cxx +++ b/benchmarks/tracking/scripts/rec_central_pions.cxx @@ -8,7 +8,7 @@ R__LOAD_LIBRARY(libeicd.so) R__LOAD_LIBRARY(libDD4pod.so) -#include "dd4pod/Geant4ParticleCollection.h" +#include "edm4hep/MCParticleCollection.h" #include "eicd/TrackParametersCollection.h" #include "eicd/ClusterCollection.h" #include "eicd/ClusterData.h" @@ -26,10 +26,10 @@ auto p_track = [](std::vector<eic::TrackParametersData> const& in) { }; -std::vector<float> pt (std::vector<dd4pod::Geant4ParticleData> const& in){ +std::vector<float> pt (std::vector<edm4hep::MCParticleData> const& in){ std::vector<float> result; for (size_t i = 0; i < in.size(); ++i) { - result.push_back(std::sqrt(in[i].ps.x * in[i].ps.x + in[i].ps.y * in[i].ps.y)); + result.push_back(std::sqrt(in[i].momentum.x * in[i].momentum.x + in[i].momentum.y * in[i].momentum.y)); } return result; } @@ -48,11 +48,11 @@ auto theta = [](std::vector<ROOT::Math::PxPyPzMVector> const& in) { } return result; }; -auto fourvec = [](ROOT::VecOps::RVec<dd4pod::Geant4ParticleData> const& in) { +auto fourvec = [](ROOT::VecOps::RVec<edm4hep::MCParticleData> const& in) { std::vector<ROOT::Math::PxPyPzMVector> result; ROOT::Math::PxPyPzMVector lv; for (size_t i = 0; i < in.size(); ++i) { - lv.SetCoordinates(in[i].ps.x, in[i].ps.y, in[i].ps.z, in[i].mass); + lv.SetCoordinates(in[i].momentum.x, in[i].momentum.y, in[i].momentum.z, in[i].mass); result.push_back(lv); } return result; @@ -84,8 +84,8 @@ int rec_central_pions(const char* fname = "topside/rec_central_pions.root") ROOT::EnableImplicitMT(); ROOT::RDataFrame df("events", fname); - auto df0 = df.Define("isThrown", "mcparticles.genStatus == 1") - .Define("thrownParticles", "mcparticles[isThrown]") + auto df0 = df.Define("isThrown", "MCParticles.generatorStatus == 1") + .Define("thrownParticles", "MCParticles[isThrown]") .Define("thrownP", fourvec, {"thrownParticles"}) .Define("p_thrown", momentum, {"thrownP"}) .Define("theta_thrown", theta, {"thrownP"}) diff --git a/benchmarks/tracking/scripts/rec_multiple_tracks.cxx b/benchmarks/tracking/scripts/rec_multiple_tracks.cxx index ada976a3..81904762 100644 --- a/benchmarks/tracking/scripts/rec_multiple_tracks.cxx +++ b/benchmarks/tracking/scripts/rec_multiple_tracks.cxx @@ -8,7 +8,7 @@ R__LOAD_LIBRARY(libeicd.so) R__LOAD_LIBRARY(libDD4pod.so) -#include "dd4pod/Geant4ParticleCollection.h" +#include "edm4hep/MCParticleCollection.h" #include "eicd/TrackParametersCollection.h" #include "eicd/ClusterCollection.h" #include "eicd/ClusterData.h" @@ -26,10 +26,10 @@ auto p_track = [](std::vector<eic::TrackParametersData> const& in) { }; -std::vector<float> pt (std::vector<dd4pod::Geant4ParticleData> const& in){ +std::vector<float> pt (std::vector<edm4hep::MCParticleData> const& in){ std::vector<float> result; for (size_t i = 0; i < in.size(); ++i) { - result.push_back(std::sqrt(in[i].ps.x * in[i].ps.x + in[i].ps.y * in[i].ps.y)); + result.push_back(std::sqrt(in[i].momentum.x * in[i].momentum.x + in[i].momentum.y * in[i].momentum.y)); } return result; } @@ -48,11 +48,11 @@ auto theta = [](std::vector<ROOT::Math::PxPyPzMVector> const& in) { } return result; }; -auto fourvec = [](ROOT::VecOps::RVec<dd4pod::Geant4ParticleData> const& in) { +auto fourvec = [](ROOT::VecOps::RVec<edm4hep::MCParticleData> const& in) { std::vector<ROOT::Math::PxPyPzMVector> result; ROOT::Math::PxPyPzMVector lv; for (size_t i = 0; i < in.size(); ++i) { - lv.SetCoordinates(in[i].ps.x, in[i].ps.y, in[i].ps.z, in[i].mass); + lv.SetCoordinates(in[i].momentum.x, in[i].momentum.y, in[i].momentum.z, in[i].mass); result.push_back(lv); } return result; @@ -84,8 +84,8 @@ int rec_multiple_tracks(const char* fname = "topside/rec_multiple_tracks.root") ROOT::EnableImplicitMT(); ROOT::RDataFrame df("events", fname); - auto df0 = df.Define("isThrown", "mcparticles.genStatus == 1") - .Define("thrownParticles", "mcparticles[isThrown]") + auto df0 = df.Define("isThrown", "MCParticles.generatorStatus == 1") + .Define("thrownParticles", "MCParticles[isThrown]") .Define("thrownP", fourvec, {"thrownParticles"}) .Define("p_thrown", momentum, {"thrownP"}) .Define("theta_thrown", theta, {"thrownP"}) diff --git a/benchmarks/tracking/scripts/tracking_performance.py b/benchmarks/tracking/scripts/tracking_performance.py index 813f4d93..d5e29954 100644 --- a/benchmarks/tracking/scripts/tracking_performance.py +++ b/benchmarks/tracking/scripts/tracking_performance.py @@ -47,7 +47,7 @@ def flatten_collection(rdf, collection, cols=None): dfp.loc[:, 'event'] = evns return dfp -def thrown_particles_figure(rdf, save, mcbranch="mcparticles"): +def thrown_particles_figure(rdf, save, mcbranch="MCParticles"): # define truth particle info dft = flatten_collection(rdf, mcbranch, ['genStatus', 'pdgID', 'ps.x', 'ps.y', 'ps.z', 'mass']) dft.rename(columns={c: c.replace(mcbranch + '.', '') for c in dft.columns}, inplace=True) @@ -112,7 +112,7 @@ if __name__ == '__main__': parser.add_argument('-t', '--nametag', type=str, default='tracking', help='Name tag for output files.') parser.add_argument('-m', '--macros', dest='macros', default='rootlogon.C', help='Macro files to be loaded by root, separated by \",\".') - parser.add_argument('--mc-collection', dest='mc', default='mcparticles', + parser.add_argument('--mc-collection', dest='mc', default='MCParticles', help='Collection name of MC particles truth info.') parser.add_argument('--tracking-collection', dest='coll', default='outputTrackParameters', help='Collection name of clusters to plot') -- GitLab