Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Oct 14, 2024
1 parent f4fe2e2 commit bead800
Show file tree
Hide file tree
Showing 78 changed files with 564 additions and 611 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Makefile
cmake_install.cmake
install_manifest.txt

# vim
# vim
~*
*.swp
*.swo
Expand Down
12 changes: 6 additions & 6 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ default:
tags:
- phy-scratch
artifacts:
expire_in: 72 hours
expire_in: 72 hours
paths:
- .local/detector
- .local/lib
Expand Down Expand Up @@ -79,11 +79,11 @@ common:setup:
script:
- |
if [[ "${COMMON_BENCH_VERSION}" == "" ]] ; then
export COMMON_BENCH_VERSION="master"
export COMMON_BENCH_VERSION="master"
fi
echo "COMMON_BENCH_VERSION = ${COMMON_BENCH_VERSION}"
echo "COMMON_BENCH_VERSION = ${COMMON_BENCH_VERSION}"
echo "COMMON_BENCH_VERSION=${COMMON_BENCH_VERSION}" >> .env
git clone -b "${COMMON_BENCH_VERSION}" https://eicweb.phy.anl.gov/EIC/benchmarks/common_bench.git setup
git clone -b "${COMMON_BENCH_VERSION}" https://eicweb.phy.anl.gov/EIC/benchmarks/common_bench.git setup
echo "BENCHMARKS_TAG: ${BENCHMARKS_TAG}"
echo "BENCHMARKS_CONTAINER: ${BENCHMARKS_CONTAINER}"
echo "BENCHMARKS_REGISTRY: ${BENCHMARKS_REGISTRY}"
Expand All @@ -109,7 +109,7 @@ get_data:
- mc config host add S3 https://eics3.sdcc.bnl.gov:9000 ${S3_ACCESS_KEY} ${S3_SECRET_KEY}
- source .local/bin/env.sh
- source /opt/detector/epic-main/setup.sh
- ls -lrtha
- ls -lrtha
- ln -s "${LOCAL_DATA_PATH}/sim_output" sim_output
- ln -s "${LOCAL_DATA_PATH}/datasets/data" data
# snakemake support
Expand All @@ -123,7 +123,7 @@ get_data:
when:
- runner_system_failure

include:
include:
- local: 'benchmarks/backgrounds/config.yml'
- local: 'benchmarks/backwards_ecal/config.yml'
- local: 'benchmarks/ecal_gaps/config.yml'
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Detector benchmarks are meant to provide a maintained set of performance plots f

## Adding new benchmarks

