45 typedef std::unordered_map< unsigned int, std::vector< size_t > >
view_keymap;
58 Comment(
"number of samples processed in one batch")
63 Comment(
"tag of deconvoluted ADC on wires (recob::Wire)")
67 Name(
"HitModuleLabel"),
68 Comment(
"tag of hits to be EM/track tagged")
72 Name(
"ClusterModuleLabel"),
73 Comment(
"tag of clusters to be used as a source of EM/track tagged new clusters (incl. single-hit clusters ) using accumulated results from hits")
77 Name(
"TrackModuleLabel"),
78 Comment(
"tag of 3D tracks to be EM/track tagged using accumulated results from hits in the best 2D projection")
83 Comment(
"tag clusters in selected views only, or in all views if empty list")
134 produces< std::vector<recob::Cluster> >();
135 produces< art::Assns<recob::Cluster, recob::Hit> >();
157 unsigned int cryo, tpc, view;
161 std::vector< art::Ptr<recob::Hit> > hitPtrList;
165 for (
auto const&
h : hitPtrList)
167 view =
h->WireID().Plane;
170 cryo =
h->WireID().Cryostat;
171 tpc =
h->WireID().TPC;
173 hitMap[cryo][tpc][view].push_back(
h.key());
179 std::vector< char > hitInFA(hitPtrList.size(), 0);
180 for (
auto const & pcryo : hitMap)
183 for (
auto const & ptpc : pcryo.second)
186 for (
auto const & pview : ptpc.second)
194 for (
size_t idx = 0; idx < pview.second.size(); idx +=
fBatchSize)
196 std::vector< std::pair<unsigned int, float> > points;
197 std::vector< size_t >
keys;
200 if (idx +
k >= pview.second.size()) {
break; }
202 size_t h = pview.second[idx+
k];
209 if (points.size() != batch_out.size())
214 for (
size_t k = 0;
k < points.size(); ++
k)
230 auto clusters = std::make_unique< std::vector< recob::Cluster > >();
231 auto clu2hit = std::make_unique< art::Assns< recob::Cluster, recob::Hit > >();
235 std::vector< art::Ptr<recob::Cluster> > cluPtrList;
239 for (
auto const&
c : cluPtrList)
241 view =
c->Plane().Plane;
244 cryo =
c->Plane().Cryostat;
245 tpc =
c->Plane().TPC;
247 cluMap[cryo][tpc][view].push_back(
c.key());
252 unsigned int cidx = 0;
254 std::vector< bool > hitUsed(hitPtrList.size(),
false);
255 for (
auto const & pcryo : cluMap)
258 for (
auto const & ptpc : pcryo.second)
261 for (
auto const & pview : ptpc.second)
266 for (
size_t c : pview.second)
268 auto v = hitsFromClusters.at(c);
269 if (v.empty())
continue;
271 for (
auto const &
hit : v)
273 if (hitUsed[
hit.key()]) {
mf::LogWarning(
"EmTrackClusterId2out") <<
"hit already used in another cluster"; }
274 hitUsed[
hit.key()] =
true;
280 mf::LogVerbatim(
"EmTrackClusterId2out") <<
"cluster in tpc:" << tpc <<
" view:" << view
281 <<
" size:" << v.size() <<
" p:" << vout[0];
283 clusters->emplace_back(
284 recob::Cluster(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F,
293 for (
size_t h : hitMap[cryo][tpc][view])
295 if (hitUsed[
h])
continue;
299 mf::LogVerbatim(
"EmTrackClusterId2out") <<
"single hit in tpc:" << tpc <<
" view:" << view
300 <<
" wire:" << hitPtrList[
h]->WireID().Wire <<
" drift:" << hitPtrList[
h]->PeakTime() <<
" p:" << vout[0];
304 clusters->emplace_back(
305 recob::Cluster(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F,
306 1, 0.0F, 0.0F, cidx, (
geo::View_t)view, hitPtrList[h]->WireID().planeID()));
312 mf::LogVerbatim(
"EmTrackClusterId2out") <<
"...produced " << cidx - pview.second.size() <<
" single-hit clusters.";
325 art::FindManyP< recob::Hit > hitsFromTracks(trkListHandle, evt,
fTrackModuleLabel);
326 std::vector< std::vector< art::Ptr<recob::Hit> > > trkHitPtrList(trkListHandle->size());
327 for (
size_t t = 0;
t < trkListHandle->size(); ++
t)
329 auto v = hitsFromTracks.at(
t);
330 size_t nh[3] = { 0, 0, 0 };
331 for (
auto const & hptr : v) { ++nh[hptr->View()]; }
332 size_t best_view = 2;
333 if ((nh[0] >= nh[1]) && (nh[0] > 2 * nh[2])) best_view = 0;
334 if ((nh[1] >= nh[0]) && (nh[1] > 2 * nh[2])) best_view = 1;
339 best_view = (best_view + 1) % 3;
343 for (
auto const & hptr : v)
345 if (hptr->View() == best_view) trkHitPtrList[
t].emplace_back(hptr);
350 for (
size_t t = 0;
t < trkHitPtrList.size(); ++
t)
365 if (
fViews.empty())
return true;
368 for (
auto k :
fViews)
if (
k == view) {
return true; }
bool isInsideFiducialRegion(unsigned int wire, float drift) const
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
fhicl::Atom< size_t > BatchSize
fhicl::Atom< art::InputTag > WireLabel
std::vector< int > fViews
EmTrackClusterId2out(Parameters const &p)
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
geo::WireID WireID() const
void setOutput(FVector_ID id, size_t key, std::array< float, N > const &values)
Declaration of signal hit object.
EDProducer(fhicl::ParameterSet const &pset)
Set of hits with a 2D structure.
WireID_t Wire
Index of the wire within its plane.
void produce(art::Event &e) override
bool setWireDriftData(const std::vector< recob::Wire > &wires, unsigned int plane, unsigned int tpc, unsigned int cryo)
std::unordered_map< unsigned int, view_keymap > tpc_view_keymap
anab::MVAWriter< 2 > fMVAWriter
std::vector< std::string > const & outputLabels(void) const
network output labels
FVector_ID initOutputs(std::string const &dataTag, size_t dataSize, std::vector< std::string > const &names=std::vector< std::string >(N,""))
bool isViewSelected(int view) const
fhicl::Atom< art::InputTag > HitModuleLabel
EmTrackClusterId2out & operator=(EmTrackClusterId2out const &)=delete
#define DEFINE_ART_MODULE(klass)
void push_back(Ptr< U > const &p)
art::InputTag fTrackModuleLabel
art::InputTag fClusterModuleLabel
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
fhicl::Sequence< int > Views
art::InputTag fWireProducerLabel
std::array< float, N > getOutput(std::vector< art::Ptr< T > > const &items) const
Declaration of cluster object.
void saveOutputs(art::Event &evt)
Check consistency and save all the results in the event.
Provides recob::Track data product.
fhicl::Atom< art::InputTag > ClusterModuleLabel
Detector simulation of raw signals on wires.
art::InputTag fHitModuleLabel
ProducesCollector & producesCollector() noexcept
void addOutput(FVector_ID id, std::array< float, N > const &values)
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.
float PeakTime() const
Time of the signal peak, in tick units.
Utility object to perform functions of association.
std::vector< std::vector< float > > predictIdVectors(std::vector< std::pair< unsigned int, float > > points) const
art::InputTag fNewClustersTag
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
std::unordered_map< unsigned int, std::vector< size_t > > view_keymap
fhicl::Atom< art::InputTag > TrackModuleLabel
EventNumber_t event() const
2D representation of charge deposited in the TDC/wire plane
constexpr PlaneID const & planeID() const
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
ProductID put(std::unique_ptr< PROD > &&edp, FullSemantic< Level::Run > const semantic)
std::unordered_map< unsigned int, tpc_view_keymap > cryo_tpc_view_keymap
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)
h
training ###############################