Public Member Functions | Private Member Functions | Private Attributes | List of all members
cvn::RegCVNImageUtils Class Reference

Class containing some utility functions for all things RegCVN. More...

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-11-25/CVN/func/RegCVNImageUtils.h"

Public Member Functions

 RegCVNImageUtils ()
 
 RegCVNImageUtils (unsigned int nPlanes, unsigned int nCells, unsigned int nViews)
 
 ~RegCVNImageUtils ()
 
void SetViewReversal (bool reverseX, bool reverseY)
 Function to set any views that need reversing. More...
 
void SetViewReversal (std::vector< bool > reverseViews)
 
void SetPixelMapSize (unsigned int nPlanes, unsigned int nCells)
 Set the input pixel map size. More...
 
void SetCompressPixels (bool compressPixels)
 Set compress pixels. More...
 
float ConvertToScaledCharge (float charge)
 
void ConvertPixelMapToImageVectorF (const RegPixelMap &pm, ImageVectorF &imageVec)
 Convert a pixel map into an image vector (float version) More...
 
void ConvertChargeVectorsToImageVectorF (std::vector< float > &v0pe, std::vector< float > &v1pe, ImageVectorF &imageVec)
 Float version of conversion for convenience of TF interface. More...
 

Private Member Functions

void ConvertChargeVectorsToViewVectors (std::vector< float > &v0pe, std::vector< float > &v1pe, ViewVectorF &view0, ViewVectorF &view1)
 Base function for conversion of the Pixel Map to our required output format. More...
 
ImageVectorF BuildImageVectorF (ViewVectorF v0, ViewVectorF v1)
 Make the image vector from the view vectors. More...
 
void ReverseView (std::vector< float > &peVec)
 Funtion to actually reverse the view. More...
 

Private Attributes

unsigned int fNViews
 Number of views of each event. More...
 
unsigned int fPixelMapPlanes
 Input pixel map sizes. More...
 
unsigned int fPixelMapCells
 
bool fCompressPixels
 Compress pixels ? More...
 
std::vector< bool > fViewReverse
 Vector of bools to decide if any views need to be reversed. More...
 

Detailed Description

Class containing some utility functions for all things RegCVN.

Definition at line 22 of file RegCVNImageUtils.h.

Constructor & Destructor Documentation

cvn::RegCVNImageUtils::RegCVNImageUtils ( )

Definition at line 5 of file RegCVNImageUtils.cxx.

References fCompressPixels, fNViews, fViewReverse, and SetPixelMapSize().

5  {
6  // Set a default image size
7  SetPixelMapSize(2880,500);
8  fCompressPixels = false;
9  fViewReverse = {false,false};
10  fNViews = 2;
11 }
std::vector< bool > fViewReverse
Vector of bools to decide if any views need to be reversed.
bool fCompressPixels
Compress pixels ?
unsigned int fNViews
Number of views of each event.
void SetPixelMapSize(unsigned int nPlanes, unsigned int nCells)
Set the input pixel map size.
cvn::RegCVNImageUtils::RegCVNImageUtils ( unsigned int  nPlanes,
unsigned int  nCells,
unsigned int  nViews 
)

Definition at line 13 of file RegCVNImageUtils.cxx.

References SetPixelMapSize().

13  {
14  SetPixelMapSize(2880,500);
15 }
void SetPixelMapSize(unsigned int nPlanes, unsigned int nCells)
Set the input pixel map size.
cvn::RegCVNImageUtils::~RegCVNImageUtils ( )

Definition at line 17 of file RegCVNImageUtils.cxx.

17  {
18 
19 }

Member Function Documentation

cvn::ImageVectorF cvn::RegCVNImageUtils::BuildImageVectorF ( cvn::ViewVectorF  v0,
cvn::ViewVectorF  v1 
)
private

Make the image vector from the view vectors.

Definition at line 158 of file RegCVNImageUtils.cxx.

References confusionMatrixTree::image, confusionMatrixTree::t, and w.

Referenced by ConvertChargeVectorsToImageVectorF().

