LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
APAHitFinder_module.cc
Go to the documentation of this file.
1 #ifndef APAHITFINDER_H
2 #define APAHITFINDER_H
3 
5 //
6 // APAHitFinder class
7 //
8 // talion@gmail.com
9 //
10 // This algorithm is designed to find hits on APA channels after
11 // deconvolution, and then disambiguate those hits, attempting to
12 // localize the hit to one segment, on one side of the APA.
13 //
14 //
16 
17 // C/C++ standard libraries
18 #include <string>
19 #include <vector>
20 #include <memory> // std::unique_ptr()
21 #include <utility> // std::move()
22 
23 // Framework includes
28 
29 
30 // LArSoft Includes
37 
38 
39 namespace apa{
40  class APAHitFinder : public art::EDProducer {
41 
42  public:
43 
44  explicit APAHitFinder(fhicl::ParameterSet const& pset);
45  virtual ~APAHitFinder();
46 
47  void produce(art::Event& evt);
48  void beginJob();
49  void endJob();
50  void reconfigure(fhicl::ParameterSet const& p);
51 
52 
53  private:
54 
57 
58  std::string fChanHitLabel;
59 
60 
61  protected:
62 
63 
64  }; // class APAHitFinder
65 
66 
67 //-------------------------------------------------
68 //-------------------------------------------------
70  : fDisambigAlg(pset.get< fhicl::ParameterSet >("DisambigAlg"))
71 {
72  this->reconfigure(pset);
73 
74  // let HitCollectionCreator declare that we are going to produce
75  // hits and associations with wires and raw digits
76  // (with no particular product label)
78 }
79 
80 
81 //-------------------------------------------------
82 //-------------------------------------------------
84 {
85 
86 }
87 
88 //-------------------------------------------------
89 //-------------------------------------------------
91 {
92 
93  fChanHitLabel = p.get< std::string >("ChanHitLabel");
94 
95 }
96 
97 //-------------------------------------------------
98 //-------------------------------------------------
100 {
101 
102 }
103 
104 //-------------------------------------------------
105 //-------------------------------------------------
107 {
108 
109 }
110 
111 
112 //-------------------------------------------------
114 {
115  // this object contains the hit collection
116  // and its associations to wires and raw digits:
117  recob::HitCollectionCreator hcol(*this, evt);
118 
120  evt.getByLabel(fChanHitLabel, ChannelHits);
121 
122  // also get the associated wires and raw digits;
123  // we assume they have been created by the same module as the hits
124  art::FindOneP<raw::RawDigit> ChannelHitRawDigits
125  (ChannelHits, evt, fChanHitLabel);
126  art::FindOneP<recob::Wire> ChannelHitWires
127  (ChannelHits, evt, fChanHitLabel);
128 
129  // Make unambiguous collection hits
130  std::vector< art::Ptr<recob::Hit> > ChHits;
131  art::fill_ptr_vector(ChHits, ChannelHits);
132  for( size_t h = 0; h < ChHits.size(); h++ ){
133  if( ChHits[h]->View() != geo::kZ ) continue;
134 
135  art::Ptr<recob::Wire> wire = ChannelHitWires.at(h);
136  art::Ptr<raw::RawDigit> rawdigits = ChannelHitRawDigits.at(h);
137 
138  // just copy it
139  hcol.emplace_back(*ChHits[h], wire, rawdigits);
140  }
141 
142 
143  // Run alg on all APAs
144  fDisambigAlg.RunDisambig(ChannelHits);
145 
146 
147  for( size_t t=0; t < fDisambigAlg.fDisambigHits.size(); t++ ){
149  geo::WireID wid = fDisambigAlg.fDisambigHits[t].second;
150 
151  // create a new hit copy of the original one, but with new wire ID
152  recob::HitCreator disambiguous_hit(*hit, wid);
153 
154  // get the objects associated with the original hit;
155  // since hit comes from ChannelHits, its key is the index in that collection
156  // and also the index for the query of associated objects
157  art::Ptr<recob::Hit>::key_type hit_index = hit.key();
158  art::Ptr<recob::Wire> wire = ChannelHitWires.at(hit_index);
159  art::Ptr<raw::RawDigit> rawdigits = ChannelHitRawDigits.at(hit_index);
160 
161  hcol.emplace_back(disambiguous_hit.move(), wire, rawdigits);
162  } // for
163 
164  // put the hit collection and associations into the event
165  hcol.put_into(evt);
166 
167 }
168 
169 
171 
172 } // end of apa namespace
173 #endif // APAHITFINDER_H
key_type key() const
Definition: Ptr.h:356
apa::DisambigAlg fDisambigAlg
art::ServiceHandle< geo::Geometry > fGeom
Declaration of signal hit object.
Definition of basic raw digits.
Planes which measure Z direction.
Definition: geo_types.h:79
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
APAHitFinder(fhicl::ParameterSet const &pset)
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:67
Class managing the creation of a new recob::Hit object.
Definition: HitCreator.h:84
Helper functions to create a hit.
A class handling a collection of hits and its associations.
Definition: HitCreator.h:513
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:42
parameter set interface
T get(std::string const &key) const
Definition: ParameterSet.h:231
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:245
void put_into(art::Event &)
Moves the data into an event.
Definition: HitCreator.h:663
Detector simulation of raw signals on wires.
Utility object to perform functions of association.
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
void produce(art::Event &evt)
std::size_t key_type
Definition: Ptr.h:102
Declaration of basic channel signal object.
TCEvent evt
Definition: DataStructs.cxx:5
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:464
recob::Hit && move()
Prepares the constructed hit to be moved away.
Definition: HitCreator.h:344
Definition: fwd.h:25
void reconfigure(fhicl::ParameterSet const &p)
void RunDisambig(art::Handle< std::vector< recob::Hit > > GausHits)
Run disambiguation as currently configured.
Definition: DisambigAlg.cxx:72