20 class DetectorClocksData;
21 class DetectorPropertiesData;
46 #include <unordered_map> 51 class KerasModelInterface;
52 class TfModelInterface;
54 class TrainingDataAlg;
64 virtual std::vector<float> Run(
std::vector<std::vector<float>>
const& inp2d) = 0;
65 virtual std::vector<std::vector<float>> Run(
70 std::string findFile(
const char* fileName)
const;
78 std::vector<float> Run(
std::vector<std::vector<float>>
const& inp2d)
override;
90 int samples = -1)
override;
91 std::vector<float> Run(
std::vector<std::vector<float>>
const& inp2d)
override;
94 std::unique_ptr<tf::Graph>
g;
105 Comment(
"Neural net model to apply.")};
107 Comment(
"Labels of the network outputs.")};
111 Comment(
"How many downsampled ADC entries in patch")};
121 std::vector<std::string>
const&
outputLabels()
const {
return fNNetOutputs; }
124 float predictIdValue(
unsigned int wire,
float drift,
size_t outIdx = 0)
const;
127 std::vector<float> predictIdVector(
unsigned int wire,
float drift)
const;
129 std::vector<std::vector<float>> predictIdVectors(
130 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()
const {
return fWireDriftPatch; }
137 return flattenData2D(fWireDriftPatch);
140 bool isInsideFiducialRegion(
unsigned int wire,
float drift)
const;
144 bool isCurrentPatch(
unsigned int wire,
float drift)
const;
147 bool isSamePatch(
unsigned int wire1,
float drift1,
unsigned int wire2,
float drift2)
const;
160 if (fDownscaleFullView) {
161 size_t sd = (size_t)(drift / fDriftWindow);
162 if ((fCurrentWireIdx == wire) && (fCurrentScaledDrift == sd))
165 fCurrentWireIdx = wire;
166 fCurrentScaledDrift = sd;
168 return patchFromDownsampledView(wire, drift, fPatchSizeW, fPatchSizeD, patch);
171 if ((fCurrentWireIdx == wire) && (fCurrentScaledDrift == drift))
174 fCurrentWireIdx = wire;
175 fCurrentScaledDrift = drift;
177 return patchFromOriginalView(wire, drift, fPatchSizeW, fPatchSizeD, patch);
182 return bufferPatch(wire, drift, fWireDriftPatch);
188 if (fNNet)
delete fNNet;
200 kPdgMask = 0x00000FFF,
201 kTypeMask = 0x0000F000,
202 kVtxMask = 0xFFFF0000
223 kElectronEnd = 0x10000000,
224 kElastic = 0x20000000,
225 kInelastic = 0x40000000
239 Comment(
"Tag of simulation producer.")};
242 Comment(
"Tag of sim::SimChannel producer.")};
245 Comment(
"Include (or not) vertex info in PDG map.")};
248 Name(
"AdcDelayTicks"),
249 Comment(
"ADC pulse peak delay in ticks (non-zero for not deconvoluted waveforms).")};
260 void reconfigure(
const Config& config);
272 bool setDataEventData(
280 bool findCrop(
float max_e_cut,
284 unsigned int& d1)
const;
287 std::vector<float>
const&
wireEdep(
size_t widx)
const {
return fWireDriftEdep[widx]; }
288 std::vector<int>
const&
wirePdg(
size_t widx)
const {
return fWireDriftPdg[widx]; }
294 size_t drifts)
override;
307 const TLorentzVector& tvec,
308 unsigned int plane)
const;
310 bool setWireEdepsAndLabels(std::vector<float>
const& edeps,
311 std::vector<int>
const& pdgs,
314 void collectVtxFlags(
315 std::unordered_map<
size_t, std::unordered_map<int, int>>& wireToDriftToVtxFlags,
318 const std::unordered_map<int, const simb::MCParticle*>& particleMap,
319 unsigned int plane)
const;
323 float dx = particle.
EndX() - particle.
Vx();
324 float dy = particle.
EndY() - particle.
Vy();
325 float dz = particle.
EndZ() - particle.
Vz();
326 return dx * dx + dy * dy + dz * dz;
329 const std::unordered_map<int, const simb::MCParticle*>& particleMap)
const;
332 const std::unordered_map<int, const simb::MCParticle*>& particleMap)
const;
std::vector< std::string > const & outputLabels() const
network output labels
std::vector< float > const & wireEdep(size_t widx) const
std::vector< std::vector< float > > fWireDriftPatch
bool bufferPatch(size_t wire, float drift) const
art::InputTag fTrackModuleLabel
bool bufferPatch(size_t wire, float drift, std::vector< std::vector< float >> &patch) const
double getEdepTot() const
std::vector< std::string > fNNetOutputs
std::vector< float > patchData1D() const
virtual ~ModelInterface()
art::InputTag fWireProducerLabel
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
std::vector< std::vector< float > > const & patchData2D() const
std::vector< size_t > fEventsPerBin
art::InputTag fSimChannelProducerLabel
General LArSoft Utilities.
std::vector< std::vector< int > > fWireDriftPdg
double Vx(const int i=0) const
std::vector< std::vector< float > > fWireDriftEdep
Contains all timing reference information for the detector.
static float particleRange2(const simb::MCParticle &particle)
double Vz(const int i=0) const
nnet::ModelInterface * fNNet
std::unique_ptr< tf::Graph > g
art::InputTag fSimulationProducerLabel
std::string fNNetModelFilePath
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)
map< int, array< map< int, double >, 2 >> Table
PointIdAlg(const fhicl::ParameterSet &pset)