23 #include <TApplication.h>
24 #include <boost/program_options.hpp>
25 #include <nlohmann/json.hpp>
27 #define BOOST_AVAILABLE 1
28 #if ((BOOST_VERSION / 100) % 1000) <= 71
30 #include <boost/progress.hpp>
35 #include <boost/timer/progress_display.hpp>
40 #define NLOHMANN_AVAILABLE 1
43 using namespace boost::program_options;
48 int main(
int argc,
char** argv) {
49 std::cout <<
"*** ACTS Perigee parameters and Track summary plotting "
56 auto ao = description.add_options();
57 ao(
"help,h",
"Display this help message");
58 ao(
"silent,s", bool_switch(),
"Silent mode (without X-window/display).");
59 ao(
"events,n", value<unsigned long>()->default_value(0),
60 "(Optionally) limit number of events to be processed.");
61 ao(
"peak-events,p", value<unsigned long>()->default_value(0),
62 "(Optionally) limit number of events for the range peaking.");
63 ao(
"input,i",
value<std::vector<std::string>>()->required(),
64 "Input ROOT file(s) containing the input TTree.");
65 ao(
"tree,t", value<std::string>()->default_value(
"tracksummary"),
66 "Input TTree/TChain name.");
67 ao(
"output,o", value<std::string>()->default_value(
""),
68 "Output ROOT file with histograms");
69 ao(
"hist-bins", value<unsigned int>()->default_value(61),
70 "Number of bins for the residual/pull histograms");
71 ao(
"pull-range", value<float>()->default_value(5.),
72 "Number of sigmas for the pull range.");
73 ao(
"eta-bins", value<unsigned int>()->default_value(10),
74 "Number of bins in eta.");
76 value<Interval>()->value_name(
"MIN:MAX")->default_value({-3.0, 3.0}),
77 "Range for the eta bins.");
78 ao(
"phi-bins", value<unsigned int>()->default_value(10),
79 "Number of bins in phi.");
81 value<Interval>()->value_name(
"MIN:MAX")->default_value({-M_PI, M_PI}),
82 "Range for the phi bins.");
83 ao(
"pt-borders", value<VariableReals>()->required(),
84 "Transverse momentum borders.");
85 ao(
"config-output", value<std::string>()->default_value(
""),
86 "(Optional) output histogram configuration json file.");
87 ao(
"config-input", value<std::string>()->default_value(
""),
88 "(Optional) input histogram configuration json file.");
90 ao(
"all", bool_switch(),
91 "Process all residual/pull and auxiliary parameters");
93 std::vector<std::string> resPullPars = {
"d0",
"z0",
"phi0",
"theta0",
95 for (
const auto& rp : resPullPars) {
96 ao(rp.c_str(), bool_switch(),
100 std::vector<std::string> auxPars = {
"chi2ndf",
"measurements",
"holes",
101 "outliers",
"shared"};
102 for (
const auto& aux : auxPars) {
103 ao(aux.c_str(), bool_switch(),
104 (
std::string(
"Auxiliary information for ") + aux).c_str());
111 if (vm.count(
"help") != 0
u) {
119 unsigned long nEntries = vm[
"events"].as<
unsigned long>();
120 unsigned long nPeakEntries = vm[
"peak-events"].as<
unsigned long>();
123 auto iFiles = vm[
"input"].as<std::vector<std::string>>();
128 auto configInput = vm[
"config-input"].as<
std::string>();
129 auto configOutput = vm[
"config-output"].as<
std::string>();
131 float pullRange = vm[
"pull-range"].as<
float>();
132 unsigned int nHistBins = vm[
"hist-bins"].as<
unsigned int>();
133 unsigned int nEtaBins = vm[
"eta-bins"].as<
unsigned int>();
135 auto etaInterval = vm[
"eta-range"].as<
Interval>();
136 std::array<float, 2> etaRange = {
137 static_cast<float>(etaInterval.lower.value_or(-3)),
138 static_cast<float>(etaInterval.upper.value_or(3.))};
140 unsigned int nPhiBins = vm[
"phi-bins"].as<
unsigned int>();
141 auto phiInterval = vm[
"phi-range"].as<
Interval>();
142 std::array<float, 2> phiRange = {
143 static_cast<float>(phiInterval.lower.value_or(-M_PI)),
144 static_cast<float>(phiInterval.upper.value_or(M_PI))};
147 if (ptBorders.empty()) {
148 ptBorders = {0., std::numeric_limits<double>::infinity()};
152 vm[
"silent"].as<
bool>()
154 :
new TApplication(
"TrackSummary",
nullptr,
nullptr);
156 std::bitset<7> residualPulls;
157 std::bitset<5> auxiliaries;
158 if (vm[
"all"].as<bool>()) {
159 residualPulls = std::bitset<7>{
"1111111"};
160 auxiliaries = std::bitset<5>{
"11111"};
163 for (
unsigned int iresp = 0; iresp < resPullPars.size(); ++iresp) {
164 if (vm[resPullPars[iresp]].as<bool>()) {
165 residualPulls.set(iresp);
169 for (
unsigned int iaux = 0; iaux < auxPars.size(); ++iaux) {
170 if (vm[auxPars[iaux]].as<bool>()) {
171 auxiliaries.set(iaux);
178 iFiles, iTree, oFile, configInput, configOutput, nEntries, nPeakEntries,
179 pullRange, nHistBins, nPhiBins, phiRange, nEtaBins, etaRange, ptBorders,
180 residualPulls, auxiliaries)) {
182 std::cout <<
"*** Input file could not be opened, check name/path."
186 std::cout <<
"*** Input tree could not be found, check name."
190 std::cout <<
"*** Successful run." << std::endl;
194 if (tApp !=
nullptr) {
198 }
catch (std::exception&
e) {
199 std::cerr << e.what() <<
"\n";
202 std::cout <<
"*** Done." << std::endl;