Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
regcvntf::RegCVNTF Class Reference
Inheritance diagram for regcvntf::RegCVNTF:
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

 RegCVNTF (fhicl::ParameterSet const &pset)
 
virtual ~RegCVNTF ()
 
void produce (art::Event &evt)
 
std::vector< tensorflow::Tensor > vector_to_tensor_nue (std::vector< unsigned char >, unsigned int ncells, unsigned int nplanes)
 
tensorflow::Tensor vector_to_tensor_numu (std::vector< unsigned char >)
 
bool IsRHC (const art::Event &evt)
 
std::pair< RegModel *, RegModel * > GetModelsNue (const art::Event &evt)
 
RegModelGetModelsNumu (const art::Event &evt)
 
bool PassCVNCut (const cvn::Result &result)
 
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
 
std::string fGeneratorLabel
 
std::string fNuMILabel
 
bool fObeyPreselection
 
std::vector< std::stringfPreselectionLabels
 
bool fProngInput
 
std::string fProngModLabel
 
std::string fProng3DLabel
 
std::string fTrack3DLabel
 
std::string fCVNLabel1
 
std::string fCVNLabel2
 
std::string fCVNLabel3
 
bool fApplyLooseCVN
 
double fCVNCut
 
std::string fLibPath
 
std::string fTFProtoBufEvtE
 
std::string fTFProtoBufShE
 
std::string fTFProtoBufRHCEvtE
 
std::string fTFProtoBufRHCShE
 
std::string fTFProtoBufHadE
 
std::string fTFProtoBufRHCHadE
 
bool fUseOppositeHornCurrentNetwork
 
std::pair< RegModel *, RegModel * > fTFFHC
 
std::pair< RegModel *, RegModel * > fTFRHC
 
RegModelfTFFHCHad
 
RegModelfTFRHCHad
 

Detailed Description

Definition at line 34 of file RegCVNTF_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

regcvntf::RegCVNTF::RegCVNTF ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 90 of file RegCVNTF_module.cc.

References util::EnvExpansion(), fLibPath, fTFFHC, fTFFHCHad, fTFProtoBufEvtE, fTFProtoBufHadE, fTFProtoBufRHCEvtE, fTFProtoBufRHCHadE, fTFProtoBufRHCShE, fTFProtoBufShE, fTFRHC, fTFRHCHad, and make_pair().

