LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
DeltaRayShowerHitsTool.cc
Go to the documentation of this file.
1 
9 #include "Pandora/AlgorithmHeaders.h"
10 
14 
17 
18 using namespace pandora;
19 
20 namespace lar_content
21 {
22 
23 void DeltaRayShowerHitsTool::Run(ThreeDHitCreationAlgorithm *const pAlgorithm, const ParticleFlowObject *const pPfo,
24  const CaloHitVector &inputTwoDHits, ProtoHitVector &protoHitVector)
25 {
26  if (PandoraContentApi::GetSettings(*pAlgorithm)->ShouldDisplayAlgorithmInfo())
27  std::cout << "----> Running Algorithm Tool: " << this->GetInstanceName() << ", " << this->GetType() << std::endl;
28 
29  try
30  {
31  if (!LArPfoHelper::IsShower(pPfo) || (1 != pPfo->GetParentPfoList().size()))
32  return;
33 
34  const ParticleFlowObject *const pParentPfo(pPfo->GetParentPfoList().front());
35 
36  CaloHitList parentHitList3D;
37  LArPfoHelper::GetCaloHits(pParentPfo, TPC_3D, parentHitList3D);
38 
39  if (parentHitList3D.empty())
40  return;
41 
42  CaloHitVector parentHitVector3D(parentHitList3D.begin(), parentHitList3D.end());
43  std::sort(parentHitVector3D.begin(), parentHitVector3D.end(), LArClusterHelper::SortHitsByPosition);
44 
45  this->CreateDeltaRayShowerHits3D(inputTwoDHits, parentHitVector3D, protoHitVector);
46  }
47  catch (StatusCodeException &)
48  {
49  }
50 }
51 
52 //------------------------------------------------------------------------------------------------------------------------------------------
53 
54 void DeltaRayShowerHitsTool::CreateDeltaRayShowerHits3D(const CaloHitVector &inputTwoDHits, const CaloHitVector &parentHits3D,
55  ProtoHitVector &protoHitVector) const
56 {
57  for (const CaloHit *const pCaloHit2D : inputTwoDHits)
58  {
59  try
60  {
61  const HitType hitType(pCaloHit2D->GetHitType());
62  const HitType hitType1((TPC_VIEW_U == hitType) ? TPC_VIEW_V : (TPC_VIEW_V == hitType) ? TPC_VIEW_W : TPC_VIEW_U);
63  const HitType hitType2((TPC_VIEW_U == hitType) ? TPC_VIEW_W : (TPC_VIEW_V == hitType) ? TPC_VIEW_U : TPC_VIEW_V);
64 
65  bool foundClosestPosition(false);
66  float closestDistanceSquared(std::numeric_limits<float>::max());
67  CartesianVector closestPosition3D(0.f, 0.f, 0.f);
68 
69  for (const CaloHit *const pCaloHit3D : parentHits3D)
70  {
71  const CartesianVector thisPosition3D(pCaloHit3D->GetPositionVector());
72  const CartesianVector thisPosition2D(LArGeometryHelper::ProjectPosition(this->GetPandora(), thisPosition3D, hitType));
73  const float thisDistanceSquared((pCaloHit2D->GetPositionVector() - thisPosition2D).GetMagnitudeSquared());
74 
75  if (thisDistanceSquared < closestDistanceSquared)
76  {
77  foundClosestPosition = true;
78  closestDistanceSquared = thisDistanceSquared;
79  closestPosition3D = thisPosition3D;
80  }
81  }
82 
83  if (!foundClosestPosition)
84  continue;
85 
86  const CartesianVector position1(LArGeometryHelper::ProjectPosition(this->GetPandora(), closestPosition3D, hitType1));
87  const CartesianVector position2(LArGeometryHelper::ProjectPosition(this->GetPandora(), closestPosition3D, hitType2));
88 
89  ProtoHit protoHit(pCaloHit2D);
90  this->GetBestPosition3D(hitType1, hitType2, position1, position2, protoHit);
91 
92  if (protoHit.IsPositionSet())
93  protoHitVector.push_back(protoHit);
94  }
95  catch (StatusCodeException &)
96  {
97  }
98  }
99 }
100 
101 } // namespace lar_content
Header file for the pfo helper class.
Proto hits are temporary constructs to be used during iterative 3D hit procedure. ...
ThreeDHitCreationAlgorithm::ProtoHitVector ProtoHitVector
bool IsPositionSet() const
Whether the proto hit position is set.
TFile f
Definition: plotHisto.C:6
Header file for the three dimensional hit creation algorithm class.
Header file for the geometry helper class.
Int_t max
Definition: plot.C:27
Header file for the cluster helper class.
ThreeDHitCreationAlgorithm::Algorithm class.
Header file for the delta ray shower hits tool.