print_config_summary.cc
Go to the documentation of this file.
6 
7 #include <iomanip>
8 #include <iostream>
9 
10 namespace {
11  constexpr cet::HorizontalRule header_rule{50};
12 }
13 
14 //---------------------------------------------------------------
15 void
17  std::string const& header)
18 {
19  auto const names = pset.get_names();
20  std::cout << header << ": " << size(names) << '\n';
21 }
22 
23 void
25 {
26  std::cout << "Trigger paths: " << size(enabled_modules.trigger_path_specs())
27  << '\n'
28  << (enabled_modules.trigger_paths_override() ?
29  " -> 'trigger_paths' specified\n" :
30  "")
31  << "End paths: " << size(enabled_modules.end_paths()) << '\n'
32  << (enabled_modules.end_paths_override() ?
33  " -> 'end_paths' specified\n" :
34  "");
35 }
36 
37 void
39 {
40  {
41  auto const& trigger_paths = enabled_modules.trigger_path_specs();
42  std::cout << '\n'
43  << header_rule('=') << '\n'
44  << "Trigger paths: " << size(trigger_paths) << "\n"
45  << (enabled_modules.trigger_paths_override() ?
46  " -> 'trigger_paths' specified\n\n" :
47  "\n");
48  if (empty(trigger_paths)) {
49  return;
50  }
51 
52  std::string column_0{"Bit"};
53  std::string column_1{"Path name"};
54  std::string column_2{"Path size"};
55 
56  auto column_1_width = size(column_1);
57  for (auto const& pr : trigger_paths) {
58  column_1_width = std::max(column_1_width, size(pr.first.name));
59  }
60 
61  std::cout << column_0 << " " << std::left << std::setw(column_1_width)
62  << column_1 << " " << column_2 << '\n'
63  << "---"
64  << " " << std::string(column_1_width, '-') << " "
65  << std::string(size(column_2), '-') << '\n';
66  for (auto const& [path_spec, entries] :
67  enabled_modules.trigger_path_specs()) {
68  std::cout << std::right << std::setw(3) << to_string(path_spec.path_id)
69  << " " << std::left << std::setw(column_1_width)
70  << path_spec.name << " " << size(entries) << '\n';
71  }
72  }
73 
74  {
75  auto const& end_paths = enabled_modules.end_paths();
76 
77  std::cout << '\n'
78  << header_rule('=') << '\n'
79  << "End paths: " << size(end_paths) << '\n'
80  << (enabled_modules.end_paths_override() ?
81  " -> 'end_paths' specified\n\n" :
82  "\n");
83 
84  if (empty(end_paths)) {
85  return;
86  }
87 
88  std::string column_1{"Path name"};
89  std::string column_2{"Path size"};
90  auto column_1_width = size(column_1);
91  for (auto const& pr : end_paths) {
92  column_1_width = std::max(column_1_width, size(pr.first.name));
93  }
94 
95  std::cout << std::left << std::setw(column_1_width) << column_1 << " "
96  << column_2 << '\n'
97  << std::string(column_1_width, '-') << " "
98  << std::string(size(column_2), '-') << '\n';
99  for (auto const& [path_spec, entries] : end_paths) {
100  std::cout << std::left << std::setw(column_1_width) << path_spec.name
101  << " " << size(entries) << '\n';
102  }
103  }
104 }
105 
106 void
108 {
109  std::cout << '\n' << header_rule('=') << '\n';
110  print_table_numbers(pset, "Services");
111  std::cout << "\n";
112 
113  auto const names = pset.get_names();
114 
115  std::string column_1{"Service name"};
116  auto column_1_width = size(column_1);
117  auto column_2_width = std::string::size_type{};
118  for (auto const& name : names) {
119  auto const service_provider =
120  pset.get<std::string>(fhicl_key(name, "service_provider"), {});
121  column_1_width = std::max(column_1_width, size(name));
122  column_2_width = std::max(column_2_width, size(service_provider));
123  }
124 
125  cet::HorizontalRule const rule_1{column_1_width};
126  if (column_2_width == 0ull) {
127  std::cout << column_1 << '\n' << rule_1('-') << '\n';
128  for (auto const& name : names) {
129  std::cout << std::left << std::setw(column_1_width) << name << '\n';
130  }
131  } else {
132  std::string const column_2{"service_provider"};
133  cet::HorizontalRule const rule_2{std::max(column_2_width, size(column_2))};
134  std::cout << std::left << std::setw(column_1_width) << column_1 << " "
135  << column_2 << '\n'
136  << rule_1('-') << " " << rule_2('-') << '\n';
137  for (auto const& name : names) {
138  auto const service_provider =
139  pset.get<std::string>(fhicl_key(name, "service_provider"), "-");
140  std::cout << std::left << std::setw(column_1_width) << name << " "
141  << service_provider << '\n';
142  }
143  }
144 }
145 
146 void
148  std::string const& header)
149 {
150  std::cout << '\n' << header_rule('=') << "\n";
151  print_table_numbers(pset, header);
152 
153  auto const names = pset.get_names();
154  if (empty(names)) {
155  return;
156  }
157 
158  std::cout << "\n";
159  std::string column_1{"Module label"};
160  std::string column_2{"module_type"};
161  auto column_1_width = size(column_1);
162  auto column_2_width = size(column_2);
163  for (auto const& name : names) {
164  auto const module_type =
165  pset.get<std::string>(fhicl_key(name, "module_type"));
166  column_1_width = std::max(column_1_width, size(name));
167  column_2_width = std::max(column_2_width, size(module_type));
168  }
169 
170  cet::HorizontalRule const rule_1{column_1_width};
171  cet::HorizontalRule const rule_2{column_2_width};
172  std::cout << std::left << std::setw(column_1_width) << column_1 << " "
173  << column_2 << '\n'
174  << rule_1('-') << " " << rule_2('-') << '\n';
175  for (auto const& name : names) {
176  auto const module_type =
177  pset.get<std::string>(fhicl_key(name, "module_type"));
178  std::cout << std::left << std::setw(column_1_width) << name << " "
179  << module_type << '\n';
180  }
181 }
182 
183 void
185  std::string const& verbosity,
186  EnabledModules const& enabled_modules)
187 {
188  auto const process_name = pset.get<std::string>("process_name");
189  auto const source = pset.get<std::string>("source.module_type");
190  auto const services = pset.get<fhicl::ParameterSet>("services");
191  auto const physics = pset.get<fhicl::ParameterSet>("physics", {});
192  auto const analyzers = physics.get<fhicl::ParameterSet>("analyzers", {});
193  auto const filters = physics.get<fhicl::ParameterSet>("filters", {});
194  auto const producers = physics.get<fhicl::ParameterSet>("producers", {});
195  auto const outputs = pset.get<fhicl::ParameterSet>("outputs", {});
196 
197  std::cout << "Process name: " << process_name << '\n'
198  << "Source module: " << source << '\n';
199  if (verbosity == "brief") {
200  print_table_numbers(services, "Services");
201  print_table_numbers(producers, "Producers");
202  print_table_numbers(filters, "Filters");
203  print_table_numbers(analyzers, "Analyzers");
204  print_table_numbers(outputs, "Output modules");
205  print_path_numbers(enabled_modules);
206  return;
207  } else if (verbosity == "detailed") {
208  print_service_types(services);
209  std::cout << '\n' << header_rule('=') << '\n' << "Physics modules\n\n";
210  print_table_numbers(producers, "Producers");
211  print_table_numbers(filters, "Filters");
212  print_table_numbers(analyzers, "Analyzers");
213  print_module_types(outputs, "Output modules");
214  print_path_names(enabled_modules);
215  return;
216  } else if (verbosity == "full") {
217  print_service_types(services);
218  print_module_types(producers, "Producers");
219  print_module_types(filters, "Filters");
220  print_module_types(analyzers, "Analyzers");
221  print_module_types(outputs, "Output modules");
222  print_path_names(enabled_modules);
223  return;
224  }
226  << "Unrecognized configuration-summary verbosity level: '" << verbosity
227  << "'\n";
228 }
static QCString name
Definition: declinfo.cpp:673
void print_config_summary(fhicl::ParameterSet const &pset, std::string const &verbosity, EnabledModules const &enabled_modules)
std::string string
Definition: nybbler.cc:12
void print_service_types(fhicl::ParameterSet const &pset)
void print_module_types(fhicl::ParameterSet const &pset, std::string const &header)
PathID path_id
Definition: PathSpec.h:49
ModuleType module_type(std::string const &full_key)
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
void print_table_numbers(fhicl::ParameterSet const &pset, std::string const &header)
module_entries_for_ordered_path_t end_paths() const noexcept
T get(std::string const &key) const
Definition: ParameterSet.h:271
std::enable_if_t< std::is_convertible_v< T, std::string >, std::string > fhicl_key(T const &name)
Definition: fhicl_key.h:12
module_entries_for_ordered_path_t const & trigger_path_specs() const noexcept
static int max(int a, int b)
std::string name
Definition: PathSpec.h:48
bool end_paths_override() const noexcept
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
bool trigger_paths_override() const noexcept
std::vector< std::string > get_names() const
void print_path_numbers(EnabledModules const &enabled_modules)
PathSpec path_spec(std::string const &path_spec)
Definition: PathSpec.cc:22
static std::vector< std::string > const names
Definition: FragmentType.hh:8
def filters(nticks=9600, tick=0.5 *units.us, npitches=3000, pitch=1.0)
Definition: __init__.py:555
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:97
void print_path_names(EnabledModules const &enabled_modules)