90  :
91  fSliceLabel (pset.get<std::string>("SliceLabel")),
92  fPixelMapInput (pset.get<std::string>("PixelMapInput")),
93  fGeneratorLabel (pset.get<std::string>("GeneratorLabel")),
94  fNuMILabel (pset.get<std::string>("NuMILabel")),
95  fObeyPreselection (pset.get<bool> ("ObeyPreselection" )),
96  fPreselectionLabels(pset.get<std::vector<std::string>> ("PreselectionLabels")),
97  fProngInput (pset.get<bool> ("ProngInput")),
98  fProngModLabel (pset.get<std::string> ("ProngModLabel")),
99  fProng3DLabel (pset.get<std::string> ("Prong3DLabel")),
100  fTrack3DLabel (pset.get<std::string> ("Track3DLabel")),
101  fCVNLabel1 (pset.get<std::string> ("CVNLabel1")),
102  fCVNLabel2 (pset.get<std::string> ("CVNLabel2")),
103  fCVNLabel3 (pset.get<std::string> ("CVNLabel3")),
104  fApplyLooseCVN (pset.get<bool> ("ApplyLooseCVN")),
105  fCVNCut (pset.get<double> ("CVNCut")),
106  fLibPath (pset.get<std::string> ("LibPath")),
107  fTFProtoBufEvtE (pset.get<std::string> ("TFProtoBufEvtE")),
108  fTFProtoBufShE (pset.get<std::string> ("TFProtoBufShE")),
109  fTFProtoBufRHCEvtE (pset.get<std::string> ("TFProtoBufRHCEvtE")),
110  fTFProtoBufRHCShE (pset.get<std::string> ("TFProtoBufRHCShE")),
111  fTFProtoBufHadE (pset.get<std::string> ("TFProtoBufHadE")),
112  fTFProtoBufRHCHadE (pset.get<std::string> ("TFProtoBufRHCHadE")),
113  fUseOppositeHornCurrentNetwork(pset.get<bool>("UseOppositeHornCurrentNetwork"))
114  {
120 
123 
124  fTFFHC = std::make_pair(new RegModel(fTFProtoBufEvtE),
125  new RegModel(fTFProtoBufShE));
126  fTFRHC = std::make_pair(new RegModel(fTFProtoBufRHCEvtE),
127  new RegModel(fTFProtoBufRHCShE));
128  fTFFHCHad = new RegModel(fTFProtoBufHadE);
129  fTFRHCHad = new RegModel(fTFProtoBufRHCHadE);
130 
131  produces< std::vector<cvn::RegNuResult> >();
132  produces< std::vector<cvn::RegProngResult> >();
133  produces< art::Assns<cvn::RegNuResult, rb::Cluster> >();
134  produces< art::Assns<cvn::RegProngResult, rb::Prong> >();
135  produces< std::vector<cvn::RegHadronResult> >();
136  produces< art::Assns<cvn::RegHadronResult, rb::Cluster> >();
137  }
std::string fTFProtoBufHadE
std::string EnvExpansion(const std::string &inString)
Function to expand environment variables.
Definition: EnvExpand.cxx:8
std::string fTFProtoBufEvtE
std::pair< Spectrum *, CheatDecomp * > make_pair(SpectrumLoaderBase &loader_data, SpectrumLoaderBase &loader_mc, HistAxis *axis, Cut *cut, const SystShifts &shift, const Var &wei)
Definition: DataMCLoad.C:336
std::string fGeneratorLabel
std::pair< RegModel *, RegModel * > fTFFHC
std::string fCVNLabel1
std::pair< RegModel *, RegModel * > fTFRHC
std::string fTFProtoBufRHCEvtE
std::vector< std::string > fPreselectionLabels
std::string fCVNLabel3
std::string fSliceLabel
std::string fTFProtoBufRHCShE
tensorflow::TFHandler RegModel
std::string fCVNLabel2
std::string fProng3DLabel
std::string fProngModLabel
std::string fNuMILabel
std::string fTFProtoBufShE
std::string fTFProtoBufRHCHadE
std::string fPixelMapInput
std::string fTrack3DLabel
enum BeamMode string
regcvntf::RegCVNTF::~RegCVNTF ( )
virtual

Definition at line 139 of file RegCVNTF_module.cc.

References fTFFHC, and fTFRHC.

140  {
141  if(fTFFHC.first) delete fTFFHC.first;
142  if(fTFFHC.second) delete fTFFHC.second;
143  if(fTFRHC.first) delete fTFRHC.first;
144  if(fTFRHC.second) delete fTFRHC.second;
145  }
std::pair< RegModel *, RegModel * > fTFFHC
std::pair< RegModel *, RegModel * > fTFRHC

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
std::pair< RegModel *, RegModel * > regcvntf::RegCVNTF::GetModelsNue ( const art::Event evt)

Definition at line 168 of file RegCVNTF_module.cc.

References fTFFHC, fTFRHC, and IsRHC().

Referenced by produce().

169  {
170  if (IsRHC(evt))
171  return fTFRHC;
172  else
173  return fTFFHC;
174  }
std::pair< RegModel *, RegModel * > fTFFHC
std::pair< RegModel *, RegModel * > fTFRHC
bool IsRHC(const art::Event &evt)
RegModel * regcvntf::RegCVNTF::GetModelsNumu ( const art::Event evt)

Definition at line 176 of file RegCVNTF_module.cc.

References fTFFHCHad, fTFRHCHad, and IsRHC().

Referenced by produce().

