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