21 #include <TApplication.h>
22 #include <boost/program_options.hpp>
23 #include <nlohmann/json.hpp>
25 #define BOOST_AVAILABLE 1
26 #if ((BOOST_VERSION / 100) % 1000) <= 71
28 #include <boost/progress.hpp>
33 #include <boost/timer/progress_display.hpp>
40 using namespace boost::program_options;
43 int main(
int argc,
char** argv) {
44 std::cout <<
"*** Material Composition plotting " << std::endl;
50 auto ao = description.add_options();
51 ao(
"help,h",
"Display this help message");
52 ao(
"silent,s", bool_switch(),
"Silent mode (without X-window/display).");
53 ao(
"input,i", value<std::string>()->default_value(
""),
54 "Input ROOT file containing the input TTree.");
55 ao(
"tree,t", value<std::string>()->default_value(
"material-tracks"),
57 ao(
"output,o", value<std::string>()->default_value(
""),
58 "Output ROOT file with histograms");
59 ao(
"bins,b", value<unsigned int>()->default_value(60),
60 "Number of bins in eta/phi");
61 ao(
"eta,e", value<float>()->default_value(4.),
"Eta range.");
62 ao(
"sub-names",
value<std::vector<std::string>>()->multitoken(),
63 "Subdetector names.");
64 ao(
"sub-rmin", value<VariableReals>(),
"Minimal radial restrictions.");
65 ao(
"sub-rmax", value<VariableReals>(),
"Maximal radial restrictions.");
66 ao(
"sub-zmin", value<VariableReals>(),
"Minimal z radial restrictions");
67 ao(
"sub-zmax", value<VariableReals>(),
"Maximal z radial restrictions.");
68 ao(
"config,c", value<std::string>(),
"Configuration file (json).");
75 if (vm.count(
"help") != 0
u) {
85 unsigned int bins = vm[
"bins"].as<
unsigned int>();
86 float eta = vm[
"eta"].as<
float>();
89 std::vector<Region> dRegion = {};
91 if (vm.count(
"config") > 0) {
93 std::cout <<
"Reading region configuration from JSON: " << config
97 std::cerr <<
"Configuration file does not exist." << std::endl;
101 std::ifstream ifs(config.string().c_str());
104 for (
const auto& [key, regions] : j.items()) {
105 dRegion.push_back(
Region{key, {}});
106 auto& reg = dRegion.back();
107 std::cout <<
"Region(" << key <<
")" << std::endl;
108 for (
const auto& region : regions) {
109 float rmin = region[
"rmin"].template get<float>();
110 float rmax = region[
"rmax"].template get<float>();
111 float zmin = region[
"zmin"].template get<float>();
112 float zmax = region[
"zmax"].template get<float>();
114 reg.boxes.push_back({rmin, rmax, zmin, zmax});
115 std::cout <<
"* " << key <<
" r/z: " << rmin <<
"/" << rmax <<
" "
116 << zmin <<
"/" << zmax << std::endl;
120 auto snames = vm[
"sub-names"].as<std::vector<std::string>>();
126 size_t subs = snames.size();
128 if (subs != rmins.size() or subs != rmaxs.size() or
129 subs != zmins.size() or subs != zmaxs.size()) {
130 std::cerr <<
"Configuration problem." << std::endl;
135 for (
unsigned int is = 0; is < subs; ++is) {
138 {{
static_cast<float>(rmins[is]), static_cast<float>(rmaxs[is]),
139 static_cast<float>(zmins[is]), static_cast<float>(zmaxs[is])}}});
144 vm[
"silent"].as<
bool>()
146 :
new TApplication(
"ResidualAndPulls",
nullptr,
nullptr);
150 if (tApp !=
nullptr) {
154 }
catch (std::exception&
e) {
155 std::cerr << e.what() <<
"\n";
158 std::cout <<
"*** Done." << std::endl;