Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:12:10

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #include <exception>
0010 #include <iostream>
0011 #include <string>
0012 
0013 #include <TApplication.h>
0014 #include <boost/program_options.hpp>
0015 
0016 #include "boundParamResolution.C"
0017 
0018 using namespace boost::program_options;
0019 
0020 int main(int argc, char** argv) {
0021   std::cout << "*** ACTS Residual and Pull plotting " << std::endl;
0022 
0023   try {
0024     options_description description("*** Usage:");
0025 
0026     // Add the program options
0027     auto ao = description.add_options();
0028     ao("help,h", "Display this help message");
0029     ao("silent,s", bool_switch(), "Silent mode (without X-window/display).");
0030     ao("input,i", value<std::string>()->required(),
0031        "Input ROOT file containing the input TTree.");
0032     ao("tree,t", value<std::string>()->default_value("trackstates"),
0033        "Input TTree name.");
0034     ao("output,o", value<std::string>()->default_value(""),
0035        "Output ROOT file with histograms");
0036     ao("predicted", bool_switch(), "Analyze the predicted parameters.");
0037     ao("filtered", bool_switch(), "Analyze the filtered parameters.");
0038     ao("smoothed", bool_switch(), "Analyze the smoothed parameters.");
0039     ao("fit-predicted", bool_switch(), "Fit the predicted parameters.");
0040     ao("fit-filtered", bool_switch(), "Fit the filtered parameters.");
0041     ao("fit-smoothed", bool_switch(), "Fit the smoothed parameters.");
0042     ao("save", value<std::string>()->default_value("png"),
0043        "Output save format (to be interpreted by ROOT).");
0044 
0045     // Set up the variables map
0046     variables_map vm;
0047     store(command_line_parser(argc, argv).options(description).run(), vm);
0048 
0049     if (vm.contains("help")) {
0050       std::cout << description;
0051       return 1;
0052     }
0053 
0054     notify(vm);
0055 
0056     // Parse the parameters
0057     auto iFile = vm["input"].as<std::string>();
0058     auto iTree = vm["tree"].as<std::string>();
0059     auto oFile = vm["output"].as<std::string>();
0060     auto saveAs = vm["save"].as<std::string>();
0061 
0062     TApplication* tApp =
0063         vm["silent"].as<bool>()
0064             ? nullptr
0065             : new TApplication("ResidualAndPulls", nullptr, nullptr);
0066 
0067     // Run the actual resolution estimation
0068     switch (boundParamResolution(
0069         iFile, iTree, oFile, vm["predicted"].as<bool>(),
0070         vm["filtered"].as<bool>(), vm["smoothed"].as<bool>(),
0071         vm["fit-predicted"].as<bool>(), vm["fit-filtered"].as<bool>(),
0072         vm["fit-smoothed"].as<bool>(), saveAs)) {
0073       case -1:
0074         std::cout << "*** Input file could not be opened, check name/path."
0075                   << std::endl;
0076         return -1;
0077       case -2:
0078         std::cout << "*** Input tree could not be found, check name."
0079                   << std::endl;
0080         return -2;
0081       default:
0082         std::cout << "*** Successful run." << std::endl;
0083     }
0084 
0085     if (tApp != nullptr) {
0086       tApp->Run();
0087     }
0088 
0089   } catch (std::exception& e) {
0090     std::cerr << e.what() << "\n";
0091   }
0092 
0093   std::cout << "*** Done." << std::endl;
0094   return 0;
0095 }