UnTranspose_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // \file UnTranspose_module.cc
3 // \brief TODO
4 // \author Christopher Backhouse - bckhouse@caltech.edu
5 ////////////////////////////////////////////////////////////////////////
6 
7 // Framework includes
18 #include "fhiclcpp/ParameterSet.h"
20 
22 #include "LEM/func/MatchList.h"
23 
24 #include "RecoBase/Cluster.h"
25 #include "RecoBase/FilterList.h"
26 #include "Utilities/AssociationUtil.h"
27 
28 namespace lem
29 {
31  {
32  public:
33  explicit UnTranspose(const fhicl::ParameterSet& pset);
34  ~UnTranspose();
35 
36  virtual void beginRun(art::Run& run);
37 
38  void produce(art::Event& evt);
39 
40  void reconfigure(const fhicl::ParameterSet& pset);
41 
42  void beginJob();
43 
44  protected:
47 
48  std::vector<lem::MatchList> fMatchLists;
49  unsigned int fMatchIdx;
50  };
51 
52  //.......................................................................
54  : fMatchIdx(0)
55  {
56  reconfigure(pset);
57 
58  produces<lem::LibrarySummary, art::InRun>();
59 
60  produces<std::vector<lem::MatchList>>();
61  // MatchLists are associated with the slice they are against
62  produces<art::Assns<lem::MatchList, rb::Cluster>>();
63  }
64 
65  //......................................................................
67  {
68  }
69 
70  //......................................................................
72  {
73  fSlicerLabel = pset.get<std::string>("SlicerLabel");
74  fMatchLabel = pset.get<std::string>("MatchLabel");
75  }
76 
77  //......................................................................
79  {
80  }
81 
82  //......................................................................
84  {
86  run.getByLabel(fMatchLabel, ms);
87  fMatchLists = *ms;
88  fMatchIdx = 0;
89 
90  // Copy library summary
92  run.getByLabel(fMatchLabel, ls);
93  std::unique_ptr<lem::LibrarySummary> lsout(new lem::LibrarySummary(*ls));
94  run.put(std::move(lsout));
95  }
96 
97  //......................................................................
99  {
100  std::unique_ptr<std::vector<lem::MatchList> > matchcol(new std::vector<lem::MatchList>);
101 
102  // Associate matches with the slice they came from
103  std::unique_ptr<art::Assns<lem::MatchList, rb::Cluster> > assns(new art::Assns<lem::MatchList, rb::Cluster>);
104 
106  evt.getByLabel(fSlicerLabel, slices);
107 
108  const int sliceMax = slices->size();
109  for(int sliceIdx = 0; sliceIdx < sliceMax; ++sliceIdx){
110  if(rb::IsFiltered(evt, slices, sliceIdx)) continue;
111 
112  const rb::Cluster& slice = (*slices)[sliceIdx];
113 
114  if(slice.IsNoise()) continue;
115 
116  assert(fMatchIdx < fMatchLists.size());
117  const lem::MatchList& ml = fMatchLists[fMatchIdx++];
118  // Make sure we're still in sync
119  assert(ml.trial.run == int(evt.run()));
120  assert(ml.trial.subrun == int(evt.subRun()));
121  assert(ml.trial.event == int(evt.event()));
122 
123  matchcol->push_back(ml);
124 
125  util::CreateAssn(*this, evt, *matchcol,
126  art::Ptr<rb::Cluster>(slices, sliceIdx), *assns);
127  } // end for sliceIdx
128 
129  evt.put(std::move(matchcol));
130  evt.put(std::move(assns));
131  }
132 
134 
135 } // end namespace lem
136 ////////////////////////////////////////////////////////////////////////
static constexpr Double_t ms
Definition: Munits.h:192
SubRunNumber_t subRun() const
Definition: Event.h:72
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.
A collection of associated CellHits.
Definition: Cluster.h:47
art::ProductID put(std::unique_ptr< PROD > &&)
Definition: Run.h:149
DEFINE_ART_MODULE(TestTMapFile)
Definition: Run.h:31
Collection of MatchSummary objects.
PID
Definition: FillPIDs.h:14
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
Details of the library LEM matches were made against.
Collection of MatchSummary objects.
Definition: MatchList.h:17
T get(std::string const &key) const
Definition: ParameterSet.h:231
int evt
void reconfigure(const fhicl::ParameterSet &pset)
void produce(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
EventNumber_t event() const
Definition: Event.h:67
Details of the library LEM matches were made against.
Definition: run.py:1
std::vector< lem::MatchList > fMatchLists
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
unsigned int fMatchIdx
assert(nhit_max >=nhit_nbins)
def ls(target="")
Definition: g4zmq.py:69
UnTranspose(const fhicl::ParameterSet &pset)
bool IsNoise() const
Is the noise flag set?
Definition: Cluster.h:163
std::string fSlicerLabel
RunNumber_t run() const
Definition: Event.h:77
virtual void beginRun(art::Run &run)
enum BeamMode string