LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
TwoViewShowerHitsTool.cc
Go to the documentation of this file.
1 
9 #include "Pandora/AlgorithmHeaders.h"
10 
12 
13 using namespace pandora;
14 
15 namespace lar_content
16 {
17 
18 void 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 
36 void 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
TFile f
Definition: plotHisto.C:6
Header file for the two view shower hits tool.