24 fTFProtoBuf (fLibPath+
"/"+pset.
get<
std::
string>(
"TFProtoBuf")),
25 fUseLogChargeScale(pset.
get<
bool>(
"ChargeLogScale")),
26 fImageWires(pset.
get<unsigned
int>(
"NImageWires")),
27 fImageTDCs(pset.
get<unsigned
int>(
"NImageTDCs")),
44 if (
outputs.size() == 1)
return true;
46 for (
size_t o = 0; o <
outputs.size(); ++o)
50 for (
size_t i = 0; i <
outputs[o].size(); ++i)
55 return aux ==
outputs.size() ?
false :
true;
61 for (
size_t o = 0; o <
outputs.size(); ++o)
63 for (
size_t i = 0; i <
outputs[o].size(); ++i)
81 std::vector<ImageVectorF> vecForTF;
83 vecForTF.push_back(thisImage);
85 std::vector< std::vector< std::vector< float > > > cvnResults;
92 cvnResults =
fTFGraph->run(vecForTF);
93 status =
check(cvnResults[0]);
97 std::cout <<
"Error, CVN never outputing a correct result. Filling result with zeros.";
102 }
while(status ==
false);
104 std::cout <<
"Classifier summary: ";
106 int output_index = 0;
107 for(
auto const &
output : cvnResults[0])
109 std::cout <<
"Output " << output_index++ <<
": ";
110 for(
auto const v :
output)
111 std::cout << v <<
", ";
116 return cvnResults[0];
std::vector< ViewVectorF > ImageVectorF
TFNetHandler(const fhicl::ParameterSet &pset)
Constructor which takes a pset with DeployProto and ModelFile fields.
std::vector< std::vector< float > > Predict(const PixelMap &pm)
Return prediction arrays for PixelMap.
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
void SetViewReversal(bool reverseX, bool reverseY, bool reverseZ)
Function to set any views that need reversing.
void SetLogScale(bool setLog)
Set the log scale for charge.
unsigned int fImageWires
Number of wires for the network to classify.
Utility class for truth labels.
bool check(const std::vector< std::vector< float > > &outputs)
std::unique_ptr< tf::Graph > fTFGraph
Tensorflow graph.
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
unsigned int fImageTDCs
Number of tdcs for the network to classify.
Utilities for producing images for the CVN.
std::string getenv(std::string const &name)
T get(std::string const &key) const
static std::unique_ptr< Graph > create(const char *graph_file_name, const std::vector< std::string > &outputs={}, int ninputs=1, int noutputs=1)
void ConvertPixelMapToImageVectorF(const PixelMap &pm, ImageVectorF &imageVec)
Convert a pixel map into an image vector (float version)
Class containing some utility functions for all things CVN.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
void SetImageSize(unsigned int nWires, unsigned int nTDCs, unsigned int nViews)
Set up the image size that we want to have.
bool fUseLogChargeScale
Is the charge using a log scale?
std::vector< bool > fReverseViews
Do we need to reverse any views?
PixelMap, basic input to CVN neural net.
void fillEmpty(std::vector< std::vector< float > > &outputs)
auto const & get(AssnsNode< L, R, D > const &r)
QTextStream & endl(QTextStream &s)
std::string fTFProtoBuf
location of the tf .pb file in the above path