All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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
20 #include "art/Framework/Core/EDProducer.h"
21 #include "art/Framework/Core/ModuleMacros.h"
22 #include "art/Framework/Principal/Event.h"
23 #include "art/Framework/Services/Registry/ServiceHandle.h"
24 #include "canvas/Persistency/Common/FindOneP.h"
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 
45  art::ServiceHandle<geo::Geometry const> fGeom;
46 
47  std::string fChanHitLabel;
48 
49  }; // class APAHitFinder
50 
51  //-------------------------------------------------
52  //-------------------------------------------------
53  APAHitFinder::APAHitFinder(fhicl::ParameterSet const& pset)
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  //-------------------------------------------------
65  void
67  {
68  // this object contains the hit collection
69  // and its associations to wires and raw digits:
71 
72  art::Handle<std::vector<recob::Hit>> ChannelHits;
73  evt.getByLabel(fChanHitLabel, ChannelHits);
74 
75  // also get the associated wires and raw digits;
76  // we assume they have been created by the same module as the hits
77  art::FindOneP<raw::RawDigit> ChannelHitRawDigits(ChannelHits, evt, fChanHitLabel);
78  art::FindOneP<recob::Wire> ChannelHitWires(ChannelHits, evt, fChanHitLabel);
79 
80  // Make unambiguous collection hits
81  std::vector<art::Ptr<recob::Hit>> ChHits;
82  art::fill_ptr_vector(ChHits, ChannelHits);
83  for (size_t h = 0; h < ChHits.size(); h++) {
84  if (ChHits[h]->View() != geo::kZ) continue;
85 
86  art::Ptr<recob::Wire> wire = ChannelHitWires.at(h);
87  art::Ptr<raw::RawDigit> rawdigits = ChannelHitRawDigits.at(h);
88 
89  // just copy it
90  hcol.emplace_back(*ChHits[h], wire, rawdigits);
91  }
92 
93  // Run alg on all APAs
94  auto const clock_data =
95  art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
96  auto const det_prop =
97  art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(evt, clock_data);
98  fDisambigAlg.RunDisambig(clock_data, det_prop, ChannelHits);
99 
100  for (size_t t = 0; t < fDisambigAlg.fDisambigHits.size(); t++) {
101  art::Ptr<recob::Hit> hit = fDisambigAlg.fDisambigHits[t].first;
102  geo::WireID wid = fDisambigAlg.fDisambigHits[t].second;
103 
104  // create a new hit copy of the original one, but with new wire ID
105  recob::HitCreator disambiguous_hit(*hit, wid);
106 
107  // get the objects associated with the original hit;
108  // since hit comes from ChannelHits, its key is the index in that collection
109  // and also the index for the query of associated objects
110  art::Ptr<recob::Hit>::key_type hit_index = hit.key();
111  art::Ptr<recob::Wire> wire = ChannelHitWires.at(hit_index);
112  art::Ptr<raw::RawDigit> rawdigits = ChannelHitRawDigits.at(hit_index);
113 
114  hcol.emplace_back(disambiguous_hit.move(), wire, rawdigits);
115  } // for
116 
117  // put the hit collection and associations into the event
118  hcol.put_into(evt);
119  }
120 
121  DEFINE_ART_MODULE(APAHitFinder)
122 
123 } // end of apa namespace
apa::DisambigAlg fDisambigAlg
Declaration of signal hit object.
Definition of basic raw digits.
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
process_name hit
Definition: cheaterreco.fcl:51
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
while getopts h
Class managing the creation of a new recob::Hit object.
Definition: HitCreator.h:83
Helper functions to create a hit.
A class handling a collection of hits and its associations.
Definition: HitCreator.h:508
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
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
recob::Hit && move()
Prepares the constructed hit to be moved away.
Definition: HitCreator.h:343
void produce(art::Event &evt) override