103 produces< std::vector<recob::Shower> >();
104 produces< std::vector<recob::PCAxis> >();
105 produces< art::Assns<recob::PFParticle, recob::Shower> >();
106 produces< art::Assns<recob::PFParticle, recob::PCAxis> >();
107 produces< art::Assns<recob::Shower, recob::Hit> >();
108 produces< art::Assns<recob::Shower, recob::PCAxis> >();
115 std::unique_ptr< std::vector<recob::Shower> > outputShowers(
new std::vector<recob::Shower> );
116 std::unique_ptr< std::vector<recob::PCAxis> > outputPCAxes(
new std::vector<recob::PCAxis> );
145 if (pfParticlesToSpacePoints.end() == particleToSpacePointIter)
147 mf::LogDebug(
"LArPandoraShowerCreation") <<
"No spacepoints associated to particle ";
154 if (pfParticlesToClusters.end() == particleToClustersIter)
156 mf::LogDebug(
"LArPandoraShowerCreation") <<
"No clusters associated to particle ";
163 if ((pfParticlesToVertices.end() == particleToVertexIter) || (1 != particleToVertexIter->second.size()))
165 mf::LogDebug(
"LArPandoraShowerCreation") <<
"Unexpected number of vertices for particle ";
170 pandora::CartesianPointVector cartesianPointVector;
172 cartesianPointVector.emplace_back(pandora::CartesianVector(spacePoint->
XYZ()[0], spacePoint->
XYZ()[1], spacePoint->
XYZ()[2]));
174 double vertexXYZ[3] = {0., 0., 0.};
175 particleToVertexIter->second.front()->XYZ(vertexXYZ);
176 const pandora::CartesianVector vertexPosition(vertexXYZ[0], vertexXYZ[1], vertexXYZ[2]);
185 outputShowers->emplace_back(shower);
186 outputPCAxes->emplace_back(pcAxis);
188 catch (
const pandora::StatusCodeException &)
190 mf::LogDebug(
"LArPandoraShowerCreation") <<
"Unable to extract shower pca";
202 util::CreateAssn(*
this, evt, pShower, pPFParticle, *(outputParticlesToShowers.get()));
203 util::CreateAssn(*
this, evt, pPCAxis, pPFParticle, *(outputParticlesToPCAxes.get()));
204 util::CreateAssn(*
this, evt, *(outputShowers.get()), hitsInParticle, *(outputShowersToHits.get()));
205 util::CreateAssn(*
this, evt, pPCAxis, pShower, *(outputShowersToPCAxes.get()));
208 mf::LogDebug(
"LArPandora") <<
" Number of new showers: " << outputShowers->size() << std::endl;
209 mf::LogDebug(
"LArPandora") <<
" Number of new pcaxes: " << outputPCAxes->size() << std::endl;
211 evt.
put(std::move(outputShowers));
212 evt.
put(std::move(outputPCAxes));
213 evt.
put(std::move(outputParticlesToShowers));
214 evt.
put(std::move(outputParticlesToPCAxes));
215 evt.
put(std::move(outputShowersToHits));
216 evt.
put(std::move(outputShowersToPCAxes));
223 const pandora::CartesianVector &showerLength(larShowerPCA.
GetAxisLengths());
224 const pandora::CartesianVector &showerDirection(larShowerPCA.
GetPrimaryAxis());
226 const float length(showerLength.GetX());
228 const TVector3 direction(showerDirection.GetX(), showerDirection.GetY(), showerDirection.GetZ());
229 const TVector3
vertex(vertexPosition.GetX(), vertexPosition.GetY(), vertexPosition.GetZ());
232 const TVector3 directionErr;
233 const TVector3 vertexErr;
234 const std::vector<double> totalEnergyErr;
235 const std::vector<double> dEdx;
236 const std::vector<double> dEdxErr;
237 const std::vector<double> totalEnergy;
238 const int bestplane(0);
240 return recob::Shower(direction, directionErr,
vertex, vertexErr, totalEnergy, totalEnergyErr, dEdx, dEdxErr, bestplane,
util::kBogusI, length, openingAngle);
247 const pandora::CartesianVector &showerCentroid(larShowerPCA.
GetCentroid());
248 const pandora::CartesianVector &showerDirection(larShowerPCA.
GetPrimaryAxis());
249 const pandora::CartesianVector &showerSecondaryVector(larShowerPCA.
GetSecondaryAxis());
250 const pandora::CartesianVector &showerTertiaryVector(larShowerPCA.
GetTertiaryAxis());
251 const pandora::CartesianVector &showerEigenValues(larShowerPCA.
GetEigenValues());
253 const bool svdOK(
true);
254 const double eigenValues[3] = {showerEigenValues.GetX(), showerEigenValues.GetY(), showerEigenValues.GetZ()};
255 const double avePosition[3] = {showerCentroid.GetX(), showerCentroid.GetY(), showerCentroid.GetZ()};
257 std::vector< std::vector<double> > eigenVecs = {
258 { showerDirection.GetX(), showerDirection.GetY(), showerDirection.GetZ() },
259 { showerSecondaryVector.GetX(), showerSecondaryVector.GetY(), showerSecondaryVector.GetZ() },
260 { showerTertiaryVector.GetX(), showerTertiaryVector.GetY(), showerTertiaryVector.GetZ() }
264 const int numHitsUsed(100);
265 const double aveHitDoca(0.);
268 return recob::PCAxis(svdOK, numHitsUsed, eigenValues, eigenVecs, avePosition, aveHitDoca, iD);
static LArShowerPCA GetPrincipalComponents(const pandora::CartesianPointVector &pointVector, const pandora::CartesianVector &vertexPosition)
Perform PCA analysis on a set of 3D points and return results.
void produce(art::Event &evt) override
Header file for the pfo helper class.
recob::PCAxis BuildPCAxis(const lar_content::LArShowerPCA &larShowerPCA) const
Build a recob::PCAxis object.
std::map< art::Ptr< recob::PFParticle >, ClusterVector > PFParticlesToClusters
Algorithm(s) calculating energy.
LArPandoraShowerCreation & operator=(LArPandoraShowerCreation const &)=delete
const pandora::CartesianVector & GetCentroid() const
Return centroid.
bool m_useAllParticles
Build a recob::Track for every recob::PFParticle.
float GetPrimaryLength() const
Return primary length.
std::vector< art::Ptr< recob::PFParticle > > PFParticleVector
Header file for lar pfo objects.
Declaration of signal hit object.
recob::Shower BuildShower(const lar_content::LArShowerPCA &larShowerPCA, const pandora::CartesianVector &vertexPosition) const
Build a recob::Shower object.
static bool IsShower(const art::Ptr< recob::PFParticle > particle)
Determine whether a particle has been reconstructed as shower-like.
constexpr int kBogusI
obviously bogus integer value
ProductID put(std::unique_ptr< PROD > &&product)
std::string m_pfParticleLabel
The pf particle label.
LArPandoraShowerCreation(fhicl::ParameterSet const &pset)
#define DEFINE_ART_MODULE(klass)
const pandora::CartesianVector & GetEigenValues() const
Return vector of eigenvalues.
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.
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.
std::map< art::Ptr< recob::PFParticle >, VertexVector > PFParticlesToVertices
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.
const Double32_t * XYZ() const
const pandora::CartesianVector & GetAxisLengths() const
Return vector of lengths.
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
Utility object to perform functions of association.
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
const pandora::CartesianVector & GetSecondaryAxis() const
Return secondary axis.
std::map< art::Ptr< recob::PFParticle >, SpacePointVector > PFParticlesToSpacePoints
const pandora::CartesianVector & GetTertiaryAxis() const
Return tertiary axis.
float GetSecondaryLength() const
Return secondary length.
helper function for LArPandoraInterface producer module
art framework interface to geometry description
const pandora::CartesianVector & GetPrimaryAxis() const
Return primary axis.
std::vector< art::Ptr< recob::Vertex > > VertexVector