SparsePixelMap.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file SparsePixelMap.h
3 /// \brief Sparse pixel map for CVN
4 /// \author Jeremy Hewes - jhewes15@fnal.gov
5 ////////////////////////////////////////////////////////////////////////
6 
7 #pragma once
8 
9 #include <vector>
10 
11 namespace cvn
12 {
13 
15  {
16  public:
17  SparsePixelMap(unsigned int dim, unsigned int views, bool usePixelTruth=false);
20 
21  void AddHit(unsigned int view, std::vector<float> coordinates, std::vector<float> features);
22  void AddHit(unsigned int view, std::vector<float> coordinates, std::vector<float> features, std::vector<int> pdgs,
23  std::vector<int> tracks, std::vector<float> energies, std::vector<std::string> processes);
24  unsigned int GetDim() const { return fDim; };
25  unsigned int GetViews() const { return fViews; }
26  std::vector<unsigned int> GetNPixels() const;
27  unsigned int GetNPixels(size_t view) const { return fFeatures[view].size(); };
28 
29  std::vector<std::vector<std::vector<float>>> GetCoordinates() const { return fCoordinates; };
30  std::vector<std::vector<float>> GetCoordinates(size_t view) const { return fCoordinates[view]; };
31 
32  std::vector<std::vector<std::vector<float>>> GetFeatures() const { return fFeatures; };
33  std::vector<std::vector<float>> GetFeatures(size_t view) const { return fFeatures[view]; };
34 
35  std::vector<std::vector<std::vector<int>>> GetPixelPDGs() const { return fPixelPDGs; };
36  std::vector<std::vector<int>> GetPixelPDGs(size_t view) const { return fPixelPDGs[view]; };
37 
38  std::vector<std::vector<std::vector<int>>> GetPixelTrackIDs() const {return fPixelTrackIDs; };
39  std::vector<std::vector<int>> GetPixelTrackIDs(size_t view) const {return fPixelTrackIDs[view]; };
40 
41  std::vector<std::vector<std::vector<float>>> GetPixelEnergies() const {return fPixelEnergies; };
42  std::vector<std::vector<float>> GetPixelEnergies(size_t view) const {return fPixelEnergies[view]; };
43 
44  std::vector<std::vector<std::vector<std::string>>> GetProcesses() const { return fProcesses; };
45  std::vector<std::vector<std::string>> GetProcesses(size_t view) const { return fProcesses[view]; };
46 
47 
48 
49  private:
50 
51  template <class T>
52  std::vector<T> FlattenVector(std::vector<std::vector<T>> vec) const {
53  std::vector<T> ret;
54  for (auto it : vec) {
55  ret.insert(ret.end(), it.begin(), it.end());
56  }
57  return ret;
58  }
59 
60  unsigned int fDim; ///< Dimensionality of each pixel map
61  unsigned int fViews; ///< Number of views
62  bool fUsePixelTruth; ///< Whether to use a per-pixel ground truth for pixel segmentation
63  std::vector<std::vector<std::vector<float>>> fCoordinates; ///< Coordinates of non-zero pixels
64  std::vector<std::vector<std::vector<float>>> fFeatures; ///< Features of non-zero pixels
65  std::vector<std::vector<std::vector<int>>> fPixelPDGs; ///< True particle PDG responsible for pixel
66  std::vector<std::vector<std::vector<int>>> fPixelTrackIDs; ///< G4 track IDs responsible for pixelel
67  std::vector<std::vector<std::vector<float>>> fPixelEnergies;
68  std::vector<std::vector<std::vector<std::string>>> fProcesses; // physics process that created the particle
69 
70  }; // class SparsePixelMap
71 } // namespace cvn
std::vector< std::vector< std::vector< int > > > GetPixelTrackIDs() const
coordinates
Definition: geo_types.h:121
std::vector< std::vector< int > > GetPixelTrackIDs(size_t view) const
void AddHit(unsigned int view, std::vector< float > coordinates, std::vector< float > features)
Default AddHit implementation, which just adds pixel value and coordinates.
std::vector< std::vector< std::vector< std::string > > > fProcesses
std::vector< std::vector< float > > GetFeatures(size_t view) const
unsigned int fViews
Number of views.
std::vector< std::vector< std::vector< std::string > > > GetProcesses() const
struct vector vector
std::vector< std::vector< int > > GetPixelPDGs(size_t view) const
std::vector< std::vector< std::vector< int > > > fPixelPDGs
True particle PDG responsible for pixel.
std::vector< std::vector< std::vector< int > > > fPixelTrackIDs
G4 track IDs responsible for pixelel.
std::vector< std::vector< std::vector< float > > > fFeatures
Features of non-zero pixels.
Utility class for truth labels.
std::vector< std::vector< std::vector< float > > > GetFeatures() const
const char features[]
Definition: feature_tests.c:2
std::vector< T > FlattenVector(std::vector< std::vector< T >> vec) const
std::vector< unsigned int > GetNPixels() const
std::vector< std::vector< std::vector< float > > > fCoordinates
Coordinates of non-zero pixels.
unsigned int GetDim() const
unsigned int GetNPixels(size_t view) const
std::vector< std::vector< std::vector< float > > > fPixelEnergies
bool fUsePixelTruth
Whether to use a per-pixel ground truth for pixel segmentation.
Definition: tracks.py:1
std::vector< std::vector< float > > GetPixelEnergies(size_t view) const
std::vector< std::vector< std::vector< float > > > GetCoordinates() const
std::vector< std::vector< std::vector< int > > > GetPixelPDGs() const
std::vector< std::vector< std::string > > GetProcesses(size_t view) const
std::vector< std::vector< float > > GetCoordinates(size_t view) const
unsigned int GetViews() const
std::vector< std::vector< std::vector< float > > > GetPixelEnergies() const
unsigned int fDim
Dimensionality of each pixel map.