48 typedef std::unordered_map< unsigned int, std::vector< size_t > >
view_keymap;
60 Name(
"BatchSize"),
Comment(
"number of samples processed in one batch")
64 Name(
"WireLabel"),
Comment(
"tag of deconvoluted ADC on wires (recob::Wire)")
68 Name(
"HitModuleLabel"),
Comment(
"tag of hits to be EM/track / Michel tagged")
72 Name(
"ClusterModuleLabel"),
73 Comment(
"tag of clusters to be used as a source of EM/track / Michel 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 / Michel 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(
"EmTrackMichelId") <<
"hit already used in another cluster"; }
274 hitUsed[
hit.key()] =
true;
280 float pvalue = vout[0] / (vout[0] + vout[1]);
281 mf::LogVerbatim(
"EmTrackMichelId") <<
"cluster in tpc:" << tpc <<
" view:" << view
282 <<
" size:" << v.size() <<
" p:" << pvalue;
284 clusters->emplace_back(
285 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,
294 for (
size_t h : hitMap[cryo][tpc][view])
296 if (hitUsed[
h])
continue;
299 float pvalue = vout[0] / (vout[0] + vout[1]);
301 mf::LogVerbatim(
"EmTrackMichelId") <<
"single hit in tpc:" << tpc <<
" view:" << view
302 <<
" wire:" << hitPtrList[
h]->WireID().Wire <<
" drift:" << hitPtrList[
h]->PeakTime() <<
" p:" << pvalue;
306 clusters->emplace_back(
307 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,
308 1, 0.0F, 0.0F, cidx, (
geo::View_t)view, hitPtrList[h]->WireID().planeID()));
314 mf::LogVerbatim(
"EmTrackMichelId") <<
"...produced " << cidx - pview.second.size() <<
" single-hit clusters.";
327 art::FindManyP< recob::Hit > hitsFromTracks(trkListHandle, evt,
fTrackModuleLabel);
328 std::vector< std::vector< art::Ptr<recob::Hit> > > trkHitPtrList(trkListHandle->size());
329 for (
size_t t = 0;
t < trkListHandle->size(); ++
t)
331 auto v = hitsFromTracks.at(
t);
332 size_t nh[3] = { 0, 0, 0 };
333 for (
auto const & hptr : v) { ++nh[hptr->View()]; }
334 size_t best_view = 2;
335 if ((nh[0] >= nh[1]) && (nh[0] > 2 * nh[2])) best_view = 0;
336 if ((nh[1] >= nh[0]) && (nh[1] > 2 * nh[2])) best_view = 1;
341 best_view = (best_view + 1) % 3;
345 for (
auto const & hptr : v)
347 if (hptr->View() == best_view) trkHitPtrList[
t].emplace_back(hptr);
352 for (
size_t t = 0;
t < trkHitPtrList.size(); ++
t)
367 if (
fViews.empty())
return true;
370 bool selected =
false;
371 for (
auto k :
fViews)
if (
k == view) { selected =
true;
break; }
bool isInsideFiducialRegion(unsigned int wire, float drift) const
art::InputTag fNewClustersTag
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
geo::WireID WireID() const
art::InputTag fHitModuleLabel
void setOutput(FVector_ID id, size_t key, std::array< float, N > const &values)
Declaration of signal hit object.
EDProducer(fhicl::ParameterSet const &pset)
fhicl::Atom< art::InputTag > WireLabel
EmTrackMichelId(Parameters const &p)
std::vector< int > fViews
art::InputTag fClusterModuleLabel
Set of hits with a 2D structure.
std::unordered_map< unsigned int, std::vector< size_t > > view_keymap
WireID_t Wire
Index of the wire within its plane.
fhicl::Atom< art::InputTag > TrackModuleLabel
fhicl::Atom< art::InputTag > HitModuleLabel
EmTrackMichelId & operator=(EmTrackMichelId const &)=delete
bool setWireDriftData(const std::vector< recob::Wire > &wires, unsigned int plane, unsigned int tpc, unsigned int cryo)
anab::MVAWriter< 4 > fMVAWriter
bool isViewSelected(int view) const
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,""))
#define DEFINE_ART_MODULE(klass)
void push_back(Ptr< U > const &p)
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
void produce(art::Event &e) override
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.
Detector simulation of raw signals on wires.
ProducesCollector & producesCollector() noexcept
std::unordered_map< unsigned int, tpc_view_keymap > cryo_tpc_view_keymap
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.
fhicl::Atom< art::InputTag > ClusterModuleLabel
std::unordered_map< unsigned int, view_keymap > tpc_view_keymap
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
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
fhicl::Atom< size_t > BatchSize
EventNumber_t event() const
2D representation of charge deposited in the TDC/wire plane
constexpr PlaneID const & planeID() const
fhicl::Sequence< int > Views
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
ProductID put(std::unique_ptr< PROD > &&edp, FullSemantic< Level::Run > const semantic)
art::InputTag fTrackModuleLabel
art::InputTag fWireProducerLabel
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 ###############################