9 #include "Pandora/AlgorithmHeaders.h" 22 CheatingCosmicRayIdentificationAlg::CheatingCosmicRayIdentificationAlg() :
23 m_maxNeutrinoFraction(0.5
f)
31 const PfoList *pPfoList(
nullptr);
32 PANDORA_RETURN_RESULT_IF_AND_IF(
33 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*
this,
m_inputPfoListName, pPfoList));
37 if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
38 std::cout <<
"CheatingCosmicRayIdentificationAlg: pfo list " <<
m_inputPfoListName <<
" unavailable." << std::endl;
40 return STATUS_CODE_SUCCESS;
43 PfoList outputPfoList, outputDaughterPfoList;
45 for (
const ParticleFlowObject *
const pPfo : *pPfoList)
47 if (!pPfo->GetParentPfoList().empty())
50 PfoList downstreamPfos;
53 float thisNeutrinoWeight(0.
f), thisTotalWeight(0.
f);
56 if ((thisTotalWeight < std::numeric_limits<float>::epsilon()) || ((thisNeutrinoWeight / thisTotalWeight) <
m_maxNeutrinoFraction))
57 outputPfoList.push_back(pPfo);
60 if (!outputPfoList.empty())
64 if (!outputDaughterPfoList.empty())
65 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=,
69 return STATUS_CODE_SUCCESS;
76 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle,
"InputPfoListName",
m_inputPfoListName));
78 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle,
"OutputPfoListName",
m_outputPfoListName));
81 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
85 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
88 PANDORA_RETURN_RESULT_IF_AND_IF(
89 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"MaxNeutrinoFraction",
m_maxNeutrinoFraction));
91 return STATUS_CODE_SUCCESS;
Header file for the pfo helper class.
Header file for the cosmic ray identification cheater class.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
std::string m_inputPfoListName
The input pfo list name.
std::string m_inputDaughterPfoListName
The input daughter pfo list name (if not specified, will assume same as main input list) ...
std::string m_outputDaughterPfoListName
The output daughter pfo list name (if not specified, will assume same as main output list) ...
float m_maxNeutrinoFraction
The maximum true neutrino fraction in a particle to be labelled as a cosmic ray.
Header file for the lar monte carlo particle helper helper class.
pandora::StatusCode Run()
std::string m_outputPfoListName
The output pfo list name.
static void GetTargetParticleWeight(const pandora::PfoList *const pPfoList, float &targetParticleWeight, float &totalWeight, std::function< bool(const pandora::MCParticle *const)> fCriteria)
Get the target particle weight in a list of pfos.
static void GetAllDownstreamPfos(const pandora::PfoList &inputPfoList, pandora::PfoList &outputPfoList)
Get a flat list of all pfos, recursively, of all daughters associated with those pfos in an input lis...
static bool IsNeutrino(const pandora::MCParticle *const pMCParticle)
Whether a mc particle is a neutrino or antineutrino.