All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CheatingCosmicRayIdentificationAlg.cc
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArCheating/CheatingCosmicRayIdentificationAlg.cc
3  *
4  * @brief Implementation of the cheater for the cosmic ray identification algorithm class.
5  *
6  * $Log: $
7  */
8 
9 #include "Pandora/AlgorithmHeaders.h"
10 
13 
16 
17 using namespace pandora;
18 
19 namespace lar_content
20 {
21 
22 CheatingCosmicRayIdentificationAlg::CheatingCosmicRayIdentificationAlg() : m_maxNeutrinoFraction(0.5f)
23 {
24 }
25 
26 //------------------------------------------------------------------------------------------------------------------------------------------
27 
29 {
30  const PfoList *pPfoList(nullptr);
31  PANDORA_RETURN_RESULT_IF_AND_IF(
32  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*this, m_inputPfoListName, pPfoList));
33 
34  if (!pPfoList)
35  {
36  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
37  std::cout << "CheatingCosmicRayIdentificationAlg: pfo list " << m_inputPfoListName << " unavailable." << std::endl;
38 
39  return STATUS_CODE_SUCCESS;
40  }
41 
42  PfoList outputPfoList, outputDaughterPfoList;
43 
44  for (const ParticleFlowObject *const pPfo : *pPfoList)
45  {
46  if (!pPfo->GetParentPfoList().empty())
47  continue;
48 
49  PfoList downstreamPfos;
50  LArPfoHelper::GetAllDownstreamPfos(pPfo, downstreamPfos);
51 
52  float thisNeutrinoWeight(0.f), thisTotalWeight(0.f);
53  CheatingSliceIdBaseTool::GetTargetParticleWeight(&downstreamPfos, thisNeutrinoWeight, thisTotalWeight, LArMCParticleHelper::IsNeutrino);
54 
55  if ((thisTotalWeight < std::numeric_limits<float>::epsilon()) || ((thisNeutrinoWeight / thisTotalWeight) < m_maxNeutrinoFraction))
56  outputPfoList.push_back(pPfo);
57  }
58 
59  if (!outputPfoList.empty())
60  {
61  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList(*this, m_inputPfoListName, m_outputPfoListName, outputPfoList));
62 
63  if (!outputDaughterPfoList.empty())
64  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=,
65  PandoraContentApi::SaveList(*this, m_inputDaughterPfoListName, m_outputDaughterPfoListName, outputDaughterPfoList));
66  }
67 
68  return STATUS_CODE_SUCCESS;
69 }
70 
71 //------------------------------------------------------------------------------------------------------------------------------------------
72 
73 StatusCode CheatingCosmicRayIdentificationAlg::ReadSettings(const TiXmlHandle xmlHandle)
74 {
75  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "InputPfoListName", m_inputPfoListName));
76 
77  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "OutputPfoListName", m_outputPfoListName));
78 
80  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
81  XmlHelper::ReadValue(xmlHandle, "InputDaughterPfoListName", m_inputDaughterPfoListName));
82 
84  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
85  XmlHelper::ReadValue(xmlHandle, "OutputDaughterPfoListName", m_outputDaughterPfoListName));
86 
87  PANDORA_RETURN_RESULT_IF_AND_IF(
88  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MaxNeutrinoFraction", m_maxNeutrinoFraction));
89 
90  return STATUS_CODE_SUCCESS;
91 }
92 
93 } // namespace lar_content
Header file for the pfo helper class.
Header file for the cosmic ray identification cheater class.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Header file for the cheating slice id base tool class.
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.
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.
required by fuzzyCluster table::sbnd_g4_services gaushitTruthMatch pandora
Definition: reco_sbnd.fcl:182
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...
BEGIN_PROLOG could also be cout
static bool IsNeutrino(const pandora::MCParticle *const pMCParticle)
Whether a mc particle is a neutrino or antineutrino.