diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f68226e47101879610edfb511f8fb049030297be..af39d9347d77c759a43806401c9a838c4be1eb23 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -51,6 +51,18 @@ common:setup: echo "JUGGLER_DETECTOR=$JUGGLER_DETECTOR" >> juggler.env echo "JUGGLER_DETECTOR_VERSION=$JUGGLER_DETECTOR_VERSION" >> juggler.env echo "COMMON_BENCH_VERSION=$COMMON_BENCH_VERSION" >> juggler.env + else + if [[ "${JUGGLER_DETECTOR}" == "" ]] ; then + export JUGGLER_DETECTOR="athena" + fi + if [[ "${JUGGLER_DETECTOR_VERSION}" == "" ]] ; then + export JUGGLER_DETECTOR_VERSION="master" + fi + echo "JUGGLER_DETECTOR = ${JUGGLER_DETECTOR}" + echo "JUGGLER_DETECTOR_VERSION = ${JUGGLER_DETECTOR_VERSION}" + echo "JUGGLER_DETECTOR=$JUGGLER_DETECTOR" >> juggler.env + echo "JUGGLER_DETECTOR_VERSION=$JUGGLER_DETECTOR_VERSION" >> juggler.env + echo "COMMON_BENCH_VERSION=$COMMON_BENCH_VERSION" >> juggler.env fi - source setup/bin/env.sh && ./setup/bin/install_common.sh diff --git a/benchmarks/b0_tracker/scripts/b0_tracker_hits.cxx b/benchmarks/b0_tracker/scripts/b0_tracker_hits.cxx index 35217959eec519866002fe04dcf3ee5ac35b88cd..31266703852d3d5667ef2a2d3d6671777f4131b3 100644 --- a/benchmarks/b0_tracker/scripts/b0_tracker_hits.cxx +++ b/benchmarks/b0_tracker/scripts/b0_tracker_hits.cxx @@ -36,7 +36,6 @@ void b0_tracker_hits(const char* fname = "./sim_output/sim_forward_protons.root" ROOT::RDataFrame d0(*t); - dd4pod::MonteCarloContrib auto MC_hits_theta = [&](const std:vector<dd4pod::MonteCarloContrib>& mchits){ std::vector<double> result; @@ -101,15 +100,59 @@ void b0_tracker_hits(const char* fname = "./sim_output/sim_forward_protons.root" auto h1 = d2.Histo1D({"h1", "hits_theta", 100, 0,20}, "hits_theta"); auto hMCTheta = d3.Histo1D({"mchitstheta", "MC_hits_theta", 100, 0, 20}); + auto local_position = [&](const std::vector<dd4pod::TrackerHitData>& hits) { + std::vector<std::array<double, 2>> result; + for (const auto& h : hits) { + + auto pos0 = (h.position); + result.push_back({pos0.x , pos0.y}); + } + return result; + }; + + + auto x_pos = [&](const std::vector<std::array<double, 2>>& xypos) { + std::vector<double> result; + for (const auto& h : xypos) { + + result.push_back(h.at(0)); + } + return result; + }; + + auto y_pos = [&](const std::vector<std::array<double, 2>>& xypos) { + std::vector<double> result; + for (const auto& h : xypos) { + + result.push_back(h.at(1)); + } + return result; + }; + + auto d1 = d0.Define("nhits", hits_theta, {"B0TrackerHits"}) + .Define("xy_hit_pos", local_position, {"B0TrackerHits"}) + .Define("x_pos", x_pos, {"xy_hit_pos"}) + .Define("y_pos", y_pos, {"xy_hit_pos"}); + + auto h_local_pos = d1.Histo2D({"h_local_pos", ";x [mm]; y [mm] ", 100, -100.0, -200.0, 100, -100.0, 100.0}, "x_pos", "y_pos"); + + + auto d2 = d0.Define("hits_theta", hits_theta, {"B0TrackerHits"}); + + auto h1 = d2.Histo1D({"h1", "hits_theta", 100, 0,20}, "hits_theta"); +>>>>>>> 548e97b5b5705204a320a076b0c6b7b125aa0cef TCanvas* c = new TCanvas(); h1->DrawCopy(); c->SaveAs("results/b0_tracker_hits_theta.png"); c->SaveAs("results/b0_tracker_hits_theta.pdf"); +<<<<<<< HEAD hMCTheta->DrawCopy(); c->SaveAs("results/MC_hits_theta.png"); c->SaveAs("results/MC_hits_theta.pdf"); +======= +>>>>>>> 548e97b5b5705204a320a076b0c6b7b125aa0cef h_local_pos->DrawCopy("colz"); c->SaveAs("results/b0_tracker_hits_occupancy_disk_1.png"); c->SaveAs("results/b0_tracker_hits_occupancy_disk_1.pdf"); 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()); + } +}