To get an idea of what to do look at an existing benchmark in the
To get an idea of what to do look at an existing benchmark in the
[`benchmarks` directory](https://github.com/eic/detector_benchmarks/tree/master/benchmarks).
Currently a good reference for Snakemake instrumentation is available in the `tracking\_performances` benchmark.
It relies on single particle simulations that can be either produced on eicweb or downloaded from official campagins.
Expand Down
1 change: 0 additions & 1 deletion benchmarks/b0_tracker/analysis/b0_tracker_hits.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,3 @@ void b0_tracker_hits(const char* fname = "./sim_output/sim_forward_protons.edm4h
//}

}

5 changes: 1 addition & 4 deletions benchmarks/b0_tracker/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ bench:b0_tracker:
results:b0_tracker:
extends: .det_benchmark
stage: collect
needs:
needs:
- ["bench:b0_tracker"]
script:
- echo "Collecting results for B0 Tracker"



5 changes: 2 additions & 3 deletions benchmarks/b0_tracker/forward_protons.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash

if [[ ! -n "${DETECTOR}" ]] ; then
if [[ ! -n "${DETECTOR}" ]] ; then
export DETECTOR="topside"
fi

if [[ ! -n "${JUGGLER_N_EVENTS}" ]] ; then
if [[ ! -n "${JUGGLER_N_EVENTS}" ]] ; then
export JUGGLER_N_EVENTS=100
fi

Expand Down Expand Up @@ -47,4 +47,3 @@ if [[ "$?" -ne "0" ]] ; then
echo "ERROR running script: events"
exit 1
fi

2 changes: 1 addition & 1 deletion benchmarks/b0_tracker/scripts/gen_forward_protons.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ using namespace HepMC3;
/** Generate electrons in the central region.
* This is for testing detectors in the "barrel" region.
*/
void gen_forward_protons(int n_events = 100,
void gen_forward_protons(int n_events = 100,
const char* out_fname = "forward_protons.hepmc")
{
double cos_theta_min = std::cos(0.5*(M_PI/180.0));
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/backwards_ecal/backwards_ecal.org
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ vector.register_awkward()
#+end_src

* Plotting setup

#+begin_src jupyter-python :results silent
import matplotlib as mpl
import matplotlib.pyplot as plt

def setup_presentation_style():
mpl.rcParams.update(mpl.rcParamsDefault)
plt.style.use('ggplot')
Expand All @@ -49,7 +49,7 @@ def setup_presentation_style():
})

setup_presentation_style()
#+end_src
#+end_src

* Parameters

Expand Down
5 changes: 2 additions & 3 deletions benchmarks/barrel_ecal/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ bench:emcal_barrel_pion_rejection:
collect_results:barrel_ecal:
extends: .det_benchmark
stage: collect
needs:
needs:
- "calib:emcal_barrel_electrons"
- "bench:emcal_barrel_electrons_scan"
- "bench:emcal_barrel_photons"
Expand All @@ -103,5 +103,4 @@ collect_results:barrel_ecal:
- "bench:emcal_barrel_pion_rejection"
script:
- ls -lrht
- echo " FIX ME"

- echo " FIX ME"
4 changes: 2 additions & 2 deletions benchmarks/barrel_ecal/run_emcal_barrel_energy_scan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ E_file="sim_output/emcal_barrel_energy_scan_points_${PARTICLE}.txt"

MIN_N_EVENTS=750
if (( $JUGGLER_N_EVENTS < $MIN_N_EVENTS )); then
ORIGINAL_JUGGLER_N_EVENTS=$JUGGLER_N_EVENTS
ORIGINAL_JUGGLER_N_EVENTS=$JUGGLER_N_EVENTS
export JUGGLER_N_EVENTS=$MIN_N_EVENTS
echo "Setting JUGGLER_N_EVENTS to ${MIN_N_EVENTS}"
fi
#0.5 1 2 3 4 7 15 20
for E in 0.5 1 2 5 10
do
export E_START="$E"
export E_END="$E"
export E_END="$E"
bash benchmarks/barrel_ecal/run_emcal_barrel_particles.sh "${PARTICLE}" && echo "$E" >> "$E_file" || exit 1
path_rootfiles="sim_output/energy_scan/${E}/"
path_plots="results/energy_scan/${E}/"
Expand Down
5 changes: 2 additions & 3 deletions benchmarks/barrel_ecal/run_emcal_barrel_particles.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash

if [[ ! -n "${DETECTOR}" ]] ; then
if [[ ! -n "${DETECTOR}" ]] ; then
export DETECTOR="athena"
fi

if [[ ! -n "${JUGGLER_N_EVENTS}" ]] ; then
if [[ ! -n "${JUGGLER_N_EVENTS}" ]] ; then
export JUGGLER_N_EVENTS=100
fi

Expand Down Expand Up @@ -64,4 +64,3 @@ mkdir -p results

# Move ROOT output file
#mv ${JUGGLER_REC_FILE} sim_output/

5 changes: 2 additions & 3 deletions benchmarks/barrel_ecal/run_emcal_barrel_pi0.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash

if [[ ! -n "${DETECTOR}" ]] ; then
if [[ ! -n "${DETECTOR}" ]] ; then
export DETECTOR="topside"
fi

if [[ ! -n "${JUGGLER_N_EVENTS}" ]] ; then
if [[ ! -n "${JUGGLER_N_EVENTS}" ]] ; then
export JUGGLER_N_EVENTS=1000
fi

Expand Down Expand Up @@ -58,4 +58,3 @@ mkdir -p results

# Move ROOT output file
#mv ${JUGGLER_REC_FILE} sim_output/

5 changes: 2 additions & 3 deletions benchmarks/barrel_ecal/run_emcal_barrel_pion_rejection.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash

if [[ ! -n "${DETECTOR}" ]] ; then
if [[ ! -n "${DETECTOR}" ]] ; then
export DETECTOR="athena"
fi

if [[ ! -n "${JUGGLER_N_EVENTS}" ]] ; then
if [[ ! -n "${JUGGLER_N_EVENTS}" ]] ; then
export JUGGLER_N_EVENTS=100
fi

Expand Down Expand Up @@ -64,4 +64,3 @@ mkdir -p results

# Move ROOT output file
#mv ${JUGGLER_REC_FILE} sim_output/

5 changes: 2 additions & 3 deletions benchmarks/barrel_ecal/run_emcal_barrel_pions.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash

if [[ ! -n "${DETECTOR}" ]] ; then
if [[ ! -n "${DETECTOR}" ]] ; then
export DETECTOR="topside"
fi

if [[ ! -n "${JUGGLER_N_EVENTS}" ]] ; then
if [[ ! -n "${JUGGLER_N_EVENTS}" ]] ; then
export JUGGLER_N_EVENTS=1000
fi

Expand Down Expand Up @@ -58,4 +58,3 @@ mkdir -p results

# Move ROOT output file
#mv ${JUGGLER_REC_FILE} sim_output/

Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ void addDetectorName(std::string name, TH1 * inhist){
x = toupper(x);
}
inhist -> SetTitle((name + " " + newName).c_str());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ void save_canvas(TCanvas* c, std::string label)

void save_canvas(TCanvas* c, std::string label, double E)
{
std::string label_with_E = fmt::format("{}/{}", E, label);
std::string label_with_E = fmt::format("{}/{}", E, label);
save_canvas(c, label_with_E);
}
void save_canvas(TCanvas* c, std::string label, std::string E_label)
{
std::string label_with_E = fmt::format("{}/{}", E_label, label);
std::string label_with_E = fmt::format("{}/{}", E_label, label);
save_canvas(c, label_with_E);
}
void save_canvas(TCanvas* c, std::string var_label, std::string E_label, std::string particle_label)
{
std::string label_with_E = fmt::format("{}/emcal_barrel_{}_{}", E_label, particle_label, var_label);
std::string label_with_E = fmt::format("{}/emcal_barrel_{}_{}", E_label, particle_label, var_label);
save_canvas(c, label_with_E);
}

Expand Down Expand Up @@ -77,7 +77,7 @@ std::tuple <double, double, double, double> extract_sampling_fraction_parameters
return sampled / thrown;
};

