LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
lcvn::PixelMap Class Reference

PixelMap, basic input to CVN neural net. More...

#include "PixelMap.h"

Public Member Functions

 PixelMap (unsigned int nWire, unsigned int nTdc, const Boundary &bound)
 
 PixelMap ()
 
unsigned int NWire () const
 Length in wires. More...
 
unsigned int NTdc () const
 Width in tdcs. More...
 
unsigned int NPixel () const
 Total number of pixels in map. More...
 
Boundary Bound () const
 Map boundary. More...
 
unsigned int NInput () const
 Number of inputs for the neural net. More...
 
void FillInputVector (float *input) const
 
void Add (const unsigned int &wire, const double &tdc, const unsigned int &view, const double &pe)
 
unsigned int GlobalToIndex (const unsigned int &wire, const double &tdc, const unsigned int &view)
 Take global wire, tdc (detector) and return index in fPE vector. More...
 
unsigned int LocalToIndex (const unsigned int &wire, const unsigned int &tdc) const
 Take local wire, tdc (within map) and return index in fPE vector. More...
 
unsigned int GlobalToIndexSingle (const unsigned int &wire, const double &tdc, const unsigned int &view)
 Take global wire, tdc (detector) and return index in fPE vector. More...
 
void SetTotHits (unsigned int tothits)
 
unsigned int GetTotHits ()
 
void Print () const
 
TH2F * ToTH2 () const
 Return the pixel map as a 2D histogram for visualization. More...
 
TH2F * ToLabTH2 () const
 
TH2F * SingleViewToTH2 (const unsigned int &view) const
 

Public Attributes

std::vector< float > fPE
 Vector of PE measurements for pixels. More...
 
std::vector< float > fPEX
 Vector of X PE measurements for pixels. More...
 
std::vector< float > fPEY
 Vector of Y PE measurements for pixels. More...
 
std::vector< float > fPEZ
 Vector of Y PE measurements for pixels. More...
 
std::vector< double > fPur
 Vector of purity for pixels. More...
 
std::vector< double > fPurX
 Vector of X purity for pixels. More...
 
std::vector< double > fPurY
 Vector of Y purity for pixels. More...
 
std::vector< double > fPurZ
 Vector of Y purity for pixels. More...
 
std::vector< HitTypefLab
 Vector of Truth labels for pixels. More...
 
std::vector< HitTypefLabX
 Vector of X Truth labels for pixels. More...
 
std::vector< HitTypefLabY
 Vector of Y Truth labels for pixels. More...
 
std::vector< HitTypefLabZ
 Vector of Y Truth labels for pixels. More...
 

Private Attributes

unsigned int fNWire
 Number of wires, length of pixel map. More...
 
unsigned int fNTdc
 Number of tdcs, width of pixel map. More...
 
unsigned int fTotHits
 Number of hits that make up the pixel map. More...
 
Boundary fBound
 

Detailed Description

PixelMap, basic input to CVN neural net.

Definition at line 20 of file PixelMap.h.

Constructor & Destructor Documentation

lcvn::PixelMap::PixelMap ( unsigned int  nWire,
unsigned int  nTdc,
const Boundary bound 
)

Definition at line 14 of file PixelMap.cxx.

References fTotHits.

