HitRepeater_module.cc
Go to the documentation of this file.
1 #ifndef HITREPEATER__H
2 #define HITREPEATER__H
3 
4 ////////////////////////////////////////////////////////////////////////
5 //
6 // HitRepeater class
7 //
8 // pplonski@ire.pw.edu.pl
9 //
10 // This class repeats hits on wires if channel has more than one wire.
11 // Based on Robert Sulej's idea - we don't need a disambiguation step
12 // before reconstruction; disambiguation step can be done during
13 // 3D tracks reconstruction.
14 //
15 ////////////////////////////////////////////////////////////////////////
16 
17 #include <string>
18 #include <vector>
19 #include <utility>
20 #include <memory>
21 #include <iostream>
22 
23 // Framework includes
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 HitRepeater : public art::EDProducer {
50  public:
51  explicit HitRepeater(fhicl::ParameterSet const& pset);
52  void reconfigure(fhicl::ParameterSet const& p);
53  void produce(art::Event& evt);
54  void beginJob() {}
55  void endJob() {}
56 
57  private:
60  };
61 
62  // implementation
63 
65  : EDProducer(pset) {
66  this->reconfigure(pset);
67  // let HitCollectionCreator declare that we are going to produce
68  // hits and associations with wires and raw digits
69  // (with no particular product label)
71  }
72 
74  fChanHitLabel = p.get< std::string >("ChanHitLabel");
75  }
76 
78  auto ChannelHits = evt.getHandle< std::vector<recob::Hit> >(fChanHitLabel);
79 
80  // also get the associated wires and raw digits;
81  // we assume they have been created by the same module as the hits
82  art::FindOneP<raw::RawDigit> ChannelHitRawDigits(ChannelHits, evt, fChanHitLabel);
83  art::FindOneP<recob::Wire> ChannelHitWires (ChannelHits, evt, fChanHitLabel);
84 
85  // this object contains the hit collection
86  // and its associations to wires and raw digits:
88  ChannelHitWires.isValid(), // doWireAssns
89  ChannelHitRawDigits.isValid() // doRawDigitAssns
90  );
91 
92  // Make hits collection
93  std::vector< art::Ptr<recob::Hit> > ChHits;
94  art::fill_ptr_vector(ChHits, ChannelHits);
95 
96  for( size_t h = 0; h < ChHits.size(); h++ ) {
97  std::vector<geo::WireID> cwids = geom->ChannelToWire(ChHits[h]->Channel());
98  for(size_t w = 0; w < cwids.size(); w++) {
99  art::Ptr<recob::Hit> hit = ChHits[h];
100  geo::WireID wid = cwids[w];
101  recob::HitCreator repeated_hit(*hit, wid);
102  art::Ptr<recob::Hit>::key_type hit_index = hit.key();
103  art::Ptr<recob::Wire> wire = ChannelHitWires.at(hit_index);
104  art::Ptr<raw::RawDigit> rawdigits = ChannelHitRawDigits.at(hit_index);
105 
106  hcol.emplace_back(repeated_hit.move(), wire, rawdigits);
107  }
108  }
109 
110  // put the hit collection and associations into the event
111  hcol.put_into(evt);
112  }
113 
115 
116 } // end of dune namespace
117 #endif
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
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
std::size_t key_type
Definition: Ptr.h:79
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
HitRepeater(fhicl::ParameterSet const &pset)
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
void produce(art::Event &evt)
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
Detector simulation of raw signals on wires.
ProducesCollector & producesCollector() noexcept
Declaration of signal hit object.
art::ServiceHandle< geo::Geometry > geom
void reconfigure(fhicl::ParameterSet const &p)
TCEvent evt
Definition: DataStructs.cxx:7
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