RegCNNImageUtils.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file RegCNNImageUtils.h
3 /// \brief Utilities for producing images for the RegCNN
4 /// \author Leigh Whitehead - leigh.howard.whitehead@cern.ch
5 ////////////////////////////////////////////////////////////////////////
6 
7 #ifndef RegCNN_IMAGE_UTILS_H
8 #define RegCNN_IMAGE_UTILS_H
9 
10 #include <vector>
11 
13 
14 namespace cnn
15 {
16 
17  /// Useful typedefs
18  typedef std::vector<std::vector<float> > ViewVectorF;
19  typedef std::vector<ViewVectorF> ImageVectorF;
20 
21  /// Class containing some utility functions for all things RegCNN
23  {
24  public:
26  RegCNNImageUtils(unsigned int nWires, unsigned int nTDCs, unsigned int nViews);
28 
29 
30  /// Function to set any views that need reversing
31  void SetViewReversal(bool reverseX, bool reverseY, bool reverseZ);
32  void SetViewReversal(std::vector<bool> reverseViews);
33 
34  /// Set the input pixel map size
35  void SetPixelMapSize(unsigned int nWires, unsigned int nTDCs);
36 
37 
38  // Scale Charges
39  float ConvertToScaledCharge(float charge);
40 
41  /// Convert a pixel map into an image vector (float version)
42  void ConvertPixelMapToImageVectorF(const RegPixelMap &pm, ImageVectorF &imageVec);
43 
44  /// Float version of conversion for convenience of TF interface
45  void ConvertChargeVectorsToImageVectorF(std::vector<float> &v0pe, std::vector<float> &v1pe,
46  std::vector<float> &v2pe, ImageVectorF &imageVec);
47 
48 
49  private:
50 
51  /// Base function for conversion of the Pixel Map to our required output format
52  void ConvertChargeVectorsToViewVectors(std::vector<float> &v0pe, std::vector<float> &v1pe, std::vector<float> &v2pe,
53  ViewVectorF& view0, ViewVectorF& view1, ViewVectorF& view2);
54 
55  /// Make the image vector from the view vectors
56  ImageVectorF BuildImageVectorF(ViewVectorF v0, ViewVectorF v1, ViewVectorF v2);
57 
58 
59  /// Funtion to actually reverse the view
60  void ReverseView(std::vector<float> &peVec);
61 
62  /// Number of views of each event
63  unsigned int fNViews;
64 
65  /// Input pixel map sizes
66  unsigned int fPixelMapWires;
67  unsigned int fPixelMapTDCs;
68 
69  /// Vector of bools to decide if any views need to be reversed
70  std::vector<bool> fViewReverse;
71 
72  };
73 
74 }
75 
76 #endif // RegCNN_IMAGE_UTILS_H
void ConvertChargeVectorsToViewVectors(std::vector< float > &v0pe, std::vector< float > &v1pe, std::vector< float > &v2pe, ViewVectorF &view0, ViewVectorF &view1, ViewVectorF &view2)
Base function for conversion of the Pixel Map to our required output format.
std::vector< bool > fViewReverse
Vector of bools to decide if any views need to be reversed.
void ReverseView(std::vector< float > &peVec)
Funtion to actually reverse the view.
RegPixelMap, basic input to CNN neural net.
Definition: RegPixelMap.h:22
void SetPixelMapSize(unsigned int nWires, unsigned int nTDCs)
Set the input pixel map size.
std::vector< std::vector< float > > ViewVectorF
Useful typedefs.
void SetViewReversal(bool reverseX, bool reverseY, bool reverseZ)
Function to set any views that need reversing.
unsigned int fPixelMapWires
Input pixel map sizes.
std::vector< ViewVectorF > ImageVectorF
float ConvertToScaledCharge(float charge)
void ConvertPixelMapToImageVectorF(const RegPixelMap &pm, ImageVectorF &imageVec)
Convert a pixel map into an image vector (float version)
ImageVectorF BuildImageVectorF(ViewVectorF v0, ViewVectorF v1, ViewVectorF v2)
Make the image vector from the view vectors.
Defines an enumeration for cellhit classification.
unsigned int fNViews
Number of views of each event.
unsigned int fPixelMapTDCs
Class containing some utility functions for all things RegCNN.
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.
RegPixelMap for RegCNN modified from PixelMap.h.