31 #include "Utilities/AssociationUtil.h" 56 bool filter(std::vector<unsigned char> pm,
int view);
57 std::vector<tensorflow::Tensor> vector_to_tensor(std::vector<unsigned char>, std::vector<unsigned char>);
105 fClusterToken(consumes<
std::vector<
rb::Cluster>>(pset.
get<
std::
string>(
"ClusterLabel"))),
106 fPixelMapInput (pset.
get<
std::
string> (
"PixelMapInput")),
109 fProngModLabel (pset.
get<
std::
string> (
"ProngModLabel")),
110 fIs2DProng (pset.
get<bool> (
"Is2DProng")),
115 fObeyPreselection (pset.
get<bool> (
"ObeyPreselection")),
116 fSkipLongProngs(pset.
get<bool> (
"SkipLongProngs")),
117 fProngOnly (pset.
get<bool> (
"ProngOnly")),
118 fProngLengthCut (pset.
get<double> (
"ProngLengthCut")),
121 fPreselectionLabels (pset.
get<
std::vector<
std::
string>> (
"PreselectionLabels")),
128 produces< std::vector<cvn::Result> >();
129 produces< art::Assns<cvn::Result, rb::Cluster> >();
130 produces< art::Assns<cvn::Result, rb::Prong> >();
131 produces< std::vector<rb::PID> >();
132 produces< art::Assns<rb::PID, rb::Prong> >();
147 float x(0),
y(0), tmpx(0), tmpy(0);
148 for(
int i = 0;
i<8000;
i++){
154 for(
int i = 8000;
i<16000;
i++){
158 if(view &&
y<=3)
return false;
159 if((!view) &&
x<=3)
return false;
165 tensorflow::Tensor tensorx(tensorflow::DT_FLOAT, {1,16000});
166 tensorflow::Tensor tensory(tensorflow::DT_FLOAT, {1,16000});
168 auto relx = tensorx.tensor<
float,2>();
169 auto rely = tensory.tensor<
float,2>();
172 for(
int i = 0;
i<8000;
i++){
174 relx(0,
i) = slicepm[
i];
175 relx(0,
i+8000) = prongpm[
i];
178 for(
int i = 8000;
i< 16000;
i++){
179 rely(0,
i-8000) = slicepm[
i];
180 rely(0,
i) = prongpm[
i];
183 return {tensorx, tensory};
200 std::unique_ptr< std::vector<Result> >
201 resultCol(
new std::vector<Result>);
202 std::unique_ptr< std::vector<rb::PID> >
203 pidCol(
new std::vector<rb::PID>);
204 std::unique_ptr< art::Assns<Result, rb::Cluster> >
206 std::unique_ptr< art::Assns<Result, rb::Prong> >
208 std::unique_ptr< art::Assns<rb::PID, rb::Prong> >
214 const std::vector<rb::Cluster> & clusters = *clusterHandle;
217 for(
unsigned int i = 0;
i<clusterHandle->size();
i++){
223 if(!fmSlicePM.isValid())
return;
225 for(
size_t iClust = 0; iClust < clusters.size(); iClust++) {
228 if(clusters[iClust].IsNoise())
continue;
230 const std::vector<art::Ptr<PixelMap> > slicePMs = fmSlicePM.at(iClust);
233 if(!fmProng.isValid())
continue;
235 std::vector<art::Ptr<rb::Prong>> prongs;
237 prongs = fmProng.at(iClust);
239 if(prongs.empty())
continue;
241 if( !fmProngPM.isValid())
continue;
243 for(
unsigned int iProng = 0; iProng < prongs.size(); iProng++ ){
248 if(prong->
NXCell()) view = 0;
249 else if(prong->
NYCell()) view = 1;
260 const std::vector<art::Ptr<PixelMap>> pm = fmProngPM.at(iProng);
261 if (pm.empty())
continue;
262 if (slicePMs.empty())
continue;
263 std::vector<unsigned char> prongpm = (*pm[0]).PixelMapToVector(
fUseGeV);
264 std::vector<unsigned char> slicepm = (*slicePMs[0]).PixelMapToVector(
fUseGeV);
266 if(!
filter(prongpm, view))
continue;
267 std::vector<tensorflow::Tensor> tensor =
vector_to_tensor(prongpm, slicepm);
272 auto tfoutput = result[0].tensor<
float,2>();
274 std::vector<std::pair<int, double>> outputwithpdg;
278 pidCol->emplace_back(outputwithpdg[j].first, outputwithpdg[j].
second);
280 prongs[iProng], *(assocpid.get()), UINT_MAX);
281 output[
j] = (
float)tfoutput(0,j);
283 const float* outputptr =
output;
284 resultCol->emplace_back(outputptr, fNOutput);
291 sliceCol[iClust], *(assoc.get()), UINT_MAX);
293 prongs[iProng], *(assocp.get()), UINT_MAX);
297 evt.
put(std::move(pidCol));
298 evt.
put(std::move(resultCol));
299 evt.
put(std::move(assoc));
300 evt.
put(std::move(assocp));
301 evt.
put(std::move(assocpid));
std::string fProng2DLabel
static bool CreateAssn(art::EDProducer const &prod, art::Event &evt, std::vector< T > &a, art::Ptr< U > b, art::Assns< T, U > &assn, size_t indx=UINT_MAX, std::string const &instance=std::string())
Create a 1 to 1 association between a new product and one already in the event.
void produce(art::Event &evt)
bool filter(std::vector< unsigned char > pm, int view)
tensorflow::TFHandler * fTF
std::string fProngPMLabel
std::string EnvExpansion(const std::string &inString)
Function to expand environment variables.
std::vector< std::string > fPreselectionLabels
std::pair< Spectrum *, CheatDecomp * > make_pair(SpectrumLoaderBase &loader_data, SpectrumLoaderBase &loader_mc, HistAxis *axis, Cut *cut, const SystShifts &shift, const Var &wei)
DEFINE_ART_MODULE(TestTMapFile)
Defines an enumeration for prong classification.
std::vector< Tensor > Predict(std::vector< std::pair< std::string, Tensor >> inputs, std::vector< std::string > outputLabels)
std::string fSlicePMLabel
Module that kips a configurable number of events between each that it allows through. Note that this module really skips (N-1) events, it uses a simple modular division as its critera. This module will cut down the data sample to 1/N of its original size.
std::string fProngModLabel
Module lablel for input prongs.
ProductID put(std::unique_ptr< PROD > &&product)
const art::ProductToken< std::vector< rb::Cluster > > fClusterToken
Module lablel for input clusters.
virtual double TotalLength() const
Distance along prong to reach last cell hit.
void push_back(Ptr< U > const &p)
std::vector< tensorflow::Tensor > vector_to_tensor(std::vector< unsigned char >, std::vector< unsigned char >)
std::string fProng3DLabel
bool IsFiltered(const art::Event &evt, art::Ptr< T > x, const std::vector< std::string > &labels)
Is this Ptr marked "filtered out"?
Perform a "2 point" Hough transform on a collection of hits.
int GetPDGByPType(PType ptype)
unsigned int NYCell() const
Number of cells in the y-view.
bool fObeyPreselection
Check rb::IsFiltered?
unsigned int fNOutput
Number of outputs fron neural net.
bool fIs2DProng
Instance lablel for input 3D prongs.
std::string fPixelMapInput
Module label for input pixel maps.
unsigned int NXCell() const
Number of cells in the x-view.
bool getByToken(ProductToken< PROD > const &token, Handle< PROD > &result) const
Wrapper for Tensorflow which handles construction and prediction.