LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
cluster::DBCluster3D Class Reference
Inheritance diagram for cluster::DBCluster3D:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Types

using ModuleType = EDProducer
 
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 

Public Member Functions

 DBCluster3D (fhicl::ParameterSet const &p)
 
 DBCluster3D (DBCluster3D const &)=delete
 
 DBCluster3D (DBCluster3D &&)=delete
 
DBCluster3Doperator= (DBCluster3D const &)=delete
 
DBCluster3Doperator= (DBCluster3D &&)=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)
 
void fillProductDescriptions ()
 
void registerProducts (ProductDescriptions &productsToRegister)
 
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)
 
std::unique_ptr< Worker > makeWorker (WorkerParams const &wp)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Protected Member Functions

ConsumesCollector & consumesCollector ()
 
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 ()
 

Private Types

using Point_t = recob::tracking::Point_t
 
using Vector_t = recob::tracking::Vector_t
 

Private Member Functions

void produce (art::Event &e) override
 

Private Attributes

const art::InputTag fHitModuleLabel
 
const art::InputTag fSpacePointModuleLabel
 
const art::InputTag fSPHitAssnLabel
 
DBScan3DAlg fDBScan
 
geo::GeometryCore const * fGeom
 
double tickToDist
 
double fMinHitDis
 

Detailed Description

Definition at line 33 of file DBCluster3D_module.cc.

Member Typedef Documentation

Definition at line 17 of file EDProducer.h.

template<typename UserConfig , typename KeysToIgnore = void>
using art::detail::Producer::Table = Modifier::Table<UserConfig, KeysToIgnore>
inherited

Definition at line 26 of file Producer.h.

Constructor & Destructor Documentation

cluster::DBCluster3D::DBCluster3D ( fhicl::ParameterSet const &  p)
explicit

Definition at line 65 of file DBCluster3D_module.cc.

References fDBScan, fGeom, fHitModuleLabel, fMinHitDis, fSpacePointModuleLabel, fSPHitAssnLabel, detinfo::sampling_rate(), and tickToDist.

66  : EDProducer{p}
67  , fHitModuleLabel(p.get<art::InputTag>("HitModuleLabel"))
68  , fSpacePointModuleLabel(p.get<art::InputTag>("SpacePointModuleLabel"))
69  , fSPHitAssnLabel(p.get<art::InputTag>("SPHitAssnLabel"))
70  , fDBScan(p.get<fhicl::ParameterSet>("DBScan3DAlg"))
71  , fMinHitDis(p.get<double>("MinHitDis"))
72 {
73  produces<std::vector<recob::Slice>>();
74  produces<art::Assns<recob::Slice, recob::Hit>>();
75  produces<art::Assns<recob::Slice, recob::SpacePoint>>();
76 
78  auto const clock_data = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataForJob();
79  auto const det_prop =
81 
82  tickToDist = det_prop.DriftVelocity(det_prop.Efield(), det_prop.Temperature());
83  tickToDist *= 1.e-3 * sampling_rate(clock_data); // 1e-3 is conversion of 1/us to 1/ns
85 }
geo::GeometryCore const * fGeom
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.cc:6
const art::InputTag fSpacePointModuleLabel
const art::InputTag fHitModuleLabel
const art::InputTag fSPHitAssnLabel
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
cluster::DBCluster3D::DBCluster3D ( DBCluster3D const &  )
delete
cluster::DBCluster3D::DBCluster3D ( DBCluster3D &&  )
delete

Member Function Documentation

template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::consumes ( InputTag const &  tag)
protectedinherited

Definition at line 61 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumes().

