Public Member Functions | Private Member Functions | Private Attributes | List of all members
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 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
 
- 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

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...
 

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 24 of file LArPandoraShowerCreation_module.cc.

Constructor & Destructor Documentation

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

Definition at line 93 of file LArPandoraShowerCreation_module.cc.

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.
std::string string
Definition: nybbler.cc:12
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
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 294 of file LArPandoraShowerCreation_module.cc.

295  {
296  const pandora::CartesianVector& showerCentroid(larShowerPCA.GetCentroid());
297  const pandora::CartesianVector& showerDirection(larShowerPCA.GetPrimaryAxis());
298  const pandora::CartesianVector& showerSecondaryVector(larShowerPCA.GetSecondaryAxis());
299  const pandora::CartesianVector& showerTertiaryVector(larShowerPCA.GetTertiaryAxis());
300  const pandora::CartesianVector& showerEigenValues(larShowerPCA.GetEigenValues());
301 
302  const bool svdOK(true); ///< SVD Decomposition was successful
303  const double eigenValues[3] = {
304  showerEigenValues.GetX(),
305  showerEigenValues.GetY(),
306  showerEigenValues.GetZ()}; ///< Eigen values from SVD decomposition
307  const double avePosition[3] = {showerCentroid.GetX(),
308  showerCentroid.GetY(),
309  showerCentroid.GetZ()}; ///< Average position of hits fed to PCA
310 
311  std::vector<std::vector<double>> eigenVecs = {
312  /// The three principle axes
313  {showerDirection.GetX(), showerDirection.GetY(), showerDirection.GetZ()},
314  {showerSecondaryVector.GetX(), showerSecondaryVector.GetY(), showerSecondaryVector.GetZ()},
315  {showerTertiaryVector.GetX(), showerTertiaryVector.GetY(), showerTertiaryVector.GetZ()}};
316 
317  // TODO
318  const int numHitsUsed(100); ///< Number of hits in the decomposition, not yet ready
319  const double aveHitDoca(0.); ///< Average doca of hits used in PCA, not ready yet
320  const size_t iD(util::kBogusI); ///< Axis ID, not ready yet
321 
322  return recob::PCAxis(svdOK, numHitsUsed, eigenValues, eigenVecs, avePosition, aveHitDoca, iD);
323  }
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 252 of file LArPandoraShowerCreation_module.cc.

255  {
256  const pandora::CartesianVector& showerLength(larShowerPCA.GetAxisLengths());
257  const pandora::CartesianVector& showerDirection(larShowerPCA.GetPrimaryAxis());
258 
259  const float length(showerLength.GetX());
260  const float openingAngle(
261  larShowerPCA.GetPrimaryLength() > 0.f ?
262  std::atan(larShowerPCA.GetSecondaryLength() / larShowerPCA.GetPrimaryLength()) :
263  0.f);
264  const TVector3 direction(
265  showerDirection.GetX(), showerDirection.GetY(), showerDirection.GetZ());
266  const TVector3 vertex(vertexPosition.GetX(), vertexPosition.GetY(), vertexPosition.GetZ());
267 
268  // TODO
269  const TVector3 directionErr;
270  const TVector3 vertexErr;
271  const std::vector<double> totalEnergyErr;
272  const std::vector<double> dEdx;
273  const std::vector<double> dEdxErr;
274  const std::vector<double> totalEnergy;
275  const int bestplane(0);
276 
277  return recob::Shower(direction,
278  directionErr,
279  vertex,
280  vertexErr,
281  totalEnergy,
282  totalEnergyErr,
283  dEdx,
284  dEdxErr,
285  bestplane,
286  id,
287  length,
288  openingAngle);
289  }
float GetPrimaryLength() const
Return primary length.
double dEdx(float dqdx, float Efield)
Definition: doAna.cpp:21
const pandora::CartesianVector & GetAxisLengths() const
Return vector of lengths.
float GetSecondaryLength() const
Return secondary length.
const pandora::CartesianVector & GetPrimaryAxis() const
Return primary axis.
vertex reconstruction
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 109 of file LArPandoraShowerCreation_module.cc.