177  {
178  if (IsRHC(evt))
179  return fTFRHCHad;
180  else
181  return fTFFHCHad;
182  }
bool IsRHC(const art::Event &evt)
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  }
bool regcvntf::RegCVNTF::IsRHC ( const art::Event evt)

Definition at line 147 of file RegCVNTF_module.cc.

References art::Handle< T >::failedToGet(), fGeneratorLabel, fNuMILabel, fUseOppositeHornCurrentNetwork, art::DataViewImpl::getByLabel(), art::Event::isRealData(), and sumdata::SpillData::isRHC.

Referenced by GetModelsNue(), and GetModelsNumu().

148  {
150  if (!evt.isRealData())
151  evt.getByLabel(fGeneratorLabel, spillPot);
152  else
153  evt.getByLabel(fNuMILabel, spillPot);
154 
155  if (spillPot.failedToGet())
156  {
157  mf::LogError("RegCVNTF") <<
158  "Spill Data not found, aborting without horn current information";
159  abort();
160  }
161 
162  if(fUseOppositeHornCurrentNetwork) return !spillPot->isRHC;
163 
164  // NB - the logic here will cause 0HC to use the FHC network
165  return spillPot->isRHC;
166  }
bool isRHC
is the beam in antineutrino mode, aka RHC
Definition: SpillData.h:28
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
bool isRealData() const
Definition: Event.h:83
std::string fGeneratorLabel
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
std::string fNuMILabel
bool failedToGet() const
Definition: Handle.h:196
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
bool regcvntf::RegCVNTF::PassCVNCut ( const cvn::Result result)

Definition at line 184 of file RegCVNTF_module.cc.

References fCVNCut, cvn::Result::fOutput, and SliceLID::nueid().

Referenced by produce().

185  {
186  double nueid = result.fOutput[1];
187  // auto output = result.fOutput;
188  // double nueid = 0;
189  // for(int idx = 0; idx < caf::kNumCVNFinalStates; ++idx){
190  // const caf::CVNFinalState state = caf::cvnStates[idx];
191  // const double prob = result.fOutput[idx];
192  //
193  // if(state.nuPdg == 12) nueid += prob;
194  // }
195  // nueid += result.fOutput[caf::kCVN_nE_Other];
196 
197  return nueid > fCVNCut;
198  }
std::vector< float > fOutput
Vector of outputs from neural net.
Definition: Result.h:30
static Var nueid(const std::shared_ptr< CAFAnaModel > &model)
Definition: SliceLIDVar.h:83
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited
void regcvntf::RegCVNTF::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 241 of file RegCVNTF_module.cc.

References util::CreateAssn(), DEFINE_ART_MODULE(), fApplyLooseCVN, fCVNLabel1, fCVNLabel2, fCVNLabel3, check_time_usage::float, fObeyPreselection, fPixelMapInput, fPreselectionLabels, fProng3DLabel, fProngInput, fProngModLabel, fSliceLabel, fTrack3DLabel, art::DataViewImpl::getByLabel(), GetModelsNue(), GetModelsNumu(), MECModelEnuComparisons::i, ip, rb::IsFiltered(), PassCVNCut(), tensorflow::TFHandler::Predict(), art::PtrVector< T >::push_back(), art::Event::put(), art::PtrVector< T >::size(), vector_to_tensor_nue(), and vector_to_tensor_numu().

