APAHitFinder_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // APAHitFinder class
4 //
5 // talion@gmail.com
6 //
7 // This algorithm is designed to find hits on APA channels after
8 // deconvolution, and then disambiguate those hits, attempting to
9 // localize the hit to one segment, on one side of the APA.
10 //
11 //
12 ////////////////////////////////////////////////////////////////////////
13 
14 // C/C++ standard libraries
15 #include <memory> // std::unique_ptr()
16 #include <string>
17 #include <utility> // std::move()
18 
19 // Framework includes
23 #include "canvas/Persistency/Common/FindOneP.h"
24 
25 // LArSoft Includes
33 
34 namespace apa {
35  class APAHitFinder : public art::EDProducer {
36 
37  public:
38  explicit APAHitFinder(fhicl::ParameterSet const& pset);
39 
40  private:
41  void produce(art::Event& evt) override;
42 
45 
47 
48  }; // class APAHitFinder
49 
50  //-------------------------------------------------
51  //-------------------------------------------------
53  : EDProducer{pset}, fDisambigAlg(pset.get<fhicl::ParameterSet>("DisambigAlg"))
54  {
55  fChanHitLabel = pset.get<std::string>("ChanHitLabel");
56 
57  // let HitCollectionCreator declare that we are going to produce
58  // hits and associations with wires and raw digits
59  // (with no particular product label)
61  }
62 
63  //-------------------------------------------------
64  void
66  {
67  // this object contains the hit collection
68  // and its associations to wires and raw digits:
70 
72  evt.getByLabel(fChanHitLabel, ChannelHits);
73 
74  // also get the associated wires and raw digits;
75  // we assume they have been created by the same module as the hits
76  art::FindOneP<raw::RawDigit> ChannelHitRawDigits(ChannelHits, evt, fChanHitLabel);
77  art::FindOneP<recob::Wire> ChannelHitWires(ChannelHits, evt, fChanHitLabel);
78 
79  // Make unambiguous collection hits
80  std::vector<art::Ptr<recob::Hit>> ChHits;
81  art::fill_ptr_vector(ChHits, ChannelHits);
82  for (size_t h = 0; h < ChHits.size(); h++) {
83  if (ChHits[h]->View() != geo::kZ) continue;
84 
85  art::Ptr<recob::Wire> wire = ChannelHitWires.at(h);
86  art::Ptr<raw::RawDigit> rawdigits = ChannelHitRawDigits.at(h);
87 
88  // just copy it
89  hcol.emplace_back(*ChHits[h], wire, rawdigits);
90  }
91 
92  // Run alg on all APAs
93  auto const clock_data =
95  auto const det_prop =
97  fDisambigAlg.RunDisambig(clock_data, det_prop, ChannelHits);
98 
99  for (size_t t = 0; t < fDisambigAlg.fDisambigHits.size(); t++) {
101  geo::WireID wid = fDisambigAlg.fDisambigHits[t].second;
102 
103  // create a new hit copy of the original one, but with new wire ID
104  recob::HitCreator disambiguous_hit(*hit, wid);
105 
106  // get the objects associated with the original hit;
107  // since hit comes from ChannelHits, its key is the index in that collection
108  // and also the index for the query of associated objects
109  art::Ptr<recob::Hit>::key_type hit_index = hit.key();
110  art::Ptr<recob::Wire> wire = ChannelHitWires.at(hit_index);
111  art::Ptr<raw::RawDigit> rawdigits = ChannelHitRawDigits.at(hit_index);
112 
113  hcol.emplace_back(disambiguous_hit.move(), wire, rawdigits);
114  } // for
115 
116  // put the hit collection and associations into the event
117  hcol.put_into(evt);
118  }
119 
121 
122 } // end of apa namespace
apa::DisambigAlg fDisambigAlg
AdcChannelData::View View
std::string string
Definition: nybbler.cc:12
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
Planes which measure Z direction.
Definition: geo_types.h:132
void RunDisambig(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, art::Handle< std::vector< recob::Hit >> GausHits)
Definition: DisambigAlg.cxx:54
std::size_t key_type
Definition: Ptr.h:79
APAHitFinder(fhicl::ParameterSet const &pset)
static void declare_products(art::ProducesCollector &collector, std::string instance_name="", bool doWireAssns=true, bool doRawDigitAssns=true)
Declares the hit products we are going to fill.
Definition: HitCreator.cxx:248
Class managing the creation of a new recob::Hit object.
Definition: HitCreator.h:83
Helper functions to create a hit.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
A class handling a collection of hits and its associations.
Definition: HitCreator.h:508
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
key_type key() const noexcept
Definition: Ptr.h:216
void emplace_back(recob::Hit &&hit, art::Ptr< recob::Wire > const &wire=art::Ptr< recob::Wire >(), art::Ptr< raw::RawDigit > const &digits=art::Ptr< raw::RawDigit >())
Adds the specified hit to the data collection.
Definition: HitCreator.cxx:290
void put_into(art::Event &)
Moves the data into an event.
Definition: HitCreator.h:652
Detector simulation of raw signals on wires.
ProducesCollector & producesCollector() noexcept
Declaration of signal hit object.
art::ServiceHandle< geo::Geometry const > fGeom
std::vector< std::pair< art::Ptr< recob::Hit >, geo::WireID > > fDisambigHits
The final list of hits to pass back to be made.
Definition: DisambigAlg.h:60
Declaration of basic channel signal object.
TCEvent evt
Definition: DataStructs.cxx:7
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
recob::Hit && move()
Prepares the constructed hit to be moved away.
Definition: HitCreator.h:343
void produce(art::Event &evt) override