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

MultiValuedTransverseTrackHitsTool class. More...

#include "MultiValuedTransverseTrackHitsTool.h"

Inheritance diagram for lar_content::MultiValuedTransverseTrackHitsTool:
lar_content::TransverseTrackHitsBaseTool lar_content::TrackHitsBaseTool lar_content::HitCreationBaseTool

Public Types

typedef ThreeDHitCreationAlgorithm::ProtoHit ProtoHit
 
typedef ThreeDHitCreationAlgorithm::ProtoHitVector ProtoHitVector
 
typedef ThreeDHitCreationAlgorithm::TrajectorySample TrajectorySample
 

Public Member Functions

virtual void Run (ThreeDHitCreationAlgorithm *const pAlgorithm, const pandora::ParticleFlowObject *const pPfo, const pandora::CaloHitVector &inputTwoDHits, ProtoHitVector &protoHitVector)
 Run the algorithm tool. More...
 

Protected Types

typedef std::map< pandora::HitType, TwoDSlidingFitResultMatchedSlidingFitMap
 

Protected Member Functions

virtual void GetTrackHits3D (const pandora::CaloHitVector &inputTwoDHits, const MatchedSlidingFitMap &matchedSlidingFitMap, ProtoHitVector &protoHitVector) const
 Calculate 3D hits from an input list of 2D hits. More...
 
virtual void AddTransverseChi2 (const MatchedSlidingFitMap &matchedSlidingFitMap, ProtoHit &protoHit) const
 Calculate an additional contribution to the chi-squared based on the steepness of the track. More...
 
virtual void BuildSlidingFitMap (const pandora::ParticleFlowObject *const pPfo, MatchedSlidingFitMap &matchedSlidingFitMap) const
 Calculate sliding fit results for clusters from each view. More...
 
virtual pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 
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 positions from the other two views. More...
 
virtual void GetBestPosition3D (const pandora::HitType hitType1, const pandora::HitType hitType2, const pandora::CartesianVector &fitPosition1, const pandora::CartesianVector &fitPosition2, ProtoHit &protoHit) const
 Get the three dimensional position using a provided two dimensional calo hit and candidate fit positions from the other two views. More...
 
virtual void GetBestPosition3D (const pandora::HitType hitType, const pandora::CartesianVector &fitPosition, ProtoHit &protoHit) const
 Get the three dimensional position using a provided two dimensional calo hit and a candidate fit position from another view. More...
 

Protected Attributes

unsigned int m_minViews
 The minimum number of views required for building hits. More...
 
unsigned int m_slidingFitWindow
 The layer window for the sliding linear fits. More...
 
double m_sigmaX2
 The sigmaX squared value, for calculation of chi2 deltaX term. More...
 
double m_chiSquaredCut
 The chi squared cut (accept only values below the cut value) More...
 

Private Member Functions

void GetTransverseTrackHit3D (const MatchedSlidingFitMap &matchedSlidingFitMap, ProtoHit &protoHit) const
 Get the three dimensional position using a provided two dimensional calo hit and sliding linear fits in the other two views. More...
 

Detailed Description

Member Typedef Documentation

typedef std::map<pandora::HitType, TwoDSlidingFitResult> lar_content::TrackHitsBaseTool::MatchedSlidingFitMap
protectedinherited

Definition at line 35 of file TrackHitsBaseTool.h.

Member Function Documentation

void lar_content::TransverseTrackHitsBaseTool::AddTransverseChi2 ( const MatchedSlidingFitMap matchedSlidingFitMap,
ProtoHit protoHit 
) const
protectedvirtualinherited

Calculate an additional contribution to the chi-squared based on the steepness of the track.

Parameters
matchedSlidingFitMapmap of sliding fit results from each view
protoHitto receive the modified proto hit

Definition at line 43 of file TransverseTrackHitsBaseTool.cc.