158  {
159 
160  // Tensorflow wants things in the arrangement <cells, Planes, views>
162  for(unsigned int w = 0; w < v0.size(); ++w){
163  std::vector<std::vector<float> > planeVec;
164  for(unsigned int t = 0; t < v0[0].size(); ++t){
165  std::vector<float> cellVec;
166  cellVec.push_back(v0[w][t]);
167  cellVec.push_back(v1[w][t]);
168  planeVec.push_back(cellVec);
169  } // Loop over cells
170  image.push_back(planeVec);
171  } // Loop over planes
172 
173 
174 
175  return image;
176 }
std::vector< ViewVectorF > ImageVectorF
Float_t w
Definition: plot.C:20
void cvn::RegCVNImageUtils::ConvertChargeVectorsToImageVectorF ( std::vector< float > &  v0pe,
std::vector< float > &  v1pe,
cvn::ImageVectorF imageVec 
)

Float version of conversion for convenience of TF interface.

Definition at line 65 of file RegCVNImageUtils.cxx.

References BuildImageVectorF(), and ConvertChargeVectorsToViewVectors().

Referenced by ConvertPixelMapToImageVectorF().

66  {
67 
68  cvn::ViewVectorF view0;
69  cvn::ViewVectorF view1;
70 
71  ConvertChargeVectorsToViewVectors(v0pe, v1pe, view0, view1);
72 
73  cvn::ImageVectorF newImage = BuildImageVectorF(view0,view1);
74 
75  imageVec = newImage;
76 }
std::vector< ViewVectorF > ImageVectorF
std::vector< std::vector< float > > ViewVectorF
Useful typedefs.
ImageVectorF BuildImageVectorF(ViewVectorF v0, ViewVectorF v1)
Make the image vector from the view vectors.
void ConvertChargeVectorsToViewVectors(std::vector< float > &v0pe, std::vector< float > &v1pe, ViewVectorF &view0, ViewVectorF &view1)
Base function for conversion of the Pixel Map to our required output format.
void cvn::RegCVNImageUtils::ConvertChargeVectorsToViewVectors ( std::vector< float > &  v0pe,
std::vector< float > &  v1pe,
cvn::ViewVectorF view0,
cvn::ViewVectorF view1 
)
private

Base function for conversion of the Pixel Map to our required output format.

Definition at line 78 of file RegCVNImageUtils.cxx.

References getBrightness::cell, ConvertToScaledCharge(), fCompressPixels, fNViews, fPixelMapCells, fPixelMapPlanes, makeBrightnessMap::maxCell, makeBrightnessMap::maxPlane, NDAPDHVSetting::plane, febshutoff_auto::val, and POTSpillRate::view.

Referenced by ConvertChargeVectorsToImageVectorF().

