9 #include "Pandora/AlgorithmHeaders.h" 20 HitCreationBaseTool::HitCreationBaseTool() : m_sigmaX2(1.), m_chiSquaredCut(1.)
33 const CartesianPointVector &fitPositionList2,
ProtoHit &protoHit)
const 35 if (fitPositionList1.empty() && fitPositionList2.empty())
37 throw StatusCodeException(STATUS_CODE_NOT_FOUND);
39 else if (fitPositionList1.empty())
41 if (fitPositionList2.size() != 1)
42 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
46 else if (fitPositionList2.empty())
48 if (fitPositionList1.size() != 1)
49 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
55 for (
const CartesianVector &fitPosition1 : fitPositionList1)
57 for (
const CartesianVector &fitPosition2 : fitPositionList2)
60 this->
GetBestPosition3D(hitType1, hitType2, fitPosition1, fitPosition2, thisProtoHit);
63 protoHit = thisProtoHit;
74 const CartesianVector &fitPosition2,
ProtoHit &protoHit)
const 78 const HitType hitType(pCaloHit2D->GetHitType());
81 const double sigmaHit(sigmaFit);
83 CartesianVector position3D(0.
f, 0.
f, 0.
f);
86 const double u((TPC_VIEW_U == hitType) ? pCaloHit2D->GetPositionVector().GetZ()
87 : (TPC_VIEW_U == hitType1) ? fitPosition1.GetZ() : fitPosition2.GetZ());
88 const double v((TPC_VIEW_V == hitType) ? pCaloHit2D->GetPositionVector().GetZ()
89 : (TPC_VIEW_V == hitType1) ? fitPosition1.GetZ() : fitPosition2.GetZ());
90 const double w((TPC_VIEW_W == hitType) ? pCaloHit2D->GetPositionVector().GetZ()
91 : (TPC_VIEW_W == hitType1) ? fitPosition1.GetZ() : fitPosition2.GetZ());
93 const double sigmaU((TPC_VIEW_U == hitType) ? sigmaHit : sigmaFit);
94 const double sigmaV((TPC_VIEW_V == hitType) ? sigmaHit : sigmaFit);
95 const double sigmaW((TPC_VIEW_W == hitType) ? sigmaHit : sigmaFit);
98 this->GetPandora().GetPlugins()->GetLArTransformationPlugin()->GetMinChiSquaredYZ(u, v,
w, sigmaU, sigmaV, sigmaW, bestY, bestZ, chi2);
99 position3D.SetValues(pCaloHit2D->GetPositionVector().GetX(),
static_cast<float>(bestY), static_cast<float>(bestZ));
101 const double deltaX1(pCaloHit2D->GetPositionVector().GetX() - fitPosition1.GetX());
102 const double deltaX2(pCaloHit2D->GetPositionVector().GetX() - fitPosition2.GetX());
103 const double chi2X(((deltaX1 * deltaX1) /
m_sigmaX2) + ((deltaX2 * deltaX2) /
m_sigmaX2));
118 if (pCaloHit2D->GetHitType() == hitType)
119 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
121 CartesianVector position3D(0.
f, 0.
f, 0.
f);
124 this->GetPandora(), pCaloHit2D->GetHitType(), hitType, pCaloHit2D->GetPositionVector(), fitPosition, position3D, chi2);
127 const double deltaX(pCaloHit2D->GetPositionVector().GetX() - fitPosition.GetX());
128 const double chi2X((deltaX * deltaX) /
m_sigmaX2);
140 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"SigmaX", sigmaX));
144 if (
m_sigmaX2 < std::numeric_limits<double>::epsilon())
146 std::cout <<
"HitCreationBaseTool - Invalid parameter, SigmaX: " << sigmaX <<
std::endl;
147 return STATUS_CODE_INVALID_PARAMETER;
150 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"ChiSquaredCut",
m_chiSquaredCut));
152 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...
static int max(int a, int b)
virtual ~HitCreationBaseTool()
Destructor.
void SetPosition3D(const pandora::CartesianVector &position3D, const double chi2)
Set position 3D.
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
QTextStream & endl(QTextStream &s)