9 #include "Pandora/AlgorithmHeaders.h" 18 void TwoViewShowerHitsTool::GetShowerHit3D(
const CaloHitVector &caloHitVector1,
const CaloHitVector &caloHitVector2, ProtoHit &protoHit)
const 20 if (!caloHitVector1.empty() && caloHitVector2.empty())
22 this->GetShowerHit3D(caloHitVector1, protoHit);
24 else if (caloHitVector1.empty() && !caloHitVector2.empty())
26 this->GetShowerHit3D(caloHitVector2, protoHit);
30 throw StatusCodeException(STATUS_CODE_NOT_FOUND);
36 void TwoViewShowerHitsTool::GetShowerHit3D(
const CaloHitVector &caloHitVector, ProtoHit &protoHit)
const 38 if (caloHitVector.empty())
39 throw StatusCodeException(STATUS_CODE_NOT_FOUND);
41 const CaloHit *
const pCaloHit2D(protoHit.GetParentCaloHit2D());
42 const HitType hitType(caloHitVector.at(0)->GetHitType());
44 if (pCaloHit2D->GetHitType() == hitType)
45 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
47 double Sqz(0.), Sqx(0.), Sq(0.);
49 for (
const CaloHit *
const pCaloHit : caloHitVector)
51 Sqx += pCaloHit->GetMipEquivalentEnergy() * pCaloHit->GetPositionVector().GetX();
52 Sqz += pCaloHit->GetMipEquivalentEnergy() * pCaloHit->GetPositionVector().GetZ();
53 Sq += pCaloHit->GetMipEquivalentEnergy();
56 if (Sq < std::numeric_limits<double>::epsilon())
57 throw StatusCodeException(STATUS_CODE_FAILURE);
59 const CartesianVector
position(static_cast<float>(Sqx / Sq), 0.
f, static_cast<float>(Sqz / Sq));
60 this->GetBestPosition3D(hitType,
position, protoHit);