8 #include "art/Framework/Core/EDProducer.h"
9 #include "art/Framework/Core/ModuleMacros.h"
10 #include "art/Framework/Principal/Event.h"
11 #include "art/Framework/Principal/Handle.h"
12 #include "art/Framework/Services/Registry/ServiceHandle.h"
13 #include "fhiclcpp/ParameterSet.h"
14 #include "messagefacility/MessageLogger/MessageLogger.h"
28 typedef std::map<unsigned int, std::vector<tss::Hit2D>>
view_hitmap;
42 void produce(art::Event&
e)
override;
47 art::ServiceHandle<geo::Geometry const>
fGeom;
59 : EDProducer{p}, fSegmentation2D(
p.get<fhicl::ParameterSet>(
"Segmentation2DAlg"))
61 fHitModuleLabel =
p.get<std::string>(
"HitModuleLabel");
62 fHugeShowers =
p.get<
bool>(
"FindHugeShowers");
63 fShowersBySeg2D =
p.get<
bool>(
"FindMoreShowers");
65 produces<std::vector<recob::Cluster>>();
66 produces<art::Assns<recob::Cluster, recob::Hit>>();
74 art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(evt);
77 art::Handle<std::vector<recob::Hit>> hitListHandle;
78 std::vector<art::Ptr<recob::Hit>> hitlist;
80 art::fill_ptr_vector(hitlist, hitListHandle);
82 unsigned int cryo, tpc, view;
83 for (
auto const&
h : hitlist) {
84 cryo =
h->WireID().Cryostat;
85 tpc =
h->WireID().TPC;
86 view =
h->WireID().Plane;
100 std::unique_ptr<std::vector<recob::Cluster>> clusters(
new std::vector<recob::Cluster>);
101 std::unique_ptr<art::Assns<recob::Cluster, recob::Hit>> clu2hit(
102 new art::Assns<recob::Cluster, recob::Hit>);
105 unsigned int cidx = 0;
106 const unsigned int emTag = 0x10000;
108 for (
auto tpc_iter =
fGeom->begin_TPC_id(); tpc_iter !=
fGeom->end_TPC_id(); tpc_iter++) {
109 for (
const auto& v :
fHitMap[tpc_iter->Cryostat][tpc_iter->TPC]) {
113 mf::LogVerbatim(
"TrackShowerHits") <<
"Find huge EM showers (cores).";
115 int c = 0, clsSize = cls.size();
116 while (c < clsSize) {
117 if (cls[c].hits().
size() < 2) {
122 std::vector<const tss::Hit2D*> trks, ems;
124 cls.erase(cls.begin() + c);
129 cls.back().tagEM(
true);
134 mf::LogVerbatim(
"TrackShowerHits") <<
"Find EM showers by density of vtxs.";
136 int c = 0, clsSize = cls.size();
137 while (c < clsSize) {
138 if (cls[c].isEM() || (cls[c].hits().
size() < 2)) {
145 for (
const auto&
s : segs)
148 cls.erase(cls.begin() + c);
153 for (
auto& c : cls) {
154 if (!c.hits().size())
continue;
156 if (!c.isEM())
continue;
158 clusters->emplace_back(
182 c.hits().front()->Hit2DPtr()->WireID().planeID()));
184 std::vector<art::Ptr<recob::Hit>> hits2d;
185 hits2d.reserve(c.hits().size());
187 for (
auto h2d : c.hits())
188 hits2d.push_back(h2d->Hit2DPtr());
190 if (hits2d.size())
util::CreateAssn(*
this, evt, *clusters, hits2d, *clu2hit);
198 mf::LogWarning(
"TrackShowerHits") <<
"Hits not found in the event.";
200 evt.put(std::move(clusters));
201 evt.put(std::move(clu2hit));
cryo_tpc_view_hitmap fHitMap
TrackShowerHits & operator=(TrackShowerHits const &)=delete
tss::SimpleClustering fSimpleClustering
art::ServiceHandle< geo::Geometry const > fGeom
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
Declaration of signal hit object.
tss::Segmentation2D fSegmentation2D
std::size_t size(FixedBins< T, C > const &) noexcept
void splitHitsNaive(const tss::Cluster2D &inp, std::vector< const tss::Hit2D * > &trackHits, std::vector< const tss::Hit2D * > &emHits) const
Set of hits with a 2D structure.
Split into linear clusters.
TrackShowerHits(fhicl::ParameterSet const &p)
std::vector< tss::Cluster2D > run(const std::vector< tss::Hit2D > &inp) const
void produce(art::Event &e) override
std::map< unsigned int, view_hitmap > tpc_view_hitmap
std::vector< tss::Cluster2D > run(tss::Cluster2D &inp) const
Declaration of cluster object.
std::map< unsigned int, tpc_view_hitmap > cryo_tpc_view_hitmap
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.
then echo File list $list not found else cat $list while read file do echo $file sed s
std::map< unsigned int, std::vector< tss::Hit2D > > view_hitmap
bool sortHits(const art::Event &evt)
std::string fHitModuleLabel
art framework interface to geometry description