LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
HitFinder_module.cc
Go to the documentation of this file.
1 
10 // C/C++ standard libraries
11 #include <utility> // std::unique_ptr<>
12 
13 // Framework libraries
18 #include "fhiclcpp/ParameterSet.h"
20 
21 //LArSoft includes
23 
24 // ... more includes in the implementation section
25 
26 namespace hit {
27 
28  class HitFinder : public art::EDProducer {
29 
30  public:
31  explicit HitFinder(fhicl::ParameterSet const& pset);
32 
33  private:
34  void produce(art::Event& evt) override;
35 
36  void endJob() override;
37 
39  CCHitFinderAlg fCCHFAlg; // define CCHitFinderAlg object
40 
41  }; // hit::HitFinder()
42 
43 } // namespace hit
44 
45 //******************************************************************************
46 //*** implementation
47 //***
48 
49 // C/C++ standard libraries
50 #include <memory> // std::move()
51 
52 // Framework libraries
54 
55 //LArSoft includes
56 #include "lardata/ArtDataHelper/HitCreator.h" // recob::HitCollectionAssociator
59 
60 namespace hit {
61 
62  //----------------------------------------------------------------------------
64  : EDProducer{pset}, fCCHFAlg{pset.get<fhicl::ParameterSet>("CCHitFinderAlg")}
65  {
66  fCalDataModuleLabel = pset.get<art::InputTag>("CalDataModuleLabel");
67 
68  // let HitCollectionAssociator declare that we are going to produce
69  // hits and associations with wires and raw digits
70  // (with no particular product label);
71  // TODO this should be marked as transient when art will implement issue #8018
73 
74  } // HitFinder::HitFinder()
75 
76  //----------------------------------------------------------------------------
78  {
79  // fetch the wires needed by HitFinder
80 
81  // make this accessible to ClusterCrawler_module
83  evt.getValidHandle<std::vector<recob::Wire>>(fCalDataModuleLabel);
84 
85  // find hits in all planes
86  fCCHFAlg.RunCCHitFinder(*wireVecHandle);
87 
88  // extract the result of the algorithm (it's moved)
89  std::unique_ptr<std::vector<recob::Hit>> Hits(
90  new std::vector<recob::Hit>(std::move(fCCHFAlg.YieldHits())));
91 
92  mf::LogInfo("HitFinder") << Hits->size() << " hits produced.";
93 
94  // shcol contains the hit collection
95  // and its associations to wires and raw digits;
96  // we get the association to raw digits through wire associations
98 
99  shcol.use_hits(std::move(Hits));
100 
101  // move the hit collection and the associations into the event:
102  shcol.put_into(evt);
103 
104  } // produce()
105 
106  //----------------------------------------------------------------------------
108  {
109  // print the statistics about fits
110  mf::LogInfo log("HitFinder"); // messages are printed on "log" destruction
111  fCCHFAlg.PrintStats(log);
112  } // HitFinder::endJob()
113 
115 
116 } // namespace hit
void RunCCHitFinder(std::vector< recob::Wire > const &Wires)
art::InputTag fCalDataModuleLabel
label of module producing input wires
void PrintStats(Stream &out) const
Print the fit statistics.
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
Declaration of signal hit object.
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.cc:6
void produce(art::Event &evt) override
void use_hits(std::unique_ptr< std::vector< recob::Hit >> &&srchits)
Uses the specified collection as data product.
Definition: HitCreator.cxx:376
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
Hit finder algorithm designed to work with Cluster Crawler.
Helper functions to create a hit.
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:65
HitFinder(fhicl::ParameterSet const &pset)
A class handling a collection of hits and its associations.
Definition: HitCreator.h:650
size_type size() const
Definition: PtrVector.h:302
Detector simulation of raw signals on wires.
ProducesCollector & producesCollector() noexcept
art::PtrVector< recob::Hit > Hits
void endJob() override
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
CCHitFinderAlg fCCHFAlg
void put_into(art::Event &)
Moves the data into the event.
Definition: HitCreator.h:748
Declaration of basic channel signal object.
std::vector< recob::Hit > && YieldHits()
Returns (and loses) the collection of reconstructed hits.
TCEvent evt
Definition: DataStructs.cxx:8