diff --git a/benchmarks/dis/analysis/dis_electrons.cxx b/benchmarks/dis/analysis/dis_electrons.cxx index e59c69a5c0fb43ba9c8a079ed6edfa3491f89508..d1ddb07d614047158f01861a800c0463b450e1f0 100644 --- a/benchmarks/dis/analysis/dis_electrons.cxx +++ b/benchmarks/dis/analysis/dis_electrons.cxx @@ -35,6 +35,8 @@ int dis_electrons(const std::string& config_name) const std::string detector = config["detector"]; const std::string output_prefix = config["output_prefix"]; const std::string test_tag = config["test_tag"]; + const int ebeam = config["ebeam"]; + const int pbeam = config["pbeam"]; fmt::print(fmt::emphasis::bold | fg(fmt::color::forest_green), "Running DIS electron analysis...\n"); @@ -42,6 +44,8 @@ int dis_electrons(const std::string& config_name) fmt::print(" - input file: {}\n", rec_file); fmt::print(" - output prefix: {}\n", output_prefix); fmt::print(" - test tag: {}\n", test_tag); + fmt::print(" - ebeam: {}\n", ebeam); + fmt::print(" - pbeam: {}\n", pbeam); // create our test definition // test_tag @@ -110,6 +114,16 @@ int dis_electrons(const std::string& config_name) TFitResultPtr f_x_el_res = h_x_el_res->Fit("gaus", "S"); if (f_x_el_res == 0) f_x_el_res->Print("V"); + TFitResultPtr f_Q2_jb_res = h_Q2_jb_res->Fit("gaus", "S"); + if (f_Q2_jb_res == 0) f_Q2_jb_res->Print("V"); + TFitResultPtr f_x_jb_res = h_x_jb_res->Fit("gaus", "S"); + if (f_x_jb_res == 0) f_x_jb_res->Print("V"); + + TFitResultPtr f_Q2_da_res = h_Q2_da_res->Fit("gaus", "S"); + if (f_Q2_da_res == 0) f_Q2_da_res->Print("V"); + TFitResultPtr f_x_da_res = h_x_da_res->Fit("gaus", "S"); + if (f_x_da_res == 0) f_x_da_res->Print("V"); + // Plot our histograms. // TODO: to start I'm explicitly plotting the histograms, but want to // factorize out the plotting code moving forward. @@ -141,8 +155,8 @@ int dis_electrons(const std::string& config_name) h2.DrawClone("hist same"); h3.DrawClone("hist same"); h4.DrawClone("hist same"); - // FIXME hardcoded beam configuration - common_bench::plot::draw_label(18, 275, detector); + // legend + common_bench::plot::draw_label(ebeam, pbeam, detector); TText* tptr1; TPaveText t1(.6, .8417, .9, .925, "NB NDC"); t1.SetFillColorAlpha(kWhite, 0); @@ -150,14 +164,14 @@ int dis_electrons(const std::string& config_name) t1.SetTextSize(25); tptr1 = t1.AddText("simulated"); tptr1->SetTextColor(common_bench::plot::kMpBlue); - tptr1 = t1.AddText("electron"); + tptr1 = t1.AddText("EL method"); tptr1->SetTextColor(common_bench::plot::kMpOrange); - tptr1 = t1.AddText("JB"); + tptr1 = t1.AddText("JB method"); tptr1->SetTextColor(common_bench::plot::kMpRed); - tptr1 = t1.AddText("DA"); + tptr1 = t1.AddText("DA method"); tptr1->SetTextColor(common_bench::plot::kMpGreen); t1.Draw(); - c.Print(fmt::format("{}Q2.png", output_prefix).c_str()); + c.Print(fmt::format("{}_Q2.png", output_prefix).c_str()); } // Q2 resolution @@ -170,11 +184,11 @@ int dis_electrons(const std::string& config_name) auto& h2 = *h_Q2_jb_res; auto& h3 = *h_Q2_da_res; // histogram style - h1.SetLineColor(common_bench::plot::kMpBlue); + h1.SetLineColor(common_bench::plot::kMpOrange); h1.SetLineWidth(2); - h2.SetLineColor(common_bench::plot::kMpOrange); + h2.SetLineColor(common_bench::plot::kMpRed); h2.SetLineWidth(2); - h3.SetLineColor(common_bench::plot::kMpRed); + h3.SetLineColor(common_bench::plot::kMpGreen); h3.SetLineWidth(2); // axes h1.GetXaxis()->CenterTitle(); @@ -183,9 +197,21 @@ int dis_electrons(const std::string& config_name) h1.DrawClone("hist"); h2.DrawClone("hist same"); h3.DrawClone("hist same"); - // FIXME hardcoded beam configuration - common_bench::plot::draw_label(18, 275, detector); - c.Print(fmt::format("{}Q2resolution.png", output_prefix).c_str()); + // legend + common_bench::plot::draw_label(ebeam, pbeam, detector); + TText* tptr1; + TPaveText t1(.6, .8417, .9, .925, "NB NDC"); + t1.SetFillColorAlpha(kWhite, 0); + t1.SetTextFont(43); + t1.SetTextSize(25); + tptr1 = t1.AddText("EL method"); + tptr1->SetTextColor(common_bench::plot::kMpOrange); + tptr1 = t1.AddText("JB method"); + tptr1->SetTextColor(common_bench::plot::kMpRed); + tptr1 = t1.AddText("DA method"); + tptr1->SetTextColor(common_bench::plot::kMpGreen); + t1.Draw(); + c.Print(fmt::format("{}_Q2_resolution.png", output_prefix).c_str()); } // x comparison @@ -215,8 +241,8 @@ int dis_electrons(const std::string& config_name) h2.DrawClone("hist same"); h3.DrawClone("hist same"); h4.DrawClone("hist same"); - // FIXME hardcoded beam configuration - common_bench::plot::draw_label(18, 275, detector); + // legend + common_bench::plot::draw_label(ebeam, pbeam, detector); TText* tptr1; TPaveText t1(.6, .8417, .9, .925, "NB NDC"); t1.SetFillColorAlpha(kWhite, 0); @@ -224,10 +250,14 @@ int dis_electrons(const std::string& config_name) t1.SetTextSize(25); tptr1 = t1.AddText("simulated"); tptr1->SetTextColor(common_bench::plot::kMpBlue); - tptr1 = t1.AddText("reconstructed"); + tptr1 = t1.AddText("EL method"); tptr1->SetTextColor(common_bench::plot::kMpOrange); + tptr1 = t1.AddText("JB method"); + tptr1->SetTextColor(common_bench::plot::kMpRed); + tptr1 = t1.AddText("DA method"); + tptr1->SetTextColor(common_bench::plot::kMpGreen); t1.Draw(); - c.Print(fmt::format("{}x.png", output_prefix).c_str()); + c.Print(fmt::format("{}_x.png", output_prefix).c_str()); } // x resolution @@ -240,11 +270,11 @@ int dis_electrons(const std::string& config_name) auto& h2 = *h_x_jb_res; auto& h3 = *h_x_da_res; // histogram style - h1.SetLineColor(common_bench::plot::kMpBlue); + h1.SetLineColor(common_bench::plot::kMpOrange); h1.SetLineWidth(2); - h2.SetLineColor(common_bench::plot::kMpOrange); + h2.SetLineColor(common_bench::plot::kMpRed); h2.SetLineWidth(2); - h3.SetLineColor(common_bench::plot::kMpRed); + h3.SetLineColor(common_bench::plot::kMpGreen); h3.SetLineWidth(2); // axes h1.GetXaxis()->CenterTitle(); @@ -253,9 +283,21 @@ int dis_electrons(const std::string& config_name) h1.DrawClone("hist"); h2.DrawClone("hist same"); h3.DrawClone("hist same"); - // FIXME hardcoded beam configuration - common_bench::plot::draw_label(18, 275, detector); - c.Print(fmt::format("{}xresolution.png", output_prefix).c_str()); + // legend + common_bench::plot::draw_label(ebeam, pbeam, detector); + TText* tptr1; + TPaveText t1(.6, .8417, .9, .925, "NB NDC"); + t1.SetFillColorAlpha(kWhite, 0); + t1.SetTextFont(43); + t1.SetTextSize(25); + tptr1 = t1.AddText("EL method"); + tptr1->SetTextColor(common_bench::plot::kMpOrange); + tptr1 = t1.AddText("JB method"); + tptr1->SetTextColor(common_bench::plot::kMpRed); + tptr1 = t1.AddText("DA method"); + tptr1->SetTextColor(common_bench::plot::kMpGreen); + t1.Draw(); + c.Print(fmt::format("{}_x_resolution.png", output_prefix).c_str()); } common_bench::write_test({dis_Q2_resolution}, fmt::format("{}dis_electrons.json", output_prefix)); diff --git a/benchmarks/dis/analysis/rec_analysis_ecal.cxx b/benchmarks/dis/analysis/rec_analysis_ecal.cxx index 4aba2ca555cafc4b701b43288b5bd1ff37d525da..3d0af430474e00bb53ee90ceb4ee4cd7dbbf2e5c 100644 --- a/benchmarks/dis/analysis/rec_analysis_ecal.cxx +++ b/benchmarks/dis/analysis/rec_analysis_ecal.cxx @@ -35,6 +35,8 @@ int rec_analysis_ecal(const std::string& config_name) const std::string detector = config["detector"]; const std::string output_prefix = config["output_prefix"]; const std::string test_tag = config["test_tag"]; + const int ebeam = config["ebeam"]; + const int pbeam = config["pbeam"]; fmt::print(fmt::emphasis::bold | fg(fmt::color::forest_green), "Running DIS electron analysis...\n"); @@ -42,6 +44,8 @@ int rec_analysis_ecal(const std::string& config_name) fmt::print(" - input file: {}\n", rec_file); fmt::print(" - output prefix: {}\n", output_prefix); fmt::print(" - test tag: {}\n", test_tag); + fmt::print(" - ebeam: {}\n", ebeam); + fmt::print(" - pbeam: {}\n", pbeam); // create our test definition // test_tag diff --git a/benchmarks/dis/analysis/rec_analysis_hcal.cxx b/benchmarks/dis/analysis/rec_analysis_hcal.cxx index df0185478823c78f3544aafaee30682c7b48c732..06641d3443dfeec35846c6394fee9907032df2cf 100644 --- a/benchmarks/dis/analysis/rec_analysis_hcal.cxx +++ b/benchmarks/dis/analysis/rec_analysis_hcal.cxx @@ -35,6 +35,8 @@ int rec_analysis_hcal(const std::string& config_name) const std::string detector = config["detector"]; const std::string output_prefix = config["output_prefix"]; const std::string test_tag = config["test_tag"]; + const int ebeam = config["ebeam"]; + const int pbeam = config["pbeam"]; fmt::print(fmt::emphasis::bold | fg(fmt::color::forest_green), "Running DIS electron analysis...\n"); @@ -42,6 +44,8 @@ int rec_analysis_hcal(const std::string& config_name) fmt::print(" - input file: {}\n", rec_file); fmt::print(" - output prefix: {}\n", output_prefix); fmt::print(" - test tag: {}\n", test_tag); + fmt::print(" - ebeam: {}\n", ebeam); + fmt::print(" - pbeam: {}\n", pbeam); // create our test definition // test_tag diff --git a/benchmarks/dis/config.yml b/benchmarks/dis/config.yml index f619d1a6f5a9ea8d20c4e7f8e8d9a291f2a77dba..6c11310548dcd9a68b05b0325a8b242f7f698f0a 100644 --- a/benchmarks/dis/config.yml +++ b/benchmarks/dis/config.yml @@ -12,7 +12,7 @@ dis:generate: PBEAM: 275 timeout: 1 hours script: - - bash benchmarks/dis/gen.sh --config dis_${EBEAM}x${PBEAM} --ebeam ${EBEAM} --pbeam ${PBEAM} + - bash benchmarks/dis/get.sh --config dis_${EBEAM}x${PBEAM} --ebeam ${EBEAM} --pbeam ${PBEAM} dis:process: stage: process diff --git a/benchmarks/dis/get.sh b/benchmarks/dis/get.sh new file mode 100644 index 0000000000000000000000000000000000000000..f6625a54977eed27f818720b413ede8abf777e13 --- /dev/null +++ b/benchmarks/dis/get.sh @@ -0,0 +1,77 @@ +#!/bin/bash + +## ============================================================================= +## Standin for a proper pythia generation process, similar to how we +## generate events for DVMP +## Runs in 5 steps: +## 1. Parse the command line and setup the environment +## 2. Check if we can download the file +## 3. Finalize +## ============================================================================= +## ============================================================================= + +## make sure we launch this script from the project root directory +PROJECT_ROOT="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"/../.. +pushd ${PROJECT_ROOT} + +## ============================================================================= +## Step 1: Setup the environment variables +## First parse the command line flags. +## This sets the following environment variables: +## - CONFIG: The specific generator configuration --> not currenlty used FIXME +## - EBEAM: The electron beam energy --> not currently used FIXME +## - PBEAM: The ion beam energy --> not currently used FIXME +source parse_cmd.sh $@ + +## To run the generator, we need the following global variables: +## +## - LOCAL_PREFIX: Place to cache local packages and data +## - JUGGLER_N_EVENTS: Number of events to process +## - JUGGLER_RNG_SEED: Random seed for event generation. +## +## defined in common_bench repo +## You can ready bin/env.sh for more in-depth explanations of the variables +## and how they can be controlled. + + +## We also need the following benchmark-specific variables: +## +## - BENCHMARK_TAG: Unique identified for this benchmark process. +## - INPUT_PATH: Path for generator-level input to the benchmarks +## - TMP_PATH: Path for temporary data (not exported as artifacts) +## +## You can read dvmp/env.sh for more in-depth explanations of the variables. +source benchmarks/dis/env.sh + +## Get a unique file name prefix based on the configuration options +GEN_TAG=gen-${CONFIG}_${JUGGLER_N_EVENTS} ## Generic file prefix + +## ============================================================================= +## Step 2: Check if we can find the file +if [ -f "${INPUT_PATH}/${GEN_TAG}.hepmc" ]; then + echo "Found cached generator output for $GEN_TAG, no need to rerun" + exit 0 +fi + +## ============================================================================= +## Step 3: Copy the file (about 180 lines per event in DIS NC files) +nlines=$((180*${JUGGLER_N_EVENTS})) +mc config host add S3 https://dtn01.sdcc.bnl.gov:9000 ${S3_ACCESS_KEY} ${S3_SECRET_KEY} +mc head -n ${nlines} S3/eictest/ATHENA/EVGEN/DIS/NC/${EBEAM}x${PBEAM}/minQ2=1/pythia8NCDIS_${EBEAM}x${PBEAM}_minQ2=1_beamEffects_xAngle=-0.025_hiDiv_vtxfix_1.hepmc > ${TMP_PATH}/${GEN_TAG}.hepmc +if [[ "$?" -ne "0" ]] ; then + echo "ERROR downloading file" + exit 1 +fi + +## ============================================================================= +## Step 4: Finally, move relevant output into the artifacts directory and clean up +## ============================================================================= +echo "Moving generator output into ${INPUT_PATH}" +mv ${TMP_PATH}/${GEN_TAG}.hepmc ${INPUT_PATH}/${GEN_TAG}.hepmc +## this step only matters for local execution +echo "Cleaning up" +## does nothing + +## ============================================================================= +## All done! +echo "$BENCHMARK_TAG event generation complete"