Skip to content

Commit

Permalink
feat: add another script executable, add program options (#943)
Browse files Browse the repository at this point in the history
This PR partly harmonizes the Executables in the Script/TrackingPerformance folder.
Currently one can run:

ActsExampleResidualAndPulls
ActsExamplePerigeeParameters
both steered by program options, the efficiency & fake-rate executable with also follow in a separate PR.

The naming of the plots is slightly refined and a quite option to produce plots from shell scripts (e.g. automatically from test runs in the CI is added).
  • Loading branch information
asalzburger committed Aug 19, 2021
1 parent c020c92 commit 60c824c
Show file tree
Hide file tree
Showing 6 changed files with 590 additions and 244 deletions.
13 changes: 11 additions & 2 deletions Examples/Scripts/TrackingPerformance/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
add_executable(ActsExampleResidualsAndPulls ResidualsAndPulls.cpp)
target_link_libraries(ActsExampleResidualsAndPulls ROOT::Core ROOT::Hist ROOT::Tree ROOT::TreePlayer)
target_link_libraries(ActsExampleResidualsAndPulls ROOT::Core ROOT::Hist ROOT::Tree ROOT::TreePlayer Boost::program_options)

install(
TARGETS
ActsExampleResidualsAndPulls
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})


add_executable(ActsExamplePerigeeParameters PerigeeParameters.cpp)
target_link_libraries(ActsExamplePerigeeParameters ROOT::Core ROOT::Hist ROOT::Tree ROOT::TreePlayer Boost::program_options)

install(
TARGETS
ActsExamplePerigeeParameters
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
2 changes: 1 addition & 1 deletion Examples/Scripts/TrackingPerformance/CommonUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void setHistStyle(hist_t* hist, short color = 1) {
hist->SetMarkerStyle(20);
hist->SetMarkerSize(0.8);
hist->SetLineWidth(2);
// hist->SetTitle("");
hist->SetTitle("");
hist->SetLineColor(color);
hist->SetMarkerColor(color);
}
Expand Down
74 changes: 74 additions & 0 deletions Examples/Scripts/TrackingPerformance/PerigeeParameters.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// This file is part of the Acts project.
//
// Copyright (C) 2021 CERN for the benefit of the Acts project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

#include <exception>
#include <iostream>
#include <string>

#include <TApplication.h>
#include <boost/program_options.hpp>

#include "perigeeParamResolution.C"

using namespace boost::program_options;

int main(int argc, char** argv) {
std::cout << "*** ACTS Perigee parameter plotting" << std::endl;

try {
options_description description("*** Usage:");

// Add the program options
auto ao = description.add_options();
ao("help,h", "Display this help message");
ao("silent,s", bool_switch(), "Silent mode (without X-window/display).");
ao("input,i", value<std::string>()->default_value(""),
"Input ROOT file containing the input TTree.");
ao("fit", bool_switch(), "Fit the smoothed parameters.");
ao("save", value<std::string>()->default_value("png"),
"Output save format (to be interpreted by ROOT).");

// Set up the variables map
variables_map vm;
store(command_line_parser(argc, argv).options(description).run(), vm);
notify(vm);

if (vm.count("help")) {
std::cout << description;
}

// Parse the parameters
auto iFile = vm["input"].as<std::string>();
auto saveAs = vm["save"].as<std::string>();

TApplication* tApp = vm["silent"].as<bool>()
? nullptr
: new TApplication("ResidualAndPulls", 0, 0);

// Run the actual resolution estimation
switch (perigeeParamResolution(iFile, vm["fit"].as<bool>())) {
case -1: {
std::cout << "*** Input file could not be opened, check name/path."
<< std::endl;
} break;
default: {
std::cout << "*** Successful run." << std::endl;
};
}

if (tApp != nullptr) {
tApp->Run();
}

} catch (std::exception& e) {
std::cerr << e.what() << "\n";
}

std::cout << "*** Done." << std::endl;
return 1;
}
87 changes: 71 additions & 16 deletions Examples/Scripts/TrackingPerformance/ResidualsAndPulls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,85 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

#include <exception>
#include <iostream>
#include <string>

#include <TApplication.h>
#include <boost/program_options.hpp>

#include "boundParamResolution.C"

int main(int argc, char **argv) {
if (argc > 1) {
std::string farg = argv[1];
if (farg == "-h" or farg.find("help") != std::string::npos) {
std::cout << "*** ACTS Residual and Pull plotting " << std::endl;
std::cout << "*** Usage: ./ActsExampleResidualAndPulls input_file "
"input_tree output_file <save_extension>"
<< std::endl;
using namespace boost::program_options;

int main(int argc, char** argv) {
std::cout << "*** ACTS Residual and Pull plotting " << std::endl;

try {
options_description description("*** Usage:");

// Add the program options
auto ao = description.add_options();
ao("help,h", "Display this help message");
ao("silent,s", bool_switch(), "Silent mode (without X-window/display).");
ao("input,i", value<std::string>()->default_value(""),
"Input ROOT file containing the input TTree.");
ao("tree,t", value<std::string>()->default_value("trackstates"),
"Input TTree name.");
ao("output,o", value<std::string>()->default_value(""),
"Output ROOT file with histograms");
ao("predicted", bool_switch(), "Analyze the predicted parameters.");
ao("filtered", bool_switch(), "Analyze the filtered parameters.");
ao("smoothed", bool_switch(), "Analyze the smoothed parameters.");
ao("fit", bool_switch(), "Fit the smoothed parameters.");
ao("save", value<std::string>()->default_value("png"),
"Output save format (to be interpreted by ROOT).");

// Set up the variables map
variables_map vm;
store(command_line_parser(argc, argv).options(description).run(), vm);
notify(vm);

if (vm.count("help")) {
std::cout << description;
}

// Parse the parameters
auto iFile = vm["input"].as<std::string>();
auto iTree = vm["tree"].as<std::string>();
auto oFile = vm["output"].as<std::string>();
auto saveAs = vm["save"].as<std::string>();

TApplication* tApp = vm["silent"].as<bool>()
? nullptr
: new TApplication("ResidualAndPulls", 0, 0);

// Run the actual resolution estimation
switch (boundParamResolution(
iFile, iTree, oFile, vm["predicted"].as<bool>(),
vm["filtered"].as<bool>(), vm["smoothed"].as<bool>(),
vm["fit"].as<bool>(), saveAs)) {
case -1: {
std::cout << "*** Input file could not be opened, check name/path."
<< std::endl;
} break;
case -2: {
std::cout << "*** Input tree could not be found, check name."
<< std::endl;
} break;
default: {
std::cout << "*** Successful run." << std::endl;
};
}
if (argc >= 4) {
TApplication theApp("ResidualAndPulls", 0, 0);
std::string inputFile = farg;
std::string inputTree = argv[2];
std::string outputFile = argv[3];
std::string saveAs = (argc > 4) ? std::string(argv[4]) : std::string("");
boundParamResolution(inputFile, inputTree, outputFile, saveAs);
theApp.Run();

if (tApp != nullptr) {
tApp->Run();
}

} catch (std::exception& e) {
std::cerr << e.what() << "\n";
}

std::cout << "*** Done." << std::endl;
return 1;
}

0 comments on commit 60c824c

Please sign in to comment.