242  {
243  std::unique_ptr< std::vector<cvn::RegNuResult> >
244  resultEvtCol(new std::vector<cvn::RegNuResult>);
245  std::unique_ptr< std::vector<cvn::RegProngResult> >
246  resultShCol(new std::vector<cvn::RegProngResult>);
247  std::unique_ptr< art::Assns<cvn::RegNuResult, rb::Cluster> >
249  std::unique_ptr< art::Assns<cvn::RegProngResult, rb::Prong> >
251  std::unique_ptr< std::vector<cvn::RegHadronResult> >
252  resultHadCol(new std::vector<cvn::RegHadronResult>);
253  std::unique_ptr< art::Assns<cvn::RegHadronResult, rb::Cluster> >
255 
256 
257  std::pair<RegModel*, RegModel*> models = GetModelsNue(evt);
258  RegModel* hadModel = GetModelsNumu(evt);
259 
260  // Get slices
262  evt.getByLabel(fSliceLabel, slicecol);
263  art::PtrVector<rb::Cluster> slicelist;
264  for(unsigned int i = 0; i < slicecol->size(); ++i){
265  slicelist.push_back(art::Ptr<rb::Cluster>(slicecol, i));
266  }
267 
268  // Get pixel maps
269  art::FindManyP<cvn::PixelMap> fmPixelMap(slicecol, evt, fPixelMapInput);
270  // Get cvn nue results
271  art::FindManyP<cvn::Result> fmCVN1(slicecol, evt, fCVNLabel1);
272  art::FindManyP<cvn::Result> fmCVN2(slicecol, evt, fCVNLabel2);
273  art::FindManyP<cvn::Result> fmCVN3(slicecol, evt, fCVNLabel3);
274 
275 
276  //loop over slices
277  for(size_t iClust = 0; iClust < slicelist.size(); ++iClust) {
278  if(!fmPixelMap.isValid()) continue;
279  if(slicelist[iClust]->IsNoise()) continue;
280  if(fObeyPreselection && rb::IsFiltered(evt, slicecol, iClust, fPreselectionLabels)) continue;
281 
282  const std::vector<art::Ptr<cvn::PixelMap> > pixelMaps = fmPixelMap.at(iClust);
283  if(pixelMaps.empty()) continue;
284 
285  if(fApplyLooseCVN && fmCVN1.isValid() && fmCVN2.isValid()){
286  cvn::Result cvnNue1;
287  cvn::Result cvnNue2;
288  cvn::Result cvnNue3;
289  const std::vector<art::Ptr<cvn::Result>> results1 = fmCVN1.at(iClust);
290  const std::vector<art::Ptr<cvn::Result>> results2 = fmCVN2.at(iClust);
291  const std::vector<art::Ptr<cvn::Result>> results3 = fmCVN3.at(iClust);
292  if ( !results1.empty() && !results2.empty() && !results3.empty() ){
293  cvnNue1 = *results1[0];
294  cvnNue2 = *results2[0];
295  cvnNue3 = *results3[0];
296  if (!PassCVNCut(cvnNue1) && !PassCVNCut(cvnNue2) &&!PassCVNCut(cvnNue3)) continue;
297  }
298  }
299 
300  std::vector<unsigned char> evtpm = (*pixelMaps[0]).PixelMapToVector(true);
301  std::vector<tensorflow::Tensor> tensorEvtE = vector_to_tensor_nue(evtpm, (*pixelMaps[0]).NPlanePerView(), (*pixelMaps[0]).NCell());
302 
303  std::vector<tensorflow::Tensor> resultEvtE = models.first->Predict({{"input_1",tensorEvtE[0]},{"input_2",tensorEvtE[1]}}, {"output_node0"});
304  auto tfoutputEvtE = resultEvtE[0].tensor<float,2>();
305 
306  resultEvtCol->emplace_back(tfoutputEvtE(0,0));
307  util::CreateAssn(*this, evt, *(resultEvtCol.get()),
308  slicelist[iClust], *(assoc.get()), UINT_MAX);
309 
310 
312  art::FindManyP<rb::Track> fmTrack3D(slicecol, evt, fTrack3DLabel);
313  std::vector<art::Ptr<rb::Prong>> prongs3D;
314 
315  if( fProngInput && fmProng3D.isValid())
316  prongs3D = fmProng3D.at(iClust);
317  if( !fProngInput && fmTrack3D.isValid() ){
318  std::vector<art::Ptr<rb::Track>> tracks3D;
319  tracks3D.clear();
320  tracks3D = fmTrack3D.at(iClust);
321  for (unsigned int ip=0; ip<tracks3D.size(); ++ip){
322  prongs3D.push_back(tracks3D[ip]);
323  }
324  }
325 
326  art::FindManyP<cvn::PixelMap> fmPixelMap3D(prongs3D, evt, fPixelMapInput);
327  for( unsigned int iProng = 0; iProng < prongs3D.size(); ++iProng ){
328  if(!fmPixelMap3D.isValid()) continue;
329 
330  const std::vector< art::Ptr<cvn::PixelMap> > pixelMaps3D = fmPixelMap3D.at(iProng);
331  if(pixelMaps3D.empty()) continue;
332 
333  std::vector<unsigned char> prongpm = (*pixelMaps3D[0]).PixelMapToVector(true);
334  std::vector<tensorflow::Tensor> tensorShE = vector_to_tensor_nue(prongpm, (*pixelMaps3D[0]).NPlanePerView(), (*pixelMaps3D[0]).NCell());
335 
336  std::vector<tensorflow::Tensor> resultShE = models.second->Predict({{"input_1",tensorShE[0]},{"input_2",tensorShE[1]}}, {"output_node0"});
337  auto tfoutputShE = resultShE[0].tensor<float,2>();
338 
339  resultShCol->emplace_back(tfoutputShE(0,0));
340  util::CreateAssn(*this, evt, *(resultShCol.get()),
341  prongs3D[iProng], *(assocp.get()), UINT_MAX);
342 
343  } // prong
344  } // nue slices
345  for(size_t iClust = 0; iClust < slicelist.size(); ++iClust) {
346  if(!fmPixelMap.isValid()) continue;
347  if(slicelist[iClust]->IsNoise()) continue;
348  if(fObeyPreselection && rb::IsFiltered(evt, slicecol, iClust, fPreselectionLabels)) continue;
349 
350  const std::vector<art::Ptr<cvn::PixelMap> > pixelMaps = fmPixelMap.at(iClust);
351  if(pixelMaps.empty()) continue;
352 
353  std::vector<unsigned char> evtpm = (*pixelMaps[0]).PixelMapToVector(true);
354  tensorflow::Tensor tensorEvtE = vector_to_tensor_numu(evtpm);
355 
356  std::vector<tensorflow::Tensor> resultHadE = hadModel->Predict({{"input",tensorEvtE}}, {"output_node0"});
357  auto tfoutputHadE = resultHadE[0].tensor<float,2>();
358  resultHadCol->emplace_back(tfoutputHadE(0,0));
359  util::CreateAssn(*this, evt, *(resultHadCol.get()),
360  slicelist[iClust], *(assocHad.get()), UINT_MAX);
361 
362  } // slices
363 
364  evt.put(std::move(resultEvtCol));
365  evt.put(std::move(resultShCol));
366  evt.put(std::move(assoc));
367  evt.put(std::move(assocp));
368  evt.put(std::move(resultHadCol));
369  evt.put(std::move(assocHad));
370  } // produce
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.
bool PassCVNCut(const cvn::Result &result)
std::vector< tensorflow::Tensor > vector_to_tensor_nue(std::vector< unsigned char >, unsigned int ncells, unsigned int nplanes)
Definition: models.py:1
TString ip
Definition: loadincs.C:5
std::vector< Tensor > Predict(std::vector< std::pair< std::string, Tensor >> inputs, std::vector< std::string > outputLabels)
Definition: TFHandler.cxx:64
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
std::string fCVNLabel1
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:441
unsigned int NCell() const
Number of cells in either view.
Definition: Cluster.h:110
RegModel * GetModelsNumu(const art::Event &evt)
bool IsFiltered(const art::Event &evt, art::Ptr< T > x, const std::vector< std::string > &labels)
Is this Ptr marked "filtered out"?
Definition: FilterList.h:96
std::vector< std::string > fPreselectionLabels
std::string fCVNLabel3
size_type size() const
Definition: PtrVector.h:308
std::string fSliceLabel
Result, basic output of CVN neural net.
Definition: Result.h:15
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
std::string fCVNLabel2
std::string fProng3DLabel
std::string fProngModLabel
bool IsNoise() const
Is the noise flag set?
Definition: Cluster.h:163
std::pair< RegModel *, RegModel * > GetModelsNue(const art::Event &evt)
Wrapper for Tensorflow which handles construction and prediction.
Definition: TFHandler.h:19
tensorflow::Tensor vector_to_tensor_numu(std::vector< unsigned char >)
std::string fPixelMapInput
std::string fTrack3DLabel
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

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

