45 const pandora::CartesianVector& vertexPosition)
const;
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>>();
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(
124 int showerCounter(0);
145 pfParticlesToSpacePoints.find(pPFParticle));
147 if (pfParticlesToSpacePoints.end() == particleToSpacePointIter) {
148 mf::LogDebug(
"LArPandoraShowerCreation") <<
"No spacepoints associated to particle ";
154 pfParticlesToClusters.find(pPFParticle));
156 if (pfParticlesToClusters.end() == particleToClustersIter) {
157 mf::LogDebug(
"LArPandoraShowerCreation") <<
"No clusters associated to particle ";
163 pfParticlesToVertices.find(pPFParticle));
165 if ((pfParticlesToVertices.end() == particleToVertexIter) ||
166 (1 != particleToVertexIter->second.size())) {
167 mf::LogDebug(
"LArPandoraShowerCreation") <<
"Unexpected number of vertices for particle ";
172 pandora::CartesianPointVector cartesianPointVector;
174 cartesianPointVector.emplace_back(pandora::CartesianVector(
175 spacePoint->
XYZ()[0], spacePoint->
XYZ()[1], spacePoint->
XYZ()[2]));
177 double vertexXYZ[3] = {0., 0., 0.};
178 particleToVertexIter->second.front()->XYZ(vertexXYZ);
179 const pandora::CartesianVector vertexPosition(vertexXYZ[0], vertexXYZ[1], vertexXYZ[2]);
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());
195 const pandora::CartesianVector projectedVertexPosition(
197 primaryAxis.GetUnitVector() * (centroid - vertexPosition).GetDotProduct(primaryAxis));
200 const float testProjection(primaryAxis.GetDotProduct(projectedVertexPosition - centroid));
201 const float directionScaleFactor(
202 (testProjection > std::numeric_limits<float>::epsilon()) ? -1.
f : 1.
f);
205 primaryAxis * directionScaleFactor,
206 secondaryAxis * directionScaleFactor,
207 tertiaryAxis * directionScaleFactor,
210 showerCounter++, larShowerPCA, projectedVertexPosition));
212 outputShowers->emplace_back(shower);
213 outputPCAxes->emplace_back(pcAxis);
215 catch (
const pandora::StatusCodeException&) {
216 mf::LogDebug(
"LArPandoraShowerCreation") <<
"Unable to extract shower pca";
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()));
235 mf::LogDebug(
"LArPandora") <<
" Number of new showers: " << outputShowers->size()
237 mf::LogDebug(
"LArPandora") <<
" Number of new pcaxes: " << outputPCAxes->size() << std::endl;
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));
252 const pandora::CartesianVector& vertexPosition)
const 254 const pandora::CartesianVector& showerLength(larShowerPCA.
GetAxisLengths());
255 const pandora::CartesianVector& showerDirection(larShowerPCA.
GetPrimaryAxis());
257 const float length(showerLength.GetX());
258 const float openingAngle(
262 const TVector3 direction(
263 showerDirection.GetX(), showerDirection.GetY(), showerDirection.GetZ());
264 const TVector3
vertex(vertexPosition.GetX(), vertexPosition.GetY(), vertexPosition.GetZ());
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);
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());
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()};
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()}};
316 const int numHitsUsed(100);
317 const double aveHitDoca(0.);
320 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.
LArPandoraShowerCreation & operator=(LArPandoraShowerCreation const &)=delete
const pandora::CartesianVector & GetCentroid() const
Return centroid.
std::map< art::Ptr< recob::PFParticle >, ClusterVector > PFParticlesToClusters
bool m_useAllParticles
Build a recob::Track for every recob::PFParticle.
float GetPrimaryLength() const
Return primary length.
Header file for lar pfo objects.
Declaration of signal hit object.
EDProducer(fhicl::ParameterSet const &pset)
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.
constexpr int kBogusI
obviously bogus integer value
std::map< art::Ptr< recob::PFParticle >, VertexVector > PFParticlesToVertices
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
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.
LArPandoraShowerCreation(fhicl::ParameterSet const &pset)
#define DEFINE_ART_MODULE(klass)
const pandora::CartesianVector & GetEigenValues() const
Return vector of eigenvalues.
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
const pandora::CartesianVector & GetAxisLengths() const
Return vector of lengths.
std::map< art::Ptr< recob::PFParticle >, SpacePointVector > PFParticlesToSpacePoints
float dEdx(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, TP3D &tp3d)
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
Utility object to perform functions of association.
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
std::vector< art::Ptr< recob::Vertex > > VertexVector
const pandora::CartesianVector & GetSecondaryAxis() const
Return secondary axis.
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.