LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
HitFinder_module.cc
Go to the documentation of this file.
1 
11 // C/C++ standard libraries
12 #include <string>
13 #include <utility> // std::unique_ptr<>
14 
15 // Framework libraries
16 #include "fhiclcpp/ParameterSet.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  virtual ~HitFinder() = default;
35 
36  virtual void reconfigure(fhicl::ParameterSet const & pset) ;
37  virtual void produce(art::Event & evt) override;
38 
39  virtual void endJob() override;
40 
41  private:
43  std::unique_ptr<CCHitFinderAlg> fCCHFAlg; // define CCHitFinderAlg object
44 
45  }; // hit::HitFinder()
46 
47 } // namespace hit
48 
49 //******************************************************************************
50 //*** implementation
51 //***
52 
53 // C/C++ standard libraries
54 #include <vector>
55 #include <memory> // std::move()
56 
57 // Framework libraries
59 
60 //LArSoft includes
63 #include "lardata/ArtDataHelper/HitCreator.h" // recob::HitCollectionAssociator
64 
65 
66 namespace hit {
67 
68 
69  //----------------------------------------------------------------------------
71  {
72  reconfigure(pset);
73 
74  // let HitCollectionAssociator declare that we are going to produce
75  // hits and associations with wires and raw digits
76  // (with no particular product label);
77  // TODO this should be marked as transient when art will implement issue #8018
79 
80  } // HitFinder::HitFinder()
81 
82 
83  //----------------------------------------------------------------------------
85  {
86  fCalDataModuleLabel = pset.get<art::InputTag>("CalDataModuleLabel");
87 
88  // this trick avoids double configuration on construction
89  if (fCCHFAlg)
90  fCCHFAlg->reconfigure(pset.get<fhicl::ParameterSet>("CCHitFinderAlg"));
91  else {
92  fCCHFAlg.reset
93  (new CCHitFinderAlg(pset.get<fhicl::ParameterSet>("CCHitFinderAlg")));
94  }
95  } // HitFinder::reconfigure()
96 
97 
98  //----------------------------------------------------------------------------
100  {
101  // fetch the wires needed by HitFinder
102 
103  // make this accessible to ClusterCrawler_module
105  = evt.getValidHandle<std::vector<recob::Wire>>(fCalDataModuleLabel);
106 
107  // find hits in all planes
108  fCCHFAlg->RunCCHitFinder(*wireVecHandle);
109 
110  // extract the result of the algorithm (it's moved)
111  std::unique_ptr<std::vector<recob::Hit>> Hits
112  (new std::vector<recob::Hit>(std::move(fCCHFAlg->YieldHits())));
113 
114  mf::LogInfo("HitFinder") << Hits->size() << " hits produced.";
115 
116  // shcol contains the hit collection
117  // and its associations to wires and raw digits;
118  // we get the association to raw digits through wire associations
119  recob::HitCollectionAssociator shcol(*this, evt, fCalDataModuleLabel, true);
120 
121  shcol.use_hits(std::move(Hits));
122 
123  // move the hit collection and the associations into the event:
124  shcol.put_into(evt);
125 
126  } // produce()
127 
128 
129  //----------------------------------------------------------------------------
131  // print the statistics about fits
132  mf::LogInfo log("HitFinder"); // messages are printed on "log" destruction
133  fCCHFAlg->PrintStats(log);
134  } // HitFinder::endJob()
135 
136 
138 
139 } // namespace hit
art::InputTag fCalDataModuleLabel
label of module producing input wires
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
Declaration of signal hit object.
virtual 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:306
static void declare_products(ModuleType &producer, std::string instance_name="", bool doWireAssns=true, bool doRawDigitAssns=true)
Declares the hit products we are going to fill.
Definition: HitCreator.h:1117
Hit finder algorithm designed to work with Cluster Crawler.
std::unique_ptr< CCHitFinderAlg > fCCHFAlg
virtual void reconfigure(fhicl::ParameterSet const &pset)
Helper functions to create a hit.
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:42
HitFinder(fhicl::ParameterSet const &pset)
A class handling a collection of hits and its associations.
Definition: HitCreator.h:703
T get(std::string const &key) const
Definition: ParameterSet.h:231
size_type size() const
Definition: PtrVector.h:308
Detector simulation of raw signals on wires.
art::PtrVector< recob::Hit > Hits
virtual void endJob() override
void put_into(art::Event &)
Moves the data into the event.
Definition: HitCreator.h:824
virtual ~HitFinder()=default
Declaration of basic channel signal object.
ValidHandle< PROD > getValidHandle(InputTag const &tag) const