93 auto clusters = std::make_unique<std::vector<recob::Cluster>>();
94 auto associations = std::make_unique<art::Assns<recob::Cluster, recob::Hit>>();
98 ClusterParamsImportWrapper<StandardClusterParamsAlg> ClusterParamAlgo;
101 art::ServiceHandle<geo::Geometry const> geom;
102 auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(
evt);
104 art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(
evt, clockData);
106 int const readoutWindowSize =
detProp.ReadOutWindowSize();
109 art::Handle<std::vector<recob::Hit>> hitCollection;
110 std::vector<art::Ptr<recob::Hit>> hits;
111 std::vector<art::Ptr<recob::Hit>> hitsToCluster;
112 if (
evt.getByLabel(
fHitsModuleLabel, hitCollection)) art::fill_ptr_vector(hits, hitCollection);
117 art::Handle<std::vector<recob::Track>> trackCollection;
118 std::vector<art::Ptr<recob::Track>>
tracks;
120 art::fill_ptr_vector(tracks, trackCollection);
123 art::Handle<std::vector<recob::SpacePoint>> spacePointCollection;
124 std::vector<art::Ptr<recob::SpacePoint>> spacePoints;
126 art::fill_ptr_vector(spacePoints, spacePointCollection);
129 art::Handle<std::vector<recob::Vertex>> vertexCollection;
130 std::vector<art::Ptr<recob::Vertex>> vertices;
132 art::fill_ptr_vector(vertices, vertexCollection);
135 art::Handle<std::vector<recob::PFParticle>> pfParticleCollection;
136 std::vector<art::Ptr<recob::PFParticle>> pfParticles;
138 art::fill_ptr_vector(pfParticles, pfParticleCollection);
139 art::Handle<std::vector<recob::Cluster>> clusterCollection;
142 if (trackCollection.isValid()) {
148 evt.
event(), hits,
tracks, spacePoints, fmht, fmth, fmspt, fmtsp);
152 hitsToCluster = hits;
155 std::map<std::pair<int, int>, std::vector<art::Ptr<recob::Hit>>> planeToHits;
156 for (
auto const& hitToCluster : hitsToCluster) {
157 auto const& wireID = hitToCluster->WireID();
158 auto const planeNo = wireID.Plane;
160 planeToHits[std::make_pair(planeNo, tpc)].push_back(hitToCluster);
164 for (
auto const& [plane, hits] : planeToHits) {
165 std::vector<art::PtrVector<recob::Hit>> finalClusters;
175 std::vector<std::vector<int>>
178 mf::LogVerbatim(
"Blurred Clustering") <<
"Found " << numClusters <<
" clusters" << std::endl;
181 std::vector<art::PtrVector<recob::Hit>> planeClusters;
187 mf::LogVerbatim(
"Blurred Clustering")
188 <<
"After merging, there are " << numMergedClusters <<
" clusters" << std::endl;
191 finalClusters = planeClusters;
195 std::stringstream
name;
196 name <<
"blurred_image";
198 name <<
"_convolved";
200 auto const [planeNo, tpc] = plane;
206 blurredHist->Delete();
212 for (
auto const& clusterHits : finalClusters) {
213 if (clusterHits.empty())
continue;
216 unsigned int const startWire =
221 ClusterParamAlgo.ImportHits(gser, clusterHits);
228 clusterHits.front()->PeakTime(),
229 clusterHits.front()->SigmaPeakTime(),
232 clusterHits.back()->PeakTime(),
233 clusterHits.back()->SigmaPeakTime(),
235 clusterHits.front()->View(),
236 clusterHits.front()->WireID().planeID(),
239 clusters->emplace_back(
cluster.move());
246 evt.put(std::move(clusters));
247 evt.put(std::move(associations));
bool const fCreateDebugPDF
TH2F * MakeHistogram(std::vector< std::vector< double >> const &image, TString name) const
Converts a 2D vector in a histogram for the debug pdf.
std::string const fPFParticleModuleLabel
ClusterModuleLabel join with tracks
bool const fShowerReconOnly
cluster::MergeClusterAlg fMergeClusterAlg
std::string const fHitsModuleLabel
int FindClusters(std::vector< std::vector< double >> const &image, std::vector< std::vector< int >> &allcluster) const
Find clusters in the histogram.
static const SentryArgument_t Sentry
An instance of the sentry object.
int MergeClusters(std::vector< art::PtrVector< recob::Hit > > const &planeClusters, std::vector< art::PtrVector< recob::Hit > > &clusters) const
unsigned int GetMinSize() const noexcept
Minimum size of cluster to save.
void CreateDebugPDF(int run, int subrun, int event)
Create the PDF to save debug images.
bool const fGlobalTPCRecon
std::vector< art::Ptr< recob::Hit > > SelectShowerHits(int event, const std::vector< art::Ptr< recob::Hit > > &hits, const std::vector< art::Ptr< recob::Track > > &tracks, const std::vector< art::Ptr< recob::SpacePoint > > &spacePoints, const art::FindManyP< recob::Hit > &fmht, const art::FindManyP< recob::Track > &fmth, const art::FindManyP< recob::SpacePoint > &fmspt, const art::FindManyP< recob::Track > &fmtsp) const
int GlobalWire(geo::WireID const &wireID) const
Find the global wire position.
std::vector< std::vector< double > > GaussianBlur(std::vector< std::vector< double >> const &image) const
Applies Gaussian blur to image.
void SaveImage(TH2F *image, std::vector< art::PtrVector< recob::Hit >> const &allClusters, int pad, int tpc, int plane)
shower::TrackShowerSeparationAlg fTrackShowerSeparationAlg
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.
void ConvertBinsToClusters(std::vector< std::vector< double >> const &image, std::vector< std::vector< int >> const &allClusterBins, std::vector< art::PtrVector< recob::Hit >> &clusters) const
Takes a vector of clusters (itself a vector of hits) and turns them into clusters using the initial h...
std::string const fTrackModuleLabel
std::vector< std::vector< double > > ConvertRecobHitsToVector(std::vector< art::Ptr< recob::Hit >> const &hits, int readoutWindowSize)
Takes hit map and returns a 2D vector representing wire and tick, filled with the charge...
cluster::BlurredClusteringAlg fBlurredClusteringAlg
bool const fMergeClusters
std::string const fVertexModuleLabel