15  : fPE(nWire * nTdc)
16  , fPEX(nWire * nTdc)
17  , fPEY(nWire * nTdc)
18  , fPEZ(nWire * nTdc)
19  , fPur(nWire * nTdc)
20  , fPurX(nWire * nTdc)
21  , fPurY(nWire * nTdc)
22  , fPurZ(nWire * nTdc)
23  , fLab(nWire * nTdc)
24  , fLabX(nWire * nTdc)
25  , fLabY(nWire * nTdc)
26  , fLabZ(nWire * nTdc)
27  , fNWire(nWire)
28  , fNTdc(nTdc)
29  , fBound(bound)
30  {
31  fTotHits = 0;
32  }
std::vector< float > fPE
Vector of PE measurements for pixels.
Definition: PixelMap.h:73
std::vector< HitType > fLab
Vector of Truth labels for pixels.
Definition: PixelMap.h:81
std::vector< double > fPurY
Vector of Y purity for pixels.
Definition: PixelMap.h:79
std::vector< double > fPurX
Vector of X purity for pixels.
Definition: PixelMap.h:78
std::vector< double > fPur
Vector of purity for pixels.
Definition: PixelMap.h:77
std::vector< float > fPEX
Vector of X PE measurements for pixels.
Definition: PixelMap.h:74
std::vector< HitType > fLabX
Vector of X Truth labels for pixels.
Definition: PixelMap.h:82
std::vector< float > fPEZ
Vector of Y PE measurements for pixels.
Definition: PixelMap.h:76
std::vector< HitType > fLabZ
Vector of Y Truth labels for pixels.
Definition: PixelMap.h:84
std::vector< double > fPurZ
Vector of Y purity for pixels.
Definition: PixelMap.h:80
unsigned int fTotHits
Number of hits that make up the pixel map.
Definition: PixelMap.h:89
unsigned int fNWire
Number of wires, length of pixel map.
Definition: PixelMap.h:87
Boundary fBound
Definition: PixelMap.h:91
std::vector< float > fPEY
Vector of Y PE measurements for pixels.
Definition: PixelMap.h:75
unsigned int fNTdc
Number of tdcs, width of pixel map.
Definition: PixelMap.h:88
std::vector< HitType > fLabY
Vector of Y Truth labels for pixels.
Definition: PixelMap.h:83
lcvn::PixelMap::PixelMap ( )
inline

Definition at line 23 of file PixelMap.h.

References fTotHits.

23 { fTotHits = 0; };
unsigned int fTotHits
Number of hits that make up the pixel map.
Definition: PixelMap.h:89

Member Function Documentation

void lcvn::PixelMap::Add ( const unsigned int &  wire,
const double &  tdc,
const unsigned int &  view,
const double &  pe 
)

Add a hit to the map if it is contained within the wire, tdc rcvne Could be expanded later to add to overflow accordingly.

Definition at line 44 of file PixelMap.cxx.

References fBound, fLab, fLabX, fLabY, fLabZ, fPE, fPEX, fPEY, fPEZ, fPur, fPurX, fPurY, fPurZ, GlobalToIndex(), GlobalToIndexSingle(), lcvn::Boundary::IsWithin(), and lcvn::kEmptyHit.

Referenced by lcvn::PixelMapProducer< T, U >::CreateMapGivenBoundary(), and NInput().

48  {
49  const HitType label = kEmptyHit;
50  const double purity = 0.0;
51  if (fBound.IsWithin(wire, tdc, view)) {
52  fPE[GlobalToIndex(wire, tdc, view)] += pe;
53  fLab[GlobalToIndex(wire, tdc, view)] = label;
54  fPur[GlobalToIndexSingle(wire, tdc, view)] = purity;
55  if (view == 0) {
56  fPEX[GlobalToIndexSingle(wire, tdc, view)] += pe; //Why +=?
57  fLabX[GlobalToIndexSingle(wire, tdc, view)] = label;
58  fPurX[GlobalToIndexSingle(wire, tdc, view)] = purity;
59  }
60  if (view == 1) {
61  fPEY[GlobalToIndexSingle(wire, tdc, view)] += pe;
62  fLabY[GlobalToIndexSingle(wire, tdc, view)] = label;
63  fPurY[GlobalToIndexSingle(wire, tdc, view)] = purity;
64  }
65  if (view == 2) {
66  fPEZ[GlobalToIndexSingle(wire, tdc, view)] += pe;
67  fLabZ[GlobalToIndexSingle(wire, tdc, view)] = label;
68  fPurZ[GlobalToIndexSingle(wire, tdc, view)] = purity;
69  }
70  }
71  }
unsigned int GlobalToIndex(const unsigned int &wire, const double &tdc, const unsigned int &view)
Take global wire, tdc (detector) and return index in fPE vector.
Definition: PixelMap.cxx:73
std::vector< float > fPE
Vector of PE measurements for pixels.
Definition: PixelMap.h:73
std::vector< HitType > fLab
Vector of Truth labels for pixels.
Definition: PixelMap.h:81
std::vector< double > fPurY
Vector of Y purity for pixels.
Definition: PixelMap.h:79
std::vector< double > fPurX
Vector of X purity for pixels.
Definition: PixelMap.h:78
std::vector< double > fPur
Vector of purity for pixels.
Definition: PixelMap.h:77
std::vector< float > fPEX
Vector of X PE measurements for pixels.
Definition: PixelMap.h:74
std::vector< HitType > fLabX
Vector of X Truth labels for pixels.
Definition: PixelMap.h:82
std::vector< float > fPEZ
Vector of Y PE measurements for pixels.
Definition: PixelMap.h:76
std::vector< HitType > fLabZ
Vector of Y Truth labels for pixels.
Definition: PixelMap.h:84
std::vector< double > fPurZ
Vector of Y purity for pixels.
Definition: PixelMap.h:80
HitType
Definition: HitType.h:12
bool IsWithin(const unsigned int wire, const double cell, const unsigned int view)
Definition: Boundary.cxx:40
Boundary fBound
Definition: PixelMap.h:91
unsigned int GlobalToIndexSingle(const unsigned int &wire, const double &tdc, const unsigned int &view)
Take global wire, tdc (detector) and return index in fPE vector.
Definition: PixelMap.cxx:102
std::vector< float > fPEY
Vector of Y PE measurements for pixels.
Definition: PixelMap.h:75
std::vector< HitType > fLabY
Vector of Y Truth labels for pixels.
Definition: PixelMap.h:83
Boundary lcvn::PixelMap::Bound ( ) const
inline

