96 mf::LogError(
"Shower2DLinearRegressionTrackHitFinder")
97 <<
"Start position not set, returning " << std::endl;
102 mf::LogError(
"Shower2DLinearRegressionTrackHitFinder")
103 <<
"Direction not set, returning " << std::endl;
107 TVector3 ShowerStartPosition = {-999, -999, -999};
110 TVector3 ShowerDirection = {-999, -999, -999};
114 auto const pfpHandle = Event.getValidHandle<std::vector<recob::PFParticle>>(
fPFParticleLabel);
117 auto const clusHandle = Event.getValidHandle<std::vector<recob::Cluster>>(
fPFParticleLabel);
119 const art::FindManyP<recob::Cluster>& fmc =
121 std::vector<art::Ptr<recob::Cluster>> clusters = fmc.at(pfparticle.key());
123 if (clusters.size() < 2) {
125 mf::LogError(
"Shower2DLinearRegressionTrackHitFinder")
126 <<
"Not enough clusters: " << clusters.size() << std::endl;
131 const art::FindManyP<recob::Hit>& fmhc =
133 std::map<geo::PlaneID, std::vector<art::Ptr<recob::Hit>>> plane_clusters;
135 for (
auto const&
cluster : clusters) {
138 std::vector<art::Ptr<recob::Hit>> hits = fmhc.at(
cluster.key());
140 for (
auto hit : hits) {
143 plane_clusters[plane].push_back(
hit);
151 auto const clockData =
152 art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(Event);
154 art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(Event, clockData);
156 std::vector<art::Ptr<recob::Hit>> InitialTrackHits;
158 for (
auto const&
cluster : plane_clusters) {
161 std::vector<art::Ptr<recob::Hit>> hits =
cluster.second;
165 detProp, hits, ShowerStartPosition, ShowerDirection);
170 InitialTrackHits.insert(InitialTrackHits.end(), trackhits.begin(), trackhits.end());
178 auto const hitHandle = Event.getValidHandle<std::vector<recob::Hit>>(
fHitLabel);
181 const art::FindManyP<recob::SpacePoint>& fmsp =
185 std::vector<art::Ptr<recob::SpacePoint>> intitaltrack_sp;
186 for (
auto const&
hit : InitialTrackHits) {
187 std::vector<art::Ptr<recob::SpacePoint>> sps = fmsp.at(
hit.key());
188 for (
auto const sp : sps) {
189 intitaltrack_sp.push_back(sp);
The data type to uniquely identify a Plane.
void SetElement(T &dataproduct, const std::string &Name, bool checktag=false)
Set of hits with a 2D structure.
const art::FindManyP< T1 > & GetFindManyP(const art::ValidHandle< std::vector< T2 > > &handle, const art::Event &evt, const art::InputTag &moduleTag)
bool CheckElement(const std::string &Name) const
constexpr PlaneID const & asPlaneID() const
Conversion to PlaneID (for convenience of notation).
int GetElement(const std::string &Name, T &Element) const
2D representation of charge deposited in the TDC/wire plane
void OrderShowerHits(detinfo::DetectorPropertiesData const &detProp, std::vector< art::Ptr< recob::Hit >> &hits, TVector3 const &ShowerDirection, TVector3 const &ShowerPosition) const