LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
lar_content::ProtoShowerMatchingTool Class Reference

#include "ProtoShowerMatchingTool.h"

Inheritance diagram for lar_content::ProtoShowerMatchingTool:

Public Member Functions

 ProtoShowerMatchingTool ()
 Default constructor. More...
 
pandora::StatusCode Run (const ProtoShowerVector &protoShowerVectorU, const ProtoShowerVector &protoShowerVectorV, const ProtoShowerVector &protoShowerVectorW, ProtoShowerMatchVector &protoShowerMatchVector)
 

Private Member Functions

pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 
bool ArePathwaysConsistent (const ProtoShower &protoShowerU, const ProtoShower &protoShowerV, const ProtoShower &protoShowerW, Consistency &consistency) const
 Determine whether three 2D connection pathways form a consistent 3D connection pathway. More...
 
bool AreShowerStartsConsistent (const ProtoShower &protoShowerU, const ProtoShower &protoShowerV, const ProtoShower &protoShowerW) const
 Determine whether three 2D shower start positions correspond to the same 3D shower start position. More...
 
bool AreDirectionsConsistent (const ProtoShower &protoShowerU, const ProtoShower &protoShowerV, const ProtoShower &protoShowerW) const
 Determine whether three 2D initial spine directions correspond to the same 3D initial spine direction. More...
 
bool AreDirectionsConsistent (pandora::CartesianVector directionU, pandora::CartesianVector directionV, pandora::CartesianVector directionW) const
 Determine whether three 2D initial spine directions correspond to the same 3D initial spine direction. More...
 

Private Attributes

unsigned int m_spineSlidingFitWindow
 The shower spine sliding fit window. More...
 
float m_maxXSeparation
 The max. drift-coordinate separation between matched 2D shower start positions. More...
 
float m_maxSeparation
 The max. average separation between true and projected 2D shower start positions for a match. More...
 
float m_maxAngularDeviation
 The max. opening angle between true and projected 2D initial directions for a match. More...
 

Detailed Description

Definition at line 19 of file ProtoShowerMatchingTool.h.

Constructor & Destructor Documentation

lar_content::ProtoShowerMatchingTool::ProtoShowerMatchingTool ( )

Default constructor.

Definition at line 25 of file ProtoShowerMatchingTool.cc.

25  :
28  m_maxSeparation(5.f),
30 {
31 }
float m_maxXSeparation
The max. drift-coordinate separation between matched 2D shower start positions.
TFile f
Definition: plotHisto.C:6
unsigned int m_spineSlidingFitWindow
The shower spine sliding fit window.
float m_maxAngularDeviation
The max. opening angle between true and projected 2D initial directions for a match.
float m_maxSeparation
The max. average separation between true and projected 2D shower start positions for a match...

Member Function Documentation

bool lar_content::ProtoShowerMatchingTool::AreDirectionsConsistent ( const ProtoShower protoShowerU,
const ProtoShower protoShowerV,
const ProtoShower protoShowerW 
) const
private

Determine whether three 2D initial spine directions correspond to the same 3D initial spine direction.

Parameters
protoShowerUthe U view ProtoShower
protoShowerVthe V view ProtoShower
protoShowerWthe W view ProtoShower
Returns
whether three 2D initial spine directions correspond to the same 3D initial spine direction

Definition at line 141 of file ProtoShowerMatchingTool.cc.

References f, lar_content::ProtoShower::GetConnectionPathway(), lar_content::TwoDSlidingFitResult::GetGlobalMaxLayerDirection(), lar_content::TwoDSlidingFitResult::GetGlobalMinLayerDirection(), lar_content::ProtoShower::GetShowerCore(), lar_content::ProtoShower::GetSpineHitList(), lar_content::ConnectionPathway::GetStartDirection(), lar_content::ShowerCore::GetStartPosition(), lar_content::ConnectionPathway::GetStartPosition(), lar_content::LArGeometryHelper::GetWirePitch(), m_maxAngularDeviation, m_spineSlidingFitWindow, and lar_content::LArGeometryHelper::MergeTwoDirections().

Referenced by ArePathwaysConsistent().