// Energy deposited in layers
// Energy deposited in layers
auto decoder = detector.readout("EcalBarrelImagingHits").idSpec().decoder();
fmt::print("{}\n", decoder->fieldDescription());
auto layer_index = decoder->index("layer");
Expand Down Expand Up @@ -142,14 +142,14 @@ std::tuple <double, double, double, double> extract_sampling_fraction_parameters
auto down_range = h->GetMean() - 3*h->GetStdDev();
h->SetLineWidth(2);
h->SetLineColor(kBlue);
h->GetXaxis()->SetRange(h->GetXaxis()->GetBinUpEdge(1), up_range); // skip 0th bin

h->GetXaxis()->SetRange(h->GetXaxis()->GetBinUpEdge(1), up_range); // skip 0th bin
auto mean_layer = h->GetMean();
auto rms_layer = h->GetStdDev();
h->GetXaxis()->SetRange(); // reset the range
h->GetXaxis()->SetRangeUser(0.,up_range);

auto no_edep = (h->GetBinContent(1)/h->GetEntries())*100;
auto no_edep = (h->GetBinContent(1)/h->GetEntries())*100;
gr_no_edep.SetPoint(gr_no_edep.GetN(),layer,no_edep);
gr_edep_mean.SetPoint(gr_edep_mean.GetN(),layer, mean_layer);
gr_edep_mean.SetPointError(gr_edep_mean.GetN()-1,0, rms_layer);
Expand Down Expand Up @@ -183,7 +183,7 @@ std::tuple <double, double, double, double> extract_sampling_fraction_parameters
auto h = hEthr->DrawCopy();
h->SetLineWidth(2);
h->SetLineColor(kBlue);
save_canvas(c1, "Ethr", E_label, particle_label);
save_canvas(c1, "Ethr", E_label, particle_label);
}

{
Expand Down Expand Up @@ -211,15 +211,15 @@ std::tuple <double, double, double, double> extract_sampling_fraction_parameters
TCanvas* c4 = new TCanvas("c4", "c4", 700, 500);
auto h = hfsam->DrawCopy();
h->SetLineWidth(2);
h->SetLineColor(kBlue);
h->SetLineColor(kBlue);
double up_fit = h->GetMean() + 5*h->GetStdDev();
double down_fit = h->GetMean() - 5*h->GetStdDev();
if(down_fit <=0 ) down_fit = h->GetXaxis()->GetBinUpEdge(1);
h->Fit("gaus", "", "", down_fit, up_fit);
h->GetXaxis()->SetRangeUser(0.,up_fit);
TF1 *gaus = h->GetFunction("gaus");
gaus->SetLineWidth(2);
gaus->SetLineColor(kRed);
gaus->SetLineColor(kRed);
double mean = gaus->GetParameter(1);
double sigma = gaus->GetParameter(2);
double mean_err = gaus->GetParError(1);
Expand Down Expand Up @@ -265,8 +265,8 @@ void emcal_barrel_energy_scan_analysis(std::string particle_label = "electron")
gStyle->SetPadRightMargin(0.14);

auto scanned_energies = read_scanned_energies(fmt::format("sim_output/emcal_barrel_energy_scan_points_{}.txt", particle_label));
//Take detector layers

//Take detector layers
std::string detector_path = "";
std::string detector_name = "athena";
if(std::getenv("DETECTOR_PATH")) {
Expand All @@ -278,7 +278,7 @@ void emcal_barrel_energy_scan_analysis(std::string particle_label = "electron")

dd4hep::Detector& detector = dd4hep::Detector::getInstance();
detector.fromCompact(fmt::format("{}/{}.xml", detector_path, detector_name));

TGraphErrors gr_fsam(scanned_energies.size()-1);
TGraphErrors gr_fsam_res(scanned_energies.size()-1);

Expand All @@ -292,7 +292,7 @@ void emcal_barrel_energy_scan_analysis(std::string particle_label = "electron")
auto fsam_res_rel_err = 100.0*(sqrt(pow((fsam_res_err/fsam),2)+pow((fsam_err*fsam_res)/(fsam*fsam),2)));
gr_fsam_res.SetPointError(gr_fsam_res.GetN()-1,0.,fsam_res_rel_err);
}

TCanvas* c5 = new TCanvas("c5", "c5", 700, 500);
c5->cd();
gr_fsam.SetTitle("Sampling Fraction Scan;True Energy [GeV];Sampling Fraction [%]");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void save_canvas(TCanvas* c, std::string label)

void save_canvas(TCanvas* c, std::string label, std::string particle_label)
{
std::string label_with_E = fmt::format("emcal_barrel_{}_{}", particle_label, label);
std::string label_with_E = fmt::format("emcal_barrel_{}_{}", particle_label, label);
save_canvas(c, label_with_E);
}

Expand Down Expand Up @@ -208,7 +208,7 @@ void emcal_barrel_particles_analysis(std::string particle_name = "electron", boo
fSam_mean = gaus->GetParameter(1);
fSam_mean_err = gaus->GetParError(1);
gaus->SetLineWidth(2);
gaus->SetLineColor(kRed);
gaus->SetLineColor(kRed);
save_canvas(c4,"fsam",particle_name);
}

Expand All @@ -225,7 +225,7 @@ void emcal_barrel_particles_analysis(std::string particle_name = "electron", boo
fSam_img_mean = gaus->GetParameter(1);
fSam_img_mean_err = gaus->GetParError(1);
gaus->SetLineWidth(2);
gaus->SetLineColor(kRed);
gaus->SetLineColor(kRed);
save_canvas(c5,"fsamImg",particle_name);
}

Expand All @@ -242,7 +242,7 @@ void emcal_barrel_particles_analysis(std::string particle_name = "electron", boo
fSam_scfi_mean = gaus->GetParameter(1);
fSam_scfi_mean_err = gaus->GetParError(1);
gaus->SetLineWidth(2);
gaus->SetLineColor(kRed);
gaus->SetLineColor(kRed);
save_canvas(c6,"fsamScFi",particle_name);
}

Expand All @@ -254,7 +254,7 @@ void emcal_barrel_particles_analysis(std::string particle_name = "electron", boo
{"sampling_fraction_img", fSam_img_mean},
{"sampling_fraction_error_img", fSam_img_mean_err},
{"sampling_fraction_scfi", fSam_scfi_mean},
{"sampling_fraction_error_scfi", fSam_scfi_mean_err}
{"sampling_fraction_error_scfi", fSam_scfi_mean_err}
};
if (save_calib) {
std::string calib_output_path = fmt::format("results/emcal_barrel_{}_calibration.json", particle_name);
Expand All @@ -263,4 +263,3 @@ void emcal_barrel_particles_analysis(std::string particle_name = "electron", boo
o << std::setw(4) << j << std::endl;
}
}

Loading

0 comments on commit bead800

Please sign in to comment.