Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
TrackHitsBaseTool.cc
Go to the documentation of this file.
1
10
14
17
18using namespace pandora;
19
20namespace lar_content
21{
22
23TrackHitsBaseTool::TrackHitsBaseTool() : m_minViews(2), m_slidingFitWindow(20)
24{
25}
26
27//------------------------------------------------------------------------------------------------------------------------------------------
28
30 const CaloHitVector &inputTwoDHits, ProtoHitVector &protoHitVector)
31{
33 std::cout << "----> Running Algorithm Tool: " << this->GetInstanceName() << ", " << this->GetType() << std::endl;
34
35 try
36 {
37 if (!LArPfoHelper::IsTrack(pPfo))
38 return;
39
40 MatchedSlidingFitMap matchedSlidingFitMap;
41 this->BuildSlidingFitMap(pPfo, matchedSlidingFitMap);
42
43 if (matchedSlidingFitMap.size() < 2)
44 return;
45
46 this->GetTrackHits3D(inputTwoDHits, matchedSlidingFitMap, protoHitVector);
47 }
48 catch (StatusCodeException &)
49 {
50 }
51}
52
53//------------------------------------------------------------------------------------------------------------------------------------------
54
55void TrackHitsBaseTool::BuildSlidingFitMap(const ParticleFlowObject *const pPfo, MatchedSlidingFitMap &matchedSlidingFitMap) const
56{
57 const ClusterList &pfoClusterList(pPfo->GetClusterList());
58 const float slidingFitPitch(LArGeometryHelper::GetWireZPitch(this->GetPandora()));
59
60 ClusterVector pfoClusterVector;
61 pfoClusterVector.insert(pfoClusterVector.end(), pfoClusterList.begin(), pfoClusterList.end());
62 std::sort(pfoClusterVector.begin(), pfoClusterVector.end(), LArClusterHelper::SortByNHits);
63
64 for (const Cluster *const pCluster : pfoClusterVector)
65 {
66 const HitType hitType(LArClusterHelper::GetClusterHitType(pCluster));
67
68 if (TPC_3D == hitType)
69 continue;
70
71 if (matchedSlidingFitMap.end() != matchedSlidingFitMap.find(hitType))
72 continue;
73
74 try
75 {
76 const TwoDSlidingFitResult slidingFitResult(pCluster, m_slidingFitWindow, slidingFitPitch);
77
78 if (!matchedSlidingFitMap.insert(MatchedSlidingFitMap::value_type(hitType, slidingFitResult)).second)
79 throw StatusCodeException(STATUS_CODE_FAILURE);
80 }
81 catch (StatusCodeException &statusCodeException)
82 {
83 if (STATUS_CODE_FAILURE == statusCodeException.GetStatusCode())
84 throw statusCodeException;
85 }
86 }
87}
88
89//------------------------------------------------------------------------------------------------------------------------------------------
90
92{
93 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinViews", m_minViews));
94
96 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "SlidingFitWindow", m_slidingFitWindow));
97
98 return HitCreationBaseTool::ReadSettings(xmlHandle);
99}
100
101} // namespace lar_content
Grouping of header files for many classes of use in particle flow algorithms.
Header file for the cluster helper class.
Header file for the geometry helper class.
Header file for the pfo helper class.
#define PANDORA_RETURN_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
Definition StatusCodes.h:31
Header file for the three dimensional hit creation algorithm class.
Header file for the track hits base tool.
static const pandora::PandoraSettings * GetSettings(const pandora::Algorithm &algorithm)
Get the pandora settings instance.
ThreeDHitCreationAlgorithm::ProtoHitVector ProtoHitVector
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
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,...
static float GetWireZPitch(const pandora::Pandora &pandora, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
static bool IsTrack(const pandora::ParticleFlowObject *const pPfo)
Return track flag based on Pfo Particle ID.
ThreeDHitCreationAlgorithm::Algorithm class.
virtual void Run(ThreeDHitCreationAlgorithm *const pAlgorithm, const pandora::ParticleFlowObject *const pPfo, const pandora::CaloHitVector &inputTwoDHits, ProtoHitVector &protoHitVector)
Run the algorithm tool.
virtual void GetTrackHits3D(const pandora::CaloHitVector &inputTwoDHits, const MatchedSlidingFitMap &matchedSlidingFitMap, ProtoHitVector &protoHitVector) const =0
Calculate 3D hits from an input list of 2D hits.
TrackHitsBaseTool()
Default constructor.
virtual void BuildSlidingFitMap(const pandora::ParticleFlowObject *const pPfo, MatchedSlidingFitMap &matchedSlidingFitMap) const
Calculate sliding fit results for clusters from each view.
unsigned int m_minViews
The minimum number of views required for building hits.
unsigned int m_slidingFitWindow
The layer window for the sliding linear fits.
std::map< pandora::HitType, TwoDSlidingFitResult > MatchedSlidingFitMap
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
Cluster class.
Definition Cluster.h:31
bool ShouldDisplayAlgorithmInfo() const
Whether to display algorithm information during processing.
ParticleFlowObject class.
const ClusterList & GetClusterList() const
Get the cluster list.
const std::string & GetType() const
Get the type.
Definition Process.h:102
const Pandora & GetPandora() const
Get the associated pandora instance.
Definition Process.h:116
const std::string & GetInstanceName() const
Get the instance name.
Definition Process.h:109
StatusCodeException class.
StatusCode GetStatusCode() const
Get status code.
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
Definition XmlHelper.h:136
HitType
Calorimeter hit type enum.
std::vector< const CaloHit * > CaloHitVector
std::vector< const Cluster * > ClusterVector
MANAGED_CONTAINER< const Cluster * > ClusterList
StatusCode
The StatusCode enum.