All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HitFinder_module.cc
Go to the documentation of this file.
1 /**
2  * @file HitFinder_module.cc
3  * @brief Hit finder (originating for cluster crawler algorithm)
4  * @author Bruce Baller (bballer@fnal.gov)
5  *
6  * Generated at Fri Jun 7 09:44:09 2013 by Bruce Baller using artmod
7  * from cetpkgsupport v1_02_00.
8  */
9 
10 
11 // C/C++ standard libraries
12 #include <utility> // std::unique_ptr<>
13 
14 // Framework libraries
15 #include "fhiclcpp/ParameterSet.h"
16 #include "art/Framework/Core/EDProducer.h"
17 #include "art/Framework/Core/ModuleMacros.h"
18 #include "art/Framework/Principal/Event.h"
19 #include "canvas/Utilities/InputTag.h"
20 #include "messagefacility/MessageLogger/MessageLogger.h"
21 
22 //LArSoft includes
24 
25 // ... more includes in the implementation section
26 
27 
28 namespace hit {
29 
30  class HitFinder: public art::EDProducer {
31 
32  public:
33  explicit HitFinder(fhicl::ParameterSet const & pset);
34 
35  private:
36  void produce(art::Event & evt) override;
37 
38  void endJob() override;
39 
40  art::InputTag fCalDataModuleLabel; ///< label of module producing input wires
41  CCHitFinderAlg fCCHFAlg; // define CCHitFinderAlg object
42 
43  }; // hit::HitFinder()
44 
45 } // namespace hit
46 
47 //******************************************************************************
48 //*** implementation
49 //***
50 
51 // C/C++ standard libraries
52 #include <memory> // std::move()
53 
54 // Framework libraries
55 #include "art/Framework/Principal/Handle.h"
56 
57 //LArSoft includes
60 #include "lardata/ArtDataHelper/HitCreator.h" // recob::HitCollectionAssociator
61 
62 
63 namespace hit {
64 
65 
66  //----------------------------------------------------------------------------
67  HitFinder::HitFinder(fhicl::ParameterSet const& pset)
68  : EDProducer{pset}
69  , fCCHFAlg{pset.get<fhicl::ParameterSet>("CCHitFinderAlg")}
70  {
71  fCalDataModuleLabel = pset.get<art::InputTag>("CalDataModuleLabel");
72 
73  // let HitCollectionAssociator declare that we are going to produce
74  // hits and associations with wires and raw digits
75  // (with no particular product label);
76  // TODO this should be marked as transient when art will implement issue #8018
78 
79  } // HitFinder::HitFinder()
80 
81 
82  //----------------------------------------------------------------------------
83  void HitFinder::produce(art::Event & evt)
84  {
85  // fetch the wires needed by HitFinder
86 
87  // make this accessible to ClusterCrawler_module
88  art::ValidHandle< std::vector<recob::Wire>> wireVecHandle
89  = evt.getValidHandle<std::vector<recob::Wire>>(fCalDataModuleLabel);
90 
91  // find hits in all planes
92  fCCHFAlg.RunCCHitFinder(*wireVecHandle);
93 
94  // extract the result of the algorithm (it's moved)
95  std::unique_ptr<std::vector<recob::Hit>> Hits
96  (new std::vector<recob::Hit>(std::move(fCCHFAlg.YieldHits())));
97 
98  mf::LogInfo("HitFinder") << Hits->size() << " hits produced.";
99 
100  // shcol contains the hit collection
101  // and its associations to wires and raw digits;
102  // we get the association to raw digits through wire associations
104 
105  shcol.use_hits(std::move(Hits));
106 
107  // move the hit collection and the associations into the event:
108  shcol.put_into(evt);
109 
110  } // produce()
111 
112 
113  //----------------------------------------------------------------------------
115  // print the statistics about fits
116  mf::LogInfo log("HitFinder"); // messages are printed on "log" destruction
117  fCCHFAlg.PrintStats(log);
118  } // HitFinder::endJob()
119 
120 
121  DEFINE_ART_MODULE(HitFinder)
122 
123 } // 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.
Declaration of signal hit object.
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:390
process_name hit
Definition: cheaterreco.fcl:51
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.
HitFinder(fhicl::ParameterSet const &pset)
A class handling a collection of hits and its associations.
Definition: HitCreator.h:692
art::PtrVector< recob::Hit > Hits
void endJob() override
CCHitFinderAlg fCCHFAlg
void put_into(art::Event &)
Moves the data into the event.
Definition: HitCreator.h:801
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