void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited
std::vector< tensorflow::Tensor > regcvntf::RegCVNTF::vector_to_tensor_nue ( std::vector< unsigned char >  pm,
unsigned int  ncells,
unsigned int  nplanes 
)

Definition at line 200 of file RegCVNTF_module.cc.

References plot_validation_datamc::c, cols, check_time_usage::float, ncells, nplanes, r(), and fillBadChanDBTables::rows.

Referenced by produce().

201  {
202 
203  std::size_t const half_size = pm.size() / 2;
204  std::vector<unsigned char> pm_x(pm.begin(), pm.begin() + half_size);
205  std::vector<unsigned char> pm_y(pm.begin() + half_size, pm.end());
206 
207  long long int samples = 1, rows = nplanes, cols = ncells;
208 
209  std::vector< tensorflow::Tensor > _x;
210  for (unsigned int ii = 0; ii < 2; ++ii){
211  tensorflow::Tensor _xtemp(tensorflow::DT_FLOAT, tensorflow::TensorShape({ samples, rows, cols, 1 }));
212  _x.push_back(_xtemp);
213  }
214 
215  for (long long int s = 0; s < samples; ++s) {
216  for (long long int r = 0; r < rows; ++r) {
217  for (long long int c = 0; c < cols; ++c) {
218  unsigned int element = c + cols * r;
219  _x[0].tensor<float, 4>()(s, r, c, 0) = pm_x[element];
220  _x[1].tensor<float, 4>()(s, r, c, 0) = pm_y[element];
221  }
222  }
223  }
224  return _x;
225 
226  }
const XML_Char * s
Definition: expat.h:262
const int cols[3]
int nplanes
Definition: geom.C:145
TRandom3 r(0)
int ncells
Definition: geom.C:124
tensorflow::Tensor regcvntf::RegCVNTF::vector_to_tensor_numu ( std::vector< unsigned char >  pm)

