Png3dVars.cxx
Go to the documentation of this file.
2 
3 namespace SliceLID
4 {
5 
6 std::vector<size_t> Png3dVars::getSortedIndices(
7  const std::vector<double> &values
8 )
9 {
10  std::vector<size_t> result(values.size());
11  std::iota(result.begin(), result.end(), 0);
12 
13  std::sort(
14  result.begin(), result.end(),
15  [values] (const size_t &a, const size_t &b) {
16  return values[a] > values[b];
17  }
18  );
19 
20  return result;
21 }
22 
24  std::unordered_map<std::string, std::vector<double>> &dict,
25  const std::string &key
26 )
27 {
28  const std::vector<size_t> sortedIndices = getSortedIndices(dict.at(key));
29 
30  for (auto &item : dict)
31  {
32  std::vector<double> sortedValues;
33  sortedValues.reserve(item.second.size());
34 
35  for (const size_t sortedIndex : sortedIndices) {
36  sortedValues.push_back(item.second[sortedIndex]);
37  }
38 
39  item.second = std::move(sortedValues);
40  }
41 }
42 
44  std::unordered_map<std::string, std::vector<double>> &dict,
45  const std::string &prefix
46 ) const
47 {
48  std::unordered_map<std::string, std::vector<double>> tmpDict;
49 
50  basicPngVars .saveToDict(tmpDict, prefix);
51  prongCVNVars .saveToDict(tmpDict, prefix);
52  prongShwVars .saveToDict(tmpDict, prefix + "shwlid.");
53  prongShwLIDVars.saveToDict(tmpDict, prefix + "shwlid.");
54 
55  sortDict(tmpDict, prefix + "calE");
56 
57  dict.insert(tmpDict.begin(), tmpDict.end());
58 }
59 
61  const art::Event &evt,
62  const std::vector<art::Ptr<rb::Vertex>> &elastics,
63  const Config &config
64 ) : basicPngVars(
65  evt, elastics,
66  config.fuzzykLabel, config.fuzzyk3dAssnLabel
67  ),
68  prongCVNVars(evt, basicPngVars, config.prongCVNLabel),
69  prongShwVars(evt, basicPngVars, config.prongShwLabel),
71  evt, basicPngVars, config.prongShwLabel, config.prongShwLIDLabel
72  )
73 { }
74 
75 }
static void sortDict(std::unordered_map< std::string, std::vector< double >> &dict, const std::string &key)
Definition: Png3dVars.cxx:23
void saveToDict(std::unordered_map< std::string, std::vector< double >> &dict, const std::string &prefix) const
Definition: config.py:1
Png3dVars(const art::Event &evt, const std::vector< art::Ptr< rb::Vertex >> &elastics, const Config &config)
Definition: Png3dVars.cxx:60
BasicProngVars basicPngVars
Definition: Png3dVars.h:19
const double a
ProngCVNVars prongCVNVars
Definition: Png3dVars.h:20
int evt
ProngShwLIDVars prongShwLIDVars
Definition: Png3dVars.h:22
const XML_Char * prefix
Definition: expat.h:380
ProngShwVars prongShwVars
Definition: Png3dVars.h:21
void saveToDict(std::unordered_map< std::string, std::vector< double >> &dict, const std::string &prefix) const
static std::vector< size_t > getSortedIndices(const std::vector< double > &values)
Definition: Png3dVars.cxx:6
void saveToDict(std::unordered_map< std::string, std::vector< double >> &dict, const std::string &prefix) const
Definition: Png3dVars.cxx:43
const hit & b
Definition: hits.cxx:21
void saveToDict(std::unordered_map< std::string, std::vector< double >> &dict, const std::string &prefix) const
Definition: fwd.h:28
void saveToDict(std::unordered_map< std::string, std::vector< double >> &dict, const std::string &prefix) const
enum BeamMode string