33 if (!pPfoList || pPfoList->empty())
36 std::cout <<
"NeutrinoDaughterVerticesAlgorithm: unable to find pfo list " <<
m_neutrinoListName << std::endl;
38 return STATUS_CODE_SUCCESS;
48 return STATUS_CODE_SUCCESS;
57 for (PfoList::const_iterator pIter = pPfoList->begin(), pIterEnd = pPfoList->end(); pIter != pIterEnd; ++pIter)
65 for (PfoList::const_iterator pIter = outputList.begin(), pIterEnd = outputList.end(); pIter != pIterEnd; ++pIter)
70 if (clusterList.empty())
73 pfoVector.push_back(*pIter);
83 for (PfoVector::const_iterator pIter = pfoList.begin(), pIterEnd = pfoList.end(); pIter != pIterEnd; ++pIter)
93 for (ClusterList::const_iterator cIter = clusterList.begin(), cIterEnd = clusterList.end(); cIter != cIterEnd; ++cIter)
95 const Cluster *
const pCluster = *cIter;
101 if (!pointingClusterMap.insert(LArPointingClusterMap::value_type(pCluster, pointingCluster)).second)
106 if (STATUS_CODE_FAILURE == statusCodeException.
GetStatusCode())
107 throw statusCodeException;
117 for (PfoVector::const_iterator iter = pfoVector.begin(), iterEnd = pfoVector.end(); iter != iterEnd; ++iter)
145 if (parentList.empty() && pParentPfo->
GetVertexList().empty())
148 bool foundVtx(
false);
149 float vtxDistance(0.f);
153 for (ClusterList::const_iterator dIter = daughterList.begin(), dIterEnd = daughterList.end(); dIter != dIterEnd; ++dIter)
155 const Cluster *
const pDaughterCluster = *dIter;
157 CartesianVector minPosition(0.f, 0.f, 0.f), maxPosition(0.f, 0.f, 0.f);
158 CartesianVector minDirection(0.f, 0.f, 0.f), maxDirection(0.f, 0.f, 0.f);
159 bool foundDirection(
false);
161 LArPointingClusterMap::const_iterator cIter = pointingClusterMap.find(pDaughterCluster);
163 if (pointingClusterMap.end() != cIter)
171 foundDirection =
true;
178 if ((maxPosition - minPosition).GetMagnitudeSquared() < std::numeric_limits<float>::epsilon())
183 minDirection = (maxPosition - minPosition).GetUnitVector();
184 maxDirection = (minPosition - maxPosition).GetUnitVector();
187 float minDistance(std::numeric_limits<float>::max());
188 float maxDistance(std::numeric_limits<float>::max());
190 for (ClusterList::const_iterator pIter = parentList.begin(), pIterEnd = parentList.end(); pIter != pIterEnd; ++pIter)
192 const Cluster *
const pParentCluster = *pIter;
200 minDistance = std::min(minDistance, (pVertex->
GetPosition() - minPosition).GetMagnitude());
201 maxDistance = std::min(maxDistance, (pVertex->
GetPosition() - maxPosition).GetMagnitude());
204 if (!foundVtx || (minDistance < vtxDistance))
207 vtxDistance = minDistance;
208 vtxPosition = minPosition;
209 vtxDirection = minDirection;
212 if (!foundVtx || (maxDistance < vtxDistance))
215 vtxDistance = maxDistance;
216 vtxPosition = maxPosition;
217 vtxDirection = maxDirection;
243 if (daughterList.empty())
255 if (parentList.empty())
258 bool foundVtx(
false);
259 float vtxDistanceSquared(0.f);
262 for (ClusterList::const_iterator dIter = daughterList.begin(), dIterEnd = daughterList.end(); dIter != dIterEnd; ++dIter)
264 const Cluster *
const pDaughterCluster = *dIter;
266 for (ClusterList::const_iterator pIter = parentList.begin(), pIterEnd = parentList.end(); pIter != pIterEnd; ++pIter)
268 const Cluster *
const pParentCluster = *pIter;
270 CartesianVector closestDaughterPosition(0.f, 0.f, 0.f), closestParentPosition(0.f, 0.f, 0.f);
273 const float closestDistanceSquared((closestDaughterPosition - closestParentPosition).GetMagnitudeSquared());
275 if (!foundVtx || closestDistanceSquared < vtxDistanceSquared)
278 vtxDistanceSquared = closestDistanceSquared;
298 PandoraContentApi::ParticleFlowObject::Metadata metadata;
299 metadata.m_momentum = vtxDirection;
303 std::string vertexListName;
306 PandoraContentApi::Vertex::Parameters parameters;
307 parameters.m_position = vtxPosition;
311 const Vertex *pVertex(NULL);
312 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Vertex::Create(*
this, parameters, pVertex));
314 if (!pVertexList->empty())
335 return STATUS_CODE_SUCCESS;
Header file for the cluster helper class.
Header file for the geometry helper class.
Header file for the pfo helper class.
Header file for the neutrino daughter vertices algorithm class.
#define PANDORA_THROW_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
#define PANDORA_THROW_RESULT_IF(StatusCode1, Operator, Command)
#define PANDORA_RETURN_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
#define PANDORA_RETURN_RESULT_IF(StatusCode1, Operator, Command)
static pandora::StatusCode ReplaceCurrentList(const pandora::Algorithm &algorithm, const std::string &newListName)
Replace the current list with a pre-saved list; use this new list as a permanent replacement for the ...
static pandora::StatusCode CreateTemporaryListAndSetCurrent(const pandora::Algorithm &algorithm, const T *&pT, std::string &temporaryListName)
Create a temporary list and set it to be the current list, enabling object creation.
static pandora::StatusCode GetList(const pandora::Algorithm &algorithm, const std::string &listName, const T *&pT)
Get a named list.
static const pandora::PandoraSettings * GetSettings(const pandora::Algorithm &algorithm)
Get the pandora settings instance.
static pandora::CartesianVector GetClosestPosition(const pandora::CartesianVector &position, const pandora::ClusterList &clusterList)
Get closest position in a list of clusters to a specified input position vector.
static void GetClosestPositions(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2, pandora::CartesianVector &position1, pandora::CartesianVector &position2)
Get pair of closest positions for a pair of clusters.
static void GetExtremalCoordinates(const pandora::ClusterList &clusterList, pandora::CartesianVector &innerCoordinate, pandora::CartesianVector &outerCoordinate)
Get positions of the two most distant calo hits in a list of cluster (ordered by Z)
static float GetClosestDistance(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2)
Get closest distance between clusters in a pair of cluster lists.
static float GetWireZPitch(const pandora::Pandora &pandora, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
static void GetAllDownstreamPfos(const pandora::PfoList &inputPfoList, pandora::PfoList &outputPfoList)
Get a flat list of all pfos, recursively, of all daughters associated with those pfos in an input lis...
static bool IsTrack(const pandora::ParticleFlowObject *const pPfo)
Return track flag based on Pfo Particle ID.
static bool IsNeutrino(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a neutrino or (antineutrino)
static void GetClusters(const pandora::PfoList &pfoList, const pandora::HitType &hitType, pandora::ClusterList &clusterList)
Get a list of clusters of a particular hit type from a list of pfos.
const pandora::CartesianVector & GetDirection() const
Get the vertex direction.
const pandora::CartesianVector & GetPosition() const
Get the vertex position.
LArPointingCluster class.
const Vertex & GetInnerVertex() const
Get the inner vertex.
const Vertex & GetOuterVertex() const
Get the outer vertex.
void BuildDaughterShower(const pandora::ParticleFlowObject *const pDaughterPfo) const
Reconstruct the vertex and direction of a shower-like Pfos.
void GetDaughterPfos(const pandora::PfoList *const pfoList, pandora::PfoVector &pfoVector) const
Get the vector of daughter pfos.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
void BuildDaughterParticles(const LArPointingClusterMap &pointingClusterMap, const pandora::PfoVector &pfoVector) const
Reconstruct the vertex and direction of daughter Pfos.
void BuildDaughterTrack(const LArPointingClusterMap &pointingClusterMap, const pandora::ParticleFlowObject *const pDaughterPfo) const
Reconstruct the vertex and direction of a track-like Pfos.
void BuildPointingClusterMap(const pandora::PfoVector &pfoVector, LArPointingClusterMap &pointingClusterMap) const
Build a map of 3D sliding fits from the input Pfos.
unsigned int m_halfWindowLayers
number of layers to use for half-window of sliding fit
void SetParticleParameters(const pandora::CartesianVector &vtxPosition, const pandora::CartesianVector &vtxDirection, const pandora::ParticleFlowObject *const pPfo) const
Set the vertex and direction of the Pfos.
std::string m_vertexListName
The name of the output cosmic-ray vertex list.
bool m_useParentShowerVertex
use the parent pfo for the shower vertices
std::string m_neutrinoListName
The input list of pfo list names.
pandora::StatusCode Run()
Run the algorithm.
NeutrinoDaughterVerticesAlgorithm()
Default constructor.
bool ShouldDisplayAlgorithmInfo() const
Whether to display algorithm information during processing.
ParticleFlowObject class.
const PfoList & GetParentPfoList() const
Get the parent pfo list.
const VertexList & GetVertexList() const
Get the vertex list.
StatusCode AlterMetadata(const object_creation::ParticleFlowObject::Metadata &metadata)
Alter particle flow object metadata parameters.
const Pandora & GetPandora() const
Get the associated pandora instance.
StatusCodeException class.
StatusCode GetStatusCode() const
Get status code.
const CartesianVector & GetPosition() const
Get the vertex position.
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
std::unordered_map< const pandora::Cluster *, LArPointingCluster > LArPointingClusterMap
MANAGED_CONTAINER< const Cluster * > ClusterList
std::vector< const ParticleFlowObject * > PfoVector
MANAGED_CONTAINER< const Vertex * > VertexList
StatusCode
The StatusCode enum.
MANAGED_CONTAINER< const ParticleFlowObject * > PfoList