LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
TrackHitsBaseTool.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 TrackHitsBaseTool::TrackHitsBaseTool() :
24  m_minViews(2),
25  m_slidingFitWindow(20)
26 {
27 }
28 
29 //------------------------------------------------------------------------------------------------------------------------------------------
30 
31 void TrackHitsBaseTool::Run(ThreeDHitCreationAlgorithm *const pAlgorithm, const ParticleFlowObject *const pPfo,
32  const CaloHitVector &inputTwoDHits, ProtoHitVector &protoHitVector)
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 }
54 
55 //------------------------------------------------------------------------------------------------------------------------------------------
56 
57 void TrackHitsBaseTool::BuildSlidingFitMap(const ParticleFlowObject *const pPfo, MatchedSlidingFitMap &matchedSlidingFitMap) const
58 {
59  const ClusterList &pfoClusterList(pPfo->GetClusterList());
60  const float slidingFitPitch(LArGeometryHelper::GetWireZPitch(this->GetPandora()));
61 
62  ClusterVector pfoClusterVector;
63  pfoClusterVector.insert(pfoClusterVector.end(), pfoClusterList.begin(), pfoClusterList.end());
64  std::sort(pfoClusterVector.begin(), pfoClusterVector.end(), LArClusterHelper::SortByNHits);
65 
66  for (const Cluster *const pCluster : pfoClusterVector)
67  {
68  const HitType hitType(LArClusterHelper::GetClusterHitType(pCluster));
69 
70  if (TPC_3D == hitType)
71  continue;
72 
73  if (matchedSlidingFitMap.end() != matchedSlidingFitMap.find(hitType))
74  continue;
75 
76  try
77  {
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 }
90 
91 //------------------------------------------------------------------------------------------------------------------------------------------
92 
93 StatusCode TrackHitsBaseTool::ReadSettings(const TiXmlHandle xmlHandle)
94 {
95  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
96  "MinViews", m_minViews));
97 
98  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
99  "SlidingFitWindow", m_slidingFitWindow));
100 
101  return HitCreationBaseTool::ReadSettings(xmlHandle);
102 }
103 
104 } // namespace lar_content
virtual void GetTrackHits3D(const pandora::CaloHitVector &inputTwoDHits, const MatchedSlidingFitMap &matchedSlidingFitMap, ProtoHitVector &protoHitVector) const =0
Calculate 3D hits from an input list of 2D hits.
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.
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
virtual void BuildSlidingFitMap(const pandora::ParticleFlowObject *const pPfo, MatchedSlidingFitMap &matchedSlidingFitMap) const
Calculate sliding fit results for clusters from each view.
Header file for the pfo helper class.
std::map< pandora::HitType, TwoDSlidingFitResult > MatchedSlidingFitMap
ThreeDHitCreationAlgorithm::ProtoHitVector ProtoHitVector
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
static bool IsTrack(const pandora::ParticleFlowObject *const pPfo)
Return track flag based on Pfo Particle ID.
static float GetWireZPitch(const pandora::Pandora &pandora, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
Header file for the three dimensional hit creation algorithm class.
Header file for the geometry helper class.
Header file for the cluster helper class.
Header file for the track hits base tool.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
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.
ThreeDHitCreationAlgorithm::Algorithm class.
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
virtual void Run(ThreeDHitCreationAlgorithm *const pAlgorithm, const pandora::ParticleFlowObject *const pPfo, const pandora::CaloHitVector &inputTwoDHits, ProtoHitVector &protoHitVector)
Run the algorithm tool.