62  {
63  return collector_.consumes<T, BT>(tag);
64  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ProductToken< T > consumes(InputTag const &)
ConsumesCollector & art::ModuleBase::consumesCollector ( )
protectedinherited

Definition at line 57 of file ModuleBase.cc.

References art::ModuleBase::collector_.

58  {
59  return collector_;
60  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::consumesMany ( )
protectedinherited

Definition at line 75 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesMany().

76  {
77  collector_.consumesMany<T, BT>();
78  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::consumesView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::consumesView ( InputTag const &  tag)
inherited

Definition at line 68 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesView().

69  {
70  return collector_.consumesView<T, BT>(tag);
71  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > consumesView(InputTag const &)
void art::detail::Producer::doBeginJob ( SharedResources const &  resources)
inherited

Definition at line 22 of file Producer.cc.

References art::detail::Producer::beginJobWithFrame(), and art::detail::Producer::setupQueues().

23  {
24  setupQueues(resources);
25  ProcessingFrame const frame{ScheduleID{}};
26  beginJobWithFrame(frame);
27  }
virtual void setupQueues(SharedResources const &)=0
virtual void beginJobWithFrame(ProcessingFrame const &)=0
bool art::detail::Producer::doBeginRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 65 of file Producer.cc.

References art::detail::Producer::beginRunWithFrame(), art::RangeSet::forRun(), art::RunPrincipal::makeRun(), r, art::RunPrincipal::runID(), and art::ModuleContext::scheduleID().

66  {
67  auto r = rp.makeRun(mc, RangeSet::forRun(rp.runID()));
68  ProcessingFrame const frame{mc.scheduleID()};
69  beginRunWithFrame(r, frame);
70  r.commitProducts();
71  return true;
72  }
TRandom r
Definition: spectrum.C:23
virtual void beginRunWithFrame(Run &, ProcessingFrame const &)=0
static RangeSet forRun(RunID)
Definition: RangeSet.cc:51
bool art::detail::Producer::doBeginSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 85 of file Producer.cc.

References art::detail::Producer::beginSubRunWithFrame(), art::RangeSet::forSubRun(), art::SubRunPrincipal::makeSubRun(), art::ModuleContext::scheduleID(), and art::SubRunPrincipal::subRunID().

86  {
87  auto sr = srp.makeSubRun(mc, RangeSet::forSubRun(srp.subRunID()));
88  ProcessingFrame const frame{mc.scheduleID()};
89  beginSubRunWithFrame(sr, frame);
90  sr.commitProducts();
91  return true;
92  }
virtual void beginSubRunWithFrame(SubRun &, ProcessingFrame const &)=0
static RangeSet forSubRun(SubRunID)
Definition: RangeSet.cc:57
void art::detail::Producer::doEndJob ( )
inherited

Definition at line 30 of file Producer.cc.

References art::detail::Producer::endJobWithFrame().

31  {
32  ProcessingFrame const frame{ScheduleID{}};
33  endJobWithFrame(frame);
34  }
virtual void endJobWithFrame(ProcessingFrame const &)=0
bool art::detail::Producer::doEndRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 75 of file Producer.cc.

References art::detail::Producer::endRunWithFrame(), art::RunPrincipal::makeRun(), r, art::ModuleContext::scheduleID(), and art::Principal::seenRanges().

76  {
77  auto r = rp.makeRun(mc, rp.seenRanges());
78  ProcessingFrame const frame{mc.scheduleID()};
79  endRunWithFrame(r, frame);
80  r.commitProducts();
81  return true;
82  }
TRandom r
Definition: spectrum.C:23
virtual void endRunWithFrame(Run &, ProcessingFrame const &)=0
bool art::detail::Producer::doEndSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 95 of file Producer.cc.

References art::detail::Producer::endSubRunWithFrame(), art::SubRunPrincipal::makeSubRun(), art::ModuleContext::scheduleID(), and art::Principal::seenRanges().

96  {
97  auto sr = srp.makeSubRun(mc, srp.seenRanges());
98  ProcessingFrame const frame{mc.scheduleID()};
99  endSubRunWithFrame(sr, frame);
100  sr.commitProducts();
101  return true;
102  }
virtual void endSubRunWithFrame(SubRun &, ProcessingFrame const &)=0
bool art::detail::Producer::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 
)
inherited

Definition at line 105 of file Producer.cc.

References art::detail::Producer::checkPutProducts_, e, art::EventPrincipal::makeEvent(), art::detail::Producer::produceWithFrame(), and art::ModuleContext::scheduleID().

110  {
111  auto e = ep.makeEvent(mc);
112  ++counts_run;
113  ProcessingFrame const frame{mc.scheduleID()};
114  produceWithFrame(e, frame);
115  e.commitProducts(checkPutProducts_, &expectedProducts<InEvent>());
116  ++counts_passed;
117  return true;
118  }
bool const checkPutProducts_
Definition: Producer.h:70
Float_t e
Definition: plot.C:35
virtual void produceWithFrame(Event &, ProcessingFrame const &)=0
void art::detail::Producer::doRespondToCloseInputFile ( FileBlock const &  fb)
inherited

Definition at line 44 of file Producer.cc.

References art::detail::Producer::respondToCloseInputFileWithFrame().

45  {
46  ProcessingFrame const frame{ScheduleID{}};
48  }
virtual void respondToCloseInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Producer::doRespondToCloseOutputFiles ( FileBlock const &  fb)
inherited

Definition at line 58 of file Producer.cc.

References art::detail::Producer::respondToCloseOutputFilesWithFrame().

59  {
60  ProcessingFrame const frame{ScheduleID{}};
62  }
virtual void respondToCloseOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Producer::doRespondToOpenInputFile ( FileBlock const &  fb)
inherited

Definition at line 37 of file Producer.cc.

References art::detail::Producer::respondToOpenInputFileWithFrame().

38  {
39  ProcessingFrame const frame{ScheduleID{}};
41  }
virtual void respondToOpenInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Producer::doRespondToOpenOutputFiles ( FileBlock const &  fb)
inherited

Definition at line 51 of file Producer.cc.

References art::detail::Producer::respondToOpenOutputFilesWithFrame().

52  {
53  ProcessingFrame const frame{ScheduleID{}};
55  }
virtual void respondToOpenOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::Modifier::fillProductDescriptions ( )
inherited

Definition at line 10 of file Modifier.cc.

References art::ProductRegistryHelper::fillDescriptions(), and art::ModuleBase::moduleDescription().

11  {
13  }
void fillDescriptions(ModuleDescription const &md)
ModuleDescription const & moduleDescription() const
Definition: ModuleBase.cc:13
std::array< std::vector< ProductInfo >, NumBranchTypes > const & art::ModuleBase::getConsumables ( ) const
inherited

Definition at line 43 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::getConsumables().

44  {
45  return collector_.getConsumables();
46  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables() const
std::unique_ptr< Worker > art::ModuleBase::makeWorker ( WorkerParams const &  wp)
inherited

Definition at line 37 of file ModuleBase.cc.

References art::ModuleBase::doMakeWorker(), and art::NumBranchTypes.

38  {
39  return doMakeWorker(wp);
40  }
virtual std::unique_ptr< Worker > doMakeWorker(WorkerParams const &wp)=0
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::mayConsume ( InputTag const &  tag)
protectedinherited

Definition at line 82 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsume().

83  {
84  return collector_.mayConsume<T, BT>(tag);
85  }
ProductToken< T > mayConsume(InputTag const &)
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::mayConsumeMany ( )
protectedinherited

Definition at line 96 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeMany().

97  {
98  collector_.mayConsumeMany<T, BT>();
99  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::mayConsumeView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::mayConsumeView ( InputTag const &  tag)
inherited

Definition at line 89 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeView().

90  {
91  return collector_.mayConsumeView<T, BT>(tag);
92  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > mayConsumeView(InputTag const &)
ModuleDescription const & art::ModuleBase::moduleDescription ( ) const
inherited

Definition at line 13 of file ModuleBase.cc.

References art::errors::LogicError.

Referenced by art::OutputModule::doRespondToOpenInputFile(), art::OutputModule::doWriteEvent(), art::Modifier::fillProductDescriptions(), art::OutputModule::makePlugins_(), art::OutputWorker::OutputWorker(), reco::shower::LArPandoraModularShowerCreation::produce(), art::Modifier::registerProducts(), and art::OutputModule::registerProducts().

14  {
15  if (md_.has_value()) {
16  return *md_;
17  }
18 
20  "There was an error while calling moduleDescription().\n"}
21  << "The moduleDescription() base-class member function cannot be called\n"
22  "during module construction. To determine which module is "
23  "responsible\n"
24  "for calling it, find the '<module type>:<module "
25  "label>@Construction'\n"
26  "tag in the message prefix above. Please contact artists@fnal.gov\n"
27  "for guidance.\n";
28  }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
DBCluster3D& cluster::DBCluster3D::operator= ( DBCluster3D const &  )
delete
DBCluster3D& cluster::DBCluster3D::operator= ( DBCluster3D &&  )
delete
void cluster::DBCluster3D::produce ( art::Event e)
overrideprivatevirtual

Implements art::EDProducer.

Definition at line 87 of file DBCluster3D_module.cc.

References util::abs(), util::begin(), util::CreateAssn(), cluster::DBScan3DAlg::dbscan(), DEFINE_ART_MODULE, dir, util::end(), fDBScan, fGeom, fHitModuleLabel, art::fill_ptr_vector(), fMinHitDis, fSpacePointModuleLabel, fSPHitAssnLabel, art::ProductRetriever::getValidHandle(), hits(), cluster::DBScan3DAlg::init(), norm, cluster::DBScan3DAlg::points, art::Event::put(), sum, tickToDist, geo::GeometryCore::WirePitch(), xx, and zz.

88 {
89  auto scol = std::make_unique<std::vector<recob::Slice>>();
90  auto slc_hit_assn = std::make_unique<art::Assns<recob::Slice, recob::Hit>>();
91  auto slc_sps_assn = std::make_unique<art::Assns<recob::Slice, recob::SpacePoint>>();
92 
93  auto hitsHandle = evt.getValidHandle<std::vector<recob::Hit>>(fHitModuleLabel);
94  auto spsHandle = evt.getValidHandle<std::vector<recob::SpacePoint>>(fSpacePointModuleLabel);
95 
96  // all hits in the collection
97  std::vector<art::Ptr<recob::Hit>> hits;
98  art::fill_ptr_vector(hits, hitsHandle);
99 
100  // all space points in the collection
101  std::vector<art::Ptr<recob::SpacePoint>> sps;
102  art::fill_ptr_vector(sps, spsHandle);
103 
104  art::FindManyP<recob::SpacePoint> spFromHit(hitsHandle, evt, fSPHitAssnLabel);
105  if (!spFromHit.isValid()) {
106  std::cout << "spFromHit is invalid\n";
107  return;
108  }
109  // Find the first Hit - SpacePoint assn and check consistency on the first event
110  static bool first = true;
111  if (first) {
112  bool success = false;
113  bool foundsps = false;
114  for (auto& hit : hits) {
115  auto& sps = spFromHit.at(hit.key());
116  if (sps.empty()) continue;
117  success = (sps[0].id() == spsHandle.id());
118  foundsps = true;
119  break;
120  } // hit
121  if ((!success) && foundsps)
122  throw cet::exception("DBCluster3D")
123  << "HitModuleLabel, SpacePointModuleLabel and SPHitAssnLabel are inconsistent\n";
124  first = false;
125  } // first
126 
127  art::FindManyP<recob::Hit> hitFromSp(spsHandle, evt, fSPHitAssnLabel);
128  if (!hitFromSp.isValid()) {
129  std::cout << "hitFromSp is invalid\n";
130  return;
131  }
132  fDBScan.init(sps, hitFromSp);
133  fDBScan.dbscan();
134 
135  //Find number of slices
136  int maxid = INT_MIN;
137  for (size_t i = 0; i < fDBScan.points.size(); ++i) {
138  if (fDBScan.points[i].cluster_id > maxid) maxid = fDBScan.points[i].cluster_id;
139  }
140  size_t nslc = 0;
141  if (maxid >= 0) nslc = maxid + 1;
142 
143  //Save hits associated with each slice
144  std::vector<std::vector<art::Ptr<recob::Hit>>> slcHits(nslc);
145  //Save hits on each PlaneID with pfparticle index
146  std::map<geo::PlaneID, std::vector<std::pair<art::Ptr<recob::Hit>, unsigned int>>> hitmap;
147  for (auto& hit : hits) {
148  auto& sps = spFromHit.at(hit.key());
149  if (sps.size()) { //found associated space point
150  if (fDBScan.points[sps[0].key()].cluster_id >= 0) {
151  slcHits[fDBScan.points[sps[0].key()].cluster_id].push_back(hit);
152  hitmap[geo::PlaneID(hit->WireID())].push_back(
153  std::make_pair(hit, fDBScan.points[sps[0].key()].cluster_id));
154  }
155  } // sps.size()
156  } // hit
157 
158  //Save hits not associated with any spacepoints
159  for (auto& hit : hits) {
160  bool found = false;
161  for (size_t i = 0; i < slcHits.size(); ++i) {
162  if (std::find(slcHits[i].begin(), slcHits[i].end(), hit) != slcHits[i].end()) {
163  found = true;
164  break;
165  }
166  }
167  if (!found) {
168  double wirePitch = fGeom->WirePitch(hit->WireID());
169  double UnitsPerTick = tickToDist / wirePitch;
170  double x0 = hit->WireID().Wire;
171  double y0 = hit->PeakTime() * UnitsPerTick;
172  double mindis = DBL_MAX;
173  unsigned slcIndex = UINT_MAX;
174  for (auto& hit2 : hitmap[geo::PlaneID(hit->WireID())]) {
175  double dx = hit2.first->WireID().Wire - x0;
176  double dy = hit2.first->PeakTime() * UnitsPerTick - y0;
177  double dis = dx * dx + dy * dy;
178  if (dis < mindis) {
179  mindis = dis;
180  slcIndex = hit2.second;
181  }
182  }
183  if (slcIndex != UINT_MAX && mindis < fMinHitDis) { slcHits[slcIndex].push_back(hit); }
184  }
185  }
186 
187  //Save spacepoints for each slice
188  std::vector<std::vector<art::Ptr<recob::SpacePoint>>> sps_in_slc(nslc);
189  for (size_t i = 0; i < fDBScan.points.size(); ++i) {
190  if (fDBScan.points[i].cluster_id >= 0) {
191  sps_in_slc[fDBScan.points[i].cluster_id].push_back(sps[i]);
192  }
193  } // i
194 
195  // calculate the properties of the slice
196  for (size_t isl = 0; isl < nslc; ++isl) {
197  double sum = sps_in_slc[isl].size();
198  // find the center
199  double center[3] = {0.};
200  // TODO: calculate the charge using recob::PointCharge instead of just counting hits
201  float charge = slcHits[isl].size();
202  for (auto& spt : sps_in_slc[isl]) {
203  for (unsigned short xyz = 0; xyz < 3; ++xyz)
204  center[xyz] += spt->XYZ()[xyz];
205  } // spt
206  for (unsigned short xyz = 0; xyz < 3; ++xyz)
207  center[xyz] /= sum;
208  // do a linear fit
209  double sumx = 0, sumy = 0., sumz = 0., sumx2 = 0, sumy2 = 0, sumz2 = 0;
210  double sumxy = 0, sumxz = 0;
211  for (auto& spt : sps_in_slc[isl]) {
212  double xx = spt->XYZ()[0] - center[0];
213  double yy = spt->XYZ()[1] - center[1];
214  double zz = spt->XYZ()[2] - center[2];
215  sumx += xx;
216  sumy += yy;
217  sumz += zz;
218  sumx2 += xx * xx;
219  sumy2 += yy * yy;
220  sumz2 += zz * zz;
221  sumxy += xx * yy;
222  sumxz += xx * zz;
223  } // spt
224  double delta = sum * sumx2 - sumx * sumx;
225  if (delta <= 0) continue;
226  // calculate the slopes
227  double dydx = (sumxy * sum - sumx * sumy) / delta;
228  double dzdx = (sumxz * sum - sumx * sumz) / delta;
229  // and convert to direction vector
230  double direction[3];
231  double norm = std::sqrt(1 + dydx * dydx + dzdx * dzdx);
232  direction[0] = 1 / norm;
233  direction[1] = dydx / norm;
234  direction[2] = dzdx / norm;
235  // Find the points that are farthest away from the center along the slice axis
236  unsigned int imax = 0, imin = 0;
237  float minAlong = 1E6, maxAlong = -1E6;
238  double tmpVec[3];
239  for (unsigned int ipt = 0; ipt < sps_in_slc[isl].size(); ++ipt) {
240  auto& spt = sps_in_slc[isl][ipt];
241  for (unsigned short xyz = 0; xyz < 3; ++xyz)
242  tmpVec[xyz] = spt->XYZ()[xyz] - center[xyz];
243  double dotp = 0;
244  for (unsigned short xyz = 0; xyz < 3; ++xyz)
245  dotp += tmpVec[xyz] * direction[xyz];
246  if (dotp < minAlong) {
247  minAlong = dotp;
248  imin = ipt;
249  }
250  if (dotp > maxAlong) {
251  maxAlong = dotp;
252  imax = ipt;
253  }
254  } // spt
255  // Find the aspect ratio
256  float cnt = 0.;
257  float aspectRatio = 0;
258  double arg = sum * sumy2 - sumy * sumy;
259  if (arg > 0) {
260  aspectRatio += std::abs(sum * sumxy - sumx * sumy) / sqrt(delta * arg);
261  ++cnt;
262  }
263  arg = sum * sumz2 - sumz * sumz;
264  if (arg > 0) {
265  aspectRatio += std::abs(sum * sumxz - sumx * sumz) / sqrt(delta * arg);
266  ++cnt;
267  }
268  if (cnt > 1) aspectRatio /= cnt;
269  int id = isl + 1;
270  Point_t ctr(center[0], center[1], center[2]);
271  Vector_t dir(direction[0], direction[1], direction[2]);
272  auto pos0 = sps_in_slc[isl][imin]->XYZ();
273  Point_t ep0(pos0[0], pos0[1], pos0[2]);
274  auto pos1 = sps_in_slc[isl][imax]->XYZ();
275  Point_t ep1(pos1[0], pos1[1], pos1[2]);
276  scol->emplace_back(id, ctr, dir, ep0, ep1, aspectRatio, charge);
277  util::CreateAssn(evt, *scol, slcHits[isl], *slc_hit_assn);
278  util::CreateAssn(evt, *scol, sps_in_slc[isl], *slc_sps_assn);
279  } // isl
280 
281  evt.put(std::move(scol));
282  evt.put(std::move(slc_hit_assn));
283  evt.put(std::move(slc_sps_assn));
284 }
geo::GeometryCore const * fGeom
Double_t xx
Definition: macro.C:12
The data type to uniquely identify a Plane.
Definition: geo_types.h:463
constexpr auto abs(T v)
Returns the absolute value of the argument.
Double_t zz
Definition: plot.C:276
const art::InputTag fSpacePointModuleLabel
const art::InputTag fHitModuleLabel
const art::InputTag fSPHitAssnLabel
recob::tracking::Point_t Point_t
IDparameter< geo::PlaneID > PlaneID
Member type of validated geo::PlaneID parameter.
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
void hits()
Definition: readHits.C:15
void init(const std::vector< art::Ptr< recob::SpacePoint >> &sps, art::FindManyP< recob::Hit > &hitFromSp)
Definition: DBScan3DAlg.cxx:29
Detector simulation of raw signals on wires.
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_t norm
TDirectory * dir
Definition: macro.C:5
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:69
std::vector< point_t > points
Definition: DBScan3DAlg.h:82
TCEvent evt
Definition: DataStructs.cxx:8
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:306
Double_t sum
Definition: plot.C:31
recob::tracking::Vector_t Vector_t
Length_t WirePitch(PlaneID const &planeid=plane_zero) const
Returns the distance between two consecutive wires.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void art::Modifier::registerProducts ( ProductDescriptions productsToRegister)
inherited

Definition at line 16 of file Modifier.cc.

References art::ModuleBase::moduleDescription(), and art::ProductRegistryHelper::registerProducts().

17  {
18  ProductRegistryHelper::registerProducts(productsToRegister,
20  }
void registerProducts(ProductDescriptions &productsToRegister, ModuleDescription const &md)
ModuleDescription const & moduleDescription() const
Definition: ModuleBase.cc:13
void art::ModuleBase::setModuleDescription ( ModuleDescription const &  md)
inherited

Definition at line 31 of file ModuleBase.cc.

References art::ModuleBase::md_.

32  {
33  md_ = md;
34  }
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
void art::ModuleBase::sortConsumables ( std::string const &  current_process_name)
inherited

Definition at line 49 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::sortConsumables().

50  {
51  // Now that we know we have seen all the consumes declarations,
52  // sort the results for fast lookup later.
53  collector_.sortConsumables(current_process_name);
54  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
void sortConsumables(std::string const &current_process_name)

Member Data Documentation

DBScan3DAlg cluster::DBCluster3D::fDBScan
private

Definition at line 57 of file DBCluster3D_module.cc.

Referenced by DBCluster3D(), and produce().

geo::GeometryCore const* cluster::DBCluster3D::fGeom
private

Definition at line 59 of file DBCluster3D_module.cc.

Referenced by DBCluster3D(), and produce().

const art::InputTag cluster::DBCluster3D::fHitModuleLabel
private

Definition at line 53 of file DBCluster3D_module.cc.

Referenced by DBCluster3D(), and produce().

double cluster::DBCluster3D::fMinHitDis
private

Definition at line 62 of file DBCluster3D_module.cc.

Referenced by DBCluster3D(), and produce().

const art::InputTag cluster::DBCluster3D::fSpacePointModuleLabel
private

Definition at line 54 of file DBCluster3D_module.cc.

Referenced by DBCluster3D(), and produce().

const art::InputTag cluster::DBCluster3D::fSPHitAssnLabel
private

Definition at line 55 of file DBCluster3D_module.cc.

Referenced by DBCluster3D(), and produce().

double cluster::DBCluster3D::tickToDist
private

Definition at line 61 of file DBCluster3D_module.cc.

Referenced by DBCluster3D(), and produce().


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