Public Member Functions | Private Attributes | List of all members
nnet::EventImageData Class Reference

#include <EventImageData.h>

Public Member Functions

 EventImageData (size_t w, size_t d, bool saveDep)
 
void addTpc (const TrainingDataAlg &dataAlg, size_t gw, bool flipw, size_t gd, bool flipd)
 
bool findCrop (size_t max_area_cut, unsigned int &w0, unsigned int &w1, unsigned int &d0, unsigned int &d1) const
 
const std::vector< std::vector< float > > & adcData (void) const
 
const std::vector< float > & wireAdc (size_t widx) const
 
const std::vector< std::vector< float > > & depData (void) const
 
const std::vector< float > & wireDep (size_t widx) const
 
const std::vector< std::vector< int > > & pdgData (void) const
 
const std::vector< int > & wirePdg (size_t widx) const
 
void setProjXY (const TrainingDataAlg &dataAlg, float x, float y, size_t gw, bool flipw, size_t gd, bool flipd)
 
float getProjX (void) const
 
float getProjY (void) const
 
int getVtxX (void) const
 
int getVtxY (void) const
 

Private Attributes

std::vector< std::vector< float > > fAdc
 
std::vector< std::vector< float > > fDeposit
 
std::vector< std::vector< int > > fPdg
 
int fVtxX
 
int fVtxY
 
float fProjX
 
float fProjY
 
bool fSaveDep
 

Detailed Description

Definition at line 28 of file EventImageData.h.

Constructor & Destructor Documentation

nnet::EventImageData::EventImageData ( size_t  w,
size_t  d,
bool  saveDep 
)

Definition at line 51 of file EventImageData.cxx.

51  :
52  fVtxX(-9999), fVtxY(-9999),
53  fProjX(-9999), fProjY(-9999),
54  fSaveDep(saveDep)
55 {
56  fAdc.resize(w, std::vector<float>(d, 0));
57  if (saveDep) { fDeposit.resize(w, std::vector<float>(d, 0)); }
58  fPdg.resize(w, std::vector<int>(d, 0));
59 }
std::vector< std::vector< float > > fAdc
std::vector< std::vector< float > > fDeposit
std::vector< std::vector< int > > fPdg

Member Function Documentation

const std::vector< std::vector<float> >& nnet::EventImageData::adcData ( void  ) const
inline

Definition at line 36 of file EventImageData.h.

36 { return fAdc; }
std::vector< std::vector< float > > fAdc
void nnet::EventImageData::addTpc ( const TrainingDataAlg dataAlg,
size_t  gw,
bool  flipw,
size_t  gd,
bool  flipd 
)

Definition at line 71 of file EventImageData.cxx.

72 {
73  float zero = dataAlg.ZeroLevel();
74  for (size_t w = 0; w < dataAlg.NWires(); ++w)
75  {
76  size_t drift_size = dataAlg.NScaledDrifts();
77  std::vector<float> & dstAdc = fAdc[gw + w];
78  std::vector<float> & dstDep = fDeposit[gw + w];
79  std::vector<int> & dstPdg = fPdg[gw + w];
80  const float* srcAdc = 0;
81  const float* srcDep = 0;
82  const int* srcPdg = 0;
83  if (flipw)
84  {
85  srcAdc = dataAlg.wireData(dataAlg.NWires() - w - 1).data();
86  srcDep = dataAlg.wireEdep(dataAlg.NWires() - w - 1).data();
87  srcPdg = dataAlg.wirePdg(dataAlg.NWires() - w - 1).data();
88  }
89  else
90  {
91  srcAdc = dataAlg.wireData(w).data();
92  srcDep = dataAlg.wireEdep(w).data();
93  srcPdg = dataAlg.wirePdg(w).data();
94  }
95  if (flipd)
96  {
97  for (size_t d = 0; d < drift_size; ++d) { dstAdc[gd + d] += srcAdc[drift_size - d - 1] - zero; }
98  if (fSaveDep) { for (size_t d = 0; d < drift_size; ++d) { dstDep[gd + d] += srcDep[drift_size - d - 1]; } }
99  for (size_t d = 0; d < drift_size; ++d)
100  {
101  int code = srcPdg[drift_size - d - 1];
102  int best_pdg = code & nnet::TrainingDataAlg::kPdgMask;
103  int vtx_flags = (dstPdg[gd + d] | code) & nnet::TrainingDataAlg::kVtxMask;
104  dstPdg[gd + d] = vtx_flags | best_pdg; // now just overwrite pdg and keep all vtx flags
105 
106  if (code & nnet::TrainingDataAlg::kNuPri) { fVtxX = gw + w; fVtxY = gd + d; } // dstAdc[gd + d] = 127; }
107  }
108  }
109  else
110  {
111  for (size_t d = 0; d < drift_size; ++d) { dstAdc[gd + d] += srcAdc[d] - zero; }
112  if (fSaveDep) { for (size_t d = 0; d < drift_size; ++d) { dstDep[gd + d] += srcDep[d]; } }
113  for (size_t d = 0; d < drift_size; ++d)
114  {
115  int code = srcPdg[d];
116  int best_pdg = code & nnet::TrainingDataAlg::kPdgMask;
117  int vtx_flags = (dstPdg[gd + d] | code) & nnet::TrainingDataAlg::kVtxMask;
118  dstPdg[gd + d] = vtx_flags | best_pdg; // now just overwrite pdg and keep all vtx flags
119 
120  if (code & nnet::TrainingDataAlg::kNuPri) { fVtxX = gw + w; fVtxY = gd + d; } // dstAdc[gd + d] = 127; }
121  }
122  }
123  }
124 }
std::vector< std::vector< float > > fAdc
std::vector< std::vector< float > > fDeposit
std::vector< std::vector< int > > fPdg
CodeOutputInterface * code
const std::vector< std::vector<float> >& nnet::EventImageData::depData ( void  ) const
inline

