23 #include "canvas/Persistency/Common/FindManyP.h" 39 class KerasModelInterface;
40 class TfModelInterface;
42 class TrainingDataAlg;
53 virtual std::vector<float>
Run(
std::vector< std::vector<float> >
const & inp2d) = 0;
54 virtual std::vector< std::vector<float> >
Run(
std::vector<
std::vector< std::vector<float> > >
const & inps,
int samples = -1);
68 std::vector<float>
Run(
std::vector< std::vector<float> >
const & inp2d)
override;
80 std::vector< std::vector<float> >
Run(
std::vector<
std::vector< std::vector<float> > >
const & inps,
int samples = -1)
override;
81 std::vector<float>
Run(
std::vector< std::vector<float> >
const & inp2d)
override;
84 std::unique_ptr<tf::Graph>
g;
98 Name(
"NNetModelFile"),
Comment(
"Neural net model to apply.")
101 Name(
"NNetOutputs"),
Comment(
"Labels of the network outputs.")
105 Name(
"PatchSizeW"),
Comment(
"How many wires in patch.")
109 Name(
"PatchSizeD"),
Comment(
"How many downsampled ADC entries in patch")
122 std::vector< std::string >
const &
outputLabels(
void)
const {
return fNNetOutputs; }
125 float predictIdValue(
unsigned int wire,
float drift,
size_t outIdx = 0)
const;
128 std::vector<float> predictIdVector(
unsigned int wire,
float drift)
const;
130 std::vector< std::vector<float> > predictIdVectors(
std::vector< std::pair<unsigned int, float> > points)
const;
132 static std::vector<float> flattenData2D(
std::vector< std::vector<float> >
const &
patch);
134 std::vector< std::vector<float> >
const &
patchData2D(
void)
const {
return fWireDriftPatch; }
135 std::vector<float>
patchData1D(
void)
const {
return flattenData2D(fWireDriftPatch); }
137 bool isInsideFiducialRegion(
unsigned int wire,
float drift)
const;
141 bool isCurrentPatch(
unsigned int wire,
float drift)
const;
144 bool isSamePatch(
unsigned int wire1,
float drift1,
unsigned int wire2,
float drift2)
const;
157 if (fDownscaleFullView)
159 size_t sd = (size_t)(drift / fDriftWindow);
160 if ((fCurrentWireIdx == wire) && (fCurrentScaledDrift == sd))
163 fCurrentWireIdx = wire; fCurrentScaledDrift = sd;
165 return patchFromDownsampledView(wire, drift, fPatchSizeW, fPatchSizeD,
patch);
169 if ((fCurrentWireIdx == wire) && (fCurrentScaledDrift == drift))
172 fCurrentWireIdx = wire; fCurrentScaledDrift = drift;
174 return patchFromOriginalView(wire, drift, fPatchSizeW, fPatchSizeD,
patch);
178 void resizePatch(
void);
180 void deleteNNet(
void) {
if (fNNet)
delete fNNet; fNNet = 0; }
193 kPdgMask = 0x00000FFF,
194 kTypeMask = 0x0000F000,
195 kVtxMask = 0xFFFF0000
208 kNuNC = 0x0010000, kNuCC = 0x0020000, kNuPri = 0x0040000,
209 kNuE = 0x0100000, kNuMu = 0x0200000, kNuTau = 0x0400000,
214 kElectronEnd = 0x10000000,
236 Comment(
"Tag of recob::Track.")
240 Name(
"SimulationLabel"),
241 Comment(
"Tag of simulation producer.")
245 Name(
"SaveVtxFlags"),
246 Comment(
"Include (or not) vertex info in PDG map.")
250 Name(
"AdcDelayTicks"),
251 Comment(
"ADC pulse peak delay in ticks (non-zero for not deconvoluted waveforms).")
263 void reconfigure(
const Config& config);
268 unsigned int plane,
unsigned int tpc,
unsigned int cryo);
270 bool setDataEventData(
const art::Event& event,
271 unsigned int plane,
unsigned int tpc,
unsigned int cryo);
274 bool findCrop(
float max_e_cut,
unsigned int & w0,
unsigned int & w1,
unsigned int & d0,
unsigned int & d1)
const;
277 std::vector<float>
const &
wireEdep(
size_t widx)
const {
return fWireDriftEdep[widx]; }
278 std::vector<int>
const &
wirePdg(
size_t widx)
const {
return fWireDriftPdg[widx]; }
282 void resizeView(
size_t wires,
size_t drifts)
override;
294 WireDrift getProjection(
const TLorentzVector& tvec,
unsigned int plane)
const;
296 bool setWireEdepsAndLabels(
297 std::vector<float>
const & edeps,
298 std::vector<int>
const & pdgs,
301 void collectVtxFlags(
302 std::unordered_map<
size_t, std::unordered_map< int, int > > & wireToDriftToVtxFlags,
303 const std::unordered_map< int, const simb::MCParticle* > & particleMap,
304 unsigned int plane)
const;
308 float dx = particle.
EndX() - particle.
Vx();
309 float dy = particle.
EndY() - particle.
Vy();
310 float dz = particle.
EndZ() - particle.
Vz();
311 return dx*dx + dy*dy + dz*dz;
315 const std::unordered_map< int, const simb::MCParticle* > & particleMap)
const;
319 const std::unordered_map< int, const simb::MCParticle* > & particleMap)
const;
bool bufferPatch(size_t wire, float drift, std::vector< std::vector< float > > &patch) const
std::vector< float > const & wireEdep(size_t widx) const
std::vector< float > patchData1D(void) const
std::vector< std::vector< int > > fWireDriftPdg
std::vector< std::vector< float > > const & patchData2D(void) const
bool bufferPatch(size_t wire, float drift) const
art::InputTag fTrackModuleLabel
Declaration of signal hit object.
std::vector< std::vector< float > > fWireDriftPatch
virtual std::vector< float > Run(std::vector< std::vector< float > > const &inp2d)=0
std::vector< size_t > fEventsPerBin
std::vector< std::string > fNNetOutputs
nnet::ModelInterface * fNNet
art::InputTag fWireProducerLabel
std::vector< std::string > const & outputLabels(void) const
network output labels
std::vector< std::vector< float > > fWireDriftEdep
Provides recob::Track data product.
double getEdepTot(void) const
double Vx(const int i=0) const
virtual ~ModelInterface(void)
std::string findFile(const char *fileName) const
static float particleRange2(const simb::MCParticle &particle)
double Vz(const int i=0) const
art::InputTag fSimulationProducerLabel
std::string fNNetModelFilePath
std::unique_ptr< tf::Graph > g
std::vector< int > const & wirePdg(size_t widx) const
art::InputTag fHitProducerLabel
double Vy(const int i=0) const
Event finding and building.
TrainingDataAlg(const fhicl::ParameterSet &pset)
PointIdAlg(const fhicl::ParameterSet &pset)