LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
ShowerHitsBaseTool.cc
Go to the documentation of this file.
1 
9 #include "Pandora/AlgorithmHeaders.h"
10 
12 
15 
16 using namespace pandora;
17 
18 namespace lar_content
19 {
20 
21 ShowerHitsBaseTool::ShowerHitsBaseTool() :
22  m_xTolerance(1.f)
23 {
24 }
25 
26 //------------------------------------------------------------------------------------------------------------------------------------------
27 
28 void ShowerHitsBaseTool::Run(ThreeDHitCreationAlgorithm *const pAlgorithm, const ParticleFlowObject *const pPfo,
29  const CaloHitVector &inputTwoDHits, ProtoHitVector &protoHitVector)
30 {
31  if (PandoraContentApi::GetSettings(*pAlgorithm)->ShouldDisplayAlgorithmInfo())
32  std::cout << "----> Running Algorithm Tool: " << this->GetInstanceName() << ", " << this->GetType() << std::endl;
33 
34  try
35  {
36  if (!LArPfoHelper::IsShower(pPfo))
37  return;
38 
39  CaloHitVector caloHitVectorU, caloHitVectorV, caloHitVectorW;
40  pAlgorithm->FilterCaloHitsByType(inputTwoDHits, TPC_VIEW_U, caloHitVectorU);
41  pAlgorithm->FilterCaloHitsByType(inputTwoDHits, TPC_VIEW_V, caloHitVectorV);
42  pAlgorithm->FilterCaloHitsByType(inputTwoDHits, TPC_VIEW_W, caloHitVectorW);
43 
44  this->GetShowerHits3D(caloHitVectorU, caloHitVectorV, caloHitVectorW, protoHitVector);
45  this->GetShowerHits3D(caloHitVectorV, caloHitVectorU, caloHitVectorW, protoHitVector);
46  this->GetShowerHits3D(caloHitVectorW, caloHitVectorU, caloHitVectorV, protoHitVector);
47  }
48  catch (StatusCodeException &)
49  {
50  }
51 }
52 
53 //------------------------------------------------------------------------------------------------------------------------------------------
54 
55 void ShowerHitsBaseTool::GetShowerHits3D(const CaloHitVector &inputTwoDHits, const CaloHitVector &caloHitVector1,
56  const CaloHitVector &caloHitVector2, ProtoHitVector &protoHitVector) const
57 {
58  for (const CaloHit *const pCaloHit2D : inputTwoDHits)
59  {
60  try
61  {
62  CaloHitVector filteredHits1, filteredHits2;
63  this->FilterCaloHits(pCaloHit2D->GetPositionVector().GetX(), m_xTolerance, caloHitVector1, filteredHits1);
64  this->FilterCaloHits(pCaloHit2D->GetPositionVector().GetX(), m_xTolerance, caloHitVector2, filteredHits2);
65 
66  ProtoHit protoHit(pCaloHit2D);
67  this->GetShowerHit3D(filteredHits1, filteredHits2, protoHit);
68 
69  if (protoHit.IsPositionSet() && (protoHit.GetChi2() < m_chiSquaredCut))
70  protoHitVector.push_back(protoHit);
71  }
72  catch (StatusCodeException &)
73  {
74  }
75  }
76 }
77 
78 //------------------------------------------------------------------------------------------------------------------------------------------
79 
80 void ShowerHitsBaseTool::FilterCaloHits(const float x, const float xTolerance, const CaloHitVector &inputCaloHitVector, CaloHitVector &outputCaloHitVector) const
81 {
82  for (const CaloHit *const pCaloHit : inputCaloHitVector)
83  {
84  const float deltaX(pCaloHit->GetPositionVector().GetX() - x);
85 
86  if (std::fabs(deltaX) < xTolerance)
87  outputCaloHitVector.push_back(pCaloHit);
88  }
89 }
90 
91 //------------------------------------------------------------------------------------------------------------------------------------------
92 
93 StatusCode ShowerHitsBaseTool::ReadSettings(const TiXmlHandle xmlHandle)
94 {
95  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "XTolerance", m_xTolerance));
96 
97  return HitCreationBaseTool::ReadSettings(xmlHandle);
98 }
99 
100 } // namespace lar_content
Float_t x
Definition: compare.C:6
Header file for the pfo helper class.
Proto hits are temporary constructs to be used during iterative 3D hit procedure. ...
Header file for the shower hits base tool.
ThreeDHitCreationAlgorithm::ProtoHitVector ProtoHitVector
float m_xTolerance
The x tolerance to use when looking for associated calo hits between views.
double m_chiSquaredCut
The chi squared cut (accept only values below the cut value)
void FilterCaloHits(const float x, const float xTolerance, const pandora::CaloHitVector &inputCaloHitVector, pandora::CaloHitVector &outputCaloHitVector) const
Filter a list of calo hits to find those within a specified tolerance of a give x position...
TFile f
Definition: plotHisto.C:6
Header file for the three dimensional hit creation algorithm class.
static bool IsShower(const pandora::ParticleFlowObject *const pPfo)
Return shower flag based on Pfo Particle ID.
virtual void GetShowerHit3D(const pandora::CaloHitVector &caloHitVector1, const pandora::CaloHitVector &caloHitVector2, ProtoHit &protoHit) const =0
Get the three dimensional position for to a two dimensional calo hit, using the hit and a list of can...
virtual void GetShowerHits3D(const pandora::CaloHitVector &inputTwoDHits, const pandora::CaloHitVector &caloHitVector1, const pandora::CaloHitVector &caloHitVector2, ProtoHitVector &protoHitVector) const
Create three dimensional hits, using a list of input two dimensional hits and the hits (contained in ...
ThreeDHitCreationAlgorithm::Algorithm class.
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
void FilterCaloHitsByType(const pandora::CaloHitVector &inputCaloHitVector, const pandora::HitType hitType, pandora::CaloHitVector &outputCaloHitVector) const
Get the subset of a provided calo hit vector corresponding to a specified hit type.
virtual void Run(ThreeDHitCreationAlgorithm *const pAlgorithm, const pandora::ParticleFlowObject *const pPfo, const pandora::CaloHitVector &inputTwoDHits, ProtoHitVector &protoHitVector)
Run the algorithm tool.