Public Member Functions | Private Member Functions | Private Attributes | List of all members
cluster::LineMerger Class Reference
Inheritance diagram for cluster::LineMerger:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Member Functions

 LineMerger (fhicl::ParameterSet const &pset)
 
- Public Member Functions inherited from art::EDProducer
 EDProducer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDProducer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Producer
virtual ~Producer () noexcept
 
 Producer (fhicl::ParameterSet const &)
 
 Producer (Producer const &)=delete
 
 Producer (Producer &&)=delete
 
Produceroperator= (Producer const &)=delete
 
Produceroperator= (Producer &&)=delete
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Modifier
 ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Member Functions

void produce (art::Event &evt) override
 
bool SlopeCompatibility (double slope1, double slope2)
 
int EndpointCompatibility (float sclstartwire, float sclstarttime, float sclendwire, float sclendtime, float cl2startwire, float cl2starttime, float cl2endwire, float cl2endtime)
 

Private Attributes

std::string fClusterModuleLabel
 
double fSlope
 
double fEndpointWindow
 

Additional Inherited Members

- Public Types inherited from art::EDProducer
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
- Public Types inherited from art::detail::Producer
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 
- Static Public Member Functions inherited from art::EDProducer
static void commitEvent (EventPrincipal &ep, Event &e)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Definition at line 47 of file LineMerger_module.cc.

Constructor & Destructor Documentation

cluster::LineMerger::LineMerger ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 467 of file LineMerger_module.cc.

468  : EDProducer{pset}
469  , fClusterModuleLabel(pset.get<std::string>("ClusterModuleLabel"))
470  , fSlope(pset.get<double>("Slope"))
471  , fEndpointWindow(pset.get<double>("EndpointWindow"))
472  {
473  produces<std::vector<recob::Cluster>>();
474  produces<art::Assns<recob::Cluster, recob::Hit>>();
475  }
std::string string
Definition: nybbler.cc:12
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
std::string fClusterModuleLabel

Member Function Documentation

int cluster::LineMerger::EndpointCompatibility ( float  sclstartwire,
float  sclstarttime,
float  sclendwire,
float  sclendtime,
float  cl2startwire,
float  cl2starttime,
float  cl2endwire,
float  cl2endtime 
)
private
Todo:
13.5 ticks/wire. need to make this detector agnostic–spitz

Definition at line 650 of file LineMerger_module.cc.

658  {
659 
660  /// \todo 13.5 ticks/wire. need to make this detector agnostic--spitz
661  float distance =
662  std::sqrt((pow(sclendwire - cl2startwire, 2) * 13.5) + pow(sclendtime - cl2starttime, 2));
663 
664  //not sure if this line is necessary--spitz
665  float distance2 =
666  std::sqrt((pow(sclstartwire - cl2endwire, 2) * 13.5) + pow(sclstarttime - cl2endtime, 2));
667 
668  //determine which way the two clusters should be merged. TY
669  int comp = 0;
670  if (distance < fEndpointWindow)
671  comp = 1;
672  else if (distance2 < fEndpointWindow)
673  comp = -1;
674  return comp;
675  }
constexpr T pow(T x)
Definition: pow.h:72
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
double distance2(double x, double y, double z, double *p)
void cluster::LineMerger::produce ( art::Event evt)
overrideprivatevirtual

Implements art::EDProducer.

Definition at line 479 of file LineMerger_module.cc.

