LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
TCTrack_module.cc
Go to the documentation of this file.
1 
7 // C/C++ standard libraries
8 #include <string>
9 
10 // Framework libraries
16 #include "fhiclcpp/ParameterSet.h"
17 
18 // LArSoft includes
27 
28 // ... more includes in the implementation section
29 
30 namespace trkf {
31 
32  class TCTrack : public art::EDProducer {
33 
34  public:
35  explicit TCTrack(fhicl::ParameterSet const& pset);
36 
37  private:
38  void produce(art::Event& evt) override;
39 
41 
43  }; // class TCTrack
44 
45  //----------------------------------------------------------------------------
47  : EDProducer{pset}
48  , fSptalg{pset.get<fhicl::ParameterSet>("SpacePointAlg")}
49  , fPFPtag{pset.get<std::string>("PFPModuleLabel")}
50  {
51  produces<std::vector<recob::SpacePoint>>();
52  produces<art::Assns<recob::SpacePoint, recob::Hit>>();
53  }
54 
55  //----------------------------------------------------------------------------
57  {
58  // all data products are assumed to be produced by the same module that produced the PFParticles -> TrajCluster_module
59  auto pfpHandle = evt.getValidHandle<std::vector<recob::PFParticle>>(fPFPtag);
60  auto clsHandle = evt.getValidHandle<std::vector<recob::Cluster>>(fPFPtag);
61 
62  art::FindManyP<recob::Cluster> pfp_cls(pfpHandle, evt, fPFPtag);
63  art::FindManyP<recob::Hit> cls_hit(clsHandle, evt, fPFPtag);
64 
65  auto sphitassn = std::make_unique<art::Assns<recob::SpacePoint, recob::Hit>>();
66  auto spts = std::make_unique<std::vector<recob::SpacePoint>>();
67 
68  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
69  auto const detProp =
71 
73  for (unsigned short ipfp = 0; ipfp < pfpHandle->size(); ++ipfp) {
74  // Get the clusters associated with this PFParticle - there should be one in each plane
75  std::vector<art::Ptr<recob::Cluster>> clsList;
76  pfp_cls.get(ipfp, clsList);
77  hits.clear();
78  std::cout << "PFP " << ipfp << "\n";
79  for (unsigned short icl = 0; icl < clsList.size(); ++icl) {
80  std::vector<art::Ptr<recob::Hit>> hitList;
81  unsigned int clsIndex = clsList[icl]->ID() - 1;
82  cls_hit.get(clsIndex, hitList);
83  std::cout << " cls index " << clsIndex << " hits size " << hitList.size() << " "
84  << (int)clsList[icl]->StartWire() << ":" << (int)clsList[icl]->StartTick()
85  << " EndWire " << (int)clsList[icl]->EndWire() << ":"
86  << (int)clsList[icl]->EndTick() << "\n";
87  hits.reserve(hits.size() + hitList.size());
88  hits.insert(hits.end(), hitList.begin(), hitList.end());
89  } // icl
90  // make new space points using these hits
91  std::vector<recob::SpacePoint> new_spts;
92  fSptalg.makeSpacePoints(clockData, detProp, hits, new_spts);
93  if (new_spts.empty()) continue;
94 
95  int nspt = spts->size();
96  spts->insert(spts->end(), new_spts.begin(), new_spts.end());
97  // associate the hits with the spacepoints
99  for (unsigned int ispt = nspt; ispt < spts->size(); ++ispt) {
100  const recob::SpacePoint& spt = (*spts)[ispt];
102  util::CreateAssn(evt, *spts, hits, *sphitassn, ispt);
103  } // ispt
104  } // ipfp
105 
106  evt.put(std::move(spts));
107  evt.put(std::move(sphitassn));
108 
109  } // TCTrack::produce()
110 
112 
113 } // namespace trkf
void reserve(size_type n)
Definition: PtrVector.h:337
void produce(art::Event &evt) override
SpacePointAlg fSptalg
Declaration of signal hit object.
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.cc:6
const art::PtrVector< recob::Hit > & getAssociatedHits(const recob::SpacePoint &spt) const
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: Event.h:77
void hits()
Definition: readHits.C:15
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:65
void makeSpacePoints(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const art::PtrVector< recob::Hit > &hits, std::vector< recob::SpacePoint > &spts) const
iterator end()
Definition: PtrVector.h:231
Declaration of cluster object.
size_type size() const
Definition: PtrVector.h:302
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.
iterator insert(iterator position, Ptr< U > const &p)
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Utility object to perform functions of association.
art::InputTag fPFPtag
size_type get(size_type i, reference item, data_reference data) const
Definition: FindManyP.h:453
TCEvent evt
Definition: DataStructs.cxx:8
Algorithm for generating space points from hits.
void clear()
Definition: PtrVector.h:533
TCTrack(fhicl::ParameterSet const &pset)