9 #include "Pandora/AlgorithmHeaders.h" 10 #include "Pandora/AlgorithmTool.h" 25 ProtoShowerMatchingTool::ProtoShowerMatchingTool() :
26 m_spineSlidingFitWindow(20),
27 m_maxXSeparation(5.
f),
29 m_maxAngularDeviation(5.
f)
38 IntVector usedProtoShowersU, usedProtoShowersV, usedProtoShowersW;
42 for (
unsigned int uIndex = 0; uIndex < protoShowerVectorU.size(); ++uIndex)
46 if (std::find(usedProtoShowersU.begin(), usedProtoShowersU.end(), uIndex) != usedProtoShowersU.end())
49 const ProtoShower &protoShowerU(protoShowerVectorU.at(uIndex));
51 for (
unsigned int vIndex = 0; vIndex < protoShowerVectorV.size(); ++vIndex)
53 if (std::find(usedProtoShowersV.begin(), usedProtoShowersV.end(), vIndex) != usedProtoShowersV.end())
56 const ProtoShower &protoShowerV(protoShowerVectorV.at(vIndex));
58 for (
unsigned int wIndex = 0; wIndex < protoShowerVectorW.size(); ++wIndex)
60 if (std::find(usedProtoShowersW.begin(), usedProtoShowersW.end(), wIndex) != usedProtoShowersW.end())
63 const ProtoShower &protoShowerW(protoShowerVectorW.at(wIndex));
69 usedProtoShowersU.push_back(uIndex);
70 usedProtoShowersV.push_back(vIndex);
71 usedProtoShowersW.push_back(wIndex);
73 protoShowerMatchVector.push_back(
ProtoShowerMatch(protoShowerU, protoShowerV, protoShowerW, consistency));
84 return STATUS_CODE_SUCCESS;
116 const float xSeparationUV(std::fabs(showerStartU.GetX() - showerStartV.GetX()));
117 const float xSeparationUW(std::fabs(showerStartU.GetX() - showerStartW.GetX()));
118 const float xSeparationVW(std::fabs(showerStartV.GetX() - showerStartW.GetX()));
124 CartesianVector projectionU(0.
f, 0.
f, 0.
f), projectionV(0.
f, 0.
f, 0.
f), projectionW(0.
f, 0.
f, 0.
f);
130 const float separationU((projectionU - showerStartU).GetMagnitude());
131 const float separationV((projectionV - showerStartV).GetMagnitude());
132 const float separationW((projectionW - showerStartW).GetMagnitude());
134 const float metric((separationU + separationV + separationW) / 3.
f);
153 const bool isDownstream(
156 CartesianPointVector spinePositionsU, spinePositionsV, spinePositionsW;
159 spinePositionsU.push_back(pCaloHit->GetPositionVector());
162 spinePositionsV.push_back(pCaloHit->GetPositionVector());
165 spinePositionsW.push_back(pCaloHit->GetPositionVector());
185 const CartesianVector wireAxis(0.
f, 0.
f, 1.
f);
187 float wireDeviationU(directionU.GetOpeningAngle(wireAxis));
188 wireDeviationU = std::min(wireDeviationU, static_cast<float>(M_PI - wireDeviationU));
190 float wireDeviationV(directionV.GetOpeningAngle(wireAxis));
191 wireDeviationV = std::min(wireDeviationV, static_cast<float>(M_PI - wireDeviationV));
193 float wireDeviationW(directionW.GetOpeningAngle(wireAxis));
194 wireDeviationW = std::min(wireDeviationW, static_cast<float>(M_PI - wireDeviationW));
196 float radians((2.
f * M_PI) / 180.
f);
197 bool isIsochronous((wireDeviationU < radians) && (wireDeviationV < radians) && (wireDeviationW < radians));
202 directionU = CartesianVector(std::fabs(directionU.GetX()), 0.
f, directionU.GetZ());
203 directionV = CartesianVector(std::fabs(directionV.GetX()), 0.
f, directionV.GetZ());
204 directionW = CartesianVector(std::fabs(directionW.GetX()), 0.
f, directionW.GetZ());
207 if (directionU.GetX() * directionV.GetX() < 0.f)
210 if (directionU.GetX() * directionW.GetX() < 0.f)
213 if (directionV.GetX() * directionW.GetX() < 0.f)
220 float openingAngleU(directionU.GetOpeningAngle(projectionU) * 180.f / M_PI);
221 float openingAngleV(directionV.GetOpeningAngle(projectionV) * 180.f / M_PI);
222 float openingAngleW(directionW.GetOpeningAngle(projectionW) * 180.f / M_PI);
226 openingAngleU = std::min(openingAngleU, 180.
f - openingAngleU);
227 openingAngleV = std::min(openingAngleV, 180.
f - openingAngleV);
228 openingAngleW = std::min(openingAngleW, 180.
f - openingAngleW);
241 PANDORA_RETURN_RESULT_IF_AND_IF(
242 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"SpineSlidingFitWindow",
m_spineSlidingFitWindow));
244 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"MaxXSeparation",
m_maxXSeparation));
246 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"MaxSeparation",
m_maxSeparation));
248 PANDORA_RETURN_RESULT_IF_AND_IF(
249 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"MaxAngularDeviation",
m_maxAngularDeviation));
251 return STATUS_CODE_SUCCESS;
Header file for the ProtoShower class.
Header file for the connection pathway helper class.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Consistency
Consistency enumeration.
static pandora::CartesianVector MergeTwoDirections(const pandora::Pandora &pandora, const pandora::HitType view1, const pandora::HitType view2, const pandora::CartesianVector &direction1, const pandora::CartesianVector &direction2)
Merge two views (U,V) to give a third view (Z).
const ConnectionPathway & GetConnectionPathway() const
Get the connection pathway.
pandora::StatusCode Run(const ProtoShowerVector &protoShowerVectorU, const ProtoShowerVector &protoShowerVectorV, const ProtoShowerVector &protoShowerVectorW, ProtoShowerMatchVector &protoShowerMatchVector)
bool AreDirectionsConsistent(const ProtoShower &protoShowerU, const ProtoShower &protoShowerV, const ProtoShower &protoShowerW) const
Determine whether three 2D initial spine directions correspond to the same 3D initial spine direction...
std::vector< int > IntVector
float m_maxXSeparation
The max. drift-coordinate separation between matched 2D shower start positions.
pandora::CartesianVector GetGlobalMinLayerDirection() const
Get global direction corresponding to the fit result in minimum fit layer.
const pandora::CaloHitList & GetSpineHitList() const
Get the spine hit list.
const pandora::CartesianVector & GetStartPosition() const
Get the start position of the connection pathway.
Header file for the geometry helper class.
unsigned int m_spineSlidingFitWindow
The shower spine sliding fit window.
bool AreShowerStartsConsistent(const ProtoShower &protoShowerU, const ProtoShower &protoShowerV, const ProtoShower &protoShowerW) const
Determine whether three 2D shower start positions correspond to the same 3D shower start position...
const pandora::CartesianVector & GetStartPosition() const
Get the start position of the shower core.
Header file for the lar two dimensional sliding fit result class.
static float MergeTwoPositions(const pandora::Pandora &pandora, const pandora::HitType view1, const pandora::HitType view2, const float position1, const float position2)
Merge two views (U,V) to give a third view (Z).
static float GetWirePitch(const pandora::Pandora &pandora, const pandora::HitType view, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
float m_maxAngularDeviation
The max. opening angle between true and projected 2D initial directions for a match.
float m_maxSeparation
The max. average separation between true and projected 2D shower start positions for a match...
std::vector< ProtoShowerMatch > ProtoShowerMatchVector
std::vector< ProtoShower > ProtoShowerVector
pandora::CartesianVector GetGlobalMaxLayerDirection() const
Get global direction corresponding to the fit result in maximum fit layer.
const ShowerCore & GetShowerCore() const
Get the shower core.
bool ArePathwaysConsistent(const ProtoShower &protoShowerU, const ProtoShower &protoShowerV, const ProtoShower &protoShowerW, Consistency &consistency) const
Determine whether three 2D connection pathways form a consistent 3D connection pathway.
TwoDSlidingFitResult class.
const pandora::CartesianVector & GetStartDirection() const
Get the start direction of the connection pathway.