110  {
111  std::unique_ptr<std::vector<recob::Shower>> outputShowers(new std::vector<recob::Shower>);
112  std::unique_ptr<std::vector<recob::PCAxis>> outputPCAxes(new std::vector<recob::PCAxis>);
113  std::unique_ptr<art::Assns<recob::PFParticle, recob::Shower>> outputParticlesToShowers(
115  std::unique_ptr<art::Assns<recob::PFParticle, recob::PCAxis>> outputParticlesToPCAxes(
117  std::unique_ptr<art::Assns<recob::Shower, recob::Hit>> outputShowersToHits(
119  std::unique_ptr<art::Assns<recob::Shower, recob::PCAxis>> outputShowersToPCAxes(
121 
122  const art::PtrMaker<recob::Shower> makeShowerPtr(evt);
123  const art::PtrMaker<recob::PCAxis> makePCAxisPtr(evt);
124 
125  int showerCounter(0);
126 
127  // Organise inputs
128  PFParticleVector pfParticleVector, extraPfParticleVector;
129  PFParticlesToSpacePoints pfParticlesToSpacePoints;
130  PFParticlesToClusters pfParticlesToClusters;
132  evt, m_pfParticleLabel, pfParticleVector, pfParticlesToSpacePoints);
134  evt, m_pfParticleLabel, extraPfParticleVector, pfParticlesToClusters);
135 
136  VertexVector vertexVector;
137  PFParticlesToVertices pfParticlesToVertices;
138  LArPandoraHelper::CollectVertices(evt, m_pfParticleLabel, vertexVector, pfParticlesToVertices);
139 
140  for (const art::Ptr<recob::PFParticle> pPFParticle : pfParticleVector) {
141  // Select shower-like pfparticles
142  if (!m_useAllParticles && !LArPandoraHelper::IsShower(pPFParticle)) continue;
143 
144  // Obtain associated spacepoints
145  PFParticlesToSpacePoints::const_iterator particleToSpacePointIter(
146  pfParticlesToSpacePoints.find(pPFParticle));
147 
148  if (pfParticlesToSpacePoints.end() == particleToSpacePointIter) {
149  mf::LogDebug("LArPandoraShowerCreation") << "No spacepoints associated to particle ";
150  continue;
151  }
152 
153  // Obtain associated clusters
154  PFParticlesToClusters::const_iterator particleToClustersIter(
155  pfParticlesToClusters.find(pPFParticle));
156 
157  if (pfParticlesToClusters.end() == particleToClustersIter) {
158  mf::LogDebug("LArPandoraShowerCreation") << "No clusters associated to particle ";
159  continue;
160  }
161 
162  // Obtain associated vertex
163  PFParticlesToVertices::const_iterator particleToVertexIter(
164  pfParticlesToVertices.find(pPFParticle));
165 
166  if ((pfParticlesToVertices.end() == particleToVertexIter) ||
167  (1 != particleToVertexIter->second.size())) {
168  mf::LogDebug("LArPandoraShowerCreation") << "Unexpected number of vertices for particle ";
169  continue;
170  }
171 
172  // Copy information into expected pandora form
173  pandora::CartesianPointVector cartesianPointVector;
174  for (const art::Ptr<recob::SpacePoint> spacePoint : particleToSpacePointIter->second)
175  cartesianPointVector.emplace_back(pandora::CartesianVector(
176  spacePoint->XYZ()[0], spacePoint->XYZ()[1], spacePoint->XYZ()[2]));
177 
178  double vertexXYZ[3] = {0., 0., 0.};
179  particleToVertexIter->second.front()->XYZ(vertexXYZ);
180  const pandora::CartesianVector vertexPosition(vertexXYZ[0], vertexXYZ[1], vertexXYZ[2]);
181 
182  // Call pandora "fast" shower fitter
183  try {
184  // Access centroid of shower via this method
185  const lar_content::LArShowerPCA initialLArShowerPCA(
186  lar_content::LArPfoHelper::GetPrincipalComponents(cartesianPointVector, vertexPosition));
187 
188  // Ensure successful creation of all structures before placing results in output containers, remaking LArShowerPCA with updated vertex
189  const pandora::CartesianVector& centroid(initialLArShowerPCA.GetCentroid());
190  const pandora::CartesianVector& primaryAxis(initialLArShowerPCA.GetPrimaryAxis());
191  const pandora::CartesianVector& secondaryAxis(initialLArShowerPCA.GetSecondaryAxis());
192  const pandora::CartesianVector& tertiaryAxis(initialLArShowerPCA.GetTertiaryAxis());
193  const pandora::CartesianVector& eigenvalues(initialLArShowerPCA.GetEigenValues());
194 
195  // Project the PFParticle vertex onto the PCA axis
196  const pandora::CartesianVector projectedVertexPosition(
197  centroid -
198  primaryAxis.GetUnitVector() * (centroid - vertexPosition).GetDotProduct(primaryAxis));
199 
200  // By convention, principal axis should always point away from vertex
201  const float testProjection(primaryAxis.GetDotProduct(projectedVertexPosition - centroid));
202  const float directionScaleFactor(
203  (testProjection > std::numeric_limits<float>::epsilon()) ? -1.f : 1.f);
204 
205  const lar_content::LArShowerPCA larShowerPCA(centroid,
206  primaryAxis * directionScaleFactor,
207  secondaryAxis * directionScaleFactor,
208  tertiaryAxis * directionScaleFactor,
209  eigenvalues);
211  showerCounter++, larShowerPCA, projectedVertexPosition));
212  const recob::PCAxis pcAxis(LArPandoraShowerCreation::BuildPCAxis(larShowerPCA));
213  outputShowers->emplace_back(shower);
214  outputPCAxes->emplace_back(pcAxis);
215  }
216  catch (const pandora::StatusCodeException&) {
217  mf::LogDebug("LArPandoraShowerCreation") << "Unable to extract shower pca";
218  continue;
219  }
220 
221  // Output objects
222  art::Ptr<recob::Shower> pShower(makeShowerPtr(outputShowers->size() - 1));
223  art::Ptr<recob::PCAxis> pPCAxis(makePCAxisPtr(outputPCAxes->size() - 1));
224 
225  HitVector hitsInParticle;
227  evt, m_pfParticleLabel, particleToClustersIter->second, hitsInParticle);
228 
229  // Output associations, after output objects are in place
230  util::CreateAssn(*this, evt, pShower, pPFParticle, *(outputParticlesToShowers.get()));
231  util::CreateAssn(*this, evt, pPCAxis, pPFParticle, *(outputParticlesToPCAxes.get()));
233  *this, evt, *(outputShowers.get()), hitsInParticle, *(outputShowersToHits.get()));
234  util::CreateAssn(*this, evt, pPCAxis, pShower, *(outputShowersToPCAxes.get()));
235  }
236 
237  mf::LogDebug("LArPandora") << " Number of new showers: " << outputShowers->size()
238  << std::endl;
239  mf::LogDebug("LArPandora") << " Number of new pcaxes: " << outputPCAxes->size() << std::endl;
240 
241  evt.put(std::move(outputShowers));
242  evt.put(std::move(outputPCAxes));
243  evt.put(std::move(outputParticlesToShowers));
244  evt.put(std::move(outputParticlesToPCAxes));
245  evt.put(std::move(outputShowersToHits));
246  evt.put(std::move(outputShowersToPCAxes));
247  }
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
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
def move(depos, offset)
Definition: depos.py:107
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.
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
bool CreateAssn(PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX)
Creates a single one-to-one association.
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.
std::vector< art::Ptr< recob::Hit > > HitVector
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
const Double32_t * XYZ() const
Definition: SpacePoint.h:76
std::vector< art::Ptr< recob::Vertex > > VertexVector
LArShowerPCA class.
QTextStream & endl(QTextStream &s)

Member Data Documentation

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

The pf particle label.

Definition at line 54 of file LArPandoraShowerCreation_module.cc.

bool lar_pandora::LArPandoraShowerCreation::m_useAllParticles
private

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

Definition at line 55 of file LArPandoraShowerCreation_module.cc.


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