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

Public Member Functions

 QuadVtx (const fhicl::ParameterSet &pset)
 
void beginJob () override
 
void produce (art::Event &evt) override
 
- 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

bool FindVtx (const detinfo::DetectorPropertiesData &detProp, const std::vector< recob::Hit > &hits, TVector3 &vtx, int evt) const
 

Private Attributes

std::string fHitLabel
 
bool fSavePlots
 
const geo::GeometryCoregeom
 

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 74 of file QuadVtx_module.cc.

Constructor & Destructor Documentation

quad::QuadVtx::QuadVtx ( const fhicl::ParameterSet pset)
explicit

Definition at line 97 of file QuadVtx_module.cc.

98  : EDProducer(pset)
99  , fHitLabel(pset.get<std::string>("HitLabel"))
100  , fSavePlots(pset.get<bool>("SavePlots"))
101  {
102  produces<std::vector<recob::Vertex>>();
103  }
std::string string
Definition: nybbler.cc:12
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
std::string fHitLabel
T get(std::string const &key) const
Definition: ParameterSet.h:271

Member Function Documentation

void quad::QuadVtx::beginJob ( )
overridevirtual

Reimplemented from art::EDProducer.

Definition at line 107 of file QuadVtx_module.cc.

108  {
110  }
virtual const provider_type * provider() const override
const geo::GeometryCore * geom
bool quad::QuadVtx::FindVtx ( const detinfo::DetectorPropertiesData detProp,
const std::vector< recob::Hit > &  hits,
TVector3 &  vtx,
int  evt 
) const
private

Definition at line 392 of file QuadVtx_module.cc.