Definition at line 39 of file EventImageData.h.

39 { return fDeposit; }
std::vector< std::vector< float > > fDeposit
bool nnet::EventImageData::findCrop ( size_t  max_area_cut,
unsigned int &  w0,
unsigned int &  w1,
unsigned int &  d0,
unsigned int &  d1 
) const

Definition at line 126 of file EventImageData.cxx.

127 {
128  size_t max_cut = max_area_cut / 4;
129  float adcThr = 10;
130 
131  w0 = 0;
132  size_t cut = 0;
133  while (w0 < fAdc.size())
134  {
135  for (auto const d : fAdc[w0]) { if (d > adcThr) cut++; }
136  if (cut < max_cut) w0++;
137  else break;
138  }
139  w1 = fAdc.size() - 1;
140  cut = 0;
141  while (w1 > w0)
142  {
143  for (auto const d : fAdc[w1]) { if (d > adcThr) cut++; }
144  if (cut < max_cut) w1--;
145  else break;
146  }
147  w1++;
148 
149  d0 = 0;
150  cut = 0;
151  while (d0 < fAdc.front().size())
152  {
153  for (size_t i = w0; i < w1; ++i) { if (fAdc[i][d0] > adcThr) cut++; }
154  if (cut < max_cut) d0++;
155  else break;
156  }
157  d1 = fAdc.front().size() - 1;
158  cut = 0;
159  while (d1 > d0)
160  {
161  for (size_t i = w0; i < w1; ++i) { if (fAdc[i][d1] > adcThr) cut++; }
162  if (cut < max_cut) d1--;
163  else break;
164  }
165  d1++;
166 
167  unsigned int margin = 32;
168  if ((w1 - w0 > 8) && (d1 - d0 > 8))
169  {
170  if (w0 < margin) w0 = 0;
171  else w0 -= margin;
172 
173  if (w1 > fAdc.size() - margin) w1 = fAdc.size();
174  else w1 += margin;
175 
176  if (d0 < margin) d0 = 0;
177  else d0 -= margin;
178 
179  if (d1 > fAdc.front().size() - margin) d1 = fAdc.front().size();
180  else d1 += margin;
181 
182  return true;
183  }
184  else return false;
185 }
std::vector< std::vector< float > > fAdc
float nnet::EventImageData::getProjX ( void  ) const
inline

Definition at line 46 of file EventImageData.h.

46 { return fProjX; }
float nnet::EventImageData::getProjY ( void  ) const
inline

Definition at line 47 of file EventImageData.h.

47 { return fProjY; }
int nnet::EventImageData::getVtxX ( void  ) const
inline

Definition at line 49 of file EventImageData.h.

49 { return fVtxX; }
int nnet::EventImageData::getVtxY ( void  ) const
inline

Definition at line 50 of file EventImageData.h.

50 { return fVtxY; }
const std::vector< std::vector<int> >& nnet::EventImageData::pdgData ( void  ) const
inline

Definition at line 42 of file EventImageData.h.

42 { return fPdg; }
std::vector< std::vector< int > > fPdg
void nnet::EventImageData::setProjXY ( const TrainingDataAlg dataAlg,
float  x,
float  y,
size_t  gw,
bool  flipw,
size_t  gd,
bool  flipd 
)

Definition at line 62 of file EventImageData.cxx.

63 {
64  if (flipw) { fProjX = gw + dataAlg.NWires() - x - 1; }
65  else { fProjX = gw + x; }
66 
67  if (flipd) { fProjY = gd + dataAlg.NScaledDrifts() - y/dataAlg.DriftWindow() - 1; }
68  else { fProjY = gd + y/dataAlg.DriftWindow(); }
69 }
list x
Definition: train.py:276
const std::vector<float>& nnet::EventImageData::wireAdc ( size_t  widx) const
inline

Definition at line 37 of file EventImageData.h.

37 { return fAdc[widx]; }
std::vector< std::vector< float > > fAdc
const std::vector<float>& nnet::EventImageData::wireDep ( size_t  widx) const
inline

Definition at line 40 of file EventImageData.h.

40 { return fDeposit[widx]; }
std::vector< std::vector< float > > fDeposit
const std::vector<int>& nnet::EventImageData::wirePdg ( size_t  widx) const
inline

Definition at line 43 of file EventImageData.h.

43 { return fPdg[widx]; }
std::vector< std::vector< int > > fPdg

Member Data Documentation

std::vector< std::vector<float> > nnet::EventImageData::fAdc
private

Definition at line 53 of file EventImageData.h.

std::vector< std::vector<float> > nnet::EventImageData::fDeposit
private

Definition at line 53 of file EventImageData.h.

std::vector< std::vector<int> > nnet::EventImageData::fPdg
private

Definition at line 54 of file EventImageData.h.

float nnet::EventImageData::fProjX
private

Definition at line 56 of file EventImageData.h.

float nnet::EventImageData::fProjY
private

Definition at line 56 of file EventImageData.h.

bool nnet::EventImageData::fSaveDep
private

Definition at line 57 of file EventImageData.h.

int nnet::EventImageData::fVtxX
private

Definition at line 55 of file EventImageData.h.

int nnet::EventImageData::fVtxY
private

Definition at line 55 of file EventImageData.h.


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