79  {
80 
81  // Reverse requested views
82 // if(fViewReverse[0]) ReverseView(v0pe);
83 // if(fViewReverse[1]) ReverseView(v1pe);
84 
85  // Write the values to the three vectors
86  for (unsigned int view = 0; view < fNViews; ++view){
87  cvn::ViewVectorF viewChargeVec;
88  unsigned int maxPlane = fPixelMapPlanes;
89  if(fCompressPixels==true) maxPlane = fPixelMapPlanes+1;
90 // for (unsigned int plane = 0; plane < fPixelMapPlanes; ++plane){
91 // for (unsigned int plane = 0; plane < fPixelMapPlanes; ++plane){
92  for (unsigned int plane = 0; plane < maxPlane; ++plane){
93  std::vector<float> planeCellVec;
94  unsigned int maxCell = fPixelMapCells;
95  if(fCompressPixels==true) maxCell = fPixelMapCells+1;
96 // for (unsigned int cell = 0; cell < fPixelMapPlanes; ++cell){
97 // for (unsigned int cell = 0; cell < fPixelMapCells+1; ++cell){
98  for (unsigned int cell = 0; cell < maxCell; ++cell){
99 
100  // Get the index for the pixel map
101  unsigned int element = cell + fPixelMapCells * plane;
102  unsigned int elementx = cell + fPixelMapCells * 2*plane;
103  unsigned int elementy = cell + fPixelMapCells * (2*plane + 1);
104  // FIXME: needs to add additional dimensions because of TF model
105  if (cell < fPixelMapCells && plane < fPixelMapPlanes){
106  // Scale Charges
107  float val = 0;
108  if(view == 0 && elementx < v0pe.size()){
109  if(fCompressPixels == false) val = ConvertToScaledCharge(v0pe[element]);
110  if(fCompressPixels == true) val = ConvertToScaledCharge(v0pe[elementx]);
111 // if(val>0)std::cout<<"view, plane, cell "<<view<<" "<<plane<<" "<<cell<<" "<<elementx<<" "<<val<<std::endl;
112  }
113  if(view == 1 && elementy < v1pe.size()){
114  if(fCompressPixels == false) val = ConvertToScaledCharge(v1pe[element]);
115  if(fCompressPixels == true) val = ConvertToScaledCharge(v1pe[elementy]);
116 // if(val>0)std::cout<<"view, plane, cell "<<view<<" "<<plane<<" "<<cell<<" "<<elementy<<" "<<val<<std::endl;
117  }
118  planeCellVec.push_back(val);
119  } else planeCellVec.push_back(0.);
120  }
121  //cellPlaneVec.push_back(0); // this is to increase 1 dim 280 -> 281
122  viewChargeVec.push_back(planeCellVec);
123  }
124  if(view == 0) view0 = viewChargeVec;
125  if(view == 1) view1 = viewChargeVec;
126  }
127 
128  return;
129 
130 }
float ConvertToScaledCharge(float charge)
std::vector< std::vector< float > > ViewVectorF
Useful typedefs.
unsigned int fPixelMapPlanes
Input pixel map sizes.
bool fCompressPixels
Compress pixels ?
unsigned int fNViews
Number of views of each event.
unsigned int fPixelMapCells
void cvn::RegCVNImageUtils::ConvertPixelMapToImageVectorF ( const RegPixelMap pm,
cvn::ImageVectorF imageVec 
)

Convert a pixel map into an image vector (float version)

Definition at line 48 of file RegCVNImageUtils.cxx.

References ConvertChargeVectorsToImageVectorF(), fCompressPixels, cvn::RegPixelMap::fNCell, cvn::RegPixelMap::fNPlane, cvn::RegPixelMap::fPEX, cvn::RegPixelMap::fPEY, and SetPixelMapSize().

50  {
51 
52 // SetPixelMapSize(76, 141);
53  unsigned int pmNPlane = pm.fNPlane;
54  if(fCompressPixels==true) pmNPlane = pm.fNPlane/2 + pm.fNPlane%2;
55 // std::cout<<"pm.fNPlane, pmNPlane = "<<pm.fNPlane<<" "<<pmNPlane<<std::endl;
56  SetPixelMapSize(pmNPlane, pm.fNCell);
57 
58  // Strip out the charge vectors and use these
59  std::vector<float> v0pe = pm.fPEX;
60  std::vector<float> v1pe = pm.fPEY;
61 
62  ConvertChargeVectorsToImageVectorF(v0pe, v1pe, imageVec);
63 }
bool fCompressPixels
Compress pixels ?
void ConvertChargeVectorsToImageVectorF(std::vector< float > &v0pe, std::vector< float > &v1pe, ImageVectorF &imageVec)
Float version of conversion for convenience of TF interface.
void SetPixelMapSize(unsigned int nPlanes, unsigned int nCells)
Set the input pixel map size.
float cvn::RegCVNImageUtils::ConvertToScaledCharge ( float  charge)

Definition at line 44 of file RegCVNImageUtils.cxx.

Referenced by ConvertChargeVectorsToViewVectors().

44  {
45  return charge*100.; //scale from PE to CNN input
46 }
void cvn::RegCVNImageUtils::ReverseView ( std::vector< float > &  peVec)
private

Funtion to actually reverse the view.

Definition at line 133 of file RegCVNImageUtils.cxx.

References e, fPixelMapCells, fPixelMapPlanes, confusionMatrixTree::t, febshutoff_auto::val, and w.

133  {
134 
135  std::vector<float> vecCopy(peVec.size(),0.);
136 
137  for (unsigned int w = 0; w < fPixelMapPlanes; ++w)
138  {
139  // Get our new plane number
140  unsigned int newCell = fPixelMapPlanes - w - 1;
141 
142  for (unsigned int t = 0; t < fPixelMapCells; ++t)
143  {
144  float val = peVec[t + fPixelMapCells * w];
145  vecCopy[t + fPixelMapCells * newCell] = val;
146  }
147  }
148 
149  // Copy the values back into the original vector
150  for(unsigned int e = 0; e < peVec.size(); ++e){
151  float val = vecCopy[e];
152  peVec[e] = val;
153  }
154 
155 }
unsigned int fPixelMapPlanes
Input pixel map sizes.
Float_t e
Definition: plot.C:35
Float_t w
Definition: plot.C:20
unsigned int fPixelMapCells
void cvn::RegCVNImageUtils::SetCompressPixels ( bool  compressPixels)

Set compress pixels.

Definition at line 40 of file RegCVNImageUtils.cxx.

References fCompressPixels.

40  {
41  fCompressPixels = compressPixels;
42 }
bool fCompressPixels
Compress pixels ?
void cvn::RegCVNImageUtils::SetPixelMapSize ( unsigned int  nPlanes,
unsigned int  nCells 
)

Set the input pixel map size.

Definition at line 35 of file RegCVNImageUtils.cxx.

References fPixelMapCells, and fPixelMapPlanes.

Referenced by ConvertPixelMapToImageVectorF(), and RegCVNImageUtils().

35  {
36  fPixelMapPlanes = nPlanes;
37  fPixelMapCells = nCells;
38 }
unsigned int fPixelMapPlanes
Input pixel map sizes.
unsigned int fPixelMapCells
void cvn::RegCVNImageUtils::SetViewReversal ( bool  reverseX,
bool  reverseY 
)

Function to set any views that need reversing.

Definition at line 21 of file RegCVNImageUtils.cxx.

References fViewReverse.

Referenced by SetViewReversal().

21  {
22  fViewReverse = {reverseX,reverseY};
23 }
std::vector< bool > fViewReverse
Vector of bools to decide if any views need to be reversed.
void cvn::RegCVNImageUtils::SetViewReversal ( std::vector< bool >  reverseViews)

Definition at line 25 of file RegCVNImageUtils.cxx.

References om::cout, allTimeWatchdog::endl, and SetViewReversal().

25  {
26  if(reverseViews.size() != 2){
27  std::cout << "Expected two views for view reversals... using defaults." << std::endl;
28  }
29  else{
30  SetViewReversal(reverseViews[0],reverseViews[1]);
31  }
32  return;
33 }
OStream cout
Definition: OStream.cxx:6
void SetViewReversal(bool reverseX, bool reverseY)
Function to set any views that need reversing.

Member Data Documentation

bool cvn::RegCVNImageUtils::fCompressPixels
private
unsigned int cvn::RegCVNImageUtils::fNViews
private

Number of views of each event.

Definition at line 66 of file RegCVNImageUtils.h.

Referenced by ConvertChargeVectorsToViewVectors(), and RegCVNImageUtils().

unsigned int cvn::RegCVNImageUtils::fPixelMapCells
private
unsigned int cvn::RegCVNImageUtils::fPixelMapPlanes
private

Input pixel map sizes.

Definition at line 69 of file RegCVNImageUtils.h.

Referenced by ConvertChargeVectorsToViewVectors(), ReverseView(), and SetPixelMapSize().

std::vector<bool> cvn::RegCVNImageUtils::fViewReverse
private

Vector of bools to decide if any views need to be reversed.

Definition at line 76 of file RegCVNImageUtils.h.

Referenced by RegCVNImageUtils(), and SetViewReversal().


The documentation for this class was generated from the following files: