LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
TTSpacePointFinder_module.cc
Go to the documentation of this file.
1 
20 #include <string>
21 
22 // Framework includes
27 
28 // LArSoft Includes
35 
36 namespace sppt {
37 
39  public:
40  explicit TTSpacePointFinder(fhicl::ParameterSet const& pset);
41 
42  private:
43  void produce(art::Event& evt);
44  void beginRun(art::Run& run);
45 
46  std::string fHitModuleLabel;
47  std::string fUHitsInstanceLabel;
48  std::string fVHitsInstanceLabel;
49  std::string fYHitsInstanceLabel;
50 
52  }; // class TTSpacePointFinder
53 
54  //-------------------------------------------------
56  : EDProducer{pset}, fSpptAlg(pset.get<fhicl::ParameterSet>("SpacePointAlgParams"))
57  {
58  fHitModuleLabel = pset.get<std::string>("HitModuleLabel", "tthit");
59  fUHitsInstanceLabel = pset.get<std::string>("UHitsInstaceLabel", "uhits");
60  fVHitsInstanceLabel = pset.get<std::string>("VHitsInstaceLabel", "vhits");
61  fYHitsInstanceLabel = pset.get<std::string>("YHitsInstaceLabel", "yhits");
62 
63  produces<std::vector<recob::SpacePoint>>();
64  produces<art::Assns<recob::SpacePoint, recob::Hit>>();
65  }
66 
67  //-------------------------------------------------
69  {
70  auto const detProp =
72  fSpptAlg.setTimeOffsets(detProp);
74  }
75 
76  //-------------------------------------------------
78  {
79  //initialize our spacepoint collection
80  auto spptCollection = std::make_unique<std::vector<recob::SpacePoint>>();
81  auto spptAssociatedHits = std::make_unique<std::vector<std::vector<art::Ptr<recob::Hit>>>>();
82 
83  // Read in the hits. Note, we will reorder hit vector, so we do in fact need a copy.
86  std::vector<art::Ptr<recob::Hit>> hitVec_U;
87  art::fill_ptr_vector(hitVec_U, hitHandle_U);
88 
91  std::vector<art::Ptr<recob::Hit>> hitVec_V;
92  art::fill_ptr_vector(hitVec_V, hitHandle_V);
93 
96  std::vector<art::Ptr<recob::Hit>> hitVec_Y;
97  art::fill_ptr_vector(hitVec_Y, hitHandle_Y);
98 
99  MF_LOG_DEBUG("TTSpacePointFinder") << "Got handles to hits:\n"
100  << hitVec_U.size() << " u hits, " << hitVec_V.size()
101  << " v hits, " << hitVec_Y.size() << " y hits.";
102 
103  auto const detProp =
106  detProp, hitVec_U, hitVec_V, hitVec_Y, spptCollection, spptAssociatedHits);
107 
108  mf::LogInfo("TTSpacePointFinder")
109  << "Finished spacepoint alg. Created " << spptCollection->size() << " spacepoints.";
110 
111  //check that spptCollection and spptAssociatedHits have same size
112  if (spptCollection->size() != spptAssociatedHits->size()) {
113  mf::LogError("TTSpacePointFinder")
114  << "ERROR in space point alg.\n"
115  << "Spacepoint and associated hit collections have different sizes!\n"
116  << spptCollection->size() << " != " << spptAssociatedHits->size()
117  << "\nWill return with no space points put on event.";
118  return;
119  }
120 
121  //Now, need to fill in the sppt<-->hit associations
122  std::unique_ptr<art::Assns<recob::SpacePoint, recob::Hit>> spptAssns(
124  for (unsigned int isppt = 0; isppt < spptCollection->size(); isppt++) {
125  util::CreateAssn(evt, *spptCollection, spptAssociatedHits->at(isppt), *spptAssns, isppt);
126  }
127 
128  //finally, put things on the event
129  evt.put(std::move(spptCollection));
130  evt.put(std::move(spptAssns));
131 
132  } // End of produce()
133 
135 
136 } // end of sppt namespace
void setTimeOffsets(detinfo::DetectorPropertiesData const &detProp)
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
Declaration of signal hit object.
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.cc:6
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
Definition: Run.h:37
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: Event.h:77
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:65
std::string fYHitsInstanceLabel
Input V hits instance name.
std::string fVHitsInstanceLabel
Input U hits instance name.
bool CreateAssn(art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t index=UINT_MAX)
Creates a single one-to-one association.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Utility object to perform functions of association.
#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:8
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:306
TTSpacePointFinder(fhicl::ParameterSet const &pset)