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;
106 int const readoutWindowSize = detProp.ReadOutWindowSize();
110 std::vector<art::Ptr<recob::Hit>> hits;
111 std::vector<art::Ptr<recob::Hit>> hitsToCluster;
118 std::vector<art::Ptr<recob::Track>>
tracks;
124 std::vector<art::Ptr<recob::SpacePoint>> spacePoints;
130 std::vector<art::Ptr<recob::Vertex>> vertices;
136 std::vector<art::Ptr<recob::PFParticle>> pfParticles;
142 if (trackCollection.
isValid()) {
145 art::FindManyP<recob::SpacePoint> fmspt(trackCollection, evt,
fTrackModuleLabel);
146 art::FindManyP<recob::Track> fmtsp(spacePointCollection, evt,
fTrackModuleLabel);
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>>
181 std::vector<art::PtrVector<recob::Hit>> planeClusters;
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());
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
bool const fCreateDebugPDF
EventNumber_t event() const
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
bool const fShowerReconOnly
cluster::MergeClusterAlg fMergeClusterAlg
std::string const fHitsModuleLabel
Cluster finding and building.
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.
bool isValid() const noexcept
int MergeClusters(std::vector< art::PtrVector< recob::Hit > > const &planeClusters, std::vector< art::PtrVector< recob::Hit > > &clusters) const
void CreateDebugPDF(int run, int subrun, int event)
Create the PDF to save debug images.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
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.
SubRunNumber_t subRun() const
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
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.
void SaveImage(TH2F *image, std::vector< art::PtrVector< recob::Hit >> const &allClusters, int pad, int tpc, int plane)
shower::TrackShowerSeparationAlg fTrackShowerSeparationAlg
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
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
bool const fMergeClusters
unsigned int GetMinSize() const noexcept
Minimum size of cluster to save.
std::string const fVertexModuleLabel
QTextStream & endl(QTextStream &s)