ProtoDUNESliceUtils.cxx
Go to the documentation of this file.
2 
5 #include "canvas/Persistency/Common/FindManyP.h"
6 
8 
9 }
10 
12 
13 }
14 
15 // Get the hits from a given reco slice
16 const std::vector<const recob::Hit*> protoana::ProtoDUNESliceUtils::GetRecoSliceHits(const recob::Slice &slice, art::Event const &evt, const std::string sliceModule) const{
17 
18  return GetRecoSliceHits(slice.ID(),evt,sliceModule);
19 
20 }
21 
22 // Get the reco hits but using the slice id instead
23 const std::vector<const recob::Hit*> protoana::ProtoDUNESliceUtils::GetRecoSliceHits(const unsigned int sliceID, art::Event const &evt, const std::string sliceModule) const{
24 
25  auto recoSlices = evt.getValidHandle<std::vector<recob::Slice> >(sliceModule);
26  art::FindManyP<recob::Hit> findHits(recoSlices,evt,sliceModule);
27  std::vector<art::Ptr<recob::Hit>> inputHits = findHits.at(sliceID);
28 
29  std::vector<const recob::Hit*> sliceHits;
30 
31  for(const art::Ptr<recob::Hit> hit : inputHits){
32 
33  sliceHits.push_back(hit.get());
34 
35  }
36 
37  return sliceHits;
38 
39 }
40 
41 // Get the number of hits from a given reco slice
42 unsigned int protoana::ProtoDUNESliceUtils::GetNumberRecoSliceHits(const recob::Slice &slice, art::Event const &evt, const std::string sliceModule) const{
43 
44  return GetRecoSliceHits(slice,evt,sliceModule).size();
45 
46 }
47 
48 // Get the number of hits from a given slice id
49 unsigned int protoana::ProtoDUNESliceUtils::GetNumberRecoSliceHits(const unsigned int sliceID, art::Event const &evt, const std::string sliceModule) const{
50 
51  return GetRecoSliceHits(sliceID,evt,sliceModule).size();
52 
53 }
54 
55 // Get a map of a slice number and all hits in the slice
56 const std::map<unsigned int, std::vector<const recob::Hit*>> protoana::ProtoDUNESliceUtils::GetRecoSliceHitMap(art::Event const &evt, const std::string sliceModule) const{
57 
58  auto recoSlices = evt.getValidHandle<std::vector<recob::Slice> >(sliceModule);
59  std::map<unsigned int, std::vector<const recob::Hit*>> hitMap;
60 
61  for(auto const slice : *recoSlices){
62 
63  const std::vector<const recob::Hit*> constvec = GetRecoSliceHits(slice.ID(),evt,sliceModule);
64  for(auto const h : constvec){
65  hitMap[slice.ID()].push_back(h);
66  }
67 
68  }
69 
70  return hitMap;
71 
72 }
73 
unsigned int GetNumberRecoSliceHits(const recob::Slice &slice, art::Event const &evt, const std::string sliceModule) const
std::string string
Definition: nybbler.cc:12
const std::vector< const recob::Hit * > GetRecoSliceHits(const recob::Slice &slice, art::Event const &evt, const std::string sliceModule) const
const std::map< unsigned int, std::vector< const recob::Hit * > > GetRecoSliceHitMap(art::Event const &evt, const std::string sliceModule) const
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:441
Detector simulation of raw signals on wires.
int ID() const
Definition: Slice.h:29
Declaration of signal hit object.
TCEvent evt
Definition: DataStructs.cxx:7