diff --git a/benchmarks/pid/config.yml b/benchmarks/pid/config.yml index 6e6d226d8e75eed31dcfc39625320d861f069a07..e424d369aaa7062d8075cfcfa6b5bce38fa9f981 100644 --- a/benchmarks/pid/config.yml +++ b/benchmarks/pid/config.yml @@ -1,12 +1,29 @@ -#stages: -# #- simulate -# - benchmarks -pid_test_1_dummy_test: +sim:backward: + extends: .det_benchmark + stage: simulate + script: + - npsim --runType batch --numberOfEvents 100 --compactFile ${DETECTOR_PATH}/${JUGGLER_DETECTOR}.xml --enableGun --gun.energy "5*GeV" --gun.particle "${PARTICLE}" --gun.thetaMin 130*deg --gun.thetaMax 177*deg --gun.distribution "cos(theta)" --outputFile sim_output/sim_pid_backward_${PARTICLE}_5GeV.root + - rootls -t sim_output/sim_pid_backward_${PARTICLE}_5GeV.root + parallel: + matrix: + - PARTICLE: ["e-", "pi+", "proton"] + +bench:mrich: + extends: .det_benchmark stage: benchmarks + needs: ["sim:backward"] + script: + - mkdir -p results/pid/backward/mrich/ + - root -t -x -q -b "benchmarks/pid/scripts/mrich_analysis.cxx+(\"sim_output/sim_pid_backward_${PARTICLE}_5GeV.root\", \"${PARTICLE}\")" + parallel: + matrix: + - PARTICLE: ["e-", "pi+", "proton"] + +collect_results:pid: + extends: .det_benchmark + stage: collect + needs: + - ["bench:mrich"] script: - - bash benchmarks/pid/dummy_test.sh - artifacts: - paths: - - results/ - allow_failure: true + - ls -lrht diff --git a/benchmarks/pid/dummy_test.sh b/benchmarks/pid/dummy_test.sh deleted file mode 100755 index 97f97bbc04fdeac184f105dbf33e6564442b5b22..0000000000000000000000000000000000000000 --- a/benchmarks/pid/dummy_test.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -echo "PID Dummy Test..." -echo "passes." - -exit 0 diff --git a/benchmarks/pid/scripts/mrich_analysis.cxx b/benchmarks/pid/scripts/mrich_analysis.cxx new file mode 100644 index 0000000000000000000000000000000000000000..f8ca59f4351c00396734405c79c23fc7b693af84 --- /dev/null +++ b/benchmarks/pid/scripts/mrich_analysis.cxx @@ -0,0 +1,76 @@ +//////////////////////////////////////// +// Read reconstruction ROOT output file +// Plot variables +//////////////////////////////////////// + +#include "ROOT/RDataFrame.hxx" +#include <iostream> +#include <fmt/core.h> + +#include "dd4pod/Geant4ParticleCollection.h" +#include "dd4pod/PhotoMultiplierHitCollection.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 mrich_analysis(const char* input_fname = "sim_output/sim_pid_backward_e-_5GeV.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); + + // Number of hits + auto nhits = [] (const std::vector<dd4pod::PhotoMultiplierHitData>& evt) {return (int) evt.size(); }; + + // Define variables + auto d1 = d0.Define("nhits", nhits, {"MRICHHits"}); + + // 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, -1000.0, +1000.0, 1000, -1000.0, +1000.0}, + "MRICHHits.position.x", "MRICHHits.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/backward/mrich/mrich_{}_hits_xy.png",input_pname).c_str()); + c1->SaveAs(fmt::format("results/pid/backward/mrich/mrich_{}_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/backward/mrich/mrich_{}_nhits.png",input_pname).c_str()); + c2->SaveAs(fmt::format("results/pid/backward/mrich/mrich_{}_nhits.pdf",input_pname).c_str()); + } +}