45 typedef std::unordered_map<unsigned int, std::vector<size_t>>
view_keymap;
55 Comment(
"number of samples processed in one batch")};
59 Comment(
"tag of deconvoluted ADC on wires (recob::Wire)")};
62 Comment(
"tag of hits to be EM/track tagged")};
65 Name(
"ClusterModuleLabel"),
66 Comment(
"tag of clusters to be used as a source of EM/track tagged new clusters (incl. " 67 "single-hit clusters ) using accumulated results from hits")};
70 Name(
"TrackModuleLabel"),
71 Comment(
"tag of 3D tracks to be EM/track tagged using accumulated results from hits in the " 72 "best 2D projection")};
76 Comment(
"tag clusters in selected views only, or in all views if empty list")};
126 produces<std::vector<recob::Cluster>>();
127 produces<art::Assns<recob::Cluster, recob::Hit>>();
150 <<
"next event: " << evt.
run() <<
" / " << evt.
id().
event();
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& pcryo : hitMap) {
185 for (
auto const& ptpc : pcryo.second) {
187 for (
auto const& pview : ptpc.second) {
194 for (
size_t idx = 0; idx < pview.second.size(); idx +=
fBatchSize) {
195 std::vector<std::pair<unsigned int, float>> points;
196 std::vector<size_t>
keys;
198 if (idx +
k >= pview.second.size()) {
break; }
200 size_t h = pview.second[idx +
k];
207 if (points.size() != batch_out.size()) {
211 for (
size_t k = 0;
k < points.size(); ++
k) {
226 auto clusters = std::make_unique<std::vector<recob::Cluster>>();
227 auto clu2hit = std::make_unique<art::Assns<recob::Cluster, recob::Hit>>();
231 std::vector<art::Ptr<recob::Cluster>> cluPtrList;
235 for (
auto const&
c : cluPtrList) {
236 view =
c->Plane().Plane;
239 cryo =
c->Plane().Cryostat;
240 tpc =
c->Plane().TPC;
242 cluMap[cryo][tpc][view].push_back(
c.key());
248 unsigned int cidx = 0;
250 std::vector<bool> hitUsed(hitPtrList.size(),
false);
251 for (
auto const& pcryo : cluMap) {
253 for (
auto const& ptpc : pcryo.second) {
255 for (
auto const& pview : ptpc.second) {
259 for (
size_t c : pview.second)
261 auto v = hitsFromClusters.at(c);
262 if (v.empty())
continue;
264 for (
auto const&
hit : v) {
265 if (hitUsed[
hit.key()]) {
266 mf::LogWarning(
"EmTrackClusterId2out") <<
"hit already used in another cluster";
268 hitUsed[
hit.key()] =
true;
275 <<
"cluster in tpc:" << tpc <<
" view:" << view <<
" size:" << v.size()
309 for (
size_t h : hitMap[cryo][tpc][view])
311 if (hitUsed[
h])
continue;
316 <<
"single hit in tpc:" << tpc <<
" view:" << view
317 <<
" wire:" << hitPtrList[
h]->WireID().Wire
318 <<
" drift:" << hitPtrList[
h]->PeakTime() <<
" p:" << vout[0];
345 hitPtrList[h]->
WireID().planeID()));
352 <<
"...produced " << cidx - pview.second.size() <<
" single-hit clusters.";
364 art::FindManyP<recob::Hit> hitsFromTracks(trkListHandle, evt,
fTrackModuleLabel);
365 std::vector<std::vector<art::Ptr<recob::Hit>>> trkHitPtrList(trkListHandle->size());
366 for (
size_t t = 0;
t < trkListHandle->size(); ++
t) {
367 auto v = hitsFromTracks.at(
t);
368 size_t nh[3] = {0, 0, 0};
369 for (
auto const& hptr : v) {
372 size_t best_view = 2;
373 if ((nh[0] >= nh[1]) && (nh[0] > 2 * nh[2])) best_view = 0;
374 if ((nh[1] >= nh[0]) && (nh[1] > 2 * nh[2])) best_view = 1;
378 best_view = (best_view + 1) % 3;
381 <<
"No views selected at all?" <<
std::endl;
385 for (
auto const& hptr : v) {
386 if (hptr->View() == best_view) trkHitPtrList[
t].emplace_back(hptr);
392 for (
size_t t = 0;
t < trkHitPtrList.size(); ++
t)
396 return (
float)hitInFA[ptr.key()];
414 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
EmTrackClusterId2out(Parameters const &p)
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
fhicl::Atom< art::InputTag > ClusterModuleLabel
geo::WireID WireID() const
void setOutput(FVector_ID id, size_t key, std::array< float, N > const &values)
EDProducer(fhicl::ParameterSet const &pset)
fhicl::Atom< size_t > BatchSize
ChannelGroupService::Name Name
fhicl::Atom< art::InputTag > HitModuleLabel
Set of hits with a 2D structure.
WireID_t Wire
Index of the wire within its plane.
void produce(art::Event &e) override
anab::MVAWriter< 2 > fMVAWriter
art framework interface to geometry description
fhicl::Atom< art::InputTag > TrackModuleLabel
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
EmTrackClusterId2out & operator=(EmTrackClusterId2out const &)=delete
#define DEFINE_ART_MODULE(klass)
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
void push_back(Ptr< U > const &p)
art::InputTag fTrackModuleLabel
art::InputTag fClusterModuleLabel
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.
art::InputTag fWireProducerLabel
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.
art::InputTag fHitModuleLabel
ProducesCollector & producesCollector() noexcept
void addOutput(FVector_ID id, std::array< float, N > const &values)
std::vector< int > fViews
std::unordered_map< unsigned int, tpc_view_keymap > cryo_tpc_view_keymap
float PeakTime() const
Time of the signal peak, in tick units.
fhicl::Sequence< int > Views
Declaration of signal hit object.
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)
std::unordered_map< unsigned int, std::vector< size_t > > view_keymap
art::InputTag fNewClustersTag
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Provides recob::Track data product.
EventNumber_t event() const
2D representation of charge deposited in the TDC/wire plane
constexpr PlaneID const & planeID() const
fhicl::Atom< art::InputTag > WireLabel
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
std::unordered_map< unsigned int, view_keymap > tpc_view_keymap
std::vector< std::vector< float > > predictIdVectors(std::vector< std::pair< unsigned int, float >> points) const
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)