BasicProngVars.cxx
Go to the documentation of this file.
2 
3 namespace LSTME
4 {
5 
7  return a->TotalLength() > b->TotalLength();
8 }
9 
10 void BasicProngVars::reserveVectors(size_t nProngs)
11 {
12  dir_x .reserve(nProngs);
13  dir_y .reserve(nProngs);
14  dir_z .reserve(nProngs);
15 
16  start_x.reserve(nProngs);
17  start_y.reserve(nProngs);
18  start_z.reserve(nProngs);
19 
20  nhit .reserve(nProngs);
21  nhitx .reserve(nProngs);
22  nhity .reserve(nProngs);
23  nplane .reserve(nProngs);
24  len .reserve(nProngs);
25  calE .reserve(nProngs);
26 
27  weightedCalE.reserve(nProngs);
28 }
29 
31 {
32  if (! hasProngs) {
33  return;
34  }
35 
36  reserveVectors(prongs.size());
37 
38  for (size_t pngIdx = 0; pngIdx < prongs.size(); ++pngIdx)
39  {
40  const rb::Prong &prong = *prongs[pngIdx];
41 
42  dir_x .push_back(prong.Dir().X());
43  dir_y .push_back(prong.Dir().Y());
44  dir_z .push_back(prong.Dir().Z());
45 
46  start_x.push_back(prong.Start().X());
47  start_y.push_back(prong.Start().Y());
48  start_z.push_back(prong.Start().Z());
49 
50  nhit .push_back(prong.NCell());
51  nhitx .push_back(prong.NXCell());
52  nhity .push_back(prong.NYCell());
53  nplane .push_back(prong.ExtentPlane());
54  len .push_back(prong.TotalLength());
55  calE .push_back(prong.CalorimetricEnergy());
56 
57  if (hasWeightedProngs) {
58  weightedCalE.push_back(
59  weightedProngs[pngIdx]->CalorimetricEnergy()
60  );
61  }
62  else {
63  weightedCalE.push_back(0);
64  }
65  }
66 }
67 
69  const art::Event &evt,
70  const std::vector<art::Ptr<rb::Vertex>> &elastics,
71  const std::string &baseLabel,
72  const std::string &assnLabel,
73  std::vector<art::Ptr<rb::Prong>> &prongs
74 )
75 {
76  auto png_fmp = art::FindManyP<rb::Prong>(
77  elastics, evt, art::InputTag(baseLabel, assnLabel)
78  );
79 
80  if (! png_fmp.isValid()) {
81  return false;
82  }
83 
84  prongs = png_fmp.at(0);
85  std::sort(prongs.begin(), prongs.end(), sortByLength);
86 
87  return true;
88 }
89 
91  const art::Event &evt,
92  const std::string &baseLabel,
93  const std::string &assnLabel,
95 )
96 {
97  auto weightedPng_fmp = art::FindManyP<rb::WeightedProng>(
98  prongs, evt, art::InputTag(baseLabel, assnLabel)
99  );
100 
101  if (! weightedPng_fmp.isValid()) {
102  return false;
103  }
104 
105  for (size_t i = 0; i < prongs.size(); i++) {
106  /* OMG */
107  weightedProngs.push_back(weightedPng_fmp.at(i)[0]);
108  }
109 
110  return true;
111 }
112 
114  const art::Event &evt,
115  const std::vector<art::Ptr<rb::Vertex>> &elastics
116 )
117 {
118  if (elastics.empty()) {
119  return;
120  }
121 
123  evt, elastics, fuzzykLabel, fuzzykAssnLabel, prongs
124  );
125 
126  if (! hasProngs) {
127  return;
128  }
129 
132  );
133 }
134 
136  const art::Event &evt,
137  const std::vector<art::Ptr<rb::Vertex>> &elastics,
138  const std::string &fuzzykLabel,
141 )
142  : hasProngs(false), hasWeightedProngs(false),
143  fuzzykLabel(fuzzykLabel),
144  fuzzykAssnLabel(fuzzykAssnLabel),
145  fuzzykWeightAssnLabel(fuzzykWeightAssnLabel)
146 {
147  initProngs(evt, elastics);
148  initBasicVars();
149 }
150 
152  std::unordered_map<std::string, std::vector<double>> &dict,
153  const std::string &prefix
154 ) const
155 {
156  dict.emplace(prefix + "dir.x", dir_x);
157  dict.emplace(prefix + "dir.y", dir_y);
158  dict.emplace(prefix + "dir.z", dir_z);
159 
160  dict.emplace(prefix + "start.x", start_x);
161  dict.emplace(prefix + "start.y", start_y);
162  dict.emplace(prefix + "start.z", start_z);
163 
164  dict.emplace(prefix + "nhit", nhit);
165  dict.emplace(prefix + "nhitx", nhitx);
166  dict.emplace(prefix + "nhity", nhity);
167 
168  dict.emplace(prefix + "nplane", nplane);
169  dict.emplace(prefix + "len", len);
170  dict.emplace(prefix + "calE", calE);
171 
172  dict.emplace(prefix + "weightedCalE", weightedCalE);
173 }
174 
175 
176 }
const XML_Char int len
Definition: expat.h:262
unsigned int NCell(geo::View_t view) const
Number of cells in view view.
Definition: Cluster.cxx:134
bool getWeightedProngs(const art::Event &evt, const std::string &baseLabel, const std::string &assnLabel, std::vector< art::Ptr< rb::WeightedProng >> &weightedProngs)
std::vector< double > start_y
std::vector< double > nhitx
std::vector< art::Ptr< rb::WeightedProng > > weightedProngs
std::vector< double > dir_x
std::vector< double > dir_y
void initProngs(const art::Event &evt, const std::vector< art::Ptr< rb::Vertex >> &elastics)
virtual TVector3 Start() const
Definition: Prong.h:73
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::string fuzzykWeightAssnLabel
const double a
virtual TVector3 Dir() const
Unit vector describing prong direction.
Definition: Prong.h:77
int evt
const XML_Char * prefix
Definition: expat.h:380
std::vector< double > calE
unsigned int NYCell() const
Number of cells in the y-view.
Definition: Cluster.h:108
std::vector< art::Ptr< rb::Prong > > prongs
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)
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
A Cluster with defined start position and direction.
Definition: Prong.h:19
std::vector< double > dir_z
unsigned int NXCell() const
Number of cells in the x-view.
Definition: Cluster.h:106
std::vector< double > nhit
const hit & b
Definition: hits.cxx:21
unsigned int ExtentPlane(geo::View_t view=geo::kXorY) const
Definition: Cluster.h:250
std::vector< double > nhity
std::vector< double > weightedCalE
std::string fuzzykAssnLabel
void reserveVectors(size_t nProngs)
std::vector< double > start_z
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, const std::string &fuzzykWeightAssnLabel)
std::vector< double > nplane
Definition: fwd.h:28
std::vector< double > start_x