Public Member Functions | Public Attributes | List of all members
cvn::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

unsigned int fNWire
 Number of wires, length of pixel map. More...
 
unsigned int fNTdc
 Number of tdcs, width of pixel map. More...
 
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...
 
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 22 of file PixelMap.h.

Constructor & Destructor Documentation

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

Definition at line 15 of file PixelMap.cxx.

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

Definition at line 26 of file PixelMap.h.

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

Member Function Documentation

void cvn::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 46 of file PixelMap.cxx.

47  {
48  const HitType label = kEmptyHit;
49  const double purity=0.0;
50  if(fBound.IsWithin(wire, tdc, view)){
51  fPE[GlobalToIndex(wire,tdc, view)] += pe;
52  fLab[GlobalToIndex(wire,tdc, view)] = label;
53  fPur[GlobalToIndexSingle(wire,tdc, view)] = purity;
54  if(view==0){
55  fPEX[GlobalToIndexSingle(wire,tdc, view)] += pe;//Why +=?
56  fLabX[GlobalToIndexSingle(wire,tdc, view)] = label;
57  fPurX[GlobalToIndexSingle(wire,tdc, view)] = purity;
58  }
59  if(view==1){
60  fPEY[GlobalToIndexSingle(wire,tdc, view)] += pe;
61  fLabY[GlobalToIndexSingle(wire,tdc, view)] = label;
62  fPurY[GlobalToIndexSingle(wire,tdc, view)] = purity;
63  }
64  if(view==2){
65  fPEZ[GlobalToIndexSingle(wire,tdc, view)] += pe;
66  fLabZ[GlobalToIndexSingle(wire,tdc, view)] = label;
67  fPurZ[GlobalToIndexSingle(wire,tdc, view)] = purity;
68  }
69  }
70  }
enum cvn::HType HitType
std::vector< float > fPEY
Vector of Y PE measurements for pixels.
Definition: PixelMap.h:82
std::vector< float > fPE
Vector of PE measurements for pixels.
Definition: PixelMap.h:80
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 > fPEZ
Vector of Y PE measurements for pixels.
Definition: PixelMap.h:83
std::vector< HitType > fLabY
Vector of Y Truth labels for pixels.
Definition: PixelMap.h:90
std::vector< float > fPEX
Vector of X PE measurements for pixels.
Definition: PixelMap.h:81
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:72
std::vector< double > fPurY
Vector of Y purity for pixels.
Definition: PixelMap.h:86
std::vector< HitType > fLabX
Vector of X Truth labels for pixels.
Definition: PixelMap.h:89
std::vector< double > fPurZ
Vector of Y purity for pixels.
Definition: PixelMap.h:87
std::vector< HitType > fLab
Vector of Truth labels for pixels.
Definition: PixelMap.h:88
Boundary fBound
Definition: PixelMap.h:94
std::vector< HitType > fLabZ
Vector of Y Truth labels for pixels.
Definition: PixelMap.h:91
std::vector< double > fPur
Vector of purity for pixels.
Definition: PixelMap.h:84
std::vector< double > fPurX
Vector of X purity for pixels.
Definition: PixelMap.h:85
bool IsWithin(const unsigned int &wire, const double &cell, const unsigned int &view)
Definition: Boundary.cxx:45
Boundary cvn::PixelMap::Bound ( ) const
inline

Map boundary.

Definition at line 38 of file PixelMap.h.

38 {return fBound;};
Boundary fBound
Definition: PixelMap.h:94
void cvn::PixelMap::FillInputVector ( float *  input) const

Definition at line 34 of file PixelMap.cxx.

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

Definition at line 68 of file PixelMap.h.

68 { return fTotHits; }
unsigned int fTotHits
Number of hits that make up the pixel map.
Definition: PixelMap.h:92
unsigned int cvn::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 72 of file PixelMap.cxx.

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

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  }
std::vector< float > fPEX
Vector of X PE measurements for pixels.
Definition: PixelMap.h:81
double FirstTDC(const unsigned int &view) const
Definition: Boundary.h:46
int FirstWire(const unsigned int &view) const
Definition: Boundary.h:44
unsigned int fNTdc
Number of tdcs, width of pixel map.
Definition: PixelMap.h:79
Boundary fBound
Definition: PixelMap.h:94
double LastTDC(const unsigned int &view) const
Definition: Boundary.h:47
unsigned int cvn::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 93 of file PixelMap.cxx.

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:80
unsigned int fNTdc
Number of tdcs, width of pixel map.
Definition: PixelMap.h:79
unsigned int cvn::PixelMap::NInput ( ) const
inline

