LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
APAHitFinder_module.cc
Go to the documentation of this file.
1 //
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 //
13 
14 // C/C++ standard libraries
15 #include <memory> // std::unique_ptr()
16 #include <string>
17 #include <utility> // std::move()
18 
19 // Framework includes
25 
26 // LArSoft Includes
34 
35 namespace apa {
36  class APAHitFinder : public art::EDProducer {
37 
38  public:
39  explicit APAHitFinder(fhicl::ParameterSet const& pset);
40 
41  private:
42  void produce(art::Event& evt) override;
43 
46 
47  std::string fChanHitLabel;
48 
49  }; // class APAHitFinder
50 
51  //-------------------------------------------------
52  //-------------------------------------------------
54  : EDProducer{pset}, fDisambigAlg(pset.get<fhicl::ParameterSet>("DisambigAlg"))
55  {
56  fChanHitLabel = pset.get<std::string>("ChanHitLabel");
57 
58  // let HitCollectionCreator declare that we are going to produce
59  // hits and associations with wires and raw digits
60  // (with no particular product label)
62  }
63 
64  //-------------------------------------------------
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
Declaration of signal hit object.
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.cc:6
Definition of basic raw digits.
Planes which measure Z direction.
Definition: geo_types.h:138
void RunDisambig(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, art::Handle< std::vector< recob::Hit >> GausHits)
Definition: DisambigAlg.cxx:53
std::size_t key_type
Definition: Ptr.h:78
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:87
Helper functions to create a hit.
A class handling a collection of hits and its associations.
Definition: HitCreator.h:481
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:65
key_type key() const noexcept
Definition: Ptr.h:166
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:286
void put_into(art::Event &)
Moves the data into an event.
Definition: HitCreator.h:614
Detector simulation of raw signals on wires.
ProducesCollector & producesCollector() noexcept
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
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:64
Declaration of basic channel signal object.
TCEvent evt
Definition: DataStructs.cxx:8
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:306
recob::Hit && move()
Prepares the constructed hit to be moved away.
Definition: HitCreator.h:330
Definition: fwd.h:26
void produce(art::Event &evt) override