Map boundary.

Definition at line 35 of file PixelMap.h.

References fBound.

35 { return fBound; };
Boundary fBound
Definition: PixelMap.h:91
void lcvn::PixelMap::FillInputVector ( float *  input) const

Definition at line 34 of file PixelMap.cxx.

References fPE.

Referenced by NInput().

35  {
36  unsigned int i = 0;
37 
38  for (const auto& pe : fPE) {
39  input[i] = pe;
40  ++i;
41  }
42  }
std::vector< float > fPE
Vector of PE measurements for pixels.
Definition: PixelMap.h:73
unsigned int lcvn::PixelMap::GetTotHits ( )
inline

Definition at line 63 of file PixelMap.h.

References fTotHits, Print(), SingleViewToTH2(), ToLabTH2(), and ToTH2().

Referenced by lcvn::LArNuCVNZlibMaker::write_files().

63 { return fTotHits; }
unsigned int fTotHits
Number of hits that make up the pixel map.
Definition: PixelMap.h:89
unsigned int lcvn::PixelMap::GlobalToIndex ( const unsigned int &  wire,
const double &  tdc,
const unsigned int &  view 
)

Take global wire, tdc (detector) and return index in fPE vector.

Definition at line 73 of file PixelMap.cxx.

References fBound, lcvn::Boundary::FirstTDC(), lcvn::Boundary::FirstWire(), fNTdc, fPE, and lcvn::Boundary::LastTDC().

Referenced by Add(), and NInput().

76  {
77 
78  unsigned int internalWire = wire - fBound.FirstWire(view);
79 
80  double upperTL = fBound.LastTDC(view);
81  double lowerTL = fBound.FirstTDC(view);
82  double timestep = (upperTL - lowerTL) / double(fNTdc);
83  double roundChannel = round((tdc - lowerTL) / timestep);
84 
85  unsigned int internalTdc = roundChannel;
86 
87  unsigned int index = internalWire * fNTdc + internalTdc % fNTdc;
88 
89  assert(index < fPE.size());
90 
91  return index;
92  }
std::vector< float > fPE
Vector of PE measurements for pixels.
Definition: PixelMap.h:73
int FirstWire(const unsigned int view) const
Definition: Boundary.h:37
double FirstTDC(const unsigned int view) const
Definition: Boundary.h:39
double LastTDC(const unsigned int view) const
Definition: Boundary.h:40
Boundary fBound
Definition: PixelMap.h:91
unsigned int fNTdc
Number of tdcs, width of pixel map.
Definition: PixelMap.h:88
unsigned int lcvn::PixelMap::GlobalToIndexSingle ( const unsigned int &  wire,
const double &  tdc,
const unsigned int &  view 
)

Take global wire, tdc (detector) and return index in fPE vector.

Definition at line 102 of file PixelMap.cxx.

References fBound, lcvn::Boundary::FirstTDC(), lcvn::Boundary::FirstWire(), fNTdc, fPEX, and lcvn::Boundary::LastTDC().

