BasicProngVars.cxx
Go to the documentation of this file.
2 
3 namespace SliceLID
4 {
5 
7  return a->TotalLength() > b->TotalLength();
8 }
9 
10 void BasicProngVars::reserveVectors(size_t nProngs)
11 {
12  len .reserve(nProngs);
13  calE.reserve(nProngs);
14 }
15 
17  const art::Event &evt,
18  const std::vector<art::Ptr<rb::Vertex>> &elastics,
19  const std::string &baseLabel,
20  const std::string &assnLabel,
21  std::vector<art::Ptr<rb::Prong>> &prongs
22 )
23 {
24  auto png_fmp = art::FindManyP<rb::Prong>(
25  elastics, evt, art::InputTag(baseLabel, assnLabel)
26  );
27 
28  if (! png_fmp.isValid()) {
29  return false;
30  }
31 
32  prongs = png_fmp.at(0);
33  std::sort(prongs.begin(), prongs.end(), sortByLength);
34 
35  return true;
36 }
37 
39 {
40  if (! hasProngs) {
41  return;
42  }
43 
44  reserveVectors(prongs.size());
45 
46  for (size_t pngIdx = 0; pngIdx < prongs.size(); ++pngIdx)
47  {
48  const rb::Prong &prong = *prongs[pngIdx];
49  len .push_back(prong.TotalLength());
50  calE.push_back(prong.CalorimetricEnergy());
51  }
52 }
53 
55  const art::Event &evt,
56  const std::vector<art::Ptr<rb::Vertex>> &elastics
57 )
58 {
59  if (elastics.empty()) {
60  return;
61  }
62 
64  evt, elastics, fuzzykLabel, fuzzykAssnLabel, prongs
65  );
66 }
67 
69  const art::Event &evt,
70  const std::vector<art::Ptr<rb::Vertex>> &elastics,
71  const std::string &fuzzykLabel,
73 )
74  : fuzzykLabel(fuzzykLabel),
75  fuzzykAssnLabel(fuzzykAssnLabel)
76 {
77  initProngs(evt, elastics);
78  initBasicVars();
79 }
80 
82  std::unordered_map<std::string, std::vector<double>> &dict,
83  const std::string &prefix
84 ) const
85 {
86  dict.emplace(prefix + "len", len);
87  dict.emplace(prefix + "calE", calE);
88 }
89 
90 }
const XML_Char int len
Definition: expat.h:262
bool sortByLength(const art::Ptr< rb::Prong > &a, const art::Ptr< rb::Prong > &b)
BasicProngVars(const art::Event &evt, const std::vector< art::Ptr< rb::Vertex >> &elastics, const std::string &fuzzykLabel, const std::string &fuzzykAssnLabel)
bool getProngs(const art::Event &evt, const std::vector< art::Ptr< rb::Vertex >> &elastics, const std::string &baseLabel, const std::string &assnLabel, std::vector< art::Ptr< rb::Prong >> &prongs)
std::vector< art::Ptr< rb::Prong > > prongs
virtual double TotalLength() const
Distance along prong to reach last cell hit.
Definition: Prong.cxx:186
double CalorimetricEnergy(EEnergyCalcScheme escheme=kRecomputeEnergy) const
Simple estimate of neutrino energy.
Definition: Cluster.cxx:439
std::vector< double > calE
const double a
int evt
const XML_Char * prefix
Definition: expat.h:380
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
A Cluster with defined start position and direction.
Definition: Prong.h:19
const hit & b
Definition: hits.cxx:21
void saveToDict(std::unordered_map< std::string, std::vector< double >> &dict, const std::string &prefix) const
void initProngs(const art::Event &evt, const std::vector< art::Ptr< rb::Vertex >> &elastics)
void reserveVectors(size_t nProngs)
Definition: fwd.h:28