46         typedef std::unordered_map< unsigned int, std::vector< size_t > > 
view_keymap;
    59                         Comment(
"number of samples processed in one batch")
    64                         Comment(
"tag of deconvoluted ADC on wires (recob::Wire)")
    68                         Name(
"HitModuleLabel"),
    69                         Comment(
"tag of hits to be EM/track tagged")
    73                         Name(
"ClusterModuleLabel"),
    74                         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")
    78                         Name(
"TrackModuleLabel"),
    79                         Comment(
"tag of 3D tracks to be EM/track tagged using accumulated results from hits in the best 2D projection")
    84                         Comment(
"tag clusters in selected views only, or in all views if empty list")
   135         produces< std::vector<recob::Cluster> >();
   136             produces< art::Assns<recob::Cluster, recob::Hit> >();
   158         unsigned int cryo, tpc, view;
   162         std::vector< art::Ptr<recob::Hit> > hitPtrList;
   166         for (
auto const& 
h : hitPtrList)
   168                 view = 
h->WireID().Plane;
   171                 cryo = 
h->WireID().Cryostat;
   172                 tpc = 
h->WireID().TPC;
   174                 hitMap[cryo][tpc][view].push_back(
h.key());
   180     std::vector< char > hitInFA(hitPtrList.size(), 0); 
   181     for (
auto const & pcryo : hitMap)
   184         for (
auto const & ptpc : pcryo.second)
   187             for (
auto const & pview : ptpc.second)
   195                 for (
size_t idx = 0; idx < pview.second.size(); idx += 
fBatchSize)
   197                     std::vector< std::pair<unsigned int, float> > points;
   198                     std::vector< size_t > 
keys;
   201                         if (idx + 
k >= pview.second.size()) { 
break; } 
   203                         size_t h = pview.second[idx+
k]; 
   210                     if (points.size() != batch_out.size())
   215                     for (
size_t k = 0; 
k < points.size(); ++
k)
   231             auto clusters = std::make_unique< std::vector< recob::Cluster > >();
   232             auto clu2hit = std::make_unique< art::Assns< recob::Cluster, recob::Hit > >();
   236             std::vector< art::Ptr<recob::Cluster> > cluPtrList;
   240             for (
auto const& 
c : cluPtrList)
   242                 view = 
c->Plane().Plane;
   245                 cryo = 
c->Plane().Cryostat;
   246                 tpc = 
c->Plane().TPC;
   248                 cluMap[cryo][tpc][view].push_back(
c.key());
   253         unsigned int cidx = 0; 
   255         std::vector< bool > hitUsed(hitPtrList.size(), 
false); 
   256         for (
auto const & pcryo : cluMap)
   259             for (
auto const & ptpc : pcryo.second)
   262                 for (
auto const & pview : ptpc.second)
   267                     for (
size_t c : pview.second) 
   269                                 auto v = hitsFromClusters.at(c);
   270                                 if (v.empty()) 
continue;
   272                         for (
auto const & 
hit : v)
   274                             if (hitUsed[
hit.key()]) { 
mf::LogWarning(
"EmTrackClusterId") << 
"hit already used in another cluster"; }
   275                             hitUsed[
hit.key()] = 
true;
   281                             float pvalue = vout[0] / (vout[0] + vout[1]);
   282                             mf::LogVerbatim(
"EmTrackClusterId") << 
"cluster in tpc:" << tpc << 
" view:" << view
   283                             << 
" size:" << v.size() << 
" p:" << pvalue;
   285                                 clusters->emplace_back(
   286                                     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,
   295                     for (
size_t h : hitMap[cryo][tpc][view]) 
   297                         if (hitUsed[
h]) 
continue;
   300                                 float pvalue = vout[0] / (vout[0] + vout[1]);
   302                                 mf::LogVerbatim(
"EmTrackClusterId") << 
"single hit in tpc:" << tpc << 
" view:" << view
   303                                         << 
" wire:" << hitPtrList[
h]->WireID().Wire << 
" drift:" << hitPtrList[
h]->PeakTime() << 
" p:" << pvalue;
   307                                 clusters->emplace_back(
   308                                         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,
   309                                             1, 0.0F, 0.0F, cidx, (
geo::View_t)view, hitPtrList[h]->WireID().planeID()));
   315                     mf::LogVerbatim(
"EmTrackClusterId") << 
"...produced " << cidx - pview.second.size() << 
" single-hit clusters.";
   328         art::FindManyP< recob::Hit > hitsFromTracks(trkListHandle, evt, 
fTrackModuleLabel);
   329         std::vector< std::vector< art::Ptr<recob::Hit> > > trkHitPtrList(trkListHandle->size());
   330         for (
size_t t = 0; 
t < trkListHandle->size(); ++
t)
   332             auto v = hitsFromTracks.at(
t);
   333             size_t nh[3] = { 0, 0, 0 };
   334             for (
auto const & hptr : v) { ++nh[hptr->View()]; }
   335             size_t best_view = 2; 
   336             if ((nh[0] >= nh[1]) && (nh[0] > 2 * nh[2])) best_view = 0; 
   337             if ((nh[1] >= nh[0]) && (nh[1] > 2 * nh[2])) best_view = 1; 
   342                 best_view = (best_view + 1) % 3;
   346             for (
auto const & hptr : v)
   348                 if (hptr->View() == best_view) trkHitPtrList[
t].emplace_back(hptr);
   353         for (
size_t t = 0; 
t < trkHitPtrList.size(); ++
t) 
   368         if (
fViews.empty()) 
return true;
   371                 for (
auto k : 
fViews) 
if (
k == view) { 
return true; }
 bool isInsideFiducialRegion(unsigned int wire, float drift) const 
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
std::unordered_map< unsigned int, view_keymap > tpc_view_keymap
std::unordered_map< unsigned int, std::vector< size_t > > view_keymap
fhicl::Atom< art::InputTag > TrackModuleLabel
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)
art::InputTag fWireProducerLabel
void produce(art::Event &e) override
Set of hits with a 2D structure. 
WireID_t Wire
Index of the wire within its plane. 
art::InputTag fNewClustersTag
bool setWireDriftData(const std::vector< recob::Wire > &wires, unsigned int plane, unsigned int tpc, unsigned int cryo)
bool isViewSelected(int view) const 
std::unordered_map< unsigned int, tpc_view_keymap > cryo_tpc_view_keymap
fhicl::Atom< art::InputTag > HitModuleLabel
std::vector< int > fViews
fhicl::Atom< art::InputTag > WireLabel
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)                                                                                          
art::InputTag fHitModuleLabel
void push_back(Ptr< U > const &p)
anab::MVAWriter< 3 > fMVAWriter
fhicl::Atom< art::InputTag > ClusterModuleLabel
ValidHandle< PROD > getValidHandle(InputTag const &tag) const 
fhicl::Atom< size_t > BatchSize
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
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 
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
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)
ProductID put(std::unique_ptr< PROD > &&edp, FullSemantic< Level::Run > const semantic)
fhicl::Sequence< int > Views
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)
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)
h
training ###############################