Definition at line 228 of file RegCVNTF_module.cc.

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

Referenced by produce().

228  {
229  const unsigned int vectorSize = pm.size();
230 
231  // Initialize the tensors
232  tensorflow::Tensor tensor(tensorflow::DT_FLOAT, {1, vectorSize});
233  auto rel = tensor.tensor<float,2>();
234 
235  // Loop over each element
236  for(unsigned int i = 0; i < vectorSize; ++i) rel(0, i) = pm[i];
237 
238  return tensor;
239  }
string rel
Definition: shutoffs.py:11

Member Data Documentation

bool regcvntf::RegCVNTF::fApplyLooseCVN
protected

Definition at line 66 of file RegCVNTF_module.cc.

Referenced by produce().

double regcvntf::RegCVNTF::fCVNCut
protected

Definition at line 67 of file RegCVNTF_module.cc.

Referenced by PassCVNCut().

std::string regcvntf::RegCVNTF::fCVNLabel1
protected

Definition at line 63 of file RegCVNTF_module.cc.

Referenced by produce().

std::string regcvntf::RegCVNTF::fCVNLabel2
protected

Definition at line 64 of file RegCVNTF_module.cc.

Referenced by produce().

std::string regcvntf::RegCVNTF::fCVNLabel3
protected

Definition at line 65 of file RegCVNTF_module.cc.

