HitFinder35t_module.cc
Go to the documentation of this file.
1 #ifndef HITFINDER35T_H
2 #define HITFINDER35T_H
3 
4 ////////////////////////////////////////////////////////////////////////
5 //
6 // HitFinder35t class
7 //
8 // tjyang@fnal.gov
9 //
10 // Based on Tom Junk's idea of 3-view matching
11 // HitFinder for 35t, input is undisambiguated hits, out is disambiguated hits
12 // Start from code written by talion@gmail.com
13 //
14 //
15 ////////////////////////////////////////////////////////////////////////
16 
17 #include <string>
18 #include <vector>
19 #include <utility> // std::move()
20 #include <memory> // std::unique_ptr<>
21 
22 // Framework includes
26 
27 
28 // LArSoft Includes
35 #include "DisambigAlg35t.h"
36 #include "TimeBasedDisambig.h"
37 
38 // ROOT Includes
39 #include "TH1D.h"
40 #include "TDecompSVD.h"
41 #include "TMath.h"
42 #include "TF1.h"
43 #include "TTree.h"
44 #include "TVectorD.h"
45 #include "TVector2.h"
46 #include "TVector3.h"
47 
48 namespace dune{
49  class HitFinder35t : public art::EDProducer {
50 
51  public:
52 
53  explicit HitFinder35t(fhicl::ParameterSet const& pset);
54 
55  void produce(art::Event& evt);
56  void beginJob();
57  void endJob();
58  void reconfigure(fhicl::ParameterSet const& p);
59 
60 
61  private:
62 
65 
67 
69  std::string fAlg; // which algorithm to use
70 
71  protected:
72 
73 
74  }; // class HitFinder35t
75 
76 
77  //-------------------------------------------------
78  //-------------------------------------------------
80  EDProducer(pset),
81  fDisambigAlg(pset.get< fhicl::ParameterSet >("DisambigAlg")),
82  fTimeBasedDisambigAlg(pset.get< fhicl::ParameterSet >("TimeBasedDisambigAlg"))
83  {
84  this->reconfigure(pset);
85 
86  // let HitCollectionCreator declare that we are going to produce
87  // hits and associations with wires and raw digits
88  // (with no particular product label)
90  }
91 
92 
93  //-------------------------------------------------
94  //-------------------------------------------------
96  {
97 
98  fChanHitLabel = p.get< std::string >("ChanHitLabel");
99  fAlg = p.get < std::string >("Algorithm");
100 
101  }
102 
103  //-------------------------------------------------
104  //-------------------------------------------------
106  {
107 
108  }
109 
110  //-------------------------------------------------
111  //-------------------------------------------------
113  {
114 
115  }
116 
117 
118  //-------------------------------------------------
120  {
121 
122  auto ChannelHits = evt.getHandle< std::vector<recob::Hit> >(fChanHitLabel);
123 
124  // also get the associated wires and raw digits;
125  // we assume they have been created by the same module as the hits
126 // art::FindOneP<raw::RawDigit> ChannelHitRawDigits
127 // (ChannelHits, evt, fChanHitLabel);
128  art::FindOneP<recob::Wire> ChannelHitWires
129  (ChannelHits, evt, fChanHitLabel);
130 
131  // this object contains the hit collection
132  // and its associations to wires and raw digits:
134  /* doWireAssns */ ChannelHitWires.isValid(),
135  /* doRawDigitAssns */ false
136  );
137 
138  // Make unambiguous collection hits
139  std::vector< art::Ptr<recob::Hit> > ChHits;
140  art::fill_ptr_vector(ChHits, ChannelHits);
141  for( size_t h = 0; h < ChHits.size(); h++ ){
142  if( ChHits[h]->View() != geo::kZ ) continue;
143 
144  art::Ptr<recob::Wire> wire = ChannelHitWires.at(h);
145  //art::Ptr<raw::RawDigit> rawdigits = ChannelHitRawDigits.at(h);
146 
147  // just copy it
148  hcol.emplace_back(*ChHits[h], wire);
149 
150  } // for
151 
152  // Run alg on all APAs
153  if (fAlg == "TripletMatch")
154  {
155  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
156  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(evt, clockData);
157  fDisambigAlg.RunDisambig(clockData, detProp, ChHits);
158 
159  for( size_t t=0; t < fDisambigAlg.fDisambigHits.size(); t++ ){
161  geo::WireID wid = fDisambigAlg.fDisambigHits[t].second;
162 
163  // create a new hit copy of the original one, but with new wire ID
164  recob::HitCreator disambiguous_hit(*hit, wid);
165 
166  // get the objects associated with the original hit;
167  // since hit comes from ChannelHits, its key is the index in that collection
168  // and also the index for the query of associated objects
169  art::Ptr<recob::Hit>::key_type hit_index = hit.key();
170  art::Ptr<recob::Wire> wire = ChannelHitWires.at(hit_index);
171  //art::Ptr<raw::RawDigit> rawdigits = ChannelHitRawDigits.at(hit_index);
172 
173  hcol.emplace_back(disambiguous_hit.move(), wire);
174  } // for
175 
176  }
177  else if (fAlg == "TimeBased")
178  {
180 
181  for( size_t t=0; t < fTimeBasedDisambigAlg.fDisambigHits.size(); t++ ){
184 
185  // create a new hit copy of the original one, but with new wire ID
186  recob::HitCreator disambiguous_hit(*hit, wid);
187 
188  // get the objects associated with the original hit;
189  // since hit comes from ChannelHits, its key is the index in that collection
190  // and also the index for the query of associated objects
191  art::Ptr<recob::Hit>::key_type hit_index = hit.key();
192  art::Ptr<recob::Wire> wire = ChannelHitWires.at(hit_index);
193  //art::Ptr<raw::RawDigit> rawdigits = ChannelHitRawDigits.at(hit_index);
194 
195  hcol.emplace_back(disambiguous_hit.move(), wire);
196  } // for
197 
198  }
199  else
200  {
201  throw cet::exception("HitFinder35t") << "Disambiguation algorithm name: " << fAlg << " is not supported.\n" ;
202  }
203 
204 
205  // put the hit collection and associations into the event
206  hcol.put_into(evt);
207 
208  }
209 
210 
212 
213 } // end of dune namespace
214 #endif // HITFINDER35T_H
HitFinder35t(fhicl::ParameterSet const &pset)
void reconfigure(fhicl::ParameterSet const &p)
art::ServiceHandle< geo::Geometry > fGeom
AdcChannelData::View View
Handle< PROD > getHandle(SelectorBase const &) const
Definition: DataViewImpl.h:382
std::string string
Definition: nybbler.cc:12
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
TimeBasedDisambig fTimeBasedDisambigAlg
Planes which measure Z direction.
Definition: geo_types.h:132
std::size_t key_type
Definition: Ptr.h:79
std::vector< std::pair< art::Ptr< recob::Hit >, geo::WireID > > fDisambigHits
The final list of hits to pass back to be made.
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
art framework interface to geometry description
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
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
key_type key() const noexcept
Definition: Ptr.h:216
T get(std::string const &key) const
Definition: ParameterSet.h:271
p
Definition: test.py:223
void RunDisambig(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const std::vector< art::Ptr< recob::Hit > > &OrigHits)
Run disambiguation as currently configured.
std::vector< std::pair< art::Ptr< recob::Hit >, geo::WireID > > fDisambigHits
< Run disambiguation as currently configured
Detector simulation of raw signals on wires.
ProducesCollector & producesCollector() noexcept
DisambigAlg35t fDisambigAlg
Declaration of signal hit object.
void RunDisambig(const std::vector< art::Ptr< recob::Hit > > &OrigHits)
TCEvent evt
Definition: DataStructs.cxx:7
auto const & get(AssnsNode< L, R, D > const &r)
Definition: AssnsNode.h:115
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
recob::Hit && move()
Prepares the constructed hit to be moved away.
Definition: HitCreator.h:343
void produce(art::Event &evt)
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33