Skip to content
Snippets Groups Projects

Resolve "Benchmark definition standard"

Merged Sylvester Joosten requested to merge benchmark-definition into master
3 files
+ 62
14
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 38
5
@@ -7,7 +7,9 @@
@@ -7,7 +7,9 @@
#include <cmath>
#include <cmath>
#include <fmt/color.h>
#include <fmt/color.h>
#include <fmt/core.h>
#include <fmt/core.h>
 
#include <fstream>
#include <iostream>
#include <iostream>
 
#include <nlohmann/json.hpp>
#include <string>
#include <string>
#include <vector>
#include <vector>
@@ -17,9 +19,18 @@
@@ -17,9 +19,18 @@
// file prefix), and labeled with our detector name.
// file prefix), and labeled with our detector name.
// TODO: I think it would be better to pass small json configuration file to
// TODO: I think it would be better to pass small json configuration file to
// the test, instead of this ever-expanding list of function arguments.
// the test, instead of this ever-expanding list of function arguments.
int vm_mass(std::string_view rec_file, std::string_view vm_name,
int vm_mass(const std::string& config_name) {
std::string_view decay_name, std::string_view detector,
// read our configuration
std::string output_prefix) {
std::ifstream config_file{config_name};
 
nlohmann::json config;
 
config_file >> config;
 
 
const std::string vm_name = config["vm_name"];
 
const std::string decay_name = config["decay_name"];
 
const std::string detector = config["detector"];
 
std::string output_prefix = config["output_prefix"];
 
const std::string test_tag = config["test_tag"];
 
fmt::print(fmt::emphasis::bold | fg(fmt::color::forest_green),
fmt::print(fmt::emphasis::bold | fg(fmt::color::forest_green),
"Running VM invariant mass analysis...\n");
"Running VM invariant mass analysis...\n");
fmt::print(" - Vector meson: {}\n", vm_name);
fmt::print(" - Vector meson: {}\n", vm_name);
@@ -27,6 +38,18 @@ int vm_mass(std::string_view rec_file, std::string_view vm_name,
@@ -27,6 +38,18 @@ int vm_mass(std::string_view rec_file, std::string_view vm_name,
fmt::print(" - Detector package: {}\n", detector);
fmt::print(" - Detector package: {}\n", detector);
fmt::print(" - output prefix: {}\n", output_prefix);
fmt::print(" - output prefix: {}\n", output_prefix);
 
// create our test definition
 
// test_tag
 
juggler_util::test vm_mass_resolution_test{
 
{{"name",
 
fmt::format("{}_{}_{}_mass_resolution", test_tag, vm_name, decay_name)},
 
{"title", fmt::format("{} --> {}{} Invariant Mass Resolution", vm_name,
 
decay_name, decay_name)},
 
{"description", "Invariant Mass Resolution calculated from raw "
 
"tracking data using a Gaussian fit."},
 
{"quantity", "resolution"},
 
{"target", ".1"}}};
 
// Run this in multi-threaded mode if desired
// Run this in multi-threaded mode if desired
ROOT::EnableImplicitMT(kNumThreads);
ROOT::EnableImplicitMT(kNumThreads);
@@ -41,9 +64,10 @@ int vm_mass(std::string_view rec_file, std::string_view vm_name,
@@ -41,9 +64,10 @@ int vm_mass(std::string_view rec_file, std::string_view vm_name,
}
}
// Open our input file file as a dataframe
// Open our input file file as a dataframe
ROOT::RDataFrame d{"events", rec_file};
ROOT::RDataFrame d{"events", config["rec_file"]};
// utility lambda functions to bind the vector meson and decay particle types
// utility lambda functions to bind the vector meson and decay particle
 
// types
auto momenta_from_tracking =
auto momenta_from_tracking =
[decay_mass](const std::vector<eic::TrackParametersData>& tracks) {
[decay_mass](const std::vector<eic::TrackParametersData>& tracks) {
return util::momenta_from_tracking(tracks, decay_mass);
return util::momenta_from_tracking(tracks, decay_mass);
@@ -104,6 +128,15 @@ int vm_mass(std::string_view rec_file, std::string_view vm_name,
@@ -104,6 +128,15 @@ int vm_mass(std::string_view rec_file, std::string_view vm_name,
// Print canvas to output file
// Print canvas to output file
c.Print(fmt::format("{}vm_mass.png", output_prefix).c_str());
c.Print(fmt::format("{}vm_mass.png", output_prefix).c_str());
}
}
 
 
// TODO we're not actually doing an IM fit yet, so for now just return an
 
// error for the test result
 
vm_mass_resolution_test.error(-1);
 
 
// write out our test data
 
juggler_util::write_test(vm_mass_resolution_test,
 
fmt::format("{}vm_mass.json", output_prefix));
 
// That's all!
// That's all!
return 0;
return 0;
}
}
Loading