LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
orderedProcessNamesCollection.cc
Go to the documentation of this file.
5 #include "cetlib/container_algorithms.h"
6 
7 #include <iomanip>
8 #include <iostream>
9 #include <set>
10 
11 std::vector<std::vector<std::string>>
13 {
14  std::vector<std::vector<std::string>> result;
15 
16  std::vector<ProcessHistory const*> collapsed_histories;
17  // Collapsed histories are histories that do not overlap with any
18  // others. For example, of the following process histories:
19  //
20  // 1: [A]
21  // 2: [A,B]
22  // 3: [A,B,C]
23  // 4: [A,D]
24  //
25  // The collapsed histories are 3 and 4 since 1 and 2 are subsets of
26  // 3. In otherwords, 3 and 4 are the only histories that do not
27  // have descendants.
28  //
29  // Since the ordering of the histories is determined by a hashed
30  // value, we must compare each history in pairs to determine which
31  // histories do not have descendants.
32  for (auto const& hist_i : histories) {
33  bool found_descendent{false};
34  for (auto const& hist_j : histories) {
35  if (isAncestor(hist_i.second, hist_j.second)) {
36  found_descendent = true;
37  break;
38  }
39  }
40  if (!found_descendent) {
41  collapsed_histories.push_back(&hist_i.second);
42  }
43  }
44 
45  for (auto const history : collapsed_histories) {
46  std::vector<std::string> process_names;
47  cet::transform_all(*history,
48  std::back_inserter(process_names),
49  [](auto const& config) { return config.processName(); });
50  result.push_back(std::move(process_names));
51  }
52 
53  return result;
54 }
std::vector< std::vector< std::string > > orderedProcessNamesCollection(ProcessHistoryMap const &pHistMap)
std::map< ProcessHistoryID const, ProcessHistory > ProcessHistoryMap
bool isAncestor(ProcessHistory const &a, ProcessHistory const &b)