9 #include "Pandora/AlgorithmHeaders.h" 20 HitCreationBaseTool::HitCreationBaseTool() :
35 const CartesianPointVector &fitPositionList2,
ProtoHit &protoHit)
const 37 if (fitPositionList1.empty() && fitPositionList2.empty())
39 throw StatusCodeException(STATUS_CODE_NOT_FOUND);
41 else if (fitPositionList1.empty())
43 if (fitPositionList2.size() != 1)
44 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
48 else if (fitPositionList2.empty())
50 if (fitPositionList1.size() != 1)
51 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
57 for (
const CartesianVector &fitPosition1 : fitPositionList1)
59 for (
const CartesianVector &fitPosition2 : fitPositionList2)
62 this->
GetBestPosition3D(hitType1, hitType2, fitPosition1, fitPosition2, thisProtoHit);
65 protoHit = thisProtoHit;
76 const CartesianVector &fitPosition2,
ProtoHit &protoHit)
const 80 const HitType hitType(pCaloHit2D->GetHitType());
83 const double sigmaHit(sigmaFit);
85 CartesianVector position3D(0.
f, 0.
f, 0.
f);
86 double chi2(std::numeric_limits<double>::max());
88 const double u((TPC_VIEW_U == hitType) ? pCaloHit2D->GetPositionVector().GetZ()
89 : (TPC_VIEW_U == hitType1) ? fitPosition1.GetZ()
90 : fitPosition2.GetZ());
91 const double v((TPC_VIEW_V == hitType) ? pCaloHit2D->GetPositionVector().GetZ()
92 : (TPC_VIEW_V == hitType1) ? fitPosition1.GetZ()
93 : fitPosition2.GetZ());
94 const double w((TPC_VIEW_W == hitType) ? pCaloHit2D->GetPositionVector().GetZ()
95 : (TPC_VIEW_W == hitType1) ? fitPosition1.GetZ()
96 : fitPosition2.GetZ());
98 const double sigmaU((TPC_VIEW_U == hitType) ? sigmaHit : sigmaFit);
99 const double sigmaV((TPC_VIEW_V == hitType) ? sigmaHit : sigmaFit);
100 const double sigmaW((TPC_VIEW_W == hitType) ? sigmaHit : sigmaFit);
102 double bestY(std::numeric_limits<double>::max()), bestZ(std::numeric_limits<double>::max());
103 this->GetPandora().GetPlugins()->GetLArTransformationPlugin()->GetMinChiSquaredYZ(u, v,
w, sigmaU, sigmaV, sigmaW, bestY, bestZ, chi2);
104 position3D.SetValues(pCaloHit2D->GetPositionVector().GetX(),
static_cast<float>(bestY), static_cast<float>(bestZ));
106 const double deltaX1(pCaloHit2D->GetPositionVector().GetX() - fitPosition1.GetX());
107 const double deltaX2(pCaloHit2D->GetPositionVector().GetX() - fitPosition2.GetX());
108 const double chi2X(((deltaX1 * deltaX1) /
m_sigmaX2) + ((deltaX2 * deltaX2) /
m_sigmaX2));
123 if (pCaloHit2D->GetHitType() == hitType)
124 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
126 CartesianVector position3D(0.
f, 0.
f, 0.
f);
127 float chi2(std::numeric_limits<float>::max());
129 this->GetPandora(), pCaloHit2D->GetHitType(), hitType, pCaloHit2D->GetPositionVector(), fitPosition, position3D, chi2);
132 const double deltaX(pCaloHit2D->GetPositionVector().GetX() - fitPosition.GetX());
133 const double chi2X((deltaX * deltaX) /
m_sigmaX2);
145 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"SigmaX", sigmaX));
149 if (
m_sigmaX2 < std::numeric_limits<double>::epsilon())
151 std::cout <<
"HitCreationBaseTool - Invalid parameter, SigmaX: " << sigmaX << std::endl;
152 return STATUS_CODE_INVALID_PARAMETER;
155 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"ChiSquaredCut",
m_chiSquaredCut));
157 return STATUS_CODE_SUCCESS;
Proto hits are temporary constructs to be used during iterative 3D hit procedure. ...
static float GetSigmaUVW(const pandora::Pandora &pandora, const float maxSigmaDiscrepancy=0.01)
Find the sigmaUVW value for the detector geometry.
static void MergeTwoPositions3D(const pandora::Pandora &pandora, const pandora::HitType view1, const pandora::HitType view2, const pandora::CartesianVector &position1, const pandora::CartesianVector &position2, pandora::CartesianVector &position3D, float &chiSquared)
Merge 2D positions from two views to give unified 3D position.
double m_sigmaX2
The sigmaX squared value, for calculation of chi2 deltaX term.
const pandora::CaloHit * GetParentCaloHit2D() const
Get the address of the parent 2D calo hit.
ThreeDHitCreationAlgorithm::TrajectorySample TrajectorySample
bool IsPositionSet() const
Whether the proto hit position is set.
double m_chiSquaredCut
The chi squared cut (accept only values below the cut value)
void AddTrajectorySample(const TrajectorySample &trajectorySample)
Add a trajectory sample.
Header file for the geometry helper class.
double GetChi2() const
Get the chi squared value.
virtual void GetBestPosition3D(const pandora::HitType hitType1, const pandora::HitType hitType2, const pandora::CartesianPointVector &fitPositionList1, const pandora::CartesianPointVector &fitPositionList2, ProtoHit &protoHit) const
Get the three dimensional position using a provided two dimensional calo hit and candidate fit positi...
virtual ~HitCreationBaseTool()
Destructor.
void SetPosition3D(const pandora::CartesianVector &position3D, const double chi2)
Set position 3D.
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)