Number of inputs for the neural net.

Definition at line 41 of file PixelMap.h.

41 {return NPixel();};
unsigned int NPixel() const
Total number of pixels in map.
Definition: PixelMap.h:35
unsigned int cvn::PixelMap::NPixel ( ) const
inline

Total number of pixels in map.

Definition at line 35 of file PixelMap.h.

35 {return fPE.size();};
std::vector< float > fPE
Vector of PE measurements for pixels.
Definition: PixelMap.h:80
unsigned int cvn::PixelMap::NTdc ( ) const
inline

Width in tdcs.

Definition at line 32 of file PixelMap.h.

32 {return fNTdc;};
unsigned int fNTdc
Number of tdcs, width of pixel map.
Definition: PixelMap.h:79
unsigned int cvn::PixelMap::NWire ( ) const
inline

Length in wires.

Definition at line 29 of file PixelMap.h.

29 {return fNWire;};
unsigned int fNWire
Number of wires, length of pixel map.
Definition: PixelMap.h:78
void cvn::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.

125  {
126 
127  // Start by doing even wires
128  for(unsigned int iTdc = 0; iTdc < fNTdc; ++iTdc)
129  {
130  for(unsigned int iWire = 0; iWire < fNWire; iWire += 2)
131  {
132  unsigned int index = LocalToIndex(iWire, iTdc);
133  if( fPE[index] > 0)
134  {
135  std::cout << "*";
136  }
137  else
138  {
139  std::cout << " ";
140  }
141 
142  }
143  std::cout << std::endl;
144  }
145  // Then do odd wires
146  for(unsigned int iTdc = 0; iTdc < fNTdc; ++iTdc)
147  {
148  for(unsigned int iWire = 1; iWire < fNWire; iWire += 2)
149  {
150  unsigned int index = LocalToIndex(iWire, iTdc);
151  if( fPE[index] > 0)
152  {
153  std::cout << "*";
154  }
155  else
156  {
157  std::cout << " ";
158  }
159 
160  }
161  std::cout << std::endl;
162  }
163 
164  }
unsigned int fNWire
Number of wires, length of pixel map.
Definition: PixelMap.h:78
std::vector< float > fPE
Vector of PE measurements for pixels.
Definition: PixelMap.h:80
unsigned int fNTdc
Number of tdcs, width of pixel map.
Definition: PixelMap.h:79
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:93
QTextStream & endl(QTextStream &s)
void cvn::PixelMap::SetTotHits ( unsigned int  tothits)
inline

Definition at line 67 of file PixelMap.h.

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

Definition at line 206 of file PixelMap.cxx.

207  {
208 
209  // Create a histogram
210  TH2F* hist = new TH2F("PixelMap", ";Wire;Tdc", fNWire, 0,
211  fNWire,
212  fNTdc, 0, fNTdc);
213 
214  for(unsigned int iWire = 0; iWire < fNWire; ++iWire)
215  {
216  for(unsigned int iTdc = 0; iTdc < fNTdc; ++iTdc)
217  {
218  // Add 1 to in each bin to skip underflow
219  if(view==0){
220  hist->SetBinContent(iWire+1, iTdc + 1,
221  fPEX[LocalToIndex(iWire, iTdc)]);
222  }
223  if(view==1){
224  hist->SetBinContent(iWire+1, iTdc + 1,
225  fPEY[LocalToIndex(iWire, iTdc)]);
226  }
227  if(view==2){
228  hist->SetBinContent(iWire+1, iTdc + 1,
229  fPEZ[LocalToIndex(iWire, iTdc)]);
230  }
231  }
232  }
233  return hist;
234  }
std::vector< float > fPEY
Vector of Y PE measurements for pixels.
Definition: PixelMap.h:82
unsigned int fNWire
Number of wires, length of pixel map.
Definition: PixelMap.h:78
std::vector< float > fPEZ
Vector of Y PE measurements for pixels.
Definition: PixelMap.h:83
std::vector< float > fPEX
Vector of X PE measurements for pixels.
Definition: PixelMap.h:81
unsigned int fNTdc
Number of tdcs, width of pixel map.
Definition: PixelMap.h:79
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:93
TH2F * cvn::PixelMap::ToLabTH2 ( ) const

