9 #include "Pandora/AlgorithmHeaders.h" 21 NeutrinoPropertiesAlgorithm::NeutrinoPropertiesAlgorithm() :
22 m_includeIsolatedHits(false)
30 const PfoList *pPfoList(
nullptr);
31 PANDORA_THROW_RESULT_IF_AND_IF(
32 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*
this,
m_neutrinoPfoListName, pPfoList));
34 if (!pPfoList || pPfoList->empty())
36 if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
37 std::cout <<
"NeutrinoPropertiesAlgorithm: unable to find pfo list " <<
m_neutrinoPfoListName << std::endl;
39 return STATUS_CODE_SUCCESS;
43 const ParticleFlowObject *
const pNeutrinoPfo((1 == pPfoList->size()) ? *(pPfoList->begin()) :
nullptr);
46 return STATUS_CODE_FAILURE;
49 if (pNeutrinoPfo->GetDaughterPfoList().empty())
51 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Delete(*
this, pNeutrinoPfo,
m_neutrinoPfoListName));
58 return STATUS_CODE_SUCCESS;
65 unsigned int nPrimaryTwoDHits(0);
66 const ParticleFlowObject *pPrimaryDaughter(
nullptr);
68 PfoVector daughterPfoVector(pNeutrinoPfo->GetDaughterPfoList().begin(), pNeutrinoPfo->GetDaughterPfoList().end());
71 for (
const ParticleFlowObject *
const pDaughterPfo : daughterPfoVector)
75 if (!pPrimaryDaughter || (nTwoDHits > nPrimaryTwoDHits))
77 nPrimaryTwoDHits = nTwoDHits;
78 pPrimaryDaughter = pDaughterPfo;
82 if (!pPrimaryDaughter)
83 throw StatusCodeException(STATUS_CODE_FAILURE);
85 PandoraContentApi::ParticleFlowObject::Metadata metadata;
87 if (E_MINUS ==
std::abs(pPrimaryDaughter->GetParticleId()))
89 metadata.m_particleId = NU_E;
91 else if (MU_MINUS ==
std::abs(pPrimaryDaughter->GetParticleId()))
93 metadata.m_particleId = NU_MU;
96 if (metadata.m_particleId.IsInitialized())
98 metadata.m_charge = PdgTable::GetParticleCharge(metadata.m_particleId.Get());
99 metadata.m_mass = PdgTable::GetParticleMass(metadata.m_particleId.Get());
100 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::AlterMetadata(*
this, pNeutrinoPfo, metadata));
108 unsigned int nTwoDHits(0);
110 for (
const Cluster *
const pCluster : pPfo->GetClusterList())
114 if ((TPC_VIEW_U == hitType) || (TPC_VIEW_V == hitType) || (TPC_VIEW_W == hitType))
116 nTwoDHits += pCluster->GetNCaloHits();
119 nTwoDHits += pCluster->GetNIsolatedCaloHits();
123 for (
const ParticleFlowObject *
const pDaughterPfo : pPfo->GetDaughterPfoList())
135 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle,
"NeutrinoPfoListName",
m_neutrinoPfoListName));
137 PANDORA_RETURN_RESULT_IF_AND_IF(
138 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"IncludeIsolatedHits",
m_includeIsolatedHits));
140 return STATUS_CODE_SUCCESS;
static bool SortByNHits(const pandora::ParticleFlowObject *const pLhs, const pandora::ParticleFlowObject *const pRhs)
Sort pfos by number of constituent hits.
Header file for the pfo helper class.
bool m_includeIsolatedHits
Whether to include isolated hits when counting 2d hits in pfo chain.
constexpr auto abs(T v)
Returns the absolute value of the argument.
void SetNeutrinoId(const pandora::ParticleFlowObject *const pNeutrinoPfo) const
identifying the primary daughter of a neutrino pfo and set the particle id accordingly ...
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
std::string m_neutrinoPfoListName
The name of the output neutrino pfo list.
Header file for the cluster helper class.
unsigned int GetNTwoDHitsInPfoChain(const pandora::ParticleFlowObject *const pPfo) const
Get the number of two dimensional hits (TPC_VIEW_U, V or W) contained in clusters in a pfo and all it...
Header file for the neutrino properties algorithm class.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
static bool IsNeutrino(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a neutrino or (antineutrino)
pandora::StatusCode Run()