142 {
143  const CartesianVector &directionU1(protoShowerU.GetConnectionPathway().GetStartDirection());
144  const CartesianVector &directionV1(protoShowerV.GetConnectionPathway().GetStartDirection());
145  const CartesianVector &directionW1(protoShowerW.GetConnectionPathway().GetStartDirection());
146 
147  if (this->AreDirectionsConsistent(directionU1, directionV1, directionW1))
148  {
149  return true;
150  }
151  else
152  {
153  const bool isDownstream(
154  protoShowerW.GetShowerCore().GetStartPosition().GetZ() > protoShowerW.GetConnectionPathway().GetStartPosition().GetZ());
155 
156  CartesianPointVector spinePositionsU, spinePositionsV, spinePositionsW;
157 
158  for (const CaloHit *const pCaloHit : protoShowerU.GetSpineHitList())
159  spinePositionsU.push_back(pCaloHit->GetPositionVector());
160 
161  for (const CaloHit *const pCaloHit : protoShowerV.GetSpineHitList())
162  spinePositionsV.push_back(pCaloHit->GetPositionVector());
163 
164  for (const CaloHit *const pCaloHit : protoShowerW.GetSpineHitList())
165  spinePositionsW.push_back(pCaloHit->GetPositionVector());
166 
167  const TwoDSlidingFitResult spineFitU(&spinePositionsU, m_spineSlidingFitWindow, LArGeometryHelper::GetWirePitch(this->GetPandora(), TPC_VIEW_U));
168  const TwoDSlidingFitResult spineFitV(&spinePositionsV, m_spineSlidingFitWindow, LArGeometryHelper::GetWirePitch(this->GetPandora(), TPC_VIEW_V));
169  const TwoDSlidingFitResult spineFitW(&spinePositionsW, m_spineSlidingFitWindow, LArGeometryHelper::GetWirePitch(this->GetPandora(), TPC_VIEW_W));
170 
171  const CartesianVector directionU2(isDownstream ? spineFitU.GetGlobalMinLayerDirection() : spineFitU.GetGlobalMaxLayerDirection() * (-1.f));
172  const CartesianVector directionV2(isDownstream ? spineFitV.GetGlobalMinLayerDirection() : spineFitV.GetGlobalMaxLayerDirection() * (-1.f));
173  const CartesianVector directionW2(isDownstream ? spineFitW.GetGlobalMinLayerDirection() : spineFitW.GetGlobalMaxLayerDirection() * (-1.f));
174 
175  return this->AreDirectionsConsistent(directionU2, directionV2, directionW2);
176  }
177 
178  return false;
179 }
bool AreDirectionsConsistent(const ProtoShower &protoShowerU, const ProtoShower &protoShowerV, const ProtoShower &protoShowerW) const
Determine whether three 2D initial spine directions correspond to the same 3D initial spine direction...
unsigned int m_spineSlidingFitWindow
The shower spine sliding fit window.
static float GetWirePitch(const pandora::Pandora &pandora, const pandora::HitType view, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
bool lar_content::ProtoShowerMatchingTool::AreDirectionsConsistent ( pandora::CartesianVector  directionU,
pandora::CartesianVector  directionV,
pandora::CartesianVector  directionW 
) const
private

Determine whether three 2D initial spine directions correspond to the same 3D initial spine direction.

Parameters
directionUthe U view initial spine direction
directionUthe V view initial spine direction
directionUthe W view initial spine direction
Returns
whether three 2D initial spine directions correspond to the same 3D initial spine direction
bool lar_content::ProtoShowerMatchingTool::ArePathwaysConsistent ( const ProtoShower protoShowerU,
const ProtoShower protoShowerV,
const ProtoShower protoShowerW,
Consistency consistency 
) const
private

Determine whether three 2D connection pathways form a consistent 3D connection pathway.

Parameters
protoShowerUthe U view ProtoShower
protoShowerVthe V view ProtoShower
protoShowerWthe W view ProtoShower
consistencythe basis of the match
Returns
whether three 2D connection pathways form a consistent 3D connection pathway

Definition at line 89 of file ProtoShowerMatchingTool.cc.

References AreDirectionsConsistent(), AreShowerStartsConsistent(), lar_content::DIRECTION, and lar_content::POSITION.

Referenced by Run().

91 {
92  if (this->AreShowerStartsConsistent(protoShowerU, protoShowerV, protoShowerW))
93  {
94  consistency = Consistency::POSITION;
95  }
96  else if (this->AreDirectionsConsistent(protoShowerU, protoShowerV, protoShowerW))
97  {
98  consistency = Consistency::DIRECTION;
99  }
100  else
101  {
102  return false;
103  }
104 
105  return true;
106 }
bool AreDirectionsConsistent(const ProtoShower &protoShowerU, const ProtoShower &protoShowerV, const ProtoShower &protoShowerW) const
Determine whether three 2D initial spine directions correspond to the same 3D initial spine direction...
bool AreShowerStartsConsistent(const ProtoShower &protoShowerU, const ProtoShower &protoShowerV, const ProtoShower &protoShowerW) const
Determine whether three 2D shower start positions correspond to the same 3D shower start position...
bool lar_content::ProtoShowerMatchingTool::AreShowerStartsConsistent ( const ProtoShower protoShowerU,
const ProtoShower protoShowerV,
const ProtoShower protoShowerW 
) const
private

Determine whether three 2D shower start positions correspond to the same 3D shower start position.

Parameters
protoShowerUthe U view ProtoShower
protoShowerVthe V view ProtoShower
protoShowerWthe W view ProtoShower
Returns
whether three 2D shower start positions correspond to the same 3D shower start position

Definition at line 110 of file ProtoShowerMatchingTool.cc.

References f, lar_content::ProtoShower::GetShowerCore(), lar_content::ShowerCore::GetStartPosition(), m_maxSeparation, m_maxXSeparation, and lar_content::LArGeometryHelper::MergeTwoPositions().

Referenced by ArePathwaysConsistent().

111 {
112  const CartesianVector &showerStartU(protoShowerU.GetShowerCore().GetStartPosition());
113  const CartesianVector &showerStartV(protoShowerV.GetShowerCore().GetStartPosition());
114  const CartesianVector &showerStartW(protoShowerW.GetShowerCore().GetStartPosition());
115 
116  const float xSeparationUV(std::fabs(showerStartU.GetX() - showerStartV.GetX()));
117  const float xSeparationUW(std::fabs(showerStartU.GetX() - showerStartW.GetX()));
118  const float xSeparationVW(std::fabs(showerStartV.GetX() - showerStartW.GetX()));
119 
120  if ((xSeparationUV > m_maxXSeparation) || (xSeparationUW > m_maxXSeparation) || (xSeparationVW > m_maxXSeparation))
121  return false;
122 
123  float chi2(0.f);
124  CartesianVector projectionU(0.f, 0.f, 0.f), projectionV(0.f, 0.f, 0.f), projectionW(0.f, 0.f, 0.f);
125 
126  LArGeometryHelper::MergeTwoPositions(this->GetPandora(), TPC_VIEW_V, TPC_VIEW_W, showerStartV, showerStartW, projectionU, chi2);
127  LArGeometryHelper::MergeTwoPositions(this->GetPandora(), TPC_VIEW_W, TPC_VIEW_U, showerStartW, showerStartU, projectionV, chi2);
128  LArGeometryHelper::MergeTwoPositions(this->GetPandora(), TPC_VIEW_U, TPC_VIEW_V, showerStartU, showerStartV, projectionW, chi2);
129 
130  const float separationU((projectionU - showerStartU).GetMagnitude());
131  const float separationV((projectionV - showerStartV).GetMagnitude());
132  const float separationW((projectionW - showerStartW).GetMagnitude());
133 
134  const float metric((separationU + separationV + separationW) / 3.f);
135 
136  return (metric < m_maxSeparation);
137 }
float m_maxXSeparation
The max. drift-coordinate separation between matched 2D shower start positions.
TFile f
Definition: plotHisto.C:6
static float MergeTwoPositions(const pandora::Pandora &pandora, const pandora::HitType view1, const pandora::HitType view2, const float position1, const float position2)
Merge two views (U,V) to give a third view (Z).
float m_maxSeparation
The max. average separation between true and projected 2D shower start positions for a match...
StatusCode lar_content::ProtoShowerMatchingTool::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 239 of file ProtoShowerMatchingTool.cc.

References m_maxAngularDeviation, m_maxSeparation, m_maxXSeparation, and m_spineSlidingFitWindow.

240 {
241  PANDORA_RETURN_RESULT_IF_AND_IF(
242  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "SpineSlidingFitWindow", m_spineSlidingFitWindow));
243 
244  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MaxXSeparation", m_maxXSeparation));
245 
246  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MaxSeparation", m_maxSeparation));
247 
248  PANDORA_RETURN_RESULT_IF_AND_IF(
249  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MaxAngularDeviation", m_maxAngularDeviation));
250 
251  return STATUS_CODE_SUCCESS;
252 }
float m_maxXSeparation
The max. drift-coordinate separation between matched 2D shower start positions.
unsigned int m_spineSlidingFitWindow
The shower spine sliding fit window.
float m_maxAngularDeviation
The max. opening angle between true and projected 2D initial directions for a match.
float m_maxSeparation
The max. average separation between true and projected 2D shower start positions for a match...
StatusCode lar_content::ProtoShowerMatchingTool::Run ( const ProtoShowerVector protoShowerVectorU,
const ProtoShowerVector protoShowerVectorV,
const ProtoShowerVector protoShowerVectorW,
ProtoShowerMatchVector protoShowerMatchVector 
)

Definition at line 35 of file ProtoShowerMatchingTool.cc.

References ArePathwaysConsistent(), and lar_content::POSITION.

Referenced by lar_content::ElectronInitialRegionRefinementAlgorithm::RefineShower().

37 {
38  IntVector usedProtoShowersU, usedProtoShowersV, usedProtoShowersW;
39 
40  bool added(false);
41 
42  for (unsigned int uIndex = 0; uIndex < protoShowerVectorU.size(); ++uIndex)
43  {
44  added = false;
45 
46  if (std::find(usedProtoShowersU.begin(), usedProtoShowersU.end(), uIndex) != usedProtoShowersU.end())
47  continue;
48 
49  const ProtoShower &protoShowerU(protoShowerVectorU.at(uIndex));
50 
51  for (unsigned int vIndex = 0; vIndex < protoShowerVectorV.size(); ++vIndex)
52  {
53  if (std::find(usedProtoShowersV.begin(), usedProtoShowersV.end(), vIndex) != usedProtoShowersV.end())
54  continue;
55 
56  const ProtoShower &protoShowerV(protoShowerVectorV.at(vIndex));
57 
58  for (unsigned int wIndex = 0; wIndex < protoShowerVectorW.size(); ++wIndex)
59  {
60  if (std::find(usedProtoShowersW.begin(), usedProtoShowersW.end(), wIndex) != usedProtoShowersW.end())
61  continue;
62 
63  const ProtoShower &protoShowerW(protoShowerVectorW.at(wIndex));
65 
66  if (!this->ArePathwaysConsistent(protoShowerU, protoShowerV, protoShowerW, consistency))
67  continue;
68 
69  usedProtoShowersU.push_back(uIndex);
70  usedProtoShowersV.push_back(vIndex);
71  usedProtoShowersW.push_back(wIndex);
72 
73  protoShowerMatchVector.push_back(ProtoShowerMatch(protoShowerU, protoShowerV, protoShowerW, consistency));
74 
75  added = true;
76  break;
77  }
78 
79  if (added)
80  break;
81  }
82  }
83 
84  return STATUS_CODE_SUCCESS;
85 }
Consistency
Consistency enumeration.
std::vector< int > IntVector
bool ArePathwaysConsistent(const ProtoShower &protoShowerU, const ProtoShower &protoShowerV, const ProtoShower &protoShowerW, Consistency &consistency) const
Determine whether three 2D connection pathways form a consistent 3D connection pathway.

Member Data Documentation

float lar_content::ProtoShowerMatchingTool::m_maxAngularDeviation
private

The max. opening angle between true and projected 2D initial directions for a match.

Definition at line 82 of file ProtoShowerMatchingTool.h.

Referenced by AreDirectionsConsistent(), and ReadSettings().

float lar_content::ProtoShowerMatchingTool::m_maxSeparation
private

The max. average separation between true and projected 2D shower start positions for a match.

Definition at line 81 of file ProtoShowerMatchingTool.h.

Referenced by AreShowerStartsConsistent(), and ReadSettings().

float lar_content::ProtoShowerMatchingTool::m_maxXSeparation
private

The max. drift-coordinate separation between matched 2D shower start positions.

Definition at line 80 of file ProtoShowerMatchingTool.h.

Referenced by AreShowerStartsConsistent(), and ReadSettings().

unsigned int lar_content::ProtoShowerMatchingTool::m_spineSlidingFitWindow
private

The shower spine sliding fit window.

Definition at line 79 of file ProtoShowerMatchingTool.h.

Referenced by AreDirectionsConsistent(), and ReadSettings().


The documentation for this class was generated from the following files: