TTSpacePointFinder_module.cc
Go to the documentation of this file.
1 /*!
2  * Title: TTSpacePointFinder class
3  * Author: wketchum@lanl.gov
4  * Inputs: recob::Hit
5  * Outputs: recob::SpacePoint
6  *
7  * Description:
8  * This module, TimeTickSpacePointFinder (or TTSpacePointFinder for short) was
9  * originally designed to produce a spacepoint object based on hits from
10  * TTHitFinder, with the intention to allow for a significant number of
11  * ghost spacepoints, where some downstream application would deal with the
12  * results.
13  *
14  * In reality, it is just a generic SpacePointFinder implementing the
15  * SpacePointAlg_TimeSort algorithm.
16  *
17  * This code is totally microboone specific, btw.
18  */
19 
20 #include <string>
21 
22 // Framework includes
26 
27 // LArSoft Includes
34 
35 namespace sppt {
36 
38  public:
39  explicit TTSpacePointFinder(fhicl::ParameterSet const& pset);
40 
41  private:
42  void produce(art::Event& evt);
43  void beginRun(art::Run& run);
44 
45  std::string fHitModuleLabel; /// Input hit module name
46  std::string fUHitsInstanceLabel; /// Input U hits instance name
47  std::string fVHitsInstanceLabel; /// Input V hits instance name
48  std::string fYHitsInstanceLabel; /// Input Y hits instance name
49 
51  }; // class TTSpacePointFinder
52 
53  //-------------------------------------------------
55  : EDProducer{pset}, fSpptAlg(pset.get<fhicl::ParameterSet>("SpacePointAlgParams"))
56  {
57  fHitModuleLabel = pset.get<std::string>("HitModuleLabel", "tthit");
58  fUHitsInstanceLabel = pset.get<std::string>("UHitsInstaceLabel", "uhits");
59  fVHitsInstanceLabel = pset.get<std::string>("VHitsInstaceLabel", "vhits");
60  fYHitsInstanceLabel = pset.get<std::string>("YHitsInstaceLabel", "yhits");
61 
62  produces<std::vector<recob::SpacePoint>>();
63  produces<art::Assns<recob::SpacePoint, recob::Hit>>();
64  }
65 
66  //-------------------------------------------------
67  void
69  {
70  auto const detProp =
72  fSpptAlg.setTimeOffsets(detProp);
74  }
75 
76  //-------------------------------------------------
77  void
79  {
80  //initialize our spacepoint collection
81  auto spptCollection = std::make_unique<std::vector<recob::SpacePoint>>();
82  auto spptAssociatedHits = std::make_unique<std::vector<std::vector<art::Ptr<recob::Hit>>>>();
83 
84  // Read in the hits. Note, we will reorder hit vector, so we do in fact need a copy.
87  std::vector<art::Ptr<recob::Hit>> hitVec_U;
88  art::fill_ptr_vector(hitVec_U, hitHandle_U);
89 
92  std::vector<art::Ptr<recob::Hit>> hitVec_V;
93  art::fill_ptr_vector(hitVec_V, hitHandle_V);
94 
97  std::vector<art::Ptr<recob::Hit>> hitVec_Y;
98  art::fill_ptr_vector(hitVec_Y, hitHandle_Y);
99 
100  MF_LOG_DEBUG("TTSpacePointFinder") << "Got handles to hits:\n"
101  << hitVec_U.size() << " u hits, " << hitVec_V.size()
102  << " v hits, " << hitVec_Y.size() << " y hits.";
103 
104  auto const detProp =
107  detProp, hitVec_U, hitVec_V, hitVec_Y, spptCollection, spptAssociatedHits);
108 
109  mf::LogInfo("TTSpacePointFinder")
110  << "Finished spacepoint alg. Created " << spptCollection->size() << " spacepoints.";
111 
112  //check that spptCollection and spptAssociatedHits have same size
113  if (spptCollection->size() != spptAssociatedHits->size()) {
114  mf::LogError("TTSpacePointFinder")
115  << "ERROR in space point alg.\n"
116  << "Spacepoint and associated hit collections have different sizes!\n"
117  << spptCollection->size() << " != " << spptAssociatedHits->size()
118  << "\nWill return with no space points put on event.";
119  return;
120  }
121 
122  //Now, need to fill in the sppt<-->hit associations
123  std::unique_ptr<art::Assns<recob::SpacePoint, recob::Hit>> spptAssns(
125  for (unsigned int isppt = 0; isppt < spptCollection->size(); isppt++) {
126  util::CreateAssn(evt, *spptCollection, spptAssociatedHits->at(isppt), *spptAssns, isppt);
127  }
128 
129  //finally, put things on the event
130  evt.put(std::move(spptCollection));
131  evt.put(std::move(spptAssns));
132 
133  } // End of produce()
134 
136 
137 } // end of sppt namespace
void setTimeOffsets(detinfo::DetectorPropertiesData const &detProp)
std::string string
Definition: nybbler.cc:12
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
Definition: Run.h:17
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
def move(depos, offset)
Definition: depos.py:107
std::string fYHitsInstanceLabel
Input V hits instance name.
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
bool CreateAssn(PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX)
Creates a single one-to-one association.
std::string fVHitsInstanceLabel
Input U hits instance name.
Declaration of signal hit object.
#define MF_LOG_DEBUG(id)
std::string fUHitsInstanceLabel
Input hit module name.
void createSpacePoints(detinfo::DetectorPropertiesData const &detProp, std::vector< art::Ptr< recob::Hit >> &hitVec_U, std::vector< art::Ptr< recob::Hit >> &hitVec_V, std::vector< art::Ptr< recob::Hit >> &hitVec_Y, std::unique_ptr< std::vector< recob::SpacePoint >> &spptCollection, std::unique_ptr< std::vector< std::vector< art::Ptr< recob::Hit >>>> &spptAssociatedHits)
SpacePointAlg_TimeSort fSpptAlg
Input Y hits instance name.
TCEvent evt
Definition: DataStructs.cxx:7
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
TTSpacePointFinder(fhicl::ParameterSet const &pset)