Definition at line 186 of file PixelMap.cxx.

187  {
188 
189  // Create a histogram, use twice as many tdcs to distinguish views
190  TH2F* hist = new TH2F("PixelMap", ";Wire;Tdc", fNWire, 0, fNWire,
191  fNTdc*3, 0, fNTdc*3);
192 
193  for(unsigned int iWire = 0; iWire < fNWire; ++iWire)
194  {
195  for(unsigned int iTdc = 0; iTdc < fNTdc; ++iTdc)
196  {
197  // Add 1 to in each bin to skip underflow
198  hist->SetBinContent(iWire+1, iTdc + fNTdc*(iWire%3) + 1,
199  (double)fLab[LocalToIndex(iWire, iTdc)]);
200 
201  }
202  }
203  return hist;
204  }
unsigned int fNWire
Number of wires, length of pixel map.
Definition: PixelMap.h:78
std::vector< HitType > fLab
Vector of Truth labels for pixels.
Definition: PixelMap.h:88
unsigned int fNTdc
Number of tdcs, width of pixel map.
Definition: PixelMap.h:79
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:93
TH2F * cvn::PixelMap::ToTH2 ( ) const

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

Definition at line 166 of file PixelMap.cxx.

167  {
168 
169  // Create a histogram, use twice as many tdcs to distinguish views
170  TH2F* hist = new TH2F("PixelMap", ";Wire;Tdc", fNWire, 0, fNWire,
171  fNTdc*3, 0, fNTdc*3);
172 
173  for(unsigned int iWire = 0; iWire < fNWire; ++iWire)
174  {
175  for(unsigned int iTdc = 0; iTdc < fNTdc; ++iTdc)
176  {
177  // Add 1 to in each bin to skip underflow
178  hist->SetBinContent(iWire+1, iTdc + fNTdc*(iWire%3) + 1,
179  fPE[LocalToIndex(iWire, iTdc)]);
180 
181  }
182  }
183  return hist;
184  }
unsigned int fNWire
Number of wires, length of pixel map.
Definition: PixelMap.h:78
std::vector< float > fPE
Vector of PE measurements for pixels.
Definition: PixelMap.h:80
unsigned int fNTdc
Number of tdcs, width of pixel map.
Definition: PixelMap.h:79
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:93

Member Data Documentation

Boundary cvn::PixelMap::fBound

Definition at line 94 of file PixelMap.h.

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

Vector of Truth labels for pixels.

Definition at line 88 of file PixelMap.h.

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

Vector of X Truth labels for pixels.

Definition at line 89 of file PixelMap.h.

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

Vector of Y Truth labels for pixels.

Definition at line 90 of file PixelMap.h.

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

Vector of Y Truth labels for pixels.

Definition at line 91 of file PixelMap.h.

unsigned int cvn::PixelMap::fNTdc

Number of tdcs, width of pixel map.

Definition at line 79 of file PixelMap.h.

unsigned int cvn::PixelMap::fNWire

Number of wires, length of pixel map.

Definition at line 78 of file PixelMap.h.

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

Vector of PE measurements for pixels.

Definition at line 80 of file PixelMap.h.

std::vector<float> cvn::PixelMap::fPEX

Vector of X PE measurements for pixels.

Definition at line 81 of file PixelMap.h.

std::vector<float> cvn::PixelMap::fPEY

Vector of Y PE measurements for pixels.

Definition at line 82 of file PixelMap.h.

std::vector<float> cvn::PixelMap::fPEZ

Vector of Y PE measurements for pixels.

Definition at line 83 of file PixelMap.h.

std::vector<double> cvn::PixelMap::fPur

Vector of purity for pixels.

Definition at line 84 of file PixelMap.h.

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

Vector of X purity for pixels.

Definition at line 85 of file PixelMap.h.

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

Vector of Y purity for pixels.

Definition at line 86 of file PixelMap.h.

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

Vector of Y purity for pixels.

Definition at line 87 of file PixelMap.h.

unsigned int cvn::PixelMap::fTotHits

Number of hits that make up the pixel map.

Definition at line 92 of file PixelMap.h.


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