LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
vertex::VertexFinder2D Class Reference
Inheritance diagram for vertex::VertexFinder2D:
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

 VertexFinder2D (fhicl::ParameterSet const &pset)
 
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 Member Functions

void beginJob () override
 
void produce (art::Event &evt) override
 

Private Attributes

TH1D * dtIC
 
std::string fClusterModuleLabel
 

Detailed Description

Definition at line 71 of file VertexFinder2D_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

vertex::VertexFinder2D::VertexFinder2D ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 89 of file VertexFinder2D_module.cc.

References fClusterModuleLabel.

89  : EDProducer{pset}
90  {
91  fClusterModuleLabel = pset.get<std::string>("ClusterModuleLabel");
92  produces<std::vector<recob::Vertex>>();
93  produces<std::vector<recob::EndPoint2D>>();
94  produces<art::Assns<recob::EndPoint2D, recob::Hit>>();
95  produces<art::Assns<recob::Vertex, recob::Hit>>();
96  produces<art::Assns<recob::Vertex, recob::Shower>>();
97  produces<art::Assns<recob::Vertex, recob::Track>>();
98  }
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.cc:6

Member Function Documentation

void vertex::VertexFinder2D::beginJob ( )
overrideprivatevirtual

Reimplemented from art::EDProducer.

Definition at line 101 of file VertexFinder2D_module.cc.

References dtIC.

102  {
103  // get access to the TFile service
105  dtIC = tfs->make<TH1D>("dtIC", "It0-Ct0", 100, -5, 5);
106  dtIC->Sumw2();
107  }
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
void vertex::VertexFinder2D::produce ( art::Event evt)
overrideprivatevirtual
Todo:
should really get the actual vector of hits corresponding to end point
Todo:
for now will get all hits from the current cluster
Todo:
need to actually make tracks and showers to go into 3D vertex
Todo:
currently just passing empty collections to the ctor

Implements art::EDProducer.

Definition at line 110 of file VertexFinder2D_module.cc.

References util::abs(), util::begin(), c1, c2, util::CreateAssn(), DEFINE_ART_MODULE, dtIC, util::end(), fClusterModuleLabel, Get, art::ProductRetriever::getByLabel(), geo::TPCGeo::HalfHeight(), hits(), geo::kU, geo::kV, geo::kZ, MF_LOG_VERBATIM, n, art::PtrVector< T >::push_back(), art::Event::put(), detinfo::sampling_rate(), art::PtrVector< T >::size(), util::size(), SortByWire(), t1, t2, geo::GeometryCore::TPC(), and detinfo::trigger_offset().