Referenced by Add(), and NInput().

106  {
107 
108  unsigned int internalWire = wire - fBound.FirstWire(view);
109 
110  double upperTL = fBound.LastTDC(view);
111  double lowerTL = fBound.FirstTDC(view);
112  double timestep = (upperTL - lowerTL) / double(fNTdc);
113  double roundChannel = round((tdc - lowerTL) / timestep);
114 
115  unsigned int internalTdc = roundChannel;
116 
117  unsigned int index = internalWire * fNTdc + internalTdc % fNTdc;
118 
119  assert(index < fPEX.size());
120 
121  return index;
122  }
int FirstWire(const unsigned int view) const
Definition: Boundary.h:37
double FirstTDC(const unsigned int view) const
Definition: Boundary.h:39
std::vector< float > fPEX
Vector of X PE measurements for pixels.
Definition: PixelMap.h:74
double LastTDC(const unsigned int view) const
Definition: Boundary.h:40
Boundary fBound
Definition: PixelMap.h:91
unsigned int fNTdc
Number of tdcs, width of pixel map.
Definition: PixelMap.h:88
unsigned int lcvn::PixelMap::LocalToIndex ( const unsigned int &  wire,
const unsigned int &  tdc 
) const

Take local wire, tdc (within map) and return index in fPE vector.

Definition at line 94 of file PixelMap.cxx.

References fNTdc, and fPE.

Referenced by NInput(), Print(), SingleViewToTH2(), ToLabTH2(), and ToTH2().

95  {
96  unsigned int index = wire * fNTdc + tdc % fNTdc;
97 
98  assert(index < fPE.size());
99  return index;
100  }
std::vector< float > fPE
Vector of PE measurements for pixels.
Definition: PixelMap.h:73
unsigned int fNTdc
Number of tdcs, width of pixel map.
Definition: PixelMap.h:88
unsigned int lcvn::PixelMap::NInput ( ) const
inline

Number of inputs for the neural net.

Definition at line 38 of file PixelMap.h.

References Add(), FillInputVector(), GlobalToIndex(), GlobalToIndexSingle(), LocalToIndex(), and NPixel().

38 { return NPixel(); };
unsigned int NPixel() const
Total number of pixels in map.
Definition: PixelMap.h:32
unsigned int lcvn::PixelMap::NPixel ( ) const
inline

Total number of pixels in map.

Definition at line 32 of file PixelMap.h.

References fPE.

Referenced by NInput(), and lcvn::operator<<().

32 { return fPE.size(); };
std::vector< float > fPE
Vector of PE measurements for pixels.
Definition: PixelMap.h:73
unsigned int lcvn::PixelMap::NTdc ( ) const
inline
unsigned int lcvn::PixelMap::NWire ( ) const
inline
void lcvn::PixelMap::Print ( ) const

Draw pixel map to the screen. This is pretty hokey and the aspect ratio is totally unrealistic.

Definition at line 124 of file PixelMap.cxx.

References fNTdc, fNWire, fPE, and LocalToIndex().

Referenced by GetTotHits().

125  {
126 
127  // Start by doing even wires
128  for (unsigned int iTdc = 0; iTdc < fNTdc; ++iTdc) {
129  for (unsigned int iWire = 0; iWire < fNWire; iWire += 2) {
130  unsigned int index = LocalToIndex(iWire, iTdc);
131  if (fPE[index] > 0) { std::cout << "*"; }
132  else {
133  std::cout << " ";
134  }
135  }
136  std::cout << std::endl;
137  }
138  // Then do odd wires
139  for (unsigned int iTdc = 0; iTdc < fNTdc; ++iTdc) {
140  for (unsigned int iWire = 1; iWire < fNWire; iWire += 2) {
141  unsigned int index = LocalToIndex(iWire, iTdc);
142  if (fPE[index] > 0) { std::cout << "*"; }
143  else {
144  std::cout << " ";
145  }
146  }
147  std::cout << std::endl;
148  }
149  }
std::vector< float > fPE
Vector of PE measurements for pixels.
Definition: PixelMap.h:73
unsigned int LocalToIndex(const unsigned int &wire, const unsigned int &tdc) const
Take local wire, tdc (within map) and return index in fPE vector.
Definition: PixelMap.cxx:94
unsigned int fNWire
Number of wires, length of pixel map.
Definition: PixelMap.h:87
unsigned int fNTdc
Number of tdcs, width of pixel map.
Definition: PixelMap.h:88
void lcvn::PixelMap::SetTotHits ( unsigned int  tothits)
inline

