All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Namespaces | Functions
PCAnglePlaneMaker_module.cc File Reference
#include "art/Framework/Core/EDProducer.h"
#include "art/Framework/Core/ModuleMacros.h"
#include "art/Framework/Principal/Event.h"
#include "art/Framework/Principal/Handle.h"
#include "art/Framework/Principal/Run.h"
#include "art/Framework/Principal/SubRun.h"
#include "canvas/Utilities/InputTag.h"
#include "fhiclcpp/ParameterSet.h"
#include "messagefacility/MessageLogger/MessageLogger.h"
#include "lardata/Utilities/AssociationUtil.h"
#include "lardataobj/RecoBase/PFParticle.h"
#include <memory>
#include "lardataobj/RecoBase/Wire.h"
#include "lardataobj/RecoBase/Vertex.h"
#include "lardataobj/RecoBase/Hit.h"
#include "lardataobj/RecoBase/Cluster.h"
#include "larcore/Geometry/Geometry.h"
#include "larcorealg/Geometry/GeometryCore.h"
#include "lardataalg/DetectorInfo/DetectorPropertiesStandard.h"
#include "lardata/DetectorInfoServices/DetectorPropertiesService.h"
#include "sbnobj/Common/Reco/PCAnglePlane.h"
#include "PCA.h"

Go to the source code of this file.

Classes

struct  sbn::PCAngleInfo
 
class  sbn::PCAnglePlaneMaker
 

Namespaces

 sbn
 This module creates Common Analysis Files.
 

Functions

void SaveHits (std::map< unsigned, std::array< std::vector< unsigned >, 3 >> &pfpToHits, const std::vector< art::Ptr< recob::Hit >> &hits, unsigned plane, const art::Ptr< recob::PFParticle > &pfp)
 
std::array< std::vector
< art::Ptr< recob::Hit > >, 3 > 
SortHits (const std::array< std::vector< art::Ptr< recob::Hit >>, 3 > &hits, const recob::Vertex &start, const geo::GeometryCore *geo, const detinfo::DetectorPropertiesData &dprop)
 
bool DoBranch (art::Ptr< recob::PFParticle > particle, const std::map< unsigned, art::Ptr< recob::PFParticle >> &pfpMap)
 
std::map< unsigned,
std::vector< sbn::PCAngleInfo > > 
RemoveDupes (std::vector< sbn::PCAngleInfo > &angles)
 

Function Documentation

bool DoBranch ( art::Ptr< recob::PFParticle particle,
const std::map< unsigned, art::Ptr< recob::PFParticle >> &  pfpMap 
)

Definition at line 127 of file PCAnglePlaneMaker_module.cc.

127  {
128  (void) particle;
129  (void) pfpMap;
130 
131  return true;
132 }
j template void())
Definition: json.hpp:3108
std::map<unsigned, std::vector<sbn::PCAngleInfo> > RemoveDupes ( std::vector< sbn::PCAngleInfo > &  angles)

Definition at line 135 of file PCAnglePlaneMaker_module.cc.

135  {
136  // We will eliminate duplicates by converting to a set and then back to a vector
137  //
138  // Define a struct to implement the comparator
139  struct angle_compare {
140  bool operator() (const sbn::PCAngleInfo &lhs, const sbn::PCAngleInfo &rhs) const {
141  // unique ID is hitID, hitIDLo, hitIDHi
142  if (lhs.angle.hitID != rhs.angle.hitID) return lhs.angle.hitID < rhs.angle.hitID;
143  if (lhs.angle.hitIDLo != rhs.angle.hitIDLo) return lhs.angle.hitIDLo < rhs.angle.hitIDLo;
144  if (lhs.angle.hitIDHi != rhs.angle.hitIDHi) return lhs.angle.hitIDHi < rhs.angle.hitIDHi;
145  // equal
146  return false;
147  }
148  };
149 
150  // Given the choice, we want to keep angles with a smaller generation.
151  //
152  // So first sort the input by generation (lo -> hi). So smaller generations
153  // get inserted into the set first
154  std::sort(angles.begin(), angles.end(),
155  [](auto const &lhs, auto const &rhs) {return lhs.generation < rhs.generation;});
156 
157  // make the set to unique-ify the input
158  std::set<sbn::PCAngleInfo, angle_compare> unique(angles.begin(), angles.end());
159 
160  // organize into output
161  std::map<unsigned, std::vector<sbn::PCAngleInfo>> ret;
162  for (const sbn::PCAngleInfo &angle: unique) {
163  ret[angle.branch].push_back(angle);
164  }
165 
166  // sort each ret by the hit order
167  for (auto &pair: ret) {
168  std::sort(pair.second.begin(), pair.second.end(),
169  [](auto const &lhs, auto const &rhs) {
170  return lhs.hit_ind < rhs.hit_ind;
171  });
172  }
173 
174  return ret;
175 }
finds tracks best matching by angle
void SaveHits ( std::map< unsigned, std::array< std::vector< unsigned >, 3 >> &  pfpToHits,
const std::vector< art::Ptr< recob::Hit >> &  hits,
unsigned  plane,
const art::Ptr< recob::PFParticle > &  pfp 
)

Definition at line 78 of file PCAnglePlaneMaker_module.cc.

78  {
79  for (const art::Ptr<recob::Hit> &h: hits) {
80  pfpToHits[pfp.key()][plane].push_back(h.key());
81  }
82 }
while getopts h
std::array<std::vector<art::Ptr<recob::Hit> >, 3> SortHits ( const std::array< std::vector< art::Ptr< recob::Hit >>, 3 > &  hits,
const recob::Vertex start,
const geo::GeometryCore geo,
const detinfo::DetectorPropertiesData dprop 
)

Definition at line 84 of file PCAnglePlaneMaker_module.cc.

87  {
88  // convert data to linked-list
89  std::array<std::list<art::Ptr<recob::Hit>>, 3> planar {};
90  for (unsigned i_plane = 0; i_plane < 3; i_plane++) {
91  planar[i_plane].insert(planar[i_plane].begin(), hits[i_plane].begin(), hits[i_plane].end());
92  }
93 
94  // start from the zeroth hit and grow from the nearest hit
95  std::array<std::vector<art::Ptr<recob::Hit>>, 3> ret {};
96  for (unsigned i = 0; i < 3; i++) {
97  if (planar[i].size()) {
98 
99  // find the zeroth hit
100  std::list<art::Ptr<recob::Hit>>::iterator firstHit = std::min_element(planar[i].begin(), planar[i].end(),
101  [start, geo, dprop](auto const &lhs, auto const &rhs) {
102  return sbnpca::Vert2HitDistance(*lhs, start, geo, dprop) < sbnpca::Vert2HitDistance(*rhs, start, geo, dprop);
103  });
104  ret[i].push_back(*firstHit);
105  planar[i].erase(firstHit);
106 
107  while (planar[i].size()) {
108  const recob::Hit &lastHit = *ret[i].back();
109  std::list<art::Ptr<recob::Hit>>::iterator closest = std::min_element(planar[i].begin(), planar[i].end(),
110  [lastHit, geo, dprop](auto const &lhs, auto const &rhs) {
111  return sbnpca::HitDistance(*lhs, lastHit, geo, dprop) < sbnpca::HitDistance(*rhs, lastHit, geo, dprop);
112  });
113 
114  ret[i].push_back(*closest);
115  planar[i].erase(closest);
116  }
117  }
118  }
119 
120  return ret;
121 
122 }
float Vert2HitDistance(const recob::Hit &hit, const recob::Vertex &vert, const geo::GeometryCore *geo, const detinfo::DetectorPropertiesData &dprop)
Definition: PCA.cc:174
std::size_t size(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:561
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
float HitDistance(const recob::Hit &A, const recob::Hit &B, const geo::GeometryCore *geo, const detinfo::DetectorPropertiesData &dprop)
Definition: PCA.cc:34
auto begin(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:573
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:48