TCTrack_module.cc
Go to the documentation of this file.
1 /**
2  * @file TCTrack_module.cc
3  * @brief Create seeds, spacepoints and tracks from 3D matched clusters produced by TrajCluster_module
4  * @author Bruce Baller (baller@fnal.gov)
5  */
6 
7 // C/C++ standard libraries
8 #include <string>
9 
10 // Framework libraries
14 #include "canvas/Persistency/Common/FindManyP.h"
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  //----------------------------------------------------------------------------
56  void
58  {
59  // all data products are assumed to be produced by the same module that produced the PFParticles -> TrajCluster_module
60  auto pfpHandle = evt.getValidHandle<std::vector<recob::PFParticle>>(fPFPtag);
61  auto clsHandle = evt.getValidHandle<std::vector<recob::Cluster>>(fPFPtag);
62 
63  art::FindManyP<recob::Cluster> pfp_cls(pfpHandle, evt, fPFPtag);
64  art::FindManyP<recob::Hit> cls_hit(clsHandle, evt, fPFPtag);
65 
66  auto sphitassn = std::make_unique<art::Assns<recob::SpacePoint, recob::Hit>>();
67  auto spts = std::make_unique<std::vector<recob::SpacePoint>>();
68 
69  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
70  auto const detProp =
72 
74  for (unsigned short ipfp = 0; ipfp < pfpHandle->size(); ++ipfp) {
75  // Get the clusters associated with this PFParticle - there should be one in each plane
76  std::vector<art::Ptr<recob::Cluster>> clsList;
77  pfp_cls.get(ipfp, clsList);
78  hits.clear();
79  std::cout << "PFP " << ipfp << "\n";
80  for (unsigned short icl = 0; icl < clsList.size(); ++icl) {
81  std::vector<art::Ptr<recob::Hit>> hitList;
82  unsigned int clsIndex = clsList[icl]->ID() - 1;
83  cls_hit.get(clsIndex, hitList);
84  std::cout << " cls index " << clsIndex << " hits size " << hitList.size() << " "
85  << (int)clsList[icl]->StartWire() << ":" << (int)clsList[icl]->StartTick()
86  << " EndWire " << (int)clsList[icl]->EndWire() << ":"
87  << (int)clsList[icl]->EndTick() << "\n";
88  hits.reserve(hits.size() + hitList.size());
89  hits.insert(hits.end(), hitList.begin(), hitList.end());
90  } // icl
91  // make new space points using these hits
92  std::vector<recob::SpacePoint> new_spts;
93  fSptalg.makeSpacePoints(clockData, detProp, hits, new_spts);
94  if (new_spts.empty()) continue;
95 
96  int nspt = spts->size();
97  spts->insert(spts->end(), new_spts.begin(), new_spts.end());
98  // associate the hits with the spacepoints
100  for (unsigned int ispt = nspt; ispt < spts->size(); ++ispt) {
101  const recob::SpacePoint& spt = (*spts)[ispt];
103  util::CreateAssn(evt, *spts, hits, *sphitassn, ispt);
104  } // ispt
105  } // ipfp
106 
107  evt.put(std::move(spts));
108  evt.put(std::move(sphitassn));
109 
110  } // TCTrack::produce()
111 
113 
114 } // namespace trkf
void reserve(size_type n)
Definition: PtrVector.h:337
void produce(art::Event &evt) override
SpacePointAlg fSptalg
std::string string
Definition: nybbler.cc:12
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
const art::PtrVector< recob::Hit > & getAssociatedHits(const recob::SpacePoint &spt) const
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
void makeSpacePoints(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const art::PtrVector< recob::Hit > &hits, std::vector< recob::SpacePoint > &spts) const
def move(depos, offset)
Definition: depos.py:107
iterator end()
Definition: PtrVector.h:231
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:441
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.
size_type size() const
Definition: PtrVector.h:302
iterator insert(iterator position, Ptr< U > const &p)
Declaration of signal hit object.
art::InputTag fPFPtag
TCEvent evt
Definition: DataStructs.cxx:7
Algorithm for generating space points from hits.
void clear()
Definition: PtrVector.h:533
TCTrack(fhicl::ParameterSet const &pset)