Definition at line 62 of file PixelMap.h.

References fTotHits.

Referenced by lcvn::PixelMapProducer< T, U >::CreateMapGivenBoundary(), and lcvn::ICVNMapper< T, U >::produce().

62 { fTotHits = tothits; }
unsigned int fTotHits
Number of hits that make up the pixel map.
Definition: PixelMap.h:89
TH2F * lcvn::PixelMap::SingleViewToTH2 ( const unsigned int &  view) const

Definition at line 183 of file PixelMap.cxx.

References fNTdc, fNWire, fPEX, fPEY, fPEZ, hist, and LocalToIndex().

Referenced by GetTotHits().

184  {
185 
186  // Create a histogram
187  TH2F* hist = new TH2F("PixelMap", ";Wire;Tdc", fNWire, 0, fNWire, fNTdc, 0, fNTdc);
188 
189  for (unsigned int iWire = 0; iWire < fNWire; ++iWire) {
190  for (unsigned int iTdc = 0; iTdc < fNTdc; ++iTdc) {
191  // Add 1 to in each bin to skip underflow
192  if (view == 0) {
193  hist->SetBinContent(iWire + 1, iTdc + 1, fPEX[LocalToIndex(iWire, iTdc)]);
194  }
195  if (view == 1) {
196  hist->SetBinContent(iWire + 1, iTdc + 1, fPEY[LocalToIndex(iWire, iTdc)]);
197  }
198  if (view == 2) {
199  hist->SetBinContent(iWire + 1, iTdc + 1, fPEZ[LocalToIndex(iWire, iTdc)]);
200  }
201  }
202  }
203  return hist;
204  }
unsigned int LocalToIndex(const unsigned int &wire, const unsigned int &tdc) const
Take local wire, tdc (within map) and return index in fPE vector.
Definition: PixelMap.cxx:94
std::vector< float > fPEX
Vector of X PE measurements for pixels.
Definition: PixelMap.h:74
std::vector< float > fPEZ
Vector of Y PE measurements for pixels.
Definition: PixelMap.h:76
TH2F * hist
Definition: plot.C:134
unsigned int fNWire
Number of wires, length of pixel map.
Definition: PixelMap.h:87
std::vector< float > fPEY
Vector of Y PE measurements for pixels.
Definition: PixelMap.h:75
unsigned int fNTdc
Number of tdcs, width of pixel map.
Definition: PixelMap.h:88
TH2F * lcvn::PixelMap::ToLabTH2 ( ) const

Definition at line 167 of file PixelMap.cxx.

References fLab, fNTdc, fNWire, hist, and LocalToIndex().

Referenced by GetTotHits().

168  {
169 
170  // Create a histogram, use twice as many tdcs to distinguish views
171  TH2F* hist = new TH2F("PixelMap", ";Wire;Tdc", fNWire, 0, fNWire, fNTdc * 3, 0, fNTdc * 3);
172 
173  for (unsigned int iWire = 0; iWire < fNWire; ++iWire) {
174  for (unsigned int iTdc = 0; iTdc < fNTdc; ++iTdc) {
175  // Add 1 to in each bin to skip underflow
176  hist->SetBinContent(
177  iWire + 1, iTdc + fNTdc * (iWire % 3) + 1, (double)fLab[LocalToIndex(iWire, iTdc)]);
178  }
179  }
180  return hist;
181  }
std::vector< HitType > fLab
Vector of Truth labels for pixels.
Definition: PixelMap.h:81
unsigned int LocalToIndex(const unsigned int &wire, const unsigned int &tdc) const
Take local wire, tdc (within map) and return index in fPE vector.
Definition: PixelMap.cxx:94
TH2F * hist
Definition: plot.C:134
unsigned int fNWire
Number of wires, length of pixel map.
Definition: PixelMap.h:87
unsigned int fNTdc
Number of tdcs, width of pixel map.
Definition: PixelMap.h:88
TH2F * lcvn::PixelMap::ToTH2 ( ) const

Return the pixel map as a 2D histogram for visualization.

Definition at line 151 of file PixelMap.cxx.

References fNTdc, fNWire, fPE, hist, and LocalToIndex().

Referenced by GetTotHits().

152  {
153 
154  // Create a histogram, use twice as many tdcs to distinguish views
155  TH2F* hist = new TH2F("PixelMap", ";Wire;Tdc", fNWire, 0, fNWire, fNTdc * 3, 0, fNTdc * 3);
156 
157  for (unsigned int iWire = 0; iWire < fNWire; ++iWire) {
158  for (unsigned int iTdc = 0; iTdc < fNTdc; ++iTdc) {
159  // Add 1 to in each bin to skip underflow
160  hist->SetBinContent(
161  iWire + 1, iTdc + fNTdc * (iWire % 3) + 1, fPE[LocalToIndex(iWire, iTdc)]);
162  }
163  }
164  return hist;
165  }
std::vector< float > fPE
Vector of PE measurements for pixels.
Definition: PixelMap.h:73
unsigned int LocalToIndex(const unsigned int &wire, const unsigned int &tdc) const
Take local wire, tdc (within map) and return index in fPE vector.
Definition: PixelMap.cxx:94
TH2F * hist
Definition: plot.C:134
unsigned int fNWire
Number of wires, length of pixel map.
Definition: PixelMap.h:87
unsigned int fNTdc
Number of tdcs, width of pixel map.
Definition: PixelMap.h:88

Member Data Documentation

Boundary lcvn::PixelMap::fBound
private

Definition at line 91 of file PixelMap.h.

Referenced by Add(), Bound(), GlobalToIndex(), and GlobalToIndexSingle().

std::vector<HitType> lcvn::PixelMap::fLab

Vector of Truth labels for pixels.

Definition at line 81 of file PixelMap.h.

Referenced by Add(), and ToLabTH2().

std::vector<HitType> lcvn::PixelMap::fLabX

Vector of X Truth labels for pixels.

Definition at line 82 of file PixelMap.h.

Referenced by Add().

std::vector<HitType> lcvn::PixelMap::fLabY

Vector of Y Truth labels for pixels.

Definition at line 83 of file PixelMap.h.

Referenced by Add().

std::vector<HitType> lcvn::PixelMap::fLabZ

Vector of Y Truth labels for pixels.

Definition at line 84 of file PixelMap.h.

Referenced by Add().

unsigned int lcvn::PixelMap::fNTdc
private

Number of tdcs, width of pixel map.

Definition at line 88 of file PixelMap.h.

Referenced by GlobalToIndex(), GlobalToIndexSingle(), LocalToIndex(), NTdc(), Print(), SingleViewToTH2(), ToLabTH2(), and ToTH2().

unsigned int lcvn::PixelMap::fNWire
private

Number of wires, length of pixel map.

Definition at line 87 of file PixelMap.h.

Referenced by NWire(), Print(), SingleViewToTH2(), ToLabTH2(), and ToTH2().

std::vector<float> lcvn::PixelMap::fPE

Vector of PE measurements for pixels.

Definition at line 73 of file PixelMap.h.

Referenced by Add(), FillInputVector(), GlobalToIndex(), LocalToIndex(), NPixel(), Print(), and ToTH2().

std::vector<float> lcvn::PixelMap::fPEX
std::vector<float> lcvn::PixelMap::fPEY
std::vector<float> lcvn::PixelMap::fPEZ
std::vector<double> lcvn::PixelMap::fPur

Vector of purity for pixels.

Definition at line 77 of file PixelMap.h.

Referenced by Add().

std::vector<double> lcvn::PixelMap::fPurX

Vector of X purity for pixels.

Definition at line 78 of file PixelMap.h.

Referenced by Add().

std::vector<double> lcvn::PixelMap::fPurY

Vector of Y purity for pixels.

Definition at line 79 of file PixelMap.h.

Referenced by Add().

std::vector<double> lcvn::PixelMap::fPurZ

Vector of Y purity for pixels.

Definition at line 80 of file PixelMap.h.

Referenced by Add().

unsigned int lcvn::PixelMap::fTotHits
private

Number of hits that make up the pixel map.

Definition at line 89 of file PixelMap.h.

Referenced by GetTotHits(), PixelMap(), and SetTotHits().


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