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

 LArPandoraShowerCreation (fhicl::ParameterSet const &pset)
 
 LArPandoraShowerCreation (LArPandoraShowerCreation const &)=delete
 
 LArPandoraShowerCreation (LArPandoraShowerCreation &&)=delete
 
LArPandoraShowerCreationoperator= (LArPandoraShowerCreation const &)=delete
 
LArPandoraShowerCreationoperator= (LArPandoraShowerCreation &&)=delete
 
void produce (art::Event &evt) override
 
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

recob::Shower BuildShower (const int id, const lar_content::LArShowerPCA &larShowerPCA, const pandora::CartesianVector &vertexPosition) const
 Build a recob::Shower object. More...
 
recob::PCAxis BuildPCAxis (const lar_content::LArShowerPCA &larShowerPCA) const
 Build a recob::PCAxis object. More...
 

Private Attributes

std::string m_pfParticleLabel
 The pf particle label. More...
 
bool m_useAllParticles
 Build a recob::Track for every recob::PFParticle. More...
 

Detailed Description

Definition at line 24 of file LArPandoraShowerCreation_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

lar_pandora::LArPandoraShowerCreation::LArPandoraShowerCreation ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 93 of file LArPandoraShowerCreation_module.cc.

References m_pfParticleLabel, and m_useAllParticles.

94  : EDProducer{pset}
95  , m_pfParticleLabel(pset.get<std::string>("PFParticleLabel"))
96  , m_useAllParticles(pset.get<bool>("UseAllParticles", false))
97  {
98  produces<std::vector<recob::Shower>>();
99  produces<std::vector<recob::PCAxis>>();
100  produces<art::Assns<recob::PFParticle, recob::Shower>>();
101  produces<art::Assns<recob::PFParticle, recob::PCAxis>>();
102  produces<art::Assns<recob::Shower, recob::Hit>>();
103  produces<art::Assns<recob::Shower, recob::PCAxis>>();
104  }
bool m_useAllParticles
Build a recob::Track for every recob::PFParticle.
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.cc:6
std::string m_pfParticleLabel
The pf particle label.
lar_pandora::LArPandoraShowerCreation::LArPandoraShowerCreation ( LArPandoraShowerCreation const &  )
delete
lar_pandora::LArPandoraShowerCreation::LArPandoraShowerCreation ( LArPandoraShowerCreation &&  )
delete

Member Function Documentation

recob::PCAxis lar_pandora::LArPandoraShowerCreation::BuildPCAxis ( const lar_content::LArShowerPCA larShowerPCA) const
private

Build a recob::PCAxis object.

Parameters
larShowerPCAthe lar shower pca parameters extracted from pandora

< SVD Decomposition was successful

< Eigen values from SVD decomposition

< Average position of hits fed to PCA

The three principle axes

< Number of hits in the decomposition, not yet ready

< Average doca of hits used in PCA, not ready yet

< Axis ID, not ready yet

Definition at line 291 of file LArPandoraShowerCreation_module.cc.

References lar_content::LArShowerPCA::GetCentroid(), lar_content::LArShowerPCA::GetEigenValues(), lar_content::LArShowerPCA::GetPrimaryAxis(), lar_content::LArShowerPCA::GetSecondaryAxis(), lar_content::LArShowerPCA::GetTertiaryAxis(), and util::kBogusI.

Referenced by produce().