480  {
481  // Get a Handle for the input Cluster object(s).
482  art::Handle<std::vector<recob::Cluster>> clusterVecHandle;
483  evt.getByLabel(fClusterModuleLabel, clusterVecHandle);
484 
485  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
486  auto const detProp =
488  util::GeometryUtilities const gser{*lar::providerFrom<geo::Geometry>(), clockData, detProp};
489 
490  constexpr size_t nViews = 3; // number of views we map
491 
492  //one vector for each view in the geometry (holds the index of the cluster)
493  std::array<std::vector<size_t>, nViews> ClsIndices;
494 
495  //vector with indicators for whether a cluster has been merged already
496  std::array<std::vector<int>, nViews> Cls_matches;
497 
498  // loop over the input Clusters
499  for (size_t i = 0; i < clusterVecHandle->size(); ++i) {
500 
501  //get a art::Ptr to each Cluster
502  art::Ptr<recob::Cluster> cl(clusterVecHandle, i);
503 
504  size_t view = 0;
505  switch (cl->View()) {
506  case geo::kU: view = 0; break;
507  case geo::kV: view = 1; break;
508  case geo::kZ: view = 2; break;
509  default: continue; // ignore this cluster and process the next one
510  } // end switch on view
511 
512  Cls_matches[view].push_back(0);
513  ClsIndices[view].push_back(i);
514  } // end loop over input clusters
515 
516  auto SuperClusters = std::make_unique<std::vector<recob::Cluster>>();
517  auto assn = std::make_unique<art::Assns<recob::Cluster, recob::Hit>>();
518 
519  // prepare the algorithm to compute the cluster characteristics;
520  // we use the "standard" one here; configuration would happen here,
521  // but we are using the default configuration for that algorithm
522  ClusterParamsImportWrapper<StandardClusterParamsAlg> ClusterParamAlgo;
523 
524  art::FindManyP<recob::Hit> fmh(clusterVecHandle, evt, fClusterModuleLabel);
525 
526  for (size_t i = 0; i < nViews; ++i) {
527 
528  int clustersfound = 0; // how many merged clusters found in each plane
529  int clsnum1 = 0;
530 
531  for (size_t c = 0; c < ClsIndices[i].size(); ++c) {
532  if (Cls_matches[i][clsnum1] == 1) {
533  ++clsnum1;
534  continue;
535  }
536 
537  // make a new cluster to put into the SuperClusters collection
538  // because we want to be able to adjust it later;
539  // use the hits associated with the current cluster
540  recob::Cluster const& StartingCluster = clusterVecHandle->at(ClsIndices[i][c]);
541  ClusterAndHitMerger cl1(StartingCluster, fmh.at(ClsIndices[i][c]));
542  const recob::Cluster::ID_t clusterID = StartingCluster.ID();
543 
544  Cls_matches[i][clsnum1] = 1;
545  ++clustersfound;
546 
547  int clsnum2 = 0;
548  for (size_t c2 = 0; c2 < ClsIndices[i].size(); ++c2) {
549 
550  if (Cls_matches[i][clsnum2] == 1) {
551  ++clsnum2;
552  continue;
553  }
554 
555  const recob::Cluster& cl2(clusterVecHandle->at(ClsIndices[i][c2]));
556 
557  // check that the slopes are the same
558  // added 13.5 ticks/wirelength in ArgoNeuT.
559  // \todo need to make this detector agnostic
560  // would be nice to have a LArProperties function that returns ticks/wire.
561  bool sameSlope = SlopeCompatibility(cl1.StartAngle(), cl2.EndAngle()) ||
562  SlopeCompatibility(cl1.EndAngle(), cl2.StartAngle());
563 
564  // check that the endpoints fall within a circular window of each other
565  // done in place of intercept matching
566  int sameEndpoint = EndpointCompatibility(cl1.StartWire(),
567  cl1.StartTick(),
568  cl1.EndWire(),
569  cl1.EndTick(),
570  cl2.StartWire(),
571  cl2.StartTick(),
572  cl2.EndWire(),
573  cl2.EndTick());
574 
575  // if the slopes and end points are the same, combine the clusters
576  // note that after 1 combination cl1 is no longer what we started
577  // with
578  if (sameSlope && (sameEndpoint != 0)) {
579  // combine the hit collections too
580  // (find the hits associated with this second cluster);
581  // take into account order when merging hits from two clusters: doc-1776
582  // if sameEndpoint is 1, the new hits come first
583  cl1.Add(cl2, fmh.at(ClsIndices[i][c2]), sameEndpoint == 1);
584  Cls_matches[i][clsnum2] = 1;
585  }
586 
587  ++clsnum2;
588  } // end loop over second cluster iterator
589 
590  // now add the final version of cl1 to the collection of SuperClusters
591  // and create the association between the super cluster and the hits
592  ClusterParamAlgo.ImportHits(gser, cl1.Hits());
593 
594  // create the recob::Cluster directly in the vector
595  SuperClusters->emplace_back(cl1.StartWire(), // start_wire
596  cl1.SigmaStartWire(), // sigma_start_wire
597  cl1.StartTick(), // start_tick
598  cl1.SigmaStartTick(), // sigma_start_tick
599  cl1.StartCharge(), // start_charge
600  cl1.StartAngle(), // start_angle
601  cl1.StartOpeningAngle(), // start_opening
602  cl1.EndWire(), // end_wire
603  cl1.SigmaEndWire(), // sigma_end_wire
604  cl1.EndTick(), // end_time
605  cl1.SigmaEndTick(), // sigma_end_tick
606  cl1.EndCharge(), // end_charge
607  cl1.EndAngle(), // end_angle
608  cl1.EndOpeningAngle(), // end_opening
609  ClusterParamAlgo.Integral().value(), // integral
610  ClusterParamAlgo.IntegralStdDev().value(), // integral_stddev
611  ClusterParamAlgo.SummedADC().value(), // summedADC
612  ClusterParamAlgo.SummedADCStdDev().value(), // summedADC_stddev
613  ClusterParamAlgo.NHits(), // n_hits
614  ClusterParamAlgo.MultipleHitDensity(), // multiple_hit_density
615  cl1.Width(), // width
616  clusterID, // ID
617  cl1.View(), // view
618  cl1.Plane(), // planeID
619  recob::Cluster::Sentry // sentry
620  );
621 
622  util::CreateAssn(evt, *SuperClusters, cl1.Hits(), *assn);
623  ++clsnum1;
624 
625  } // end loop over first cluster iterator
626  } // end loop over planes
627 
628  mf::LogVerbatim("Summary") << std::setfill('-') << std::setw(175) << "-" << std::setfill(' ');
629  mf::LogVerbatim("Summary") << "LineMerger Summary:";
630  for (size_t i = 0; i < SuperClusters->size(); ++i)
631  mf::LogVerbatim("Summary") << SuperClusters->at(i);
632 
633  evt.put(std::move(SuperClusters));
634  evt.put(std::move(assn));
635  }
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
int EndpointCompatibility(float sclstartwire, float sclstarttime, float sclendwire, float sclendtime, float cl2startwire, float cl2starttime, float cl2endwire, float cl2endtime)
Planes which measure V.
Definition: geo_types.h:130
Planes which measure Z direction.
Definition: geo_types.h:132
Set of hits with a 2D structure.
Definition: Cluster.h:71
QAsciiDict< Entry > cl
static const SentryArgument_t Sentry
An instance of the sentry object.
Definition: Cluster.h:182
Planes which measure U.
Definition: geo_types.h:129
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
std::string fClusterModuleLabel
def move(depos, offset)
Definition: depos.py:107
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
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.
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
ID_t ID() const
Identifier of this cluster.
Definition: Cluster.h:738
bool SlopeCompatibility(double slope1, double slope2)
Q_EXPORT QTSManip setfill(int f)
Definition: qtextstream.h:337
int ID_t
Type of cluster ID.
Definition: Cluster.h:74
bool cluster::LineMerger::SlopeCompatibility ( double  slope1,
double  slope2 
)
private

Definition at line 640 of file LineMerger_module.cc.

641  {
642  double sl1 = atan(slope1);
643  double sl2 = atan(slope2);
644 
645  //the units of fSlope are radians
646  return std::abs(sl1 - sl2) < fSlope;
647  }
T abs(T value)

Member Data Documentation

std::string cluster::LineMerger::fClusterModuleLabel
private

Definition at line 54 of file LineMerger_module.cc.

double cluster::LineMerger::fEndpointWindow
private

Definition at line 56 of file LineMerger_module.cc.

double cluster::LineMerger::fSlope
private

Definition at line 55 of file LineMerger_module.cc.


The documentation for this class was generated from the following file: