Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
cvntf::CVNTF Class Reference
Inheritance diagram for cvntf::CVNTF:
art::EDProducer art::ProducerBase art::Consumer art::EngineCreator art::ProductRegistryHelper

Public Types

using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
template<typename UserConfig , typename KeysToIgnore = void>
using Table = ProducerBase::Table< UserConfig, KeysToIgnore >
 

Public Member Functions

 CVNTF (fhicl::ParameterSet const &pset)
 
virtual ~CVNTF ()
 
void produce (art::Event &evt)
 
tensorflow::Tensor vector_to_tensor (std::vector< unsigned char >)
 
template<typename PROD , BranchType B = InEvent>
ProductID getProductID (std::string const &instanceName={}) const
 
template<typename PROD , BranchType B>
ProductID getProductID (ModuleDescription const &moduleDescription, std::string const &instanceName) const
 
bool modifiesEvent () const
 
template<typename T , BranchType = InEvent>
ProductToken< Tconsumes (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< Tconsumes (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< TconsumesView (InputTag const &it)
 
template<typename T , BranchType = InEvent>
ProductToken< TmayConsume (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< TmayConsume (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< TmayConsumeView (InputTag const &it)
 
base_engine_tcreateEngine (seed_t seed)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make, label_t const &engine_label)
 
seed_t get_seed_value (fhicl::ParameterSet const &pset, char const key[]="seed", seed_t const implicit_seed=-1)
 

Static Public Member Functions

static cet::exempt_ptr< Consumernon_module_context ()
 

Protected Member Functions

CurrentProcessingContext const * currentContext () const
 
void validateConsumedProduct (BranchType const bt, ProductInfo const &pi)
 
void prepareForJob (fhicl::ParameterSet const &pset)
 
void showMissingConsumes () const
 

Protected Attributes

std::string fSliceLabel
 
std::string fPixelMapInput
 
bool fUseGeV
 
std::string fModelPath
 
tensorflow::TFHandlerfTF
 

Detailed Description

Definition at line 22 of file CVNTF_module.cc.

Member Typedef Documentation

using art::EDProducer::ModuleType = EDProducer
inherited

Definition at line 34 of file EDProducer.h.

template<typename UserConfig , typename KeysToIgnore = void>
using art::EDProducer::Table = ProducerBase::Table<UserConfig, KeysToIgnore>
inherited

Definition at line 43 of file EDProducer.h.

using art::EDProducer::WorkerType = WorkerT<EDProducer>
inherited

Definition at line 35 of file EDProducer.h.

Constructor & Destructor Documentation

cvntf::CVNTF::CVNTF ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 41 of file CVNTF_module.cc.

References fModelPath, and fTF.

41  :
42  fSliceLabel (pset.get<std::string>("SliceLabel")),
43  fPixelMapInput(pset.get<std::string>("PixelMapInput")),
44  fUseGeV (pset.get<bool> ("UseGeV")),
45  fModelPath (pset.get<std::string>("ModelPath")),
46  fTF(0)
47  {
49  }
std::string fSliceLabel
Definition: CVNTF_module.cc:31
std::string fModelPath
Definition: CVNTF_module.cc:34
tensorflow::TFHandler * fTF
Definition: CVNTF_module.cc:36
std::string fPixelMapInput
Definition: CVNTF_module.cc:32
Wrapper for Tensorflow which handles construction and prediction.
Definition: TFHandler.h:19
enum BeamMode string
cvntf::CVNTF::~CVNTF ( )
virtual

Definition at line 51 of file CVNTF_module.cc.

References fTF.

52  {
53  if(fTF) delete fTF;
54  }
tensorflow::TFHandler * fTF
Definition: CVNTF_module.cc:36

Member Function Documentation

template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::consumes ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::consumes ( InputTag const &  it)
inherited

Definition at line 146 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

147 {
148  if (!moduleContext_)
149  return ProductToken<T>::invalid();
150 
151  consumables_[BT].emplace_back(ConsumableType::Product,
152  TypeID{typeid(T)},
153  it.label(),
154  it.instance(),
155  it.process());
156  return ProductToken<T>{it};
157 }
set< int >::iterator it
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename T , art::BranchType BT>
void art::Consumer::consumesMany ( )
inherited

Definition at line 161 of file Consumer.h.

References T.

162 {
163  if (!moduleContext_)
164  return;
165 
166  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
167 }
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::consumesView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::consumesView ( InputTag const &  it)
inherited

Definition at line 171 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

172 {
173  if (!moduleContext_)
174  return ViewToken<T>::invalid();
175 
176  consumables_[BT].emplace_back(ConsumableType::ViewElement,
177  TypeID{typeid(T)},
178  it.label(),
179  it.instance(),
180  it.process());
181  return ViewToken<T>{it};
182 }
set< int >::iterator it
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
base_engine_t& art::EngineCreator::createEngine ( seed_t  seed)
inherited
base_engine_t& art::EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make 
)
inherited
base_engine_t& art::EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make,
label_t const &  engine_label 
)
inherited
CurrentProcessingContext const* art::EDProducer::currentContext ( ) const
protectedinherited
seed_t art::EngineCreator::get_seed_value ( fhicl::ParameterSet const &  pset,
char const  key[] = "seed",
seed_t const  implicit_seed = -1 
)
inherited
template<typename PROD , BranchType B>
ProductID art::EDProducer::getProductID ( std::string const &  instanceName = {}) const
inlineinherited

Definition at line 123 of file EDProducer.h.

References art::EDProducer::moduleDescription_.

Referenced by skim::NueSkimmer::CopyMichelSlice(), and skim::NueSkimmer::CopyMichelTrack().

124  {
125  return ProducerBase::getProductID<PROD, B>(moduleDescription_,
126  instanceName);
127  }
ModuleDescription moduleDescription_
Definition: EDProducer.h:115
template<typename PROD , BranchType B>
ProductID art::ProducerBase::getProductID ( ModuleDescription const &  moduleDescription,
std::string const &  instanceName 
) const
inherited

Definition at line 56 of file ProducerBase.h.

References art::ModuleDescription::moduleLabel().

Referenced by art::ProducerBase::modifiesEvent().

58  {
59  auto const& pd =
60  get_ProductDescription<PROD>(B, md.moduleLabel(), instanceName);
61  return pd.productID();
62  }
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::mayConsume ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::mayConsume ( InputTag const &  it)
inherited

Definition at line 189 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

190 {
191  if (!moduleContext_)
192  return ProductToken<T>::invalid();
193 
194  consumables_[BT].emplace_back(ConsumableType::Product,
195  TypeID{typeid(T)},
196  it.label(),
197  it.instance(),
198  it.process());
199  return ProductToken<T>{it};
200 }
set< int >::iterator it
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename T , art::BranchType BT>
void art::Consumer::mayConsumeMany ( )
inherited

Definition at line 204 of file Consumer.h.

References T.

205 {
206  if (!moduleContext_)
207  return;
208 
209  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
210 }
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::mayConsumeView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::mayConsumeView ( InputTag const &  it)
inherited

Definition at line 214 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

215 {
216  if (!moduleContext_)
217  return ViewToken<T>::invalid();
218 
219  consumables_[BT].emplace_back(ConsumableType::ViewElement,
220  TypeID{typeid(T)},
221  it.label(),
222  it.instance(),
223  it.process());
224  return ViewToken<T>{it};
225 }
set< int >::iterator it
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
bool art::ProducerBase::modifiesEvent ( ) const
inlineinherited

Definition at line 40 of file ProducerBase.h.

References art::ProducerBase::getProductID(), and string.

41  {
42  return true;
43  }
static cet::exempt_ptr<Consumer> art::Consumer::non_module_context ( )
staticinherited
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited
void cvntf::CVNTF::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 70 of file CVNTF_module.cc.

References om::cout, DEFINE_ART_MODULE(), allTimeWatchdog::endl, check_time_usage::float, fPixelMapInput, fSliceLabel, fTF, fUseGeV, art::DataViewImpl::getByLabel(), MECModelEnuComparisons::i, tensorflow::TFHandler::Predict(), art::PtrVector< T >::push_back(), fillBadChanDBTables::result, art::PtrVector< T >::size(), and vector_to_tensor().

71  {
72  // Get slices
74  evt.getByLabel(fSliceLabel, slicecol);
76  for(unsigned int i = 0; i < slicecol->size(); ++i){
77  slicelist.push_back(art::Ptr<rb::Cluster>(slicecol, i));
78  }
79 
80  // Get pixel maps
81  art::FindManyP<cvn::PixelMap> fmPixelMap(slicecol, evt, fPixelMapInput);
82 
83  //loop over slices
84  for(size_t iClust = 0; iClust < slicelist.size(); ++iClust) {
85  if(!fmPixelMap.isValid()) continue;
86  if(slicelist[iClust]->IsNoise()) continue;
87 
88  const std::vector<art::Ptr<cvn::PixelMap> > pixelMaps = fmPixelMap.at(iClust);
89  if(pixelMaps.empty()) continue;
90 
91  // Fill the pixel map array for this slice
92  std::vector<unsigned char> pm = (*pixelMaps[0]).PixelMapToVector(fUseGeV);
93 
94  // Convert to format expected by the network
95  tensorflow::Tensor tensor = vector_to_tensor(pm);
96 
97  std::vector<tensorflow::Tensor> result = fTF->Predict({{"input",tensor}},
98  {"output_out"});
99 
100  auto tfoutput = result[0].tensor<float,2>();
101 
102  std::cout<<"Graph Output: "<<std::endl;
103  std::cout<<tfoutput(0,0)<<std::endl;
104  std::cout<<tfoutput(0,1)<<std::endl;
105  std::cout<<tfoutput(0,2)<<std::endl;
106  std::cout<<tfoutput(0,3)<<std::endl;
107  std::cout<<tfoutput(0,4)<<std::endl;
108  } // slices
109  } // produce
std::string fSliceLabel
Definition: CVNTF_module.cc:31
tensorflow::Tensor vector_to_tensor(std::vector< unsigned char >)
Definition: CVNTF_module.cc:56
std::vector< Tensor > Predict(std::vector< std::pair< std::string, Tensor >> inputs, std::vector< std::string > outputLabels)
Definition: TFHandler.cxx:64
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:441
tensorflow::TFHandler * fTF
Definition: CVNTF_module.cc:36
size_type size() const
Definition: PtrVector.h:308
OStream cout
Definition: OStream.cxx:6
std::string fPixelMapInput
Definition: CVNTF_module.cc:32
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

Referenced by art::RootOutput::endJob().

void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited
tensorflow::Tensor cvntf::CVNTF::vector_to_tensor ( std::vector< unsigned char >  pm)

Definition at line 56 of file CVNTF_module.cc.

References check_time_usage::float, MECModelEnuComparisons::i, and shutoffs::rel.

Referenced by produce().

57  {
58  const unsigned int vectorSize = pm.size();
59 
60  // Initialize the tensors
61  tensorflow::Tensor tensor(tensorflow::DT_FLOAT, {1, vectorSize});
62  auto rel = tensor.tensor<float,2>();
63 
64  // Loop over each element
65  for(unsigned int i = 0; i < vectorSize; ++i) rel(0, i) = pm[i];
66 
67  return tensor;
68  }
string rel
Definition: shutoffs.py:11

Member Data Documentation

std::string cvntf::CVNTF::fModelPath
protected

Definition at line 34 of file CVNTF_module.cc.

Referenced by CVNTF().

std::string cvntf::CVNTF::fPixelMapInput
protected

Definition at line 32 of file CVNTF_module.cc.

Referenced by produce().

std::string cvntf::CVNTF::fSliceLabel
protected

Definition at line 31 of file CVNTF_module.cc.

Referenced by produce().

tensorflow::TFHandler* cvntf::CVNTF::fTF
protected

Definition at line 36 of file CVNTF_module.cc.

Referenced by CVNTF(), produce(), and ~CVNTF().

bool cvntf::CVNTF::fUseGeV
protected

Definition at line 33 of file CVNTF_module.cc.

Referenced by produce().


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