diff --git a/benchmarks/pid/config.yml b/benchmarks/pid/config.yml index 6d93582e3bd74eb8682b895bc25641fa135959de..bc5d9971f76425f1cce80cdfa8a8dca82b996bcd 100644 --- a/benchmarks/pid/config.yml +++ b/benchmarks/pid/config.yml @@ -8,6 +8,16 @@ sim:backward: matrix: - PARTICLE: ["e-", "pi+", "proton"] +sim:forward: + extends: .det_benchmark + stage: simulate + script: + - ddsim --runType batch --numberOfEvents 100 --filter.tracker edep0 --compactFile ${DETECTOR_PATH}/${JUGGLER_DETECTOR}.xml --enableGun --gun.energy "5*GeV" --gun.particle "${PARTICLE}" --gun.thetaMin 3*deg --gun.thetaMax 50*deg --gun.distribution "cos(theta)" --outputFile sim_output/sim_pid_forward_${PARTICLE}_5GeV.edm4hep.root + - rootls -t sim_output/sim_pid_forward_${PARTICLE}_5GeV.edm4hep.root + parallel: + matrix: + - PARTICLE: ["e-", "pi+", "proton"] + bench:mrich: extends: .det_benchmark stage: benchmarks @@ -25,6 +35,18 @@ bench:mrich: matrix: - PARTICLE: ["e-", "pi+", "proton"] +bench:drich: + extends: .det_benchmark + stage: benchmarks + needs: ["sim:forward"] + script: + - | + mkdir -p results/pid/forward/drich/ + root -t -x -q -b "benchmarks/pid/scripts/drich_analysis.cxx+(\"sim_output/sim_pid_forward_${PARTICLE}_5GeV.edm4hep.root\", \"${PARTICLE}\")" + parallel: + matrix: + - PARTICLE: ["e-", "pi+", "proton"] + bench:erich: extends: .det_benchmark stage: benchmarks diff --git a/benchmarks/pid/scripts/drich_analysis.cxx b/benchmarks/pid/scripts/drich_analysis.cxx new file mode 100644 index 0000000000000000000000000000000000000000..768a1c091a5fd0e64de86c055ac5c8a6cff6bea3 --- /dev/null +++ b/benchmarks/pid/scripts/drich_analysis.cxx @@ -0,0 +1,73 @@ +//////////////////////////////////////// +// Read reconstruction ROOT output file +// Plot variables +//////////////////////////////////////// + +#include "ROOT/RDataFrame.hxx" +#include <iostream> +#include <fmt/core.h> + +#include "edm4hep/MCParticleCollection.h" +#include "edm4hep/SimTrackerHitCollection.h" + +#include "TCanvas.h" +#include "TStyle.h" +#include "TMath.h" +#include "TH1.h" +#include "TF1.h" +#include "TH1D.h" + +using ROOT::RDataFrame; +using namespace ROOT::VecOps; + +void drich_analysis(const char* input_fname = "sim_output/sim_pid_forward_e-_5GeV.edm4hep.root", const char* input_pname = "e-") +{ + // Setting for graphs + gROOT->SetStyle("Plain"); + gStyle->SetOptFit(1); + gStyle->SetLineWidth(2); + gStyle->SetPadTickX(1); + gStyle->SetPadTickY(1); + gStyle->SetPadGridX(1); + gStyle->SetPadGridY(1); + gStyle->SetPadLeftMargin(0.14); + gStyle->SetPadRightMargin(0.14); + + ROOT::EnableImplicitMT(); + ROOT::RDataFrame d0("events", input_fname); + + // Define variables + auto d1 = d0.Define("nhits", {"DRICHHits.size()"}); + + // Define Histograms + auto hNhits = + d1.Histo1D({"hNhits", "Number of hits per events; Number of hits; Events", + 100, 0.0, 2000.0}, + "nhits"); + auto hXYhits = + d1.Histo2D({"hXYhits", "Hit positions for events; Horizontal position [mm]; Vertical position [mm]", + 1000, -2500.0, +2500.0, 1000, -2500.0, +2500.0}, + "DRICHHits.position.x", "DRICHHits.position.y"); + + // Event Counts + auto nevents_thrown = d1.Count(); + std::cout << "Number of Thrown Events: " << (*nevents_thrown) << "\n"; + + // Draw Histograms + { + TCanvas* c1 = new TCanvas("c1", "c1", 700, 500); + auto h = hXYhits->DrawCopy(); + c1->SaveAs(fmt::format("results/pid/forward/drich/drich_{}_hits_xy.png",input_pname).c_str()); + c1->SaveAs(fmt::format("results/pid/forward/drich/drich_{}_hits_xy.pdf",input_pname).c_str()); + } + { + TCanvas* c2 = new TCanvas("c2", "c2", 700, 500); + c2->SetLogy(1); + auto h = hNhits->DrawCopy(); + //h->GetYaxis()->SetTitleOffset(1.4); + h->SetLineWidth(2); + h->SetLineColor(kBlue); + c2->SaveAs(fmt::format("results/pid/forward/drich/drich_{}_nhits.png",input_pname).c_str()); + c2->SaveAs(fmt::format("results/pid/forward/drich/drich_{}_nhits.pdf",input_pname).c_str()); + } +}