Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
LArParticleIdPlugins.cc
Go to the documentation of this file.
1
9#include "Helpers/XmlHelper.h"
10
11#include "Objects/Cluster.h"
12
16
18
20
21#include <algorithm>
22#include <cmath>
23
24namespace lar_content
25{
26
27using namespace pandora;
28
30 m_layerFitHalfWindow(20),
31 m_minLayerOccupancy(0.75f),
32 m_maxTrackWidth(0.5f),
33 m_trackResidualQuantile(0.8f),
34 m_minClustersPassingId(2)
35{
36}
37
38//------------------------------------------------------------------------------------------------------------------------------------------
39
40bool LArParticleIdPlugins::LArMuonId::IsMatch(const Cluster *const pCluster) const
41{
42 if (LArClusterHelper::GetLayerOccupancy(pCluster) < m_minLayerOccupancy)
43 return false;
44
45 const float slidingFitPitch(LArGeometryHelper::GetWireZPitch(this->GetPandora()));
46 const TwoDSlidingFitResult twoDSlidingFitResult(pCluster, m_layerFitHalfWindow, slidingFitPitch);
47
48 if (this->GetMuonTrackWidth(twoDSlidingFitResult) > m_maxTrackWidth)
49 return false;
50
51 return true;
52}
53
54//------------------------------------------------------------------------------------------------------------------------------------------
55
57{
58 ClusterList clusterList;
59 LArPfoHelper::GetTwoDClusterList(pPfo, clusterList);
60
61 if (clusterList.empty())
62 return false;
63
64 unsigned int nClustersPassing(0);
65
66 for (const Cluster *const pCluster : clusterList)
67 {
68 if (this->IsMatch(pCluster))
69 ++nClustersPassing;
70 }
71
72 if (nClustersPassing < m_minClustersPassingId)
73 return false;
74
75 return true;
76}
77
78//------------------------------------------------------------------------------------------------------------------------------------------
79
81{
82 FloatVector residuals;
83 const OrderedCaloHitList &orderedCaloHitList(twoDSlidingFitResult.GetCluster()->GetOrderedCaloHitList());
84 const LayerFitResultMap &layerFitResultMap(twoDSlidingFitResult.GetLayerFitResultMap());
85
86 for (OrderedCaloHitList::const_iterator iter = orderedCaloHitList.begin(); iter != orderedCaloHitList.end(); ++iter)
87 {
88 for (CaloHitList::const_iterator hitIter = iter->second->begin(), hitIterEnd = iter->second->end(); hitIter != hitIterEnd; ++hitIter)
89 {
90 float rL(0.f), rT(0.f);
91 twoDSlidingFitResult.GetLocalPosition((*hitIter)->GetPositionVector(), rL, rT);
92 const int layer(twoDSlidingFitResult.GetLayer(rL));
93
94 LayerFitResultMap::const_iterator fitResultIter = layerFitResultMap.find(layer);
95
96 if (layerFitResultMap.end() == fitResultIter)
97 continue;
98
99 const double fitT(fitResultIter->second.GetFitT());
100 const double gradient(fitResultIter->second.GetGradient());
101 const double residualSquared((fitT - rT) * (fitT - rT) / (1. + gradient * gradient)); // angular correction (note: this is cheating!)
102 residuals.push_back(residualSquared);
103 }
104 }
105
106 if (residuals.empty())
107 throw StatusCodeException(STATUS_CODE_NOT_INITIALIZED);
108
109 std::sort(residuals.begin(), residuals.end());
110 const float theQuantile(residuals[m_trackResidualQuantile * residuals.size()]);
111
112 return std::sqrt(theQuantile);
113}
114
115//------------------------------------------------------------------------------------------------------------------------------------------
116
118{
120 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "LayerFitHalfWindow", m_layerFitHalfWindow));
121
123 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinLayerOccupancy", m_minLayerOccupancy));
124
125 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MaxTrackWidth", m_maxTrackWidth));
126
128 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "TrackResidualQuantile", m_trackResidualQuantile));
129
131 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinClustersPassingId", m_minClustersPassingId));
132
133 return STATUS_CODE_SUCCESS;
134}
135
136} // namespace lar_content
Header file for the cluster class.
Header file for the cluster helper class.
Header file for the geometry helper class.
Header file for the lar particle id plugins class.
Header file for the pfo helper class.
Header file for the lar two dimensional sliding fit result class.
#define PANDORA_RETURN_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
Definition StatusCodes.h:31
Header file for the xml helper class.
static float GetLayerOccupancy(const pandora::Cluster *const pCluster)
Fraction of occupied layers in cluster.
static float GetWireZPitch(const pandora::Pandora &pandora, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
bool IsMatch(const pandora::Cluster *const pCluster) const
Whether the cluster matches the specific particle hypothesis.
float GetMuonTrackWidth(const TwoDSlidingFitResult &twoDSlidingFitResult) const
Get the muon track width estimator for a provided sliding fit result.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
static void GetTwoDClusterList(const pandora::ParticleFlowObject *const pPfo, pandora::ClusterList &clusterList)
Get the list of 2D clusters from an input pfo.
void GetLocalPosition(const pandora::CartesianVector &position, float &rL, float &rT) const
Get local sliding fit coordinates for a given global position.
const LayerFitResultMap & GetLayerFitResultMap() const
Get the layer fit result map.
const pandora::Cluster * GetCluster() const
Get the address of the cluster, if originally provided.
int GetLayer(const float rL) const
Get layer number for given sliding linear fit longitudinal coordinate.
Cluster class.
Definition Cluster.h:31
const OrderedCaloHitList & GetOrderedCaloHitList() const
Get the ordered calo hit list.
Definition Cluster.h:470
Calo hit lists arranged by pseudo layer.
const_iterator end() const
Returns a const iterator referring to the past-the-end element in the ordered calo hit list.
const_iterator begin() const
Returns a const iterator referring to the first element in the ordered calo hit list.
TheList::const_iterator const_iterator
ParticleFlowObject class.
StatusCodeException class.
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
Definition XmlHelper.h:136
std::map< int, LayerFitResult > LayerFitResultMap
MANAGED_CONTAINER< const Cluster * > ClusterList
std::vector< float > FloatVector
StatusCode
The StatusCode enum.