LEMAssociator_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // \file LEMAssociator_module.cc
3 // \brief TODO
4 // \author Christopher Backhouse - bckhouse@caltech.edu
5 ////////////////////////////////////////////////////////////////////////
6 
7 #include "LEM/PIDDetails.h"
8 
9 // NOvASoft includes
10 #include "RecoBase/Cluster.h"
11 #include "RecoBase/FilterList.h"
12 
13 // Framework includes
18 #include "fhiclcpp/ParameterSet.h"
19 
20 namespace lem
21 {
23  {
24  public:
25  explicit LEMAssociator(const fhicl::ParameterSet& pset);
27 
28  virtual void reconfigure(const fhicl::ParameterSet& pset);
29  virtual void produce(art::Event& evt);
30 
31  protected:
34  /// Labels of filterlists to obey
35  std::vector<std::string> fFilterLabels;
36 
37  };
38 
39  //......................................................................
41  {
42  reconfigure(pset);
43 
44  produces<art::Assns<lem::PIDDetails, rb::Cluster>>();
45  }
46 
47  //......................................................................
49  {
50  }
51 
52  //......................................................................
54  {
55  fPIDLabel = pset.get<std::string>("PIDLabel");
56  fSlicerLabel = pset.get<std::string>("SlicerLabel");
57  fFilterLabels = pset.get< std::vector<std::string> >("FilterLabels");
58 
59  }
60 
61  //......................................................................
63  {
64  std::unique_ptr<art::Assns<lem::PIDDetails, rb::Cluster>> assns(new art::Assns<lem::PIDDetails, rb::Cluster>);
65 
67  evt.getByLabel(fPIDLabel, pids);
68 
70  evt.getByLabel(fSlicerLabel, slices);
71 
72  unsigned int pidIdx = 0;
73 
74  const int sliceMax = slices->size();
75  for(int sliceIdx = 0; sliceIdx < sliceMax; ++sliceIdx){
76  if(rb::IsFiltered(evt, slices, sliceIdx, fFilterLabels))
77  continue;
78 
79  const art::Ptr<rb::Cluster> slice(slices, sliceIdx);
80 
81  if(slice->IsNoise()) continue;
82 
83  assert(pidIdx < pids->size());
84  const art::Ptr<lem::PIDDetails> pid(pids, pidIdx);
85  assns->addSingle(pid, slice);
86  ++pidIdx;
87  } // end for sliceIdx
88 
89  assert(pidIdx == pids->size());
90 
91  evt.put(std::move(assns));
92  }
93 
95 
96 } //namespace lem
97 ////////////////////////////////////////////////////////////////////////
DEFINE_ART_MODULE(TestTMapFile)
virtual void produce(art::Event &evt)
PID
Definition: FillPIDs.h:14
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
LEMAssociator(const fhicl::ParameterSet &pset)
T get(std::string const &key) const
Definition: ParameterSet.h:231
int 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
virtual void reconfigure(const fhicl::ParameterSet &pset)
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
std::vector< std::string > fFilterLabels
Labels of filterlists to obey.
assert(nhit_max >=nhit_nbins)
bool IsNoise() const
Is the noise flag set?
Definition: Cluster.h:163