396  {
397  if (hits.empty()) return false;
398 
399  std::vector<std::vector<Pt2D>> pts;
400  std::vector<TVector3> dirs;
401 
402  GetPts2D(detProp, hits, pts, dirs, geom);
403 
404  double minx = +1e9;
405  double maxx = -1e9;
406  double minz[3] = {+1e9, +1e9, +1e9};
407  double maxz[3] = {-1e9, -1e9, -1e9};
408  for (int view = 0; view < 3; ++view) {
409  for (const Pt2D& p : pts[view]) {
410  minx = std::min(minx, p.x);
411  maxx = std::max(maxx, p.x);
412  minz[view] = std::min(minz[view], p.z);
413  maxz[view] = std::max(maxz[view], p.z);
414  }
415  }
416 
417  // Add some padding
418  for (int view = 0; view < 3; ++view) {
419  minz[view] -= 100;
420  maxz[view] += 100;
421  }
422  minx -= 20;
423  maxx += 20;
424 
425  // Don't allow the vertex further downstream in z (view 0) than 25% of the
426  // hits.
427  std::vector<float> zs;
428  zs.reserve(pts[0].size());
429  for (const Pt2D& p : pts[0])
430  zs.push_back(p.z);
431  auto mid = zs.begin() + zs.size() / 4;
432  if (mid != zs.end()) {
433  std::nth_element(zs.begin(), mid, zs.end());
434  maxz[0] = *mid;
435  }
436 
437  std::vector<HeatMap> hms;
438  hms.reserve(3);
439  for (int view = 0; view < 3; ++view) {
440  if (pts[view].empty()) return false;
441 
442  std::vector<Line2D> lines;
443  LinesFromPoints(pts[view], lines);
444 
445  if (lines.empty()) return false;
446 
447  // Approximately cm bins
448  hms.emplace_back(maxz[view] - minz[view], minz[view], maxz[view], maxx - minx, minx, maxx);
449  MapFromLines(lines, hms.back());
450  } // end for view
451 
452  vtx = FindPeak3D(hms, dirs);
453 
454  std::vector<HeatMap> hms_zoom;
455  hms_zoom.reserve(3);
456  for (int view = 0; view < 3; ++view) {
457  const double x0 = vtx.X();
458  const double z0 = vtx.Dot(dirs[view]);
459 
460  std::vector<Line2D> lines;
461  LinesFromPoints(pts[view], lines, z0, x0, 2.5);
462 
463  if (lines.empty()) return false; // How does this happen??
464 
465  // mm granularity
466  hms_zoom.emplace_back(50, z0 - 2.5, z0 + 2.5, 50, x0 - 2.5, x0 + 2.5);
467 
468  MapFromLines(lines, hms_zoom.back());
469  }
470 
471  vtx = FindPeak3D(hms_zoom, dirs);
472 
473  if (fSavePlots) {
474  art::TFileDirectory evt_dir =
476 
477  for (int view = 0; view < 3; ++view) {
478  art::TFileDirectory view_dir = evt_dir.mkdir(TString::Format("view%d", view).Data());
479 
480  TGraph* gpts = view_dir.makeAndRegister<TGraph>("hits", "");
481  for (const Pt2D& p : pts[view])
482  gpts->SetPoint(gpts->GetN(), p.z, p.x);
483 
484  view_dir.makeAndRegister<TH2F>("hmap", "", *hms[view].AsTH2());
485 
486  view_dir.makeAndRegister<TH2F>("hmap_zoom", "", *hms_zoom[view].AsTH2());
487 
488  const double x = vtx.X();
489  const double z = vtx.Dot(dirs[view]);
490  view_dir.makeAndRegister<TGraph>("vtx3d", "", 1, &z, &x);
491  } // end for view
492  } // end if saving plots
493 
494  return true;
495  }
void GetPts2D(const detinfo::DetectorPropertiesData &detProp, const std::vector< recob::Hit > &hits, std::vector< std::vector< Pt2D >> &pts, std::vector< TVector3 > &dirs, const geo::GeometryCore *geom)
TVector3 FindPeak3D(const std::vector< HeatMap > &hs, const std::vector< TVector3 > &dirs) noexcept
Format
Definition: utils.h:7
def mkdir(path, mode=0o777)
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
void MapFromLines(const std::vector< Line2D > &lines, HeatMap &hm)
p
Definition: test.py:223
static int max(int a, int b)
Fw2dFFT::Data Data
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
void LinesFromPoints(const std::vector< Pt2D > &pts, std::vector< Line2D > &lines, float z0=0, float x0=0, float R=-1)
static constexpr double zs
Definition: Units.h:102
list x
Definition: train.py:276
TCEvent evt
Definition: DataStructs.cxx:7
const geo::GeometryCore * geom
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:97
void quad::QuadVtx::produce ( art::Event evt)
overridevirtual

Implements art::EDProducer.

Definition at line 499 of file QuadVtx_module.cc.

500  {
501  auto vtxcol = std::make_unique<std::vector<recob::Vertex>>();
502 
504  evt.getByLabel(fHitLabel, hits);
505 
506  auto const detProp =
508  TVector3 vtx;
509  if (FindVtx(detProp, *hits, vtx, evt.event())) {
510  vtxcol->emplace_back(
511  recob::Vertex::Point_t(vtx.X(), vtx.Y(), vtx.Z()), recob::Vertex::SMatrixSym33(), 0, 0);
512  }
513 
514  evt.put(std::move(vtxcol));
515  }
EventNumber_t event() const
Definition: DataViewImpl.cc:85
tracking::SMatrixSym33 SMatrixSym33
Definition: Vertex.h:40
tracking::Point_t Point_t
Definition: Vertex.h:39
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
bool FindVtx(const detinfo::DetectorPropertiesData &detProp, const std::vector< recob::Hit > &hits, TVector3 &vtx, int evt) const
std::string fHitLabel
def move(depos, offset)
Definition: depos.py:107
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686

Member Data Documentation

std::string quad::QuadVtx::fHitLabel
private

Definition at line 87 of file QuadVtx_module.cc.

bool quad::QuadVtx::fSavePlots
private

Definition at line 89 of file QuadVtx_module.cc.

const geo::GeometryCore* quad::QuadVtx::geom
private

Definition at line 91 of file QuadVtx_module.cc.


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