Referenced by produce().

std::string regcvntf::RegCVNTF::fGeneratorLabel
protected

Definition at line 53 of file RegCVNTF_module.cc.

Referenced by IsRHC().

std::string regcvntf::RegCVNTF::fLibPath
protected

Definition at line 69 of file RegCVNTF_module.cc.

Referenced by RegCVNTF().

std::string regcvntf::RegCVNTF::fNuMILabel
protected

Definition at line 54 of file RegCVNTF_module.cc.

Referenced by IsRHC().

bool regcvntf::RegCVNTF::fObeyPreselection
protected

Definition at line 55 of file RegCVNTF_module.cc.

Referenced by produce().

std::string regcvntf::RegCVNTF::fPixelMapInput
protected

Definition at line 52 of file RegCVNTF_module.cc.

Referenced by produce().

std::vector<std::string> regcvntf::RegCVNTF::fPreselectionLabels
protected

Definition at line 56 of file RegCVNTF_module.cc.

Referenced by produce().

std::string regcvntf::RegCVNTF::fProng3DLabel
protected

Definition at line 60 of file RegCVNTF_module.cc.

Referenced by produce().

bool regcvntf::RegCVNTF::fProngInput
protected

Definition at line 58 of file RegCVNTF_module.cc.

Referenced by produce().

std::string regcvntf::RegCVNTF::fProngModLabel
protected

Definition at line 59 of file RegCVNTF_module.cc.

Referenced by produce().

std::string regcvntf::RegCVNTF::fSliceLabel
protected

Definition at line 51 of file RegCVNTF_module.cc.

Referenced by produce().

std::pair<RegModel*, RegModel*> regcvntf::RegCVNTF::fTFFHC
protected

Definition at line 79 of file RegCVNTF_module.cc.

Referenced by GetModelsNue(), RegCVNTF(), and ~RegCVNTF().

RegModel* regcvntf::RegCVNTF::fTFFHCHad
protected

Definition at line 82 of file RegCVNTF_module.cc.

Referenced by GetModelsNumu(), and RegCVNTF().

std::string regcvntf::RegCVNTF::fTFProtoBufEvtE
protected

Definition at line 70 of file RegCVNTF_module.cc.

Referenced by RegCVNTF().

std::string regcvntf::RegCVNTF::fTFProtoBufHadE
protected

Definition at line 74 of file RegCVNTF_module.cc.

Referenced by RegCVNTF().

std::string regcvntf::RegCVNTF::fTFProtoBufRHCEvtE
protected

Definition at line 72 of file RegCVNTF_module.cc.

Referenced by RegCVNTF().

std::string regcvntf::RegCVNTF::fTFProtoBufRHCHadE
protected

Definition at line 75 of file RegCVNTF_module.cc.

Referenced by RegCVNTF().

std::string regcvntf::RegCVNTF::fTFProtoBufRHCShE
protected

Definition at line 73 of file RegCVNTF_module.cc.

Referenced by RegCVNTF().

std::string regcvntf::RegCVNTF::fTFProtoBufShE
protected

Definition at line 71 of file RegCVNTF_module.cc.

Referenced by RegCVNTF().

std::pair<RegModel*, RegModel*> regcvntf::RegCVNTF::fTFRHC
protected

Definition at line 80 of file RegCVNTF_module.cc.

Referenced by GetModelsNue(), RegCVNTF(), and ~RegCVNTF().

RegModel* regcvntf::RegCVNTF::fTFRHCHad
protected

Definition at line 83 of file RegCVNTF_module.cc.

Referenced by GetModelsNumu(), and RegCVNTF().

std::string regcvntf::RegCVNTF::fTrack3DLabel
protected

Definition at line 61 of file RegCVNTF_module.cc.

Referenced by produce().

bool regcvntf::RegCVNTF::fUseOppositeHornCurrentNetwork
protected

Definition at line 77 of file RegCVNTF_module.cc.

Referenced by IsRHC().


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