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(
125 int showerCounter(0);
146 pfParticlesToSpacePoints.find(pPFParticle));
148 if (pfParticlesToSpacePoints.end() == particleToSpacePointIter) {
149 mf::LogDebug(
"LArPandoraShowerCreation") <<
"No spacepoints associated to particle ";
155 pfParticlesToClusters.find(pPFParticle));
157 if (pfParticlesToClusters.end() == particleToClustersIter) {
158 mf::LogDebug(
"LArPandoraShowerCreation") <<
"No clusters associated to particle ";
164 pfParticlesToVertices.find(pPFParticle));
166 if ((pfParticlesToVertices.end() == particleToVertexIter) ||
167 (1 != particleToVertexIter->second.size())) {
168 mf::LogDebug(
"LArPandoraShowerCreation") <<
"Unexpected number of vertices for particle ";
173 pandora::CartesianPointVector cartesianPointVector;
175 cartesianPointVector.emplace_back(pandora::CartesianVector(
176 spacePoint->
XYZ()[0], spacePoint->
XYZ()[1], spacePoint->
XYZ()[2]));
178 double vertexXYZ[3] = {0., 0., 0.};
179 particleToVertexIter->second.front()->XYZ(vertexXYZ);
180 const pandora::CartesianVector vertexPosition(vertexXYZ[0], vertexXYZ[1], vertexXYZ[2]);
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());
196 const pandora::CartesianVector projectedVertexPosition(
198 primaryAxis.GetUnitVector() * (centroid - vertexPosition).GetDotProduct(primaryAxis));
201 const float testProjection(primaryAxis.GetDotProduct(projectedVertexPosition - centroid));
202 const float directionScaleFactor(
203 (testProjection > std::numeric_limits<float>::epsilon()) ? -1.
f : 1.
f);
206 primaryAxis * directionScaleFactor,
207 secondaryAxis * directionScaleFactor,
208 tertiaryAxis * directionScaleFactor,
211 showerCounter++, larShowerPCA, projectedVertexPosition));
213 outputShowers->emplace_back(
shower);
214 outputPCAxes->emplace_back(pcAxis);
216 catch (
const pandora::StatusCodeException&) {
217 mf::LogDebug(
"LArPandoraShowerCreation") <<
"Unable to extract shower pca";
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()));
237 mf::LogDebug(
"LArPandora") <<
" Number of new showers: " << outputShowers->size()
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.
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
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={})
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
std::vector< art::Ptr< recob::Vertex > > VertexVector
QTextStream & endl(QTextStream &s)