Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ResidualsAndPulls.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ResidualsAndPulls.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2021 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #include <exception>
10 #include <iostream>
11 #include <string>
12 
13 #include <TApplication.h>
14 #include <boost/program_options.hpp>
15 
16 #include "boundParamResolution.C"
17 
18 using namespace boost::program_options;
19 
20 int main(int argc, char** argv) {
21  std::cout << "*** ACTS Residual and Pull plotting " << std::endl;
22 
23  try {
24  options_description description("*** Usage:");
25 
26  // Add the program options
27  auto ao = description.add_options();
28  ao("help,h", "Display this help message");
29  ao("silent,s", bool_switch(), "Silent mode (without X-window/display).");
30  ao("input,i", value<std::string>()->required(),
31  "Input ROOT file containing the input TTree.");
32  ao("tree,t", value<std::string>()->default_value("trackstates"),
33  "Input TTree name.");
34  ao("output,o", value<std::string>()->default_value(""),
35  "Output ROOT file with histograms");
36  ao("predicted", bool_switch(), "Analyze the predicted parameters.");
37  ao("filtered", bool_switch(), "Analyze the filtered parameters.");
38  ao("smoothed", bool_switch(), "Analyze the smoothed parameters.");
39  ao("fit-predicted", bool_switch(), "Fit the predicted parameters.");
40  ao("fit-filtered", bool_switch(), "Fit the filtered parameters.");
41  ao("fit-smoothed", bool_switch(), "Fit the smoothed parameters.");
42  ao("save", value<std::string>()->default_value("png"),
43  "Output save format (to be interpreted by ROOT).");
44 
45  // Set up the variables map
46  variables_map vm;
47  store(command_line_parser(argc, argv).options(description).run(), vm);
48 
49  if (vm.count("help") != 0u) {
50  std::cout << description;
51  return 1;
52  }
53 
54  notify(vm);
55 
56  // Parse the parameters
57  auto iFile = vm["input"].as<std::string>();
58  auto iTree = vm["tree"].as<std::string>();
59  auto oFile = vm["output"].as<std::string>();
60  auto saveAs = vm["save"].as<std::string>();
61 
62  TApplication* tApp =
63  vm["silent"].as<bool>()
64  ? nullptr
65  : new TApplication("ResidualAndPulls", nullptr, nullptr);
66 
67  // Run the actual resolution estimation
68  switch (boundParamResolution(
69  iFile, iTree, oFile, vm["predicted"].as<bool>(),
70  vm["filtered"].as<bool>(), vm["smoothed"].as<bool>(),
71  vm["fit-predicted"].as<bool>(), vm["fit-filtered"].as<bool>(),
72  vm["fit-smoothed"].as<bool>(), saveAs)) {
73  case -1: {
74  std::cout << "*** Input file could not be opened, check name/path."
75  << std::endl;
76  return -1;
77  } break;
78  case -2: {
79  std::cout << "*** Input tree could not be found, check name."
80  << std::endl;
81  return -2;
82  } break;
83  default: {
84  std::cout << "*** Successful run." << std::endl;
85  };
86  }
87 
88  if (tApp != nullptr) {
89  tApp->Run();
90  }
91 
92  } catch (std::exception& e) {
93  std::cerr << e.what() << "\n";
94  }
95 
96  std::cout << "*** Done." << std::endl;
97  return 0;
98 }