LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
CVNImageUtils.h
Go to the documentation of this file.
1 
7 #ifndef LCVN_IMAGE_UTILS_H
8 #define LCVN_IMAGE_UTILS_H
9 
10 #include <vector>
11 
13 
14 namespace lcvn {
15 
17  typedef std::vector<std::vector<unsigned char>> ViewVector;
18  typedef std::vector<ViewVector> ImageVector;
19  typedef std::vector<std::vector<float>> ViewVectorF;
20  typedef std::vector<ViewVectorF> ImageVectorF;
21 
23  class CVNImageUtils {
24  public:
25  CVNImageUtils();
26  CVNImageUtils(unsigned int nWires, unsigned int nTDCs, unsigned int nViews);
27 
31  void EnableRegionSelection();
32 
34  unsigned char ConvertChargeToChar(float charge);
35 
37  void SetImageSize(unsigned int nWires, unsigned int nTDCs, unsigned int nViews);
38 
40  void SetViewReversal(bool reverseX, bool reverseY, bool reverseZ);
41  void SetViewReversal(std::vector<bool> reverseViews);
42 
44  void SetLogScale(bool setLog);
45 
47  void SetPixelMapSize(unsigned int nWires, unsigned int nTDCs);
48 
50  void ConvertPixelMapToPixelArray(const PixelMap& pm, std::vector<unsigned char>& pix);
51 
54  void ConvertChargeVectorsToPixelArray(std::vector<float>& v0pe,
55  std::vector<float>& v1pe,
56  std::vector<float>& v2pe,
57  std::vector<unsigned char>& pix);
58 
60  void ConvertPixelMapToImageVector(const PixelMap& pm, ImageVector& imageVec);
61 
63  void ConvertPixelMapToImageVectorF(const PixelMap& pm, ImageVectorF& imageVec);
64 
66  void ConvertChargeVectorsToImageVector(std::vector<float>& v0pe,
67  std::vector<float>& v1pe,
68  std::vector<float>& v2pe,
69  ImageVector& imageVec);
70 
72  void ConvertChargeVectorsToImageVectorF(std::vector<float>& v0pe,
73  std::vector<float>& v1pe,
74  std::vector<float>& v2pe,
75  ImageVectorF& imageVec);
76 
78  void ConvertPixelArrayToImageVectorF(const std::vector<unsigned char>& pixelArray,
79  ImageVectorF& imageVec);
80 
81  private:
83  void ConvertChargeVectorsToViewVectors(std::vector<float>& v0pe,
84  std::vector<float>& v1pe,
85  std::vector<float>& v2pe,
86  ViewVector& view0,
87  ViewVector& view1,
88  ViewVector& view2);
89 
91  ImageVector BuildImageVector(ViewVector& v0, ViewVector& v1, ViewVector& v2);
92  ImageVectorF BuildImageVectorF(ViewVectorF& v0, ViewVectorF& v1, ViewVectorF& v2);
93 
95  void GetMinMaxWires(std::vector<float>& wireCharges,
96  unsigned int& minWire,
97  unsigned int& maxWire);
98 
100  void GetMinMaxTDCs(std::vector<float>& tdcCharges, unsigned int& minTDC, unsigned int& maxTDC);
101 
103  void ReverseView(std::vector<float>& peVec);
104 
106  ViewVectorF ConvertViewVecToViewVecF(ViewVector& view);
107 
109  ImageVectorF ConvertImageVecToImageVecF(ImageVector& image);
110 
112  unsigned int fNViews;
113 
115  unsigned int fNWires;
116 
118  unsigned int fNTDCs;
119 
121  unsigned int fPixelMapWires;
122  unsigned int fPixelMapTDCs;
123 
125  std::vector<bool> fViewReverse;
126 
129 
132  };
133 
134 }
135 
136 #endif // CVN_IMAGE_UTILS_H
ImageVectorF BuildImageVectorF(ViewVectorF &v0, ViewVectorF &v1, ViewVectorF &v2)
void GetMinMaxWires(std::vector< float > &wireCharges, unsigned int &minWire, unsigned int &maxWire)
Get the minimum and maximum wires from the pixel map needed to make the image.
void ConvertChargeVectorsToPixelArray(std::vector< float > &v0pe, std::vector< float > &v1pe, std::vector< float > &v2pe, std::vector< unsigned char > &pix)
unsigned int fPixelMapTDCs
ViewVectorF ConvertViewVecToViewVecF(ViewVector &view)
Convert a ViewVector into a ViewVectorF.
Class containing some utility functions for all things CVN.
Definition: CVNImageUtils.h:23
void ConvertPixelArrayToImageVectorF(const std::vector< unsigned char > &pixelArray, ImageVectorF &imageVec)
Convert a pixel array into a ImageVectorF.
std::vector< std::vector< unsigned char > > ViewVector
Useful typedefs.
Definition: CVNImageUtils.h:17
void ReverseView(std::vector< float > &peVec)
Funtion to actually reverse the view.
PixelMap, basic input to CVN neural net.
Definition: PixelMap.h:20
void ConvertPixelMapToPixelArray(const PixelMap &pm, std::vector< unsigned char > &pix)
Convert a Pixel Map object into a single pixel array with an image size nWire x nTDC.
Utility class for truth labels.
void ConvertPixelMapToImageVectorF(const PixelMap &pm, ImageVectorF &imageVec)
Convert a pixel map into an image vector (float version)
bool fDisableRegionSelection
Disable the region finding?
PixelMap for CVN.
unsigned char ConvertChargeToChar(float charge)
Convert the hit charge into the range 0 to 255 required by the CVN.
void SetLogScale(bool setLog)
Set the log scale for charge.
void SetPixelMapSize(unsigned int nWires, unsigned int nTDCs)
Set the input pixel map size.
bool fUseLogScale
Use a log scale for charge?
void ConvertChargeVectorsToViewVectors(std::vector< float > &v0pe, std::vector< float > &v1pe, std::vector< float > &v2pe, ViewVector &view0, ViewVector &view1, ViewVector &view2)
Base function for conversion of the Pixel Map to our required output format.
void GetMinMaxTDCs(std::vector< float > &tdcCharges, unsigned int &minTDC, unsigned int &maxTDC)
Get the minimum and maximum tdcs from the pixel map needed to make the image.
std::vector< ViewVector > ImageVector
Definition: CVNImageUtils.h:18
unsigned int fNViews
Number of views of each event.
unsigned int fNTDCs
Number of TDCs to use for the image height.
ImageVector BuildImageVector(ViewVector &v0, ViewVector &v1, ViewVector &v2)
Make the image vector from the view vectors.
void ConvertChargeVectorsToImageVector(std::vector< float > &v0pe, std::vector< float > &v1pe, std::vector< float > &v2pe, ImageVector &imageVec)
Convert three adc vectors into an image vector (contains all three views)
void EnableRegionSelection()
Enable the selection of the wire region.
ImageVectorF ConvertImageVecToImageVecF(ImageVector &image)
Convert a ImageVector into a ImageVectorF.
unsigned int fPixelMapWires
Input pixel map sizes.
std::vector< std::vector< float > > ViewVectorF
Definition: CVNImageUtils.h:19
void DisableRegionSelection()
Disable the selection of the wire region and just use the first 500 wires.
std::vector< bool > fViewReverse
Vector of bools to decide if any views need to be reversed.
void ConvertChargeVectorsToImageVectorF(std::vector< float > &v0pe, std::vector< float > &v1pe, std::vector< float > &v2pe, ImageVectorF &imageVec)
Float version of conversion for convenience of TF interface.
std::vector< ViewVectorF > ImageVectorF
Definition: CVNImageUtils.h:20
unsigned int fNWires
Number of wires to use for the image width.
void ConvertPixelMapToImageVector(const PixelMap &pm, ImageVector &imageVec)
Convert a pixel map into an image vector (contains all three views)
void SetImageSize(unsigned int nWires, unsigned int nTDCs, unsigned int nViews)
Set up the image size that we want to have.
void SetViewReversal(bool reverseX, bool reverseY, bool reverseZ)
Function to set any views that need reversing.