111  {
113  auto const& wireReadoutGeom = art::ServiceHandle<geo::WireReadout>()->Get();
114  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
115  auto const detProp =
117 
118  auto const& tpc = geom->TPC({0, 0});
119  double YC = tpc.HalfHeight() * 2.;
120 
121  // wire angle with respect to the vertical direction
122  double Angle = wireReadoutGeom.Plane({tpc.ID(), 1}).Wire(0).ThetaZ(false) - TMath::Pi() / 2.;
123 
124  // Parameters temporary defined here, but possibly to be retrieved somewhere
125  // in the code
126  double timetick = sampling_rate(clockData) * 1.e-3; // time sample in us
127  double presamplings = trigger_offset(clockData);
128 
129  double wire_pitch = wireReadoutGeom.Plane({0, 0, 0}).WirePitch(); //wire pitch in cm
130  double Efield_drift = detProp.Efield(); // Electric Field in the drift region in kV/cm
131  double Temperature = detProp.Temperature(); // LAr Temperature in K
132 
133  //drift velocity in the drift region (cm/us)
134  double driftvelocity = detProp.DriftVelocity(Efield_drift, Temperature);
135 
136  //time sample (cm)
137  double timepitch = driftvelocity * timetick;
138 
139  art::Handle<std::vector<recob::Cluster>> clusterListHandle;
140  evt.getByLabel(fClusterModuleLabel, clusterListHandle);
141 
143  for (unsigned int ii = 0; ii < clusterListHandle->size(); ++ii) {
144  art::Ptr<recob::Cluster> clusterHolder(clusterListHandle, ii);
145  clusters.push_back(clusterHolder);
146  }
147 
148  art::FindManyP<recob::Hit> fmh(clusterListHandle, evt, fClusterModuleLabel);
149 
150  //Point to a collection of vertices to output.
151  std::unique_ptr<std::vector<recob::Vertex>> vcol(new std::vector<recob::Vertex>); //3D vertex
152  std::unique_ptr<std::vector<recob::EndPoint2D>> epcol(
153  new std::vector<recob::EndPoint2D>); //2D vertex
154  std::unique_ptr<art::Assns<recob::EndPoint2D, recob::Hit>> assnep(
156  std::unique_ptr<art::Assns<recob::Vertex, recob::Shower>> assnsh(
158  std::unique_ptr<art::Assns<recob::Vertex, recob::Track>> assntr(
160  std::unique_ptr<art::Assns<recob::Vertex, recob::Hit>> assnh(
162 
163  // nplanes here is really being used as a proxy for the number of views in the
164  // detector
165  int nplanes = wireReadoutGeom.Views().size();
166 
167  std::vector<std::vector<int>> Cls(nplanes); //index to clusters in each view
168  std::vector<std::vector<CluLen>> clulens(nplanes);
169 
170  std::vector<double> dtdwstart;
171 
172  //loop over clusters
173  for (size_t iclu = 0; iclu < clusters.size(); ++iclu) {
174 
175  float w0 = clusters[iclu]->StartWire();
176  float w1 = clusters[iclu]->EndWire();
177  float t0 = clusters[iclu]->StartTick();
178  float t1 = clusters[iclu]->EndTick();
179 
180  CluLen clulen;
181  clulen.index = iclu;
182  clulen.length = std::hypot((w0 - w1) * wire_pitch,
183  detProp.ConvertTicksToX(t0, clusters[iclu]->View(), 0, 0) -
184  detProp.ConvertTicksToX(t1, clusters[iclu]->View(), 0, 0));
185 
186  switch (clusters[iclu]->View()) {
187 
188  case geo::kU: clulens[0].push_back(clulen); break;
189  case geo::kV: clulens[1].push_back(clulen); break;
190  case geo::kZ: clulens[2].push_back(clulen); break;
191  default: break;
192  }
193 
194  std::vector<double> wires;
195  std::vector<double> times;
196 
197  std::vector<art::Ptr<recob::Hit>> hit = fmh.at(iclu);
198  std::sort(hit.begin(), hit.end(), SortByWire());
199  int n = 0;
200  for (size_t i = 0; i < hit.size(); ++i) {
201  wires.push_back(hit[i]->WireID().Wire);
202  times.push_back(hit[i]->PeakTime());
203  ++n;
204  }
205  if (n >= 2) {
206  TGraph* the2Dtrack = new TGraph(std::min(10, n), &wires[0], &times[0]);
207  try {
208  the2Dtrack->Fit("pol1", "Q");
209  TF1* pol1 = (TF1*)the2Dtrack->GetFunction("pol1");
210  double par[2];
211  pol1->GetParameters(par);
212  dtdwstart.push_back(par[1]);
213  }
214  catch (...) {
215  mf::LogWarning("VertexFinder2D") << "Fitter failed";
216  delete the2Dtrack;
217  dtdwstart.push_back(std::tan(clusters[iclu]->StartAngle()));
218  continue;
219  }
220  delete the2Dtrack;
221  }
222  else
223  dtdwstart.push_back(std::tan(clusters[iclu]->StartAngle()));
224  }
225 
226  //sort clusters based on 2D length
227  for (size_t i = 0; i < clulens.size(); ++i) {
228  std::sort(clulens[i].begin(), clulens[i].end(), myfunction);
229  for (size_t j = 0; j < clulens[i].size(); ++j) {
230  Cls[i].push_back(clulens[i][j].index);
231  }
232  }
233 
234  std::vector<std::vector<int>> cluvtx(nplanes);
235  std::vector<double> vtx_w;
236  std::vector<double> vtx_t;
237 
238  for (int i = 0; i < nplanes; ++i) {
239  if (Cls[i].size() >= 1) {
240  //at least one cluster
241  //find the longest two clusters
242  int c1 = -1;
243  int c2 = -1;
244  double ww0 = -999;
245  double wb1 = -999;
246  double we1 = -999;
247  double wb2 = -999;
248  double we2 = -999;
249  double tt1 = -999;
250  double tt2 = -999;
251  double dtdw1 = -999;
252  double dtdw2 = -999;
253  double lclu1 = -999;
254  double lclu2 = -999;
255  for (unsigned j = 0; j < Cls[i].size(); ++j) {
256  double lclu = std::sqrt(
257  pow((clusters[Cls[i][j]]->StartWire() - clusters[Cls[i][j]]->EndWire()) * 13.5, 2) +
258  pow(clusters[Cls[i][j]]->StartTick() - clusters[Cls[i][j]]->EndTick(), 2));
259  bool rev = false;
260  bool deltaraylike = false;
261  bool enoughhits = false;
262  if (c1 != -1) {
263  double wb = clusters[Cls[i][j]]->StartWire();
264  double we = clusters[Cls[i][j]]->EndWire();
265  double tt = clusters[Cls[i][j]]->StartTick();
266  double dtdw = dtdwstart[Cls[i][j]];
267  int nhits = fmh.at(Cls[i][j]).size();
268  ww0 = (tt - tt1 + dtdw1 * wb1 - dtdw * wb) / (dtdw1 - dtdw);
269  if (std::abs(wb1 - ww0) > std::abs(we1 - ww0)) rev = true; //reverse cluster dir
270  if ((!rev && ww0 > wb1 + 15) || (rev && ww0 < we1 - 15)) deltaraylike = true;
271  if (((!rev && ww0 > wb1 + 10) || (rev && ww0 < we1 - 10)) && nhits < 5)
272  deltaraylike = true;
273  if (wb > wb1 + 20 && nhits < 20) deltaraylike = true;
274  if (wb > wb1 + 50 && nhits < 20) deltaraylike = true;
275  if (wb > wb1 + 8 && TMath::Abs(dtdw1 - dtdw) < 0.15) deltaraylike = true;
276  if (std::abs(wb - wb1) > 30 && std::abs(we - we1) > 30) deltaraylike = true;
277  if (std::abs(tt - tt1) > 100)
278  deltaraylike = true; //not really deltaray, but isolated cluster
279  //make sure there are enough hits in the cluster
280  //at leaset 2 hits if goes horizentally, at leaset 4 hits if goes vertically
281  double alpha = std::atan(dtdw);
282  if (nhits >= int(2 + 3 * (1 - std::abs(std::cos(alpha))))) enoughhits = true;
283  if (nhits < 5 && (ww0 < wb1 - 20 || ww0 > we1 + 20)) enoughhits = false;
284  }
285  //do not replace the second cluster if the 3rd cluster is not consistent with the existing 2
286  bool replace = true;
287  if (c1 != -1 && c2 != -1) {
288  double wb = clusters[Cls[i][j]]->StartWire();
289  double we = clusters[Cls[i][j]]->EndWire();
290  ww0 = (tt2 - tt1 + dtdw1 * wb1 - dtdw2 * wb2) / (dtdw1 - dtdw2);
291  if ((std::abs(ww0 - wb1) < 10 || std::abs(ww0 - we1) < 10) &&
292  (std::abs(ww0 - wb2) < 10 || std::abs(ww0 - we2) < 10)) {
293  if (std::abs(ww0 - wb) > 15 && std::abs(ww0 - we) > 15) replace = false;
294  }
295  }
296  if (lclu1 < lclu) {
297  if (c1 != -1 && !deltaraylike && enoughhits) {
298  lclu2 = lclu1;
299  c2 = c1;
300  wb2 = wb1;
301  we2 = we1;
302  tt2 = tt1;
303  dtdw2 = dtdw1;
304  }
305  lclu1 = lclu;
306  c1 = Cls[i][j];
307  wb1 = clusters[Cls[i][j]]->StartWire();
308  we1 = clusters[Cls[i][j]]->EndWire();
309  tt1 = clusters[Cls[i][j]]->StartTick();
310  if (wb1 > we1) {
311  wb1 = clusters[Cls[i][j]]->EndWire();
312  we1 = clusters[Cls[i][j]]->StartWire();
313  tt1 = clusters[Cls[i][j]]->EndTick();
314  }
315  dtdw1 = dtdwstart[Cls[i][j]];
316  }
317  else if (lclu2 < lclu) {
318  if (!deltaraylike && enoughhits && replace) {
319  lclu2 = lclu;
320  c2 = Cls[i][j];
321  wb2 = clusters[Cls[i][j]]->StartWire();
322  we2 = clusters[Cls[i][j]]->EndWire();
323  tt2 = clusters[Cls[i][j]]->StartTick();
324  dtdw2 = dtdwstart[Cls[i][j]];
325  }
326  }
327  }
328  if (c1 != -1 && c2 != -1) {
329  cluvtx[i].push_back(c1);
330  cluvtx[i].push_back(c2);
331 
332  double w1 = clusters[c1]->StartWire();
333  double t1 = clusters[c1]->StartTick();
334  if (clusters[c1]->StartWire() > clusters[c1]->EndWire()) {
335  w1 = clusters[c1]->EndWire();
336  t1 = clusters[c1]->EndTick();
337  }
338  double k1 = dtdwstart[c1];
339  double w2 = clusters[c2]->StartWire();
340  double t2 = clusters[c2]->StartTick();
341  if (clusters[c2]->StartWire() > clusters[c2]->EndWire()) {
342  w1 = clusters[c2]->EndWire();
343  t1 = clusters[c2]->EndTick();
344  }
345  double k2 = dtdwstart[c2];
346  // calculate the vertex
347  if (std::abs(k1 - k2) < 0.5) {
348  vtx_w.push_back(w1);
349  vtx_t.push_back(t1);
350  }
351  else {
352  double t0 = (k1 * k2 * (w1 - w2) + k1 * t2 - k2 * t1) / (k1 - k2);
353  double w0 = (t2 - t1 + k1 * w1 - k2 * w2) / (k1 - k2);
354  vtx_w.push_back(w0);
355  vtx_t.push_back(t0);
356  }
357  }
358  else if (Cls[i].size() >= 1) {
359  if (c1 != -1) {
360  cluvtx[i].push_back(c1);
361  vtx_w.push_back(wb1);
362  vtx_t.push_back(tt1);
363  }
364  else {
365  cluvtx[i].push_back(Cls[i][0]);
366  vtx_w.push_back(clusters[Cls[i][0]]->StartWire());
367  vtx_t.push_back(clusters[Cls[i][0]]->StartTick());
368  }
369  }
370  //save 2D vertex
371  // make an empty art::PtrVector of hits
374  std::vector<art::Ptr<recob::Hit>> hits = fmh.at(Cls[i][0]);
375  double totalQ = 0.;
376  for (size_t h = 0; h < hits.size(); ++h)
377  totalQ += hits[h]->Integral();
378 
379  geo::WireID wireID(hits[0]->WireID().asPlaneID(),
380  (unsigned int)vtx_w.back()); //for update to EndPoint2D ... WK 4/22/13
381 
382  recob::EndPoint2D vertex(vtx_t.back(),
383  wireID, //for update to EndPoint2D ... WK 4/22/13
384  1,
385  epcol->size(),
386  clusters[Cls[i][0]]->View(),
387  totalQ);
388  epcol->push_back(vertex);
389 
390  util::CreateAssn(evt, *epcol, hits, *assnep);
391  }
392  else {
393  //no cluster found
394  vtx_w.push_back(-1);
395  vtx_t.push_back(-1);
396  }
397  }
398 
399  Double_t vtxcoord[3];
400  if (Cls[0].size() > 0 && Cls[1].size() > 0) { //ignore w view
401  double Iw0 = (vtx_w[0] + 3.95) * wire_pitch;
402  double Cw0 = (vtx_w[1] + 1.84) * wire_pitch;
403 
404  double It0 = vtx_t[0] - presamplings;
405  It0 *= timepitch;
406  double Ct0 = vtx_t[1] - presamplings;
407  Ct0 *= timepitch;
408  vtxcoord[0] = detProp.ConvertTicksToX(vtx_t[1], 1, 0, 0);
409  vtxcoord[1] = (Cw0 - Iw0) / (2. * std::sin(Angle));
410  vtxcoord[2] = (Cw0 + Iw0) / (2. * std::cos(Angle)) - YC / 2. * std::tan(Angle);
411 
412  if (vtx_w[0] >= 0 && vtx_w[0] <= 239 && vtx_w[1] >= 0 && vtx_w[1] <= 239) {
413  if (auto intersection = wireReadoutGeom.ChannelsIntersect(
414  wireReadoutGeom.PlaneWireToChannel(
415  geo::WireID(0, 0, 0, (int)((Iw0 / wire_pitch) - 3.95))),
416  wireReadoutGeom.PlaneWireToChannel(
417  geo::WireID(0, 0, 1, (int)((Cw0 / wire_pitch) - 1.84))))) {
418  // channelsintersect provides a slightly more accurate set of y and z coordinates.
419  // use channelsintersect in case the wires in question do cross.
420  vtxcoord[1] = intersection->y;
421  vtxcoord[2] = intersection->z;
422  }
423  else {
424  vtxcoord[0] = -99999;
425  vtxcoord[1] = -99999;
426  vtxcoord[2] = -99999;
427  }
428  }
429  dtIC->Fill(It0 - Ct0);
430  }
431  else {
432  vtxcoord[0] = -99999;
433  vtxcoord[1] = -99999;
434  vtxcoord[2] = -99999;
435  }
436 
439  art::PtrVector<recob::Track> vTracks_vec;
440  art::PtrVector<recob::Shower> vShowers_vec;
441 
442  recob::Vertex the3Dvertex(vtxcoord, vcol->size());
443  vcol->push_back(the3Dvertex);
444 
445  if (vShowers_vec.size() > 0) { util::CreateAssn(evt, *vcol, vShowers_vec, *assnsh); }
446 
447  if (vTracks_vec.size() > 0) { util::CreateAssn(evt, *vcol, vTracks_vec, *assntr); }
448 
449  MF_LOG_VERBATIM("Summary") << std::setfill('-') << std::setw(175) << "-" << std::setfill(' ');
450  MF_LOG_VERBATIM("Summary") << "VertexFinder2D Summary:";
451  for (size_t i = 0; i < epcol->size(); ++i)
452  MF_LOG_VERBATIM("Summary") << epcol->at(i);
453  for (size_t i = 0; i < vcol->size(); ++i)
454  MF_LOG_VERBATIM("Summary") << vcol->at(i);
455 
456  evt.put(std::move(epcol));
457  evt.put(std::move(vcol));
458  evt.put(std::move(assnep));
459  evt.put(std::move(assntr));
460  evt.put(std::move(assnsh));
461  evt.put(std::move(assnh));
462 
463  } // end of produce
code to link reconstructed objects back to the MC truth information
TTree * t1
Definition: plottest35.C:26
Planes which measure V.
Definition: geo_types.h:132
constexpr auto abs(T v)
Returns the absolute value of the argument.
Planes which measure Z direction.
Definition: geo_types.h:134
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
Definition: AddMC.C:8
Definition of vertex object for LArSoft.
Definition: Vertex.h:35
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: Event.h:77
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:101
Definition: type_traits.h:61
Planes which measure U.
Definition: geo_types.h:131
void hits()
Definition: readHits.C:15
bool SortByWire(art::Ptr< recob::Hit > const &h1, art::Ptr< recob::Hit > const &h2)
TCanvas * c1
Definition: plotHisto.C:7
TCanvas * c2
Definition: plot_hist.C:75
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:435
size_type size() const
Definition: PtrVector.h:302
Detector simulation of raw signals on wires.
TTree * t2
Definition: plottest35.C:36
double HalfHeight() const
Height is associated with y coordinate [cm].
Definition: TPCGeo.h:106
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.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
#define MF_LOG_VERBATIM(category)
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
int trigger_offset(DetectorClocksData const &data)
Char_t n[5]
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:69
TPCGeo const & TPC(TPCID const &tpcid=details::tpc_zero) const
Returns the specified TPC.
Definition: GeometryCore.h:448
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
vertex reconstruction
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

TH1D* vertex::VertexFinder2D::dtIC
private

Definition at line 79 of file VertexFinder2D_module.cc.

Referenced by beginJob(), and produce().

std::string vertex::VertexFinder2D::fClusterModuleLabel
private

Definition at line 81 of file VertexFinder2D_module.cc.

Referenced by produce(), and VertexFinder2D().


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