References lar_content::ThreeDHitCreationAlgorithm::ProtoHit::GetChi2(), lar_content::ThreeDHitCreationAlgorithm::ProtoHit::GetParentCaloHit2D(), lar_content::ThreeDHitCreationAlgorithm::ProtoHit::GetPosition3D(), and lar_content::ThreeDHitCreationAlgorithm::ProtoHit::SetPosition3D().

44 {
45  // TODO Develop a proper treatment of the |dz/dx| * sigmaX uncertainty
46  double chiSquared(protoHit.GetChi2());
47  const HitType inputHitType(protoHit.GetParentCaloHit2D()->GetHitType());
48  const CartesianVector &inputPosition3D(protoHit.GetPosition3D());
49 
50  for (const MatchedSlidingFitMap::value_type &mapEntry : matchedSlidingFitMap)
51  {
52  if (mapEntry.first == inputHitType)
53  continue;
54 
55  const CartesianVector inputPosition2D(LArGeometryHelper::ProjectPosition(this->GetPandora(), inputPosition3D, mapEntry.first));
56  chiSquared += this->GetTransverseChi2(inputPosition2D, mapEntry.second);
57  }
58 
59  protoHit.SetPosition3D(inputPosition3D, chiSquared);
60 }
static pandora::CartesianVector ProjectPosition(const pandora::Pandora &pandora, const pandora::CartesianVector &position3D, const pandora::HitType view)
Project 3D position into a given 2D view.
double GetTransverseChi2(const pandora::CartesianVector &position2D, const TwoDSlidingFitResult &fitResult) const
Calculate an additional contribution to the chi-squared based on the steepness of the track...
HitType
Definition: HitType.h:12
void lar_content::TrackHitsBaseTool::BuildSlidingFitMap ( const pandora::ParticleFlowObject *const  pPfo,
MatchedSlidingFitMap matchedSlidingFitMap 
) const
protectedvirtualinherited

Calculate sliding fit results for clusters from each view.

Parameters
pPfothe input particle flow object
matchedSlidingFitMapthe group of sliding fit results

Definition at line 57 of file TrackHitsBaseTool.cc.

References lar_content::LArClusterHelper::GetClusterHitType(), lar_content::LArGeometryHelper::GetWirePitch(), lar_content::TrackHitsBaseTool::m_slidingFitWindow, and lar_content::LArClusterHelper::SortByNHits().

Referenced by lar_content::TrackHitsBaseTool::Run().

58 {
59  const ClusterList &pfoClusterList(pPfo->GetClusterList());
60 
61  ClusterVector pfoClusterVector;
62  pfoClusterVector.insert(pfoClusterVector.end(), pfoClusterList.begin(), pfoClusterList.end());
63  std::sort(pfoClusterVector.begin(), pfoClusterVector.end(), LArClusterHelper::SortByNHits);
64 
65  for (const Cluster *const pCluster : pfoClusterVector)
66  {
67  const HitType hitType(LArClusterHelper::GetClusterHitType(pCluster));
68 
69  if (TPC_3D == hitType)
70  continue;
71 
72  if (matchedSlidingFitMap.end() != matchedSlidingFitMap.find(hitType))
73  continue;
74 
75  try
76  {
77  const float slidingFitPitch(LArGeometryHelper::GetWirePitch(this->GetPandora(), LArClusterHelper::GetClusterHitType(pCluster)));
78  const TwoDSlidingFitResult slidingFitResult(pCluster, m_slidingFitWindow, slidingFitPitch);
79 
80  if (!matchedSlidingFitMap.insert(MatchedSlidingFitMap::value_type(hitType, slidingFitResult)).second)
81  throw StatusCodeException(STATUS_CODE_FAILURE);
82  }
83  catch (StatusCodeException &statusCodeException)
84  {
85  if (STATUS_CODE_FAILURE == statusCodeException.GetStatusCode())
86  throw statusCodeException;
87  }
88  }
89 }
static bool SortByNHits(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
Sort clusters by number of hits, then layer span, then inner layer, then position, then pulse-height.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
static float GetWirePitch(const pandora::Pandora &pandora, const pandora::HitType view, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
unsigned int m_slidingFitWindow
The layer window for the sliding linear fits.
HitType
Definition: HitType.h:12
std::vector< art::Ptr< recob::Cluster > > ClusterVector
virtual void lar_content::HitCreationBaseTool::GetBestPosition3D ( const pandora::HitType  hitType1,
const pandora::HitType  hitType2,
const pandora::CartesianPointVector &  fitPositionList1,
const pandora::CartesianPointVector &  fitPositionList2,
ProtoHit protoHit 
) const
protectedvirtualinherited

Get the three dimensional position using a provided two dimensional calo hit and candidate fit positions from the other two views.

Parameters
hitType1the hit type identifying the first view
hitType2the hit type identifying the second view
fitPositionList1the candidate sliding fit position in the first view
fitPositionList2the candidate sliding fit position in the second view
protoHitto receive the populated proto hit

Referenced by lar_content::ThreeViewShowerHitsTool::GetShowerHit3D(), and lar_content::HitCreationBaseTool::~HitCreationBaseTool().

virtual void lar_content::HitCreationBaseTool::GetBestPosition3D ( const pandora::HitType  hitType1,
const pandora::HitType  hitType2,
const pandora::CartesianVector &  fitPosition1,
const pandora::CartesianVector &  fitPosition2,
ProtoHit protoHit 
) const
protectedvirtualinherited

Get the three dimensional position using a provided two dimensional calo hit and candidate fit positions from the other two views.

Parameters
hitType1the hit type identifying the first view
hitType2the hit type identifying the second view
fitPosition1the candidate sliding fit position in the first view
fitPosition2the candidate sliding fit position in the second view
protoHitto receive the populated proto hit
virtual void lar_content::HitCreationBaseTool::GetBestPosition3D ( const pandora::HitType  hitType,
const pandora::CartesianVector &  fitPosition,
ProtoHit protoHit 
) const
protectedvirtualinherited

Get the three dimensional position using a provided two dimensional calo hit and a candidate fit position from another view.

Parameters
hitTypethe hit type identifying the other view
fitPositionthe candidate sliding fit position in the other view
protoHitto receive the populated proto hit
void lar_content::TransverseTrackHitsBaseTool::GetTrackHits3D ( const pandora::CaloHitVector &  inputTwoDHits,
const MatchedSlidingFitMap matchedSlidingFitMap,
ProtoHitVector protoHitVector 
) const
protectedvirtualinherited

Calculate 3D hits from an input list of 2D hits.

Parameters
pAlgorithmthe hit creation algorithm
inputTwoDHitsthe input vector of 2D hits
matchedSlidingFitMapthe group of sliding fit results
protoHitVectorto receive the new three dimensional proto hits

Implements lar_content::TrackHitsBaseTool.

Definition at line 21 of file TransverseTrackHitsBaseTool.cc.

References lar_content::ThreeDHitCreationAlgorithm::ProtoHit::GetChi2(), and lar_content::ThreeDHitCreationAlgorithm::ProtoHit::IsPositionSet().

23 {
24  for (const CaloHit *const pCaloHit2D : inputTwoDHits)
25  {
26  try
27  {
28  ProtoHit protoHit(pCaloHit2D);
29  this->GetTransverseTrackHit3D(matchedSlidingFitMap, protoHit);
30  this->AddTransverseChi2(matchedSlidingFitMap, protoHit);
31 
32  if (protoHit.IsPositionSet() && (protoHit.GetChi2() < m_chiSquaredCut))
33  protoHitVector.push_back(protoHit);
34  }
35  catch (StatusCodeException &)
36  {
37  }
38  }
39 }
ThreeDHitCreationAlgorithm::ProtoHit ProtoHit
virtual void GetTransverseTrackHit3D(const MatchedSlidingFitMap &matchedSlidingFitMap, ProtoHit &protoHit) const =0
Get the three dimensional position using a provided two dimensional calo hit and sliding linear fits ...
double m_chiSquaredCut
The chi squared cut (accept only values below the cut value)
virtual void AddTransverseChi2(const MatchedSlidingFitMap &matchedSlidingFitMap, ProtoHit &protoHit) const
Calculate an additional contribution to the chi-squared based on the steepness of the track...
void lar_content::MultiValuedTransverseTrackHitsTool::GetTransverseTrackHit3D ( const MatchedSlidingFitMap matchedSlidingFitMap,
ProtoHit protoHit 
) const
privatevirtual

Get the three dimensional position using a provided two dimensional calo hit and sliding linear fits in the other two views.

Parameters
matchedSlidingFitMapmap of sliding fit results from each view
protoHitto receive the populated proto hit

Implements lar_content::TransverseTrackHitsBaseTool.

Definition at line 18 of file MultiValuedTransverseTrackHitsTool.cc.

References lar_content::TwoDSlidingFitResult::GetGlobalFitPositionListAtX(), and lar_content::ThreeDHitCreationAlgorithm::ProtoHit::GetParentCaloHit2D().

19 {
20  const CaloHit *const pCaloHit2D(protoHit.GetParentCaloHit2D());
21  const HitType hitType(pCaloHit2D->GetHitType());
22  const HitType hitType1((TPC_VIEW_U == hitType) ? TPC_VIEW_V : (TPC_VIEW_V == hitType) ? TPC_VIEW_W : TPC_VIEW_U);
23  const HitType hitType2((TPC_VIEW_U == hitType) ? TPC_VIEW_W : (TPC_VIEW_V == hitType) ? TPC_VIEW_U : TPC_VIEW_V);
24 
25  CartesianPointVector fitPositionList1, fitPositionList2;
26 
27  MatchedSlidingFitMap::const_iterator iter1 = matchedSlidingFitMap.find(hitType1);
28 
29  if (matchedSlidingFitMap.end() != iter1)
30  {
31  const TwoDSlidingFitResult &fitResult1 = iter1->second;
32  PANDORA_THROW_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
33  fitResult1.GetGlobalFitPositionListAtX(pCaloHit2D->GetPositionVector().GetX(), fitPositionList1));
34  }
35 
36  MatchedSlidingFitMap::const_iterator iter2 = matchedSlidingFitMap.find(hitType2);
37 
38  if (matchedSlidingFitMap.end() != iter2)
39  {
40  const TwoDSlidingFitResult &fitResult2 = iter2->second;
41  PANDORA_THROW_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
42  fitResult2.GetGlobalFitPositionListAtX(pCaloHit2D->GetPositionVector().GetX(), fitPositionList2));
43  }
44 
45  unsigned int nViews(1);
46  if (fitPositionList1.size() > 0)
47  ++nViews;
48  if (fitPositionList2.size() > 0)
49  ++nViews;
50 
51  if (nViews < m_minViews)
52  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
53 
54  if (nViews <= 2)
55  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
56 
57  this->GetBestPosition3D(hitType1, hitType2, fitPositionList1, fitPositionList2, protoHit);
58 }
intermediate_table::const_iterator const_iterator
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...
HitType
Definition: HitType.h:12
unsigned int m_minViews
The minimum number of views required for building hits.
StatusCode lar_content::TrackHitsBaseTool::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
protectedvirtualinherited

Reimplemented from lar_content::HitCreationBaseTool.

Reimplemented in lar_content::LongitudinalTrackHitsBaseTool.

Definition at line 93 of file TrackHitsBaseTool.cc.

References lar_content::TrackHitsBaseTool::m_minViews, lar_content::TrackHitsBaseTool::m_slidingFitWindow, and lar_content::HitCreationBaseTool::ReadSettings().

Referenced by lar_content::LongitudinalTrackHitsBaseTool::ReadSettings().

94 {
95  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinViews", m_minViews));
96 
97  PANDORA_RETURN_RESULT_IF_AND_IF(
98  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "SlidingFitWindow", m_slidingFitWindow));
99 
100  return HitCreationBaseTool::ReadSettings(xmlHandle);
101 }
unsigned int m_slidingFitWindow
The layer window for the sliding linear fits.
unsigned int m_minViews
The minimum number of views required for building hits.
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
void lar_content::TrackHitsBaseTool::Run ( ThreeDHitCreationAlgorithm *const  pAlgorithm,
const pandora::ParticleFlowObject *const  pPfo,
const pandora::CaloHitVector &  inputTwoDHits,
ProtoHitVector protoHitVector 
)
virtualinherited

Run the algorithm tool.

Parameters
pAlgorithmaddress of the calling algorithm
pPfothe address of the pfo
inputTwoDHitsthe vector of input two dimensional hits
protoHitVectorto receive the new three dimensional proto hits

Implements lar_content::HitCreationBaseTool.

Definition at line 31 of file TrackHitsBaseTool.cc.

References lar_content::TrackHitsBaseTool::BuildSlidingFitMap(), lar_content::TrackHitsBaseTool::GetTrackHits3D(), and lar_content::LArPfoHelper::IsTrack().

33 {
34  if (PandoraContentApi::GetSettings(*pAlgorithm)->ShouldDisplayAlgorithmInfo())
35  std::cout << "----> Running Algorithm Tool: " << this->GetInstanceName() << ", " << this->GetType() << std::endl;
36 
37  try
38  {
39  if (!LArPfoHelper::IsTrack(pPfo))
40  return;
41 
42  MatchedSlidingFitMap matchedSlidingFitMap;
43  this->BuildSlidingFitMap(pPfo, matchedSlidingFitMap);
44 
45  if (matchedSlidingFitMap.size() < 2)
46  return;
47 
48  this->GetTrackHits3D(inputTwoDHits, matchedSlidingFitMap, protoHitVector);
49  }
50  catch (StatusCodeException &)
51  {
52  }
53 }
virtual void GetTrackHits3D(const pandora::CaloHitVector &inputTwoDHits, const MatchedSlidingFitMap &matchedSlidingFitMap, ProtoHitVector &protoHitVector) const =0
Calculate 3D hits from an input list of 2D hits.
virtual void BuildSlidingFitMap(const pandora::ParticleFlowObject *const pPfo, MatchedSlidingFitMap &matchedSlidingFitMap) const
Calculate sliding fit results for clusters from each view.
std::map< pandora::HitType, TwoDSlidingFitResult > MatchedSlidingFitMap
static bool IsTrack(const pandora::ParticleFlowObject *const pPfo)
Return track flag based on Pfo Particle ID.

Member Data Documentation

double lar_content::HitCreationBaseTool::m_chiSquaredCut
protectedinherited
unsigned int lar_content::TrackHitsBaseTool::m_minViews
protectedinherited

The minimum number of views required for building hits.

Definition at line 58 of file TrackHitsBaseTool.h.

Referenced by lar_content::TrackHitsBaseTool::ReadSettings().

double lar_content::HitCreationBaseTool::m_sigmaX2
protectedinherited

The sigmaX squared value, for calculation of chi2 deltaX term.

Definition at line 85 of file HitCreationBaseTool.h.

Referenced by lar_content::HitCreationBaseTool::ReadSettings(), and lar_content::HitCreationBaseTool::~HitCreationBaseTool().

unsigned int lar_content::TrackHitsBaseTool::m_slidingFitWindow
protectedinherited

The layer window for the sliding linear fits.

Definition at line 59 of file TrackHitsBaseTool.h.

Referenced by lar_content::TrackHitsBaseTool::BuildSlidingFitMap(), and lar_content::TrackHitsBaseTool::ReadSettings().


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