46 typedef std::unordered_map<unsigned int, std::vector<size_t>>
view_keymap;
56 Comment(
"number of samples processed in one batch")};
60 Comment(
"tag of deconvoluted ADC on wires (recob::Wire)")};
63 Comment(
"tag of hits to be EM/track tagged")};
66 Name(
"ClusterModuleLabel"),
67 Comment(
"tag of clusters to be used as a source of EM/track tagged new clusters (incl. " 68 "single-hit clusters ) using accumulated results from hits")};
71 Name(
"TrackModuleLabel"),
72 Comment(
"tag of 3D tracks to be EM/track tagged using accumulated results from hits in the " 73 "best 2D projection")};
77 Comment(
"tag clusters in selected views only, or in all views if empty list")};
127 produces<std::vector<recob::Cluster>>();
128 produces<art::Assns<recob::Cluster, recob::Hit>>();
154 unsigned int cryo, tpc, view;
158 std::vector<art::Ptr<recob::Hit>> hitPtrList;
162 for (
auto const&
h : hitPtrList) {
163 view =
h->WireID().Plane;
166 cryo =
h->WireID().Cryostat;
167 tpc =
h->WireID().TPC;
169 hitMap[cryo][tpc][view].push_back(
h.key());
180 std::vector<char> hitInFA(
183 for (
auto const& [cryo, tpcs] : hitMap) {
184 for (
auto const& [tpc,
views] : tpcs) {
185 for (
auto const& pview :
views) {
192 for (
size_t idx = 0; idx < pview.second.size(); idx +=
fBatchSize) {
193 std::vector<std::pair<unsigned int, float>> points;
194 std::vector<size_t>
keys;
196 if (idx +
k >= pview.second.size()) {
break; }
198 size_t h = pview.second[idx +
k];
205 if (points.size() != batch_out.size()) {
209 for (
size_t k = 0;
k < points.size(); ++
k) {
224 auto clusters = std::make_unique<std::vector<recob::Cluster>>();
225 auto clu2hit = std::make_unique<art::Assns<recob::Cluster, recob::Hit>>();
229 std::vector<art::Ptr<recob::Cluster>> cluPtrList;
233 for (
auto const&
c : cluPtrList) {
234 view =
c->Plane().Plane;
237 cryo =
c->Plane().Cryostat;
238 tpc =
c->Plane().TPC;
240 cluMap[cryo][tpc][view].push_back(
c.key());
246 unsigned int cidx = 0;
248 std::vector<bool> hitUsed(hitPtrList.size(),
false);
249 for (
auto const& pcryo : cluMap) {
251 for (
auto const& ptpc : pcryo.second) {
253 for (
auto const& pview : ptpc.second) {
257 for (
size_t c : pview.second)
259 auto v = hitsFromClusters.at(c);
260 if (v.empty())
continue;
262 for (
auto const&
hit : v) {
263 if (hitUsed[
hit.key()]) {
264 mf::LogWarning(
"EmTrackClusterId") <<
"hit already used in another cluster";
266 hitUsed[
hit.key()] =
true;
272 float pvalue = vout[0] / (vout[0] + vout[1]);
273 mf::LogVerbatim(
"EmTrackClusterId") <<
"cluster in tpc:" << tpc <<
" view:" << view
274 <<
" size:" << v.size() <<
" p:" << pvalue;
307 for (
size_t h : hitMap[cryo][tpc][view])
309 if (hitUsed[
h])
continue;
312 float pvalue = vout[0] / (vout[0] + vout[1]);
315 <<
"single hit in tpc:" << tpc <<
" view:" << view
316 <<
" wire:" << hitPtrList[
h]->WireID().Wire
317 <<
" drift:" << hitPtrList[
h]->PeakTime() <<
" p:" << pvalue;
344 hitPtrList[h]->
WireID().planeID()));
351 <<
"...produced " << cidx - pview.second.size() <<
" single-hit clusters.";
363 art::FindManyP<recob::Hit> hitsFromTracks(trkListHandle, evt,
fTrackModuleLabel);
364 std::vector<std::vector<art::Ptr<recob::Hit>>> trkHitPtrList(trkListHandle->size());
365 for (
size_t t = 0;
t < trkListHandle->size(); ++
t) {
366 auto v = hitsFromTracks.at(
t);
367 size_t nh[3] = {0, 0, 0};
368 for (
auto const& hptr : v) {
371 size_t best_view = 2;
372 if ((nh[0] >= nh[1]) && (nh[0] > 2 * nh[2])) best_view = 0;
373 if ((nh[1] >= nh[0]) && (nh[1] > 2 * nh[2])) best_view = 1;
377 best_view = (best_view + 1) % 3;
383 for (
auto const& hptr : v) {
384 if (hptr->View() == best_view) trkHitPtrList[
t].emplace_back(hptr);
390 for (
size_t t = 0;
t < trkHitPtrList.size(); ++
t)
394 return (
float)hitInFA[ptr.key()];
412 if (
k == view) {
return true; }
bool isInsideFiducialRegion(unsigned int wire, float drift) const
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
std::vector< std::string > const & outputLabels() const
network output labels
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)
EDProducer(fhicl::ParameterSet const &pset)
art::InputTag fWireProducerLabel
fhicl::Atom< art::InputTag > WireLabel
ChannelGroupService::Name Name
void produce(art::Event &e) override
Set of hits with a 2D structure.
WireID_t Wire
Index of the wire within its plane.
fhicl::Atom< art::InputTag > TrackModuleLabel
art::InputTag fNewClustersTag
anab::MVAWriter< 3 > fMVAWriter
art framework interface to geometry description
bool isViewSelected(int view) const
fhicl::Atom< size_t > BatchSize
std::vector< int > fViews
std::unordered_map< unsigned int, view_keymap > tpc_view_keymap
FVector_ID initOutputs(std::string const &dataTag, size_t dataSize, std::vector< std::string > const &names=std::vector< std::string >(N,""))
fhicl::Sequence< int > Views
fhicl::Atom< art::InputTag > ClusterModuleLabel
#define DEFINE_ART_MODULE(klass)
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
art::InputTag fHitModuleLabel
void push_back(Ptr< U > const &p)
fhicl::Atom< art::InputTag > HitModuleLabel
ValidHandle< PROD > getValidHandle(InputTag const &tag) 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.
std::array< float, N > getOutput(std::vector< art::Ptr< T > > const &items) const
void saveOutputs(art::Event &evt)
Check consistency and save all the results in the event.
Detector simulation of raw signals on wires.
ProducesCollector & producesCollector() noexcept
void addOutput(FVector_ID id, std::array< float, N > const &values)
float PeakTime() const
Time of the signal peak, in tick units.
Declaration of signal hit object.
std::unordered_map< unsigned int, std::vector< size_t > > view_keymap
bool setWireDriftData(const detinfo::DetectorClocksData &clock_data, const detinfo::DetectorPropertiesData &det_prop, const std::vector< recob::Wire > &wires, unsigned int plane, unsigned int tpc, unsigned int cryo)
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Provides recob::Track data product.
EventNumber_t event() const
art::InputTag fClusterModuleLabel
2D representation of charge deposited in the TDC/wire plane
constexpr PlaneID const & planeID() const
art::InputTag fTrackModuleLabel
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
std::vector< std::vector< float > > predictIdVectors(std::vector< std::pair< unsigned int, float >> points) const
EmTrackClusterId & operator=(EmTrackClusterId const &)=delete
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
EmTrackClusterId(Parameters const &p)
std::unordered_map< unsigned int, tpc_view_keymap > cryo_tpc_view_keymap
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)