9 #include "Pandora/AlgorithmHeaders.h" 10 #include "Pandora/AlgorithmTool.h" 25 ProtoShowerMatchingTool::ProtoShowerMatchingTool() :
26 m_spineSlidingFitWindow(20),
27 m_maxXSeparation(5.
f),
29 m_xExtrapolation(5.
f),
30 m_maxAngularDeviation(5.
f)
39 IntVector usedProtoShowersU, usedProtoShowersV, usedProtoShowersW;
43 for (
unsigned int uIndex = 0; uIndex < protoShowerVectorU.size(); ++uIndex)
47 if (std::find(usedProtoShowersU.begin(), usedProtoShowersU.end(), uIndex) != usedProtoShowersU.end())
50 const ProtoShower &protoShowerU(protoShowerVectorU.at(uIndex));
52 for (
unsigned int vIndex = 0; vIndex < protoShowerVectorV.size(); ++vIndex)
54 if (std::find(usedProtoShowersV.begin(), usedProtoShowersV.end(), vIndex) != usedProtoShowersV.end())
57 const ProtoShower &protoShowerV(protoShowerVectorV.at(vIndex));
59 for (
unsigned int wIndex = 0; wIndex < protoShowerVectorW.size(); ++wIndex)
61 if (std::find(usedProtoShowersW.begin(), usedProtoShowersW.end(), wIndex) != usedProtoShowersW.end())
64 const ProtoShower &protoShowerW(protoShowerVectorW.at(wIndex));
70 usedProtoShowersU.push_back(uIndex);
71 usedProtoShowersV.push_back(vIndex);
72 usedProtoShowersW.push_back(wIndex);
74 protoShowerMatchVector.push_back(
ProtoShowerMatch(protoShowerU, protoShowerV, protoShowerW, consistency));
85 return STATUS_CODE_SUCCESS;
117 const float xSeparationUV(std::fabs(showerStartU.GetX() - showerStartV.GetX()));
118 const float xSeparationUW(std::fabs(showerStartU.GetX() - showerStartW.GetX()));
119 const float xSeparationVW(std::fabs(showerStartV.GetX() - showerStartW.GetX()));
125 CartesianVector projectionU(0.
f, 0.
f, 0.
f), projectionV(0.
f, 0.
f, 0.
f), projectionW(0.
f, 0.
f, 0.
f);
131 const float separationU((projectionU - showerStartU).GetMagnitude());
132 const float separationV((projectionV - showerStartV).GetMagnitude());
133 const float separationW((projectionW - showerStartW).GetMagnitude());
135 const float metric((separationU + separationV + separationW) / 3.
f);
155 const bool isDownstream(
158 CartesianPointVector spinePositionsU, spinePositionsV, spinePositionsW;
161 spinePositionsU.push_back(pCaloHit->GetPositionVector());
164 spinePositionsV.push_back(pCaloHit->GetPositionVector());
167 spinePositionsW.push_back(pCaloHit->GetPositionVector());
179 directionV2, directionW2);
188 const CartesianVector &nuVertexW,
const CartesianVector &directionU,
const CartesianVector &directionV,
const CartesianVector &directionW)
const 190 const CartesianVector wireAxis(0.
f, 0.
f, 1.
f);
192 float wireDeviationU(directionU.GetOpeningAngle(wireAxis));
193 wireDeviationU = std::min(wireDeviationU, static_cast<float>(M_PI - wireDeviationU));
195 float wireDeviationV(directionV.GetOpeningAngle(wireAxis));
196 wireDeviationV = std::min(wireDeviationV, static_cast<float>(M_PI - wireDeviationV));
198 float wireDeviationW(directionW.GetOpeningAngle(wireAxis));
199 wireDeviationW = std::min(wireDeviationW, static_cast<float>(M_PI - wireDeviationW));
201 float radians((2.
f * M_PI) / 180.
f);
202 bool isIsochronous((wireDeviationU < radians) && (wireDeviationV < radians) && (wireDeviationW < radians));
207 if (directionU.GetX() * directionV.GetX() < 0.f)
210 if (directionU.GetX() * directionW.GetX() < 0.f)
213 if (directionV.GetX() * directionW.GetX() < 0.f)
216 const CartesianVector xAxis(1.
f, 0.
f, 0.
f);
217 const float cosOpeningAngleU(std::fabs(directionU.GetCosOpeningAngle(xAxis)));
218 const float cosOpeningAngleV(std::fabs(directionV.GetCosOpeningAngle(xAxis)));
219 const float cosOpeningAngleW(std::fabs(directionW.GetCosOpeningAngle(xAxis)));
220 const CartesianVector uPoint(nuVertexU + (directionU * (
m_xExtrapolation / cosOpeningAngleU)));
221 const CartesianVector vPoint(nuVertexV + (directionV * (
m_xExtrapolation / cosOpeningAngleV)));
222 const CartesianVector wPoint(nuVertexW + (directionW * (
m_xExtrapolation / cosOpeningAngleW)));
224 float chiSquared(0.
f);
226 CartesianVector projectionPointU(0.
f, 0.
f, 0.
f);
229 CartesianVector projectionPointV(0.
f, 0.
f, 0.
f);
232 CartesianVector projectionPointW(0.
f, 0.
f, 0.
f);
236 const CartesianVector projectionU((projectionPointU - nuVertexU).GetUnitVector());
239 const CartesianVector projectionV((projectionPointV - nuVertexV).GetUnitVector());
242 const CartesianVector projectionW((projectionPointW - nuVertexW).GetUnitVector());
244 float openingAngleU(directionU.GetOpeningAngle(projectionU) * 180.f / M_PI);
245 float openingAngleV(directionV.GetOpeningAngle(projectionV) * 180.f / M_PI);
246 float openingAngleW(directionW.GetOpeningAngle(projectionW) * 180.f / M_PI);
248 const float metric((openingAngleU + openingAngleV + openingAngleW) / 3.
f);
260 PANDORA_RETURN_RESULT_IF_AND_IF(
261 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"SpineSlidingFitWindow",
m_spineSlidingFitWindow));
263 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"MaxXSeparation",
m_maxXSeparation));
265 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"MaxSeparation",
m_maxSeparation));
267 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"XExtrapolation",
m_xExtrapolation));
269 PANDORA_RETURN_RESULT_IF_AND_IF(
270 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"MaxAngularDeviation",
m_maxAngularDeviation));
272 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.
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.
float m_xExtrapolation
Extrapolation distance in the x-direction.
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.