293  {
294  const pandora::CartesianVector& showerCentroid(larShowerPCA.GetCentroid());
295  const pandora::CartesianVector& showerDirection(larShowerPCA.GetPrimaryAxis());
296  const pandora::CartesianVector& showerSecondaryVector(larShowerPCA.GetSecondaryAxis());
297  const pandora::CartesianVector& showerTertiaryVector(larShowerPCA.GetTertiaryAxis());
298  const pandora::CartesianVector& showerEigenValues(larShowerPCA.GetEigenValues());
299 
300  const bool svdOK(true);
301  const double eigenValues[3] = {
302  showerEigenValues.GetX(),
303  showerEigenValues.GetY(),
304  showerEigenValues.GetZ()};
305  const double avePosition[3] = {showerCentroid.GetX(),
306  showerCentroid.GetY(),
307  showerCentroid.GetZ()};
308 
309  std::vector<std::vector<double>> eigenVecs = {
311  {showerDirection.GetX(), showerDirection.GetY(), showerDirection.GetZ()},
312  {showerSecondaryVector.GetX(), showerSecondaryVector.GetY(), showerSecondaryVector.GetZ()},
313  {showerTertiaryVector.GetX(), showerTertiaryVector.GetY(), showerTertiaryVector.GetZ()}};
314 
315  // TODO
316  const int numHitsUsed(100);
317  const double aveHitDoca(0.);
318  const size_t iD(util::kBogusI);
319 
320  return recob::PCAxis(svdOK, numHitsUsed, eigenValues, eigenVecs, avePosition, aveHitDoca, iD);
321  }
const pandora::CartesianVector & GetCentroid() const
Return centroid.
constexpr int kBogusI
obviously bogus integer value
const pandora::CartesianVector & GetEigenValues() const
Return vector of eigenvalues.
const pandora::CartesianVector & GetSecondaryAxis() const
Return secondary axis.
const pandora::CartesianVector & GetTertiaryAxis() const
Return tertiary axis.
const pandora::CartesianVector & GetPrimaryAxis() const
Return primary axis.
recob::Shower lar_pandora::LArPandoraShowerCreation::BuildShower ( const int  id,
const lar_content::LArShowerPCA larShowerPCA,
const pandora::CartesianVector &  vertexPosition 
) const
private

Build a recob::Shower object.

Parameters
idthe id code for the shower
larShowerPCAthe lar shower pca parameters extracted from pandora
vertexPositionthe shower vertex position

Definition at line 249 of file LArPandoraShowerCreation_module.cc.

References tca::dEdx(), f, lar_content::LArShowerPCA::GetAxisLengths(), lar_content::LArShowerPCA::GetPrimaryAxis(), lar_content::LArShowerPCA::GetPrimaryLength(), and lar_content::LArShowerPCA::GetSecondaryLength().

Referenced by produce().

253  {
254  const pandora::CartesianVector& showerLength(larShowerPCA.GetAxisLengths());
255  const pandora::CartesianVector& showerDirection(larShowerPCA.GetPrimaryAxis());
256 
257  const float length(showerLength.GetX());
258  const float openingAngle(
259  larShowerPCA.GetPrimaryLength() > 0.f ?
260  std::atan(larShowerPCA.GetSecondaryLength() / larShowerPCA.GetPrimaryLength()) :
261  0.f);
262  const TVector3 direction(
263  showerDirection.GetX(), showerDirection.GetY(), showerDirection.GetZ());
264  const TVector3 vertex(vertexPosition.GetX(), vertexPosition.GetY(), vertexPosition.GetZ());
265 
266  // TODO
267  const TVector3 directionErr;
268  const TVector3 vertexErr;
269  const std::vector<double> totalEnergyErr;
270  const std::vector<double> dEdx;
271  const std::vector<double> dEdxErr;
272  const std::vector<double> totalEnergy;
273  const int bestplane(0);
274 
275  return recob::Shower(direction,
276  directionErr,
277  vertex,
278  vertexErr,
279  totalEnergy,
280  totalEnergyErr,
281  dEdx,
282  dEdxErr,
283  bestplane,
284  id,
285  length,
286  openingAngle);
287  }
float GetPrimaryLength() const
Return primary length.
TFile f
Definition: plotHisto.C:6
const pandora::CartesianVector & GetAxisLengths() const
Return vector of lengths.
float dEdx(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, TP3D &tp3d)
Definition: PFPUtils.cxx:2675
float GetSecondaryLength() const
Return secondary length.
const pandora::CartesianVector & GetPrimaryAxis() const
Return primary axis.
vertex reconstruction
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
LArPandoraShowerCreation& lar_pandora::LArPandoraShowerCreation::operator= ( LArPandoraShowerCreation const &  )
delete
LArPandoraShowerCreation& lar_pandora::LArPandoraShowerCreation::operator= ( LArPandoraShowerCreation &&  )
delete
void lar_pandora::LArPandoraShowerCreation::produce ( art::Event evt)
overridevirtual

Implements art::EDProducer.

Definition at line 108 of file LArPandoraShowerCreation_module.cc.

References BuildPCAxis(), BuildShower(), lar_pandora::LArPandoraHelper::CollectPFParticles(), lar_pandora::LArPandoraHelper::CollectVertices(), util::CreateAssn(), f, lar_pandora::LArPandoraHelper::GetAssociatedHits(), lar_content::LArShowerPCA::GetCentroid(), lar_content::LArShowerPCA::GetEigenValues(), lar_content::LArShowerPCA::GetPrimaryAxis(), lar_content::LArPfoHelper::GetPrincipalComponents(), lar_content::LArShowerPCA::GetSecondaryAxis(), lar_content::LArShowerPCA::GetTertiaryAxis(), lar_pandora::LArPandoraHelper::IsShower(), m_pfParticleLabel, m_useAllParticles, art::Event::put(), and recob::SpacePoint::XYZ().

109  {
110  std::unique_ptr<std::vector<recob::Shower>> outputShowers(new std::vector<recob::Shower>);
111  std::unique_ptr<std::vector<recob::PCAxis>> outputPCAxes(new std::vector<recob::PCAxis>);
112  std::unique_ptr<art::Assns<recob::PFParticle, recob::Shower>> outputParticlesToShowers(
114  std::unique_ptr<art::Assns<recob::PFParticle, recob::PCAxis>> outputParticlesToPCAxes(
116  std::unique_ptr<art::Assns<recob::Shower, recob::Hit>> outputShowersToHits(
118  std::unique_ptr<art::Assns<recob::Shower, recob::PCAxis>> outputShowersToPCAxes(
120 
121  const art::PtrMaker<recob::Shower> makeShowerPtr(evt);
122  const art::PtrMaker<recob::PCAxis> makePCAxisPtr(evt);
123 
124  int showerCounter(0);
125 
126  // Organise inputs
127  PFParticleVector pfParticleVector, extraPfParticleVector;
128  PFParticlesToSpacePoints pfParticlesToSpacePoints;
129  PFParticlesToClusters pfParticlesToClusters;
131  evt, m_pfParticleLabel, pfParticleVector, pfParticlesToSpacePoints);
133  evt, m_pfParticleLabel, extraPfParticleVector, pfParticlesToClusters);
134 
135  VertexVector vertexVector;
136  PFParticlesToVertices pfParticlesToVertices;
137  LArPandoraHelper::CollectVertices(evt, m_pfParticleLabel, vertexVector, pfParticlesToVertices);
138 
139  for (const art::Ptr<recob::PFParticle> pPFParticle : pfParticleVector) {
140  // Select shower-like pfparticles
141  if (!m_useAllParticles && !LArPandoraHelper::IsShower(pPFParticle)) continue;
142 
143  // Obtain associated spacepoints
144  PFParticlesToSpacePoints::const_iterator particleToSpacePointIter(
145  pfParticlesToSpacePoints.find(pPFParticle));
146 
147  if (pfParticlesToSpacePoints.end() == particleToSpacePointIter) {
148  mf::LogDebug("LArPandoraShowerCreation") << "No spacepoints associated to particle ";
149  continue;
150  }
151 
152  // Obtain associated clusters
153  PFParticlesToClusters::const_iterator particleToClustersIter(
154  pfParticlesToClusters.find(pPFParticle));
155 
156  if (pfParticlesToClusters.end() == particleToClustersIter) {
157  mf::LogDebug("LArPandoraShowerCreation") << "No clusters associated to particle ";
158  continue;
159  }
160 
161  // Obtain associated vertex
162  PFParticlesToVertices::const_iterator particleToVertexIter(
163  pfParticlesToVertices.find(pPFParticle));
164 
165  if ((pfParticlesToVertices.end() == particleToVertexIter) ||
166  (1 != particleToVertexIter->second.size())) {
167  mf::LogDebug("LArPandoraShowerCreation") << "Unexpected number of vertices for particle ";
168  continue;
169  }
170 
171  // Copy information into expected pandora form
172  pandora::CartesianPointVector cartesianPointVector;
173  for (const art::Ptr<recob::SpacePoint> spacePoint : particleToSpacePointIter->second)
174  cartesianPointVector.emplace_back(pandora::CartesianVector(
175  spacePoint->XYZ()[0], spacePoint->XYZ()[1], spacePoint->XYZ()[2]));
176 
177  double vertexXYZ[3] = {0., 0., 0.};
178  particleToVertexIter->second.front()->XYZ(vertexXYZ);
179  const pandora::CartesianVector vertexPosition(vertexXYZ[0], vertexXYZ[1], vertexXYZ[2]);
180 
181  // Call pandora "fast" shower fitter
182  try {
183  // Access centroid of shower via this method
184  const lar_content::LArShowerPCA initialLArShowerPCA(
185  lar_content::LArPfoHelper::GetPrincipalComponents(cartesianPointVector, vertexPosition));
186 
187  // Ensure successful creation of all structures before placing results in output containers, remaking LArShowerPCA with updated vertex
188  const pandora::CartesianVector& centroid(initialLArShowerPCA.GetCentroid());
189  const pandora::CartesianVector& primaryAxis(initialLArShowerPCA.GetPrimaryAxis());
190  const pandora::CartesianVector& secondaryAxis(initialLArShowerPCA.GetSecondaryAxis());
191  const pandora::CartesianVector& tertiaryAxis(initialLArShowerPCA.GetTertiaryAxis());
192  const pandora::CartesianVector& eigenvalues(initialLArShowerPCA.GetEigenValues());
193 
194  // Project the PFParticle vertex onto the PCA axis
195  const pandora::CartesianVector projectedVertexPosition(
196  centroid -
197  primaryAxis.GetUnitVector() * (centroid - vertexPosition).GetDotProduct(primaryAxis));
198 
199  // By convention, principal axis should always point away from vertex
200  const float testProjection(primaryAxis.GetDotProduct(projectedVertexPosition - centroid));
201  const float directionScaleFactor(
202  (testProjection > std::numeric_limits<float>::epsilon()) ? -1.f : 1.f);
203 
204  const lar_content::LArShowerPCA larShowerPCA(centroid,
205  primaryAxis * directionScaleFactor,
206  secondaryAxis * directionScaleFactor,
207  tertiaryAxis * directionScaleFactor,
208  eigenvalues);
210  showerCounter++, larShowerPCA, projectedVertexPosition));
211  const recob::PCAxis pcAxis(LArPandoraShowerCreation::BuildPCAxis(larShowerPCA));
212  outputShowers->emplace_back(shower);
213  outputPCAxes->emplace_back(pcAxis);
214  }
215  catch (const pandora::StatusCodeException&) {
216  mf::LogDebug("LArPandoraShowerCreation") << "Unable to extract shower pca";
217  continue;
218  }
219 
220  // Output objects
221  art::Ptr<recob::Shower> pShower(makeShowerPtr(outputShowers->size() - 1));
222  art::Ptr<recob::PCAxis> pPCAxis(makePCAxisPtr(outputPCAxes->size() - 1));
223 
224  HitVector hitsInParticle;
226  evt, m_pfParticleLabel, particleToClustersIter->second, hitsInParticle);
227 
228  // Output associations, after output objects are in place
229  util::CreateAssn(evt, pShower, pPFParticle, *(outputParticlesToShowers.get()));
230  util::CreateAssn(evt, pPCAxis, pPFParticle, *(outputParticlesToPCAxes.get()));
231  util::CreateAssn(evt, *(outputShowers.get()), hitsInParticle, *(outputShowersToHits.get()));
232  util::CreateAssn(evt, pPCAxis, pShower, *(outputShowersToPCAxes.get()));
233  }
234 
235  mf::LogDebug("LArPandora") << " Number of new showers: " << outputShowers->size()
236  << std::endl;
237  mf::LogDebug("LArPandora") << " Number of new pcaxes: " << outputPCAxes->size() << std::endl;
238 
239  evt.put(std::move(outputShowers));
240  evt.put(std::move(outputPCAxes));
241  evt.put(std::move(outputParticlesToShowers));
242  evt.put(std::move(outputParticlesToPCAxes));
243  evt.put(std::move(outputShowersToHits));
244  evt.put(std::move(outputShowersToPCAxes));
245  }
static LArShowerPCA GetPrincipalComponents(const pandora::CartesianPointVector &pointVector, const pandora::CartesianVector &vertexPosition)
Perform PCA analysis on a set of 3D points and return results.
recob::PCAxis BuildPCAxis(const lar_content::LArShowerPCA &larShowerPCA) const
Build a recob::PCAxis object.
std::map< art::Ptr< recob::PFParticle >, ClusterVector > PFParticlesToClusters
bool m_useAllParticles
Build a recob::Track for every recob::PFParticle.
static bool IsShower(const art::Ptr< recob::PFParticle > particle)
Determine whether a particle has been reconstructed as shower-like.
recob::Shower BuildShower(const int id, const lar_content::LArShowerPCA &larShowerPCA, const pandora::CartesianVector &vertexPosition) const
Build a recob::Shower object.
intermediate_table::const_iterator const_iterator
std::map< art::Ptr< recob::PFParticle >, VertexVector > PFParticlesToVertices
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: Event.h:77
TFile f
Definition: plotHisto.C:6
static void GetAssociatedHits(const art::Event &evt, const std::string &label, const std::vector< art::Ptr< T >> &inputVector, HitVector &associatedHits, const pandora::IntVector *const indexVector=nullptr)
Get all hits associated with input clusters.
std::string m_pfParticleLabel
The pf particle label.
std::vector< art::Ptr< recob::PFParticle > > PFParticleVector
static void CollectVertices(const art::Event &evt, const std::string &label, VertexVector &vertexVector, PFParticlesToVertices &particlesToVertices)
Collect the reconstructed PFParticles and associated Vertices from the ART event record.
const Double32_t * XYZ() const
Definition: SpacePoint.h:78
std::map< art::Ptr< recob::PFParticle >, SpacePointVector > PFParticlesToSpacePoints
static void CollectPFParticles(const art::Event &evt, const std::string &label, PFParticleVector &particleVector)
Collect the reconstructed PFParticles from the ART event record.
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.
std::vector< art::Ptr< recob::Hit > > HitVector
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
std::vector< art::Ptr< recob::Vertex > > VertexVector
LArShowerPCA class.
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

std::string lar_pandora::LArPandoraShowerCreation::m_pfParticleLabel
private

The pf particle label.

Definition at line 54 of file LArPandoraShowerCreation_module.cc.

Referenced by LArPandoraShowerCreation(), and produce().

bool lar_pandora::LArPandoraShowerCreation::m_useAllParticles
private

Build a recob::Track for every recob::PFParticle.

Definition at line 55 of file LArPandoraShowerCreation_module.cc.

Referenced by LArPandoraShowerCreation(), and produce().


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