Skip to content
Snippets Groups Projects
Commit 87c352f1 authored by Sylvester Joosten's avatar Sylvester Joosten
Browse files

Prepare canyonlands

parent 4573b716
No related branches found
No related tags found
1 merge request!96Prepare canyonlands
...@@ -7,4 +7,9 @@ Standard: Cpp11 ...@@ -7,4 +7,9 @@ Standard: Cpp11
#SpaceBeforeParens: ControlStatements #SpaceBeforeParens: ControlStatements
SpaceAfterControlStatementKeyword: true SpaceAfterControlStatementKeyword: true
PointerBindsToType: true PointerBindsToType: true
IncludeBlocks: Preserve
UseTab: Never
ColumnLimit: 120
NamespaceIndentation: Inner
AlignConsecutiveAssignments: true
... ...
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// top-level include-dir // top-level include-dir
gROOT->ProcessLine(".include include"); gROOT->ProcessLine(".include include");
R__LOAD_LIBRARY(fmt)
// Setting for Graphs // Setting for Graphs
gROOT->SetStyle("Plain"); gROOT->SetStyle("Plain");
gStyle->SetOptFit(1); gStyle->SetOptFit(1);
......
...@@ -35,7 +35,7 @@ export BEAMLINE_CONFIG=ip6 # ip6 is the default ...@@ -35,7 +35,7 @@ export BEAMLINE_CONFIG=ip6 # ip6 is the default
``` ```
git@eicweb.phy.anl.gov:EIC/benchmarks/detector_benchmarks.git && cd detector_benchmarks git clone https://eicweb.phy.anl.gov/EIC/benchmarks/detector_benchmarks.git && cd detector_benchmarks
git clone https://eicweb.phy.anl.gov/EIC/benchmarks/common_bench.git setup git clone https://eicweb.phy.anl.gov/EIC/benchmarks/common_bench.git setup
source setup/bin/env.sh && ./setup/bin/install_common.sh source setup/bin/env.sh && ./setup/bin/install_common.sh
source .local/bin/env.sh && build_detector.sh source .local/bin/env.sh && build_detector.sh
......
...@@ -13,8 +13,30 @@ bench:mrich: ...@@ -13,8 +13,30 @@ bench:mrich:
stage: benchmarks stage: benchmarks
needs: ["sim:backward"] needs: ["sim:backward"]
script: 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}\")" if [[ ${JUGGLER_DETECTOR_VERSION} =~ acadia ]]; then
echo "Performing MRICH benchmarks for acadia"
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}\")"
else
echo "Skipping MRICH Benchmarks for non-acadia detector version ${JUGGLER_DETECTOR_VERSION}"
fi
parallel:
matrix:
- PARTICLE: ["e-", "pi+", "proton"]
bench:erich:
extends: .det_benchmark
stage: benchmarks
needs: ["sim:backward"]
script:
- |
if [[ ${JUGGLER_DETECTOR_VERSION} =~ acadia ]]; then
echo "Skipping ERICH benchmarks for acadia"
else
echo "Doing MRICH Benchmarks for ${JUGGLER_DETECTOR_VERSION}"
echo "FIXME: needs implementing"
fi
parallel: parallel:
matrix: matrix:
- PARTICLE: ["e-", "pi+", "proton"] - PARTICLE: ["e-", "pi+", "proton"]
...@@ -22,8 +44,7 @@ bench:mrich: ...@@ -22,8 +44,7 @@ bench:mrich:
collect_results:pid: collect_results:pid:
extends: .det_benchmark extends: .det_benchmark
stage: collect stage: collect
needs: #needs:
- ["bench:mrich"]
script: script:
- ls -lrht - ls -lrht
#include "ROOT/RDataFrame.hxx" #include "ROOT/RDataFrame.hxx"
#include "TCanvas.h" #include "TCanvas.h"
#include "TLegend.h"
#include "TH1D.h" #include "TH1D.h"
#include "TLegend.h"
#include "TProfile.h" #include "TProfile.h"
#include <cstdlib>
#include <iostream> #include <iostream>
R__LOAD_LIBRARY(libeicd.so) R__LOAD_LIBRARY(libeicd.so)
R__LOAD_LIBRARY(libDD4pod.so) R__LOAD_LIBRARY(libDD4pod.so)
#include <fmt/format.h>
#include "dd4pod/Geant4ParticleCollection.h"
#include "dd4pod/TrackerHitCollection.h" #include "dd4pod/TrackerHitCollection.h"
#include "dd4pod/TrackerHitData.h" #include "dd4pod/TrackerHitData.h"
#include "dd4pod/Geant4ParticleCollection.h"
#include "eicd/TrackParametersCollection.h"
#include "eicd/ClusterCollection.h" #include "eicd/ClusterCollection.h"
#include "eicd/ClusterData.h" #include "eicd/ClusterData.h"
#include "eicd/TrackParametersCollection.h"
#include "eicd/TrackerHitCollection.h" #include "eicd/TrackerHitCollection.h"
using ROOT::RDataFrame; using ROOT::RDataFrame;
...@@ -23,13 +26,12 @@ using namespace ROOT::VecOps; ...@@ -23,13 +26,12 @@ using namespace ROOT::VecOps;
auto p_track = [](std::vector<eic::TrackParametersData> const& in) { auto p_track = [](std::vector<eic::TrackParametersData> const& in) {
std::vector<double> result; std::vector<double> result;
for (size_t i = 0; i < in.size(); ++i) { for (size_t i = 0; i < in.size(); ++i) {
result.push_back(std::abs(1.0/(in[i].qOverP))); result.push_back(std::abs(1.0 / (in[i].qOverP)));
} }
return result; return result;
}; };
std::vector<float> pt(std::vector<dd4pod::Geant4ParticleData> const& in) {
std::vector<float> pt (std::vector<dd4pod::Geant4ParticleData> const& in){
std::vector<float> result; std::vector<float> result;
for (size_t i = 0; i < in.size(); ++i) { 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].ps.x * in[i].ps.x + in[i].ps.y * in[i].ps.y));
...@@ -40,14 +42,14 @@ std::vector<float> pt (std::vector<dd4pod::Geant4ParticleData> const& in){ ...@@ -40,14 +42,14 @@ std::vector<float> pt (std::vector<dd4pod::Geant4ParticleData> const& in){
auto momentum = [](std::vector<ROOT::Math::PxPyPzMVector> const& in) { auto momentum = [](std::vector<ROOT::Math::PxPyPzMVector> const& in) {
std::vector<double> result; std::vector<double> result;
for (size_t i = 0; i < in.size(); ++i) { for (size_t i = 0; i < in.size(); ++i) {
result.push_back(in[i].E()); result.push_back(in[i].E());
} }
return result; return result;
}; };
auto theta = [](std::vector<ROOT::Math::PxPyPzMVector> const& in) { auto theta = [](std::vector<ROOT::Math::PxPyPzMVector> const& in) {
std::vector<double> result; std::vector<double> result;
for (size_t i = 0; i < in.size(); ++i) { for (size_t i = 0; i < in.size(); ++i) {
result.push_back(in[i].Theta()*180/M_PI); result.push_back(in[i].Theta() * 180 / M_PI);
} }
return result; return result;
}; };
...@@ -75,173 +77,122 @@ auto delta_p_over_p = [](const std::vector<double>& tracks, const std::vector<do ...@@ -75,173 +77,122 @@ auto delta_p_over_p = [](const std::vector<double>& tracks, const std::vector<do
std::vector<double> res; std::vector<double> res;
for (const auto& p1 : thrown) { for (const auto& p1 : thrown) {
for (const auto& p2 : tracks) { for (const auto& p2 : tracks) {
res.push_back((p1 - p2)/p1); res.push_back((p1 - p2) / p1);
} }
} }
return res; return res;
}; };
int sim_track_hits(const char* fname = "sim_track_hits.root") // Create dataframe with extra definitions for hit multiplicities
{ ROOT::RDF::RNode add_subsystems(ROOT::RDF::RNode df, std::vector<std::pair<std::string, std::string>> hitcols) {
if (hitcols.empty()) {
return df;
}
const auto [name, collection] = hitcols.back();
std::cout << " --> registering subsystem " << collection << "\n";
auto df2 = df.Define("N_" + name, [](std::vector<dd4pod::TrackerHitData> hits) { return hits.size(); }, {collection});
hitcols.pop_back();
return add_subsystems(df2, hitcols);
};
int sim_track_hits(const char* fname = "sim_track_hits.root") {
ROOT::EnableImplicitMT(); ROOT::EnableImplicitMT();
ROOT::RDataFrame df("events", fname); ROOT::RDataFrame df("events", fname);
// detect detector setup
std::string detector = "default";
if (const char* env_detector = std::getenv("JUGGLER_DETECTOR_VERSION")) {
if (detector.find("acadia") != std::string::npos) {
detector = "acadia";
} else if (detector.find("canyonlands") != std::string::npos) {
detector = "canyonlands";
}
}
std::cout << "sim_track_hits: detector set to " << detector << std::endl;
// minimal hit collection setup
std::vector<std::pair<std::string, std::string>> hitCollections{{"vtx_barrel", "VertexBarrelHits"},
{"trk_barrel", "TrackerBarrelHits"},
{"trk_endcap", "TrackerEndcapHits"},
{"gem_endcap", "GEMTrackerEndcapHits"}};
// append extra hit collections based on detector setup
if (detector == "acadia") {
hitCollections.push_back({"vtx_endcap", "VertexEndcapHits"});
} else if (detector == "canyonlands" || detector == "default") {
hitCollections.push_back({"mm_barrel", "MPGDTrackerBarrelHits"});
}
auto df0 = df.Define("isThrown", "mcparticles.genStatus == 1") auto df0 = df.Define("isThrown", "mcparticles.genStatus == 1")
.Define("thrownParticles", "mcparticles[isThrown]") .Define("thrownParticles", "mcparticles[isThrown]")
.Define("thrownP", fourvec, {"thrownParticles"}) .Define("thrownP", fourvec, {"thrownParticles"})
.Define("p_thrown", momentum, {"thrownP"}) .Define("p_thrown", momentum, {"thrownP"})
.Define("theta_thrown", theta, {"thrownP"}) .Define("theta_thrown", theta, {"thrownP"})
.Define("theta0", "theta_thrown[0]") .Define("theta0", "theta_thrown[0]");
.Define("N_VertexBarrelHits", [](std::vector<dd4pod::TrackerHitData> hits) { return hits.size();}, {"VertexBarrelHits"}) auto df1 = add_subsystems(df0, hitCollections);
.Define("N_VertexEndcapHits", [](std::vector<dd4pod::TrackerHitData> hits) { return hits.size();}, {"VertexEndcapHits"})
.Define("N_BarrelHits", [](std::vector<dd4pod::TrackerHitData> hits) { return hits.size();}, {"TrackerBarrelHits"}) // get 1D and 2D histogram definitions
.Define("N_EndcapHits", [](std::vector<dd4pod::TrackerHitData> hits) { return hits.size();}, {"TrackerEndcapHits"}) std::vector<decltype(df1.Histo2D({}, "", ""))> h2D;
; std::vector<decltype(df1.Histo1D(""))> hnth;
std::vector<decltype(df1.Histo1D(""))> hn;
auto hBarrel_x_vs_y = df0.Histo2D(
{"hBarrel_x_vs_y", "; x ; y ", 100, -600, 600, 100, -600, 600}, for (const auto& [name, col] : hitCollections) {
"TrackerBarrelHits.position.x", "TrackerBarrelHits.position.y"); hnth.push_back(
auto hEndcap_x_vs_y = df0.Histo2D( df1.Histo1D({(name + "_nhits_vs_theta").c_str(), "; #theta [deg.]; ", 20, 0, 180}, "theta0", "N_" + name));
{"hEndcap_x_vs_y", "; x ; y ", 100, -600, 600, 100, -600, 600}, hn.push_back(df1.Histo1D({(name + "_nhits").c_str(), "; Nhits; #", 20, 0, 20}, "N_" + name));
"TrackerEndcapHits.position.x", "TrackerEndcapHits.position.y"); h2D.push_back(df1.Histo2D({(name + "_x_vs_y").c_str(), "; x ; y ", 100, -600, 600, 100, -600, 600},
auto hVertexBarrel_x_vs_y = df0.Histo2D( col + ".position.x", col + ".position.y"));
{"hVertexBarrel_x_vs_y", "; x ; y ", 100, -600, 600, 100, -600, 600}, h2D.push_back(df1.Histo2D({(name + "_x_vs_z").c_str(), "; z ; x ", 100, -1200, 1200, 100, -900, 900},
"VertexBarrelHits.position.x", "VertexBarrelHits.position.y"); col + ".position.z", col + ".position.x"));
auto hVertexEndcap_x_vs_y = df0.Histo2D( }
{"hVertexEndcap_x_vs_y", "; x ; y ", 100, -600, 600, 100, -600, 600}, auto hth = df1.Histo1D({"theta0", "; #theta [deg.]", 20, 0, 180}, "theta0");
"VertexEndcapHits.position.x", "VertexEndcapHits.position.y");
// Draw multiplicity versus theta
auto hBarrel_x_vs_z = df0.Histo2D( {
{"hBarrel_x_vs_z", "; z ; x ", 200, -1200, 1200, 100, -900, 900}, TCanvas c;
"TrackerBarrelHits.position.z", "TrackerBarrelHits.position.x"); THStack hs{"n_hits", "; #theta [deg.] "};
auto hEndcap_x_vs_z = df0.Histo2D( int idx = 1;
{"hEndcap_x_vs_z", "; z ; x ", 200, -1200, 1200, 100, -900, 900}, for (auto& h : hnth) {
"TrackerEndcapHits.position.z", "TrackerEndcapHits.position.x"); h->Divide(&*hth);
auto hVertexBarrel_x_vs_z = df0.Histo2D( h->SetLineColor(idx++);
{"hVertexBarrel_x_vs_z", "; z ; x ", 200, -1200, 1200, 100, -900, 900}, hs.Add((TH1D*)h->Clone());
"VertexBarrelHits.position.z", "VertexBarrelHits.position.x"); }
auto hVertexEndcap_x_vs_z = df0.Histo2D( hs.Draw("nostack, hist");
{"hVertexEndcap_x_vs_z", "; z ; x ", 200, -1200, 1200, 100, -900, 900}, c.BuildLegend();
"VertexEndcapHits.position.z", "VertexEndcapHits.position.x"); c.SaveAs("results/tracking_detectors/sim_track_hits_n_hits_vs_theta.png");
c.SaveAs("results/tracking_detectors/sim_track_hits_n_hits_vs_theta.pdf");
auto hBarrel_y_vs_z = df0.Histo2D( }
{"hBarrel_y_vs_z", "; z ; x ", 200, -1200, 1200, 100, -900, 900}, // Draw nhits
"TrackerBarrelHits.position.z", "TrackerBarrelHits.position.y"); {
auto hEndcap_y_vs_z = df0.Histo2D( TCanvas c;
{"hEndcap_y_vs_z", "; z ; x ", 200, -1200, 1200, 100, -900, 900}, THStack hs{"n_hits", "; NHits "};
"TrackerEndcapHits.position.z", "TrackerEndcapHits.position.y"); int idx = 1;
auto hVertexBarrel_y_vs_z = df0.Histo2D( for (auto& h : hn) {
{"hVertexBarrel_y_vs_z", "; z ; x ", 200, -1200, 1200, 100, -900, 900}, h->SetLineColor(idx++);
"VertexBarrelHits.position.z", "VertexBarrelHits.position.y"); hs.Add((TH1D*)h->Clone());
auto hVertexEndcap_y_vs_z = df0.Histo2D( }
{"hVertexEndcap_y_vs_z", "; z ; x ", 200, -1200, 1200, 100, -900, 900}, hs.Draw("nostack, hist");
"VertexEndcapHits.position.z", "VertexEndcapHits.position.y"); c.BuildLegend();
c.SaveAs("results/tracking_detectors/sim_track_hits_n_hits.png");
auto hBarrel_N_vs_theta = df0.Histo1D({"hBarrel_N_vs_theta", "; #theta [deg.]", 20, 0, 180 }, "theta0", "N_BarrelHits"); c.SaveAs("results/tracking_detectors/sim_track_hits_n_hits.pdf");
auto hEndcap_N_vs_theta = df0.Histo1D({"hEndcap_N_vs_theta", "; #theta [deg.]", 20, 0, 180 }, "theta0", "N_EndcapHits"); }
auto hVertexBarrel_N_vs_theta = df0.Histo1D({"hVertexBarrel_N_vs_theta", "; #theta [deg.]", 20, 0, 180 }, "theta0", "N_VertexBarrelHits");
auto hVertexEndcap_N_vs_theta = df0.Histo1D({"hVertexEndcap_N_vs_theta", "; #theta [deg.]", 20, 0, 180 }, "theta0", "N_VertexEndcapHits"); // Draw total multiplicity versus theta
{
auto hBarrel_Nhits = df0.Histo1D({"hBarrel_Nhits", "; #theta [deg.]", 20, 0, 20 }, "N_BarrelHits"); TCanvas c;
auto hEndcap_Nhits = df0.Histo1D({"hEndcap_Nhits", "; #theta [deg.]", 20, 0, 20 }, "N_EndcapHits"); hth->DrawClone();
auto hVertexBarrel_Nhits = df0.Histo1D({"hVertexBarrel_Nhits", "; #theta [deg.]", 20, 0, 20 }, "N_VertexBarrelHits"); c.BuildLegend();
auto hVertexEndcap_Nhits = df0.Histo1D({"hVertexEndcap_Nhits", "; #theta [deg.]", 20, 0, 20 }, "N_VertexEndcapHits"); c.SaveAs("results/tracking_detectors/sim_track_hits_theta.png");
c.SaveAs("results/tracking_detectors/sim_track_hits_theta.pdf");
auto hBarrel_Ntheta = df0.Histo1D({"hBarrel_Ntheta", "; #theta [deg.]", 20, 0, 180 }, "theta0"); }
auto hEndcap_Ntheta = df0.Histo1D({"hEndcap_Ntheta", "; #theta [deg.]", 20, 0, 180 }, "theta0");
auto hVertexBarrel_Ntheta = df0.Histo1D({"hVertexBarrel_Ntheta", "; #theta [deg.]", 20, 0, 180 }, "theta0"); for (auto& h : h2D) {
auto hVertexEndcap_Ntheta = df0.Histo1D({"hVertexEndcap_Ntheta", "; #theta [deg.]", 20, 0, 180 }, "theta0"); TCanvas c;
h->DrawClone("colz");
auto c = new TCanvas(); c.SaveAs(fmt::format("results/tracking_detectors/sim_track_hits_{}.png", h->GetName()).c_str());
auto hs = new THStack("n_hits","; #theta "); c.SaveAs(fmt::format("results/tracking_detectors/sim_track_hits_{}.pdf", h->GetName()).c_str());
auto h1 = (TH1D*) hBarrel_N_vs_theta->Clone(); }
auto h2 = (TH1D*) hBarrel_Ntheta->Clone();
h1->Divide(h2);
hs->Add(h1);
h1 = (TH1D*) hEndcap_N_vs_theta->Clone();
h2 = (TH1D*) hEndcap_Ntheta->Clone();
h1->Divide(h2);
h1->SetLineColor(2);
hs->Add(h1);
h1 = (TH1D*) hVertexEndcap_N_vs_theta->Clone();
h2 = (TH1D*) hVertexEndcap_Ntheta->Clone();
h1->Divide(h2);
h1->SetLineColor(4);
hs->Add(h1);
h1 = (TH1D*) hVertexBarrel_N_vs_theta->Clone();
h2 = (TH1D*) hVertexBarrel_Ntheta->Clone();
h1->Divide(h2);
h1->SetLineColor(8);
hs->Add(h1);
hs->Draw("nostack, hist");
c->BuildLegend();
c->SaveAs("results/tracking_detectors/sim_track_hits_n_hits_vs_theta.png");
c->SaveAs("results/tracking_detectors/sim_track_hits_n_hits_vs_theta.pdf");
c = new TCanvas();
hs = new THStack("theta","; #theta ");
h1 = (TH1D*) hBarrel_N_vs_theta->Clone();
h2 = (TH1D*) hBarrel_Ntheta->Clone();
//h1->Divide(h2);
hs->Add(h2);
h1 = (TH1D*) hEndcap_N_vs_theta->Clone();
h2 = (TH1D*) hEndcap_Ntheta->Clone();
//h1->Divide(h2);
h1->SetLineColor(2);
h2->SetLineColor(2);
hs->Add(h2);
//h1 = (TH1D*) hVtxBarrel_vs_theta->Clone();
//h1->SetLineColor(4);
//h1->SetFillStyle(3001);
//h1->SetFillColor(4);
//hs->Add(h1);
hs->Draw("nostack hist");
c->BuildLegend();
c->SaveAs("results/tracking_detectors/sim_track_hits_theta.png");
c->SaveAs("results/tracking_detectors/sim_track_hits_theta.pdf");
c = new TCanvas();
hs = new THStack("hits","; hits ");
h1 = (TH1D*) hBarrel_Nhits->Clone();
hs->Add(h1);
h1 = (TH1D*) hEndcap_Nhits->Clone();
h1->SetLineColor(2);
h2->SetLineColor(2);
hs->Add(h2);
//h1 = (TH1D*) hVtxBarrel_Nhits->Clone();
//h1->SetLineColor(4);
//h1->SetFillStyle(3001);
//h1->SetFillColor(4);
//hs->Add(h1);
//hs->Draw("nostack hist");
c->BuildLegend();
c->SaveAs("results/tracking_detectors/sim_track_hits_nhits.png");
c->SaveAs("results/tracking_detectors/sim_track_hits_nhits.pdf");
c = new TCanvas();
hBarrel_x_vs_y->DrawCopy("colz");
c->SaveAs("results/tracking_detectors/sim_track_hits_trkBarrel_xy.png");
c->SaveAs("results/tracking_detectors/sim_track_hits_trkBarrel_xy.pdf");
c = new TCanvas();
hEndcap_x_vs_y->DrawCopy("colz");
hVertexEndcap_x_vs_y->DrawCopy("colz same");
//hBarrel_x_vs_y->DrawCopy("colz same");
//hvtxEndcap_x_vs_y->DrawCopy("colz same");
c->SaveAs("results/tracking_detectors/sim_track_hits_Hits_xy.png");
c->SaveAs("results/tracking_detectors/sim_track_hits_Hits_xy.pdf");
//hAllHits_x_vs_z->DrawCopy("colz");
hBarrel_x_vs_z->DrawCopy("colz");
hEndcap_x_vs_z->DrawCopy("colz same");
c->SaveAs("results/tracking_detectors/sim_track_hits_Hits_xz.png");
c->SaveAs("results/tracking_detectors/sim_track_hits_Hits_xz.pdf");
hBarrel_y_vs_z->DrawCopy("colz");
hEndcap_y_vs_z->DrawCopy("colz same");
c->SaveAs("results/tracking_detectors/sim_track_hits_Hits_yz.png");
c->SaveAs("results/tracking_detectors/sim_track_hits_Hits_yz.pdf");
return 0; return 0;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment