Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
TwoViewShowerHitsTool.cc
Go to the documentation of this file.
1
10
12
13using namespace pandora;
14
15namespace lar_content
16{
17
18void TwoViewShowerHitsTool::GetShowerHit3D(const CaloHitVector &caloHitVector1, const CaloHitVector &caloHitVector2, ProtoHit &protoHit) const
19{
20 if (!caloHitVector1.empty() && caloHitVector2.empty())
21 {
22 this->GetShowerHit3D(caloHitVector1, protoHit);
23 }
24 else if (caloHitVector1.empty() && !caloHitVector2.empty())
25 {
26 this->GetShowerHit3D(caloHitVector2, protoHit);
27 }
28 else
29 {
30 throw StatusCodeException(STATUS_CODE_NOT_FOUND);
31 }
32}
33
34//------------------------------------------------------------------------------------------------------------------------------------------
35
36void TwoViewShowerHitsTool::GetShowerHit3D(const CaloHitVector &caloHitVector, ProtoHit &protoHit) const
37{
38 if (caloHitVector.empty())
39 throw StatusCodeException(STATUS_CODE_NOT_FOUND);
40
41 const CaloHit *const pCaloHit2D(protoHit.GetParentCaloHit2D());
42 const HitType hitType(caloHitVector.at(0)->GetHitType());
43
44 if (pCaloHit2D->GetHitType() == hitType)
45 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
46
47 double Sqz(0.), Sqx(0.), Sq(0.);
48
49 for (const CaloHit *const pCaloHit : caloHitVector)
50 {
51 Sqx += pCaloHit->GetMipEquivalentEnergy() * pCaloHit->GetPositionVector().GetX();
52 Sqz += pCaloHit->GetMipEquivalentEnergy() * pCaloHit->GetPositionVector().GetZ();
53 Sq += pCaloHit->GetMipEquivalentEnergy();
54 }
55
56 if (Sq < std::numeric_limits<double>::epsilon())
57 throw StatusCodeException(STATUS_CODE_FAILURE);
58
59 const CartesianVector position(static_cast<float>(Sqx / Sq), 0.f, static_cast<float>(Sqz / Sq));
60 this->GetBestPosition3D(hitType, position, protoHit);
61}
62
63} // namespace lar_content
Grouping of header files for many classes of use in particle flow algorithms.
Header file for the two view shower hits tool.
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...
Proto hits are temporary constructs to be used during iterative 3D hit procedure.
const pandora::CaloHit * GetParentCaloHit2D() const
Get the address of the parent 2D calo hit.
void GetShowerHit3D(const pandora::CaloHitVector &caloHitVector1, const pandora::CaloHitVector &caloHitVector2, ProtoHit &protoHit) const
Get the three dimensional position for to a two dimensional calo hit, using the hit and a list of can...
CaloHit class.
Definition CaloHit.h:26
HitType GetHitType() const
Get the calorimeter hit type.
Definition CaloHit.h:441
CartesianVector class.
StatusCodeException class.
HitType
Calorimeter hit type enum.
std::vector< const CaloHit * > CaloHitVector