27 std::cout <<
"LArStitchingHelper::FindClosestTPC - functionality only available to primary/master Pandora instance " << std::endl;
33 const LArTPC *pClosestTPC(
nullptr);
34 float closestSeparation(std::numeric_limits<float>::max());
35 const float maxDisplacement(30.f);
37 for (
const LArTPCMap::value_type &mapEntry : larTPCMap)
39 const LArTPC &checkTPC(*(mapEntry.second));
41 if (&inputTPC == &checkTPC)
51 if (deltaY > maxDisplacement || deltaZ > maxDisplacement)
54 if (deltaX < closestSeparation)
56 closestSeparation = deltaX;
57 pClosestTPC = &checkTPC;
64 return (*pClosestTPC);
71 if (&firstTPC == &secondTPC)
86 const float maxDisplacement(30.f);
92 if (std::fabs(deltaX - widthX) > maxDisplacement || deltaY > maxDisplacement || deltaZ > maxDisplacement)
108 if ((&firstTPCCheck == &firstTPC) && (&secondTPCCheck == &secondTPC))
121 if ((&firstTPCCheck == &firstTPC) && (&secondTPCCheck == &secondTPC))
173 return std::sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ);
181 if (&larTPC1 == &larTPC2)
189 if (std::fabs(dx1) < std::numeric_limits<float>::epsilon() || std::fabs(dx2) < std::numeric_limits<float>::epsilon())
192 const bool useInner1((dxVolume > 0.f) == (dx1 < 0.f));
193 const bool useInner2((dxVolume > 0.f) == (dx2 > 0.f));
202 const float dxNearNear(0.f);
203 const float dyNearNear(nearVertex1.GetPosition().GetY() - nearVertex2.GetPosition().GetY());
204 const float dzNearNear(nearVertex1.GetPosition().GetZ() - nearVertex2.GetPosition().GetZ());
205 const float drNearNearSquared(dxNearNear * dxNearNear + dyNearNear * dyNearNear + dzNearNear * dzNearNear);
207 const float dxNearFar(std::fabs(dx2));
208 const float dyNearFar(nearVertex1.GetPosition().GetY() - farVertex2.GetPosition().GetY());
209 const float dzNearFar(nearVertex1.GetPosition().GetZ() - farVertex2.GetPosition().GetZ());
210 const float drNearFarSquared(dxNearFar * dxNearFar + dyNearFar * dyNearFar + dzNearFar * dzNearFar);
212 const float dxFarNear(std::fabs(dx1));
213 const float dyFarNear(farVertex1.GetPosition().GetY() - nearVertex2.GetPosition().GetY());
214 const float dzFarNear(farVertex1.GetPosition().GetZ() - nearVertex2.GetPosition().GetZ());
215 const float drFarNearSquared(dxFarNear * dxFarNear + dyFarNear * dyFarNear + dzFarNear * dzFarNear);
217 const float dxFarFar(std::fabs(dx1) + std::fabs(dx2));
218 const float dyFarFar(farVertex1.GetPosition().GetY() - farVertex2.GetPosition().GetY());
219 const float dzFarFar(farVertex1.GetPosition().GetZ() - farVertex2.GetPosition().GetZ());
220 const float drFarFarSquared(dxFarFar * dxFarFar + dyFarFar * dyFarFar + dzFarFar * dzFarFar);
222 if (drNearNearSquared > std::min(drFarFarSquared, std::min(drNearFarSquared, drFarNearSquared)))
225 closestVertex1 = nearVertex1;
226 closestVertex2 = nearVertex2;
234 if (&firstTPC == &secondTPC)
245 if (std::fabs(firstDirectionX.
GetX()) > 1.f - std::numeric_limits<float>::epsilon() ||
246 std::fabs(secondDirectionX.
GetX()) > 1.f - std::numeric_limits<float>::epsilon())
249 if (-firstDirectionX.
GetDotProduct(secondDirectionX) < std::numeric_limits<float>::epsilon())
259 const float firstDirectionYZmag(firstDirectionYZ.
GetMagnitude());
260 const float secondDirectionYZmag(secondDirectionYZ.
GetMagnitude());
262 if (firstDirectionYZmag < std::numeric_limits<float>::epsilon() || secondDirectionYZmag < std::numeric_limits<float>::epsilon())
274 return (X1 + X2) * 0.25f;
295 const PropertiesMap::const_iterator iter(properties.find(
"X0"));
297 if (iter != properties.end())
Header file for the geometry manager class.
Header file for the helper class for multiple drift volumes.
Header file for the MultiPandoraApi class.
static const PandoraInstanceMap & GetPandoraInstanceMap()
Get the pandora instance map.
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.
static bool SortTPCs(const pandora::LArTPC *const pLhs, const pandora::LArTPC *const pRhs)
Sort tpcs by central positions.
static bool CanTPCsBeStitched(const pandora::LArTPC &firstTPC, const pandora::LArTPC &secondTPC)
Whether particles from a given pair of tpcs can be stitched together.
static bool HasPfoBeenStitched(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo has been stitched.
static const pandora::LArTPC & FindClosestTPC(const pandora::Pandora &pandora, const pandora::LArTPC &inputTPC, const bool checkPositive)
Find closest tpc to a specified input tpc.
static float GetTPCBoundaryWidthX(const pandora::LArTPC &firstTPC, const pandora::LArTPC &secondTPC)
Determine width in X at the boundary between a pair of tpcs.
static bool AreTPCsAdjacent(const pandora::LArTPC &firstTPC, const pandora::LArTPC &secondTPC)
Whether a pair of drift volumes are adjacent to each other.
static float GetPfoX0(const pandora::ParticleFlowObject *const pPfo)
Return the x0 for a pfo.
static float GetTPCBoundaryCenterX(const pandora::LArTPC &firstTPC, const pandora::LArTPC &secondTPC)
Determine centre in X at the boundary between a pair of tpcs.
static float GetTPCDisplacement(const pandora::LArTPC &firstTPC, const pandora::LArTPC &secondTPC)
Calculate distance between central positions of a pair of tpcs.
static void GetClosestVertices(const pandora::LArTPC &larTPC1, const pandora::LArTPC &larTPC2, const LArPointingCluster &pointingCluster1, const LArPointingCluster &pointingCluster2, LArPointingCluster::Vertex &closestVertex1, LArPointingCluster::Vertex &closestVertex2)
Given a pair of pointing clusters, find the pair of vertices with smallest yz-separation.
static float CalculateX0(const pandora::LArTPC &firstTPC, const pandora::LArTPC &secondTPC, const LArPointingCluster::Vertex &firstVertex, const LArPointingCluster::Vertex &secondVertex)
Calculate X0 for a pair of vertices.
float GetX() const
Get the cartesian x coordinate.
CartesianVector GetUnitVector() const
Get a unit vector in the direction of the cartesian vector.
float GetZ() const
Get the cartesian z coordinate.
float GetDotProduct(const CartesianVector &rhs) const
Get the dot product of the cartesian vector with a second cartesian vector.
float GetMagnitude() const
Get the magnitude.
float GetY() const
Get the cartesian y coordinate.
float GetCenterY() const
Get center in y, units mm.
float GetCenterZ() const
Get center in z, units mm.
bool IsDriftInPositiveX() const
Whether the electron drift is in the positive x direction.
float GetCenterX() const
Get center in x, units mm.
float GetWidthX() const
Get the width in x, units mm.
ParticleFlowObject class.
const PropertiesMap & GetPropertiesMap() const
Get the map from registered property name to floating point property value.
StatusCodeException class.
std::map< unsigned int, const LArTPC * > LArTPCMap
std::map< std::string, float > PropertiesMap