LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
lar_content::CheatingNeutrinoDaughterVerticesAlgorithm Class Reference

CheatingNeutrinoDaughterVerticesAlgorithm::Algorithm class. More...

#include "CheatingNeutrinoDaughterVerticesAlgorithm.h"

Inheritance diagram for lar_content::CheatingNeutrinoDaughterVerticesAlgorithm:

Public Member Functions

 CheatingNeutrinoDaughterVerticesAlgorithm ()
 Default constructor. More...
 

Private Member Functions

pandora::StatusCode Run ()
 
void GetMCPrimaryMap (LArMCParticleHelper::MCRelationMap &mcPrimaryMap) const
 Get the mapping from mc particle to primary, only required if collapsed mc particle hierarchy specified. More...
 
void ProcessRecoNeutrinos (const pandora::PfoList &neutrinoPfos, const LArMCParticleHelper::MCRelationMap &mcPrimaryMap) const
 Process the list of reconstructed neutrinos. More...
 
void ProcessDaughterPfo (const pandora::ParticleFlowObject *const pDaughterPfo, const LArMCParticleHelper::MCRelationMap &mcPrimaryMap) const
 Process a daughter pfo. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Private Attributes

bool m_collapseToPrimaryMCParticles
 Whether to collapse mc particle hierarchies to primary particles. More...
 
std::string m_mcParticleListName
 The mc particle list name, required if want to collapse mc particle hierarchy. More...
 
std::string m_neutrinoListName
 The input list of pfo list names. More...
 
std::string m_vertexListName
 The name of the output cosmic-ray vertex list. More...
 

Detailed Description

CheatingNeutrinoDaughterVerticesAlgorithm::Algorithm class.

Definition at line 21 of file CheatingNeutrinoDaughterVerticesAlgorithm.h.

Constructor & Destructor Documentation

lar_content::CheatingNeutrinoDaughterVerticesAlgorithm::CheatingNeutrinoDaughterVerticesAlgorithm ( )

Default constructor.

Definition at line 20 of file CheatingNeutrinoDaughterVerticesAlgorithm.cc.

20  :
22 {
23 }
bool m_collapseToPrimaryMCParticles
Whether to collapse mc particle hierarchies to primary particles.

Member Function Documentation

void lar_content::CheatingNeutrinoDaughterVerticesAlgorithm::GetMCPrimaryMap ( LArMCParticleHelper::MCRelationMap mcPrimaryMap) const
private

Get the mapping from mc particle to primary, only required if collapsed mc particle hierarchy specified.

Parameters
mcPrimaryMapto receive the mapping from mc particle to primary

Definition at line 53 of file CheatingNeutrinoDaughterVerticesAlgorithm.cc.

References lar_content::LArMCParticleHelper::GetMCPrimaryMap(), m_collapseToPrimaryMCParticles, and m_mcParticleListName.

Referenced by Run().

54 {
56  {
57  const MCParticleList *pMCParticleList(nullptr);
58  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*this, m_mcParticleListName, pMCParticleList));
59 
60  LArMCParticleHelper::GetMCPrimaryMap(pMCParticleList, mcPrimaryMap);
61  }
62 }
std::string m_mcParticleListName
The mc particle list name, required if want to collapse mc particle hierarchy.
static void GetMCPrimaryMap(const pandora::MCParticleList *const pMCParticleList, MCRelationMap &mcPrimaryMap)
Get mapping from individual mc particles (in a provided list) and their primary parent mc particles...
bool m_collapseToPrimaryMCParticles
Whether to collapse mc particle hierarchies to primary particles.
void lar_content::CheatingNeutrinoDaughterVerticesAlgorithm::ProcessDaughterPfo ( const pandora::ParticleFlowObject *const  pDaughterPfo,
const LArMCParticleHelper::MCRelationMap mcPrimaryMap 
) const
private

Process a daughter pfo.

Parameters
pDaughterPfothe address of a daughter pfo
mcPrimaryMapthe mapping from mc particle to primary, only required if collapsed mc particle hierarchy specified

Definition at line 93 of file CheatingNeutrinoDaughterVerticesAlgorithm.cc.

References lar_content::LArMCParticleHelper::GetMainMCParticle(), m_collapseToPrimaryMCParticles, and m_vertexListName.

Referenced by ProcessRecoNeutrinos().

95 {
96  const MCParticle *pMCParticle(LArMCParticleHelper::GetMainMCParticle(pDaughterPfo));
97 
99  {
100  LArMCParticleHelper::MCRelationMap::const_iterator primaryIter = mcPrimaryMap.find(pMCParticle);
101 
102  if (mcPrimaryMap.end() == primaryIter)
103  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
104 
105  pMCParticle = primaryIter->second;
106  }
107 
108  const VertexList *pVertexList(nullptr);
109  std::string vertexListName;
110  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CreateTemporaryListAndSetCurrent(*this, pVertexList, vertexListName));
111 
112  PandoraContentApi::Vertex::Parameters parameters;
113  parameters.m_position = pMCParticle->GetVertex();
114  parameters.m_vertexLabel = VERTEX_INTERACTION;
115  parameters.m_vertexType = VERTEX_3D;
116 
117  const Vertex *pVertex(nullptr);
118  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Vertex::Create(*this, parameters, pVertex));
119 
120  if (!pVertexList->empty())
121  {
122  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList<Vertex>(*this, m_vertexListName));
123  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToPfo<Vertex>(*this, pDaughterPfo, pVertex));
124  }
125 }
std::string m_vertexListName
The name of the output cosmic-ray vertex list.
intermediate_table::const_iterator const_iterator
static const pandora::MCParticle * GetMainMCParticle(const pandora::ParticleFlowObject *const pPfo)
Find the mc particle making the largest contribution to 2D clusters in a specified pfo...
bool m_collapseToPrimaryMCParticles
Whether to collapse mc particle hierarchies to primary particles.
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
Definition: ModuleGraph.h:25
std::list< Vertex > VertexList
Definition: DCEL.h:169
void lar_content::CheatingNeutrinoDaughterVerticesAlgorithm::ProcessRecoNeutrinos ( const pandora::PfoList &  neutrinoPfos,
const LArMCParticleHelper::MCRelationMap mcPrimaryMap 
) const
private

Process the list of reconstructed neutrinos.

Parameters
neutrinoPfosthe list of neutrino pfos
mcPrimaryMapthe mapping from mc particle to primary, only required if collapsed mc particle hierarchy specified

Definition at line 66 of file CheatingNeutrinoDaughterVerticesAlgorithm.cc.

References lar_content::LArPfoHelper::GetAllDownstreamPfos(), and ProcessDaughterPfo().

Referenced by Run().

67 {
68  for (const ParticleFlowObject *const pNeutrinoPfo : neutrinoPfos)
69  {
70  PfoList daughterPfos;
71  LArPfoHelper::GetAllDownstreamPfos(pNeutrinoPfo, daughterPfos);
72 
73  PfoList::iterator neutrinoIter(std::find(daughterPfos.begin(), daughterPfos.end(), pNeutrinoPfo));
74 
75  if (daughterPfos.end() != neutrinoIter)
76  daughterPfos.erase(neutrinoIter);
77 
78  for (const ParticleFlowObject *const pDaughterPfo : daughterPfos)
79  {
80  try
81  {
82  this->ProcessDaughterPfo(pDaughterPfo, mcPrimaryMap);
83  }
84  catch (const StatusCodeException &)
85  {
86  }
87  }
88  }
89 }
intermediate_table::iterator iterator
void ProcessDaughterPfo(const pandora::ParticleFlowObject *const pDaughterPfo, const LArMCParticleHelper::MCRelationMap &mcPrimaryMap) const
Process a daughter pfo.
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...
StatusCode lar_content::CheatingNeutrinoDaughterVerticesAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 129 of file CheatingNeutrinoDaughterVerticesAlgorithm.cc.

References m_collapseToPrimaryMCParticles, m_mcParticleListName, m_neutrinoListName, and m_vertexListName.

130 {
131  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
132  XmlHelper::ReadValue(xmlHandle, "CollapseToPrimaryMCParticles", m_collapseToPrimaryMCParticles));
133 
135  {
136  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "MCParticleListName", m_mcParticleListName));
137  }
138 
139  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "NeutrinoPfoListName", m_neutrinoListName));
140 
141  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "OutputVertexListName", m_vertexListName));
142 
143  return STATUS_CODE_SUCCESS;
144 }
std::string m_mcParticleListName
The mc particle list name, required if want to collapse mc particle hierarchy.
std::string m_vertexListName
The name of the output cosmic-ray vertex list.
bool m_collapseToPrimaryMCParticles
Whether to collapse mc particle hierarchies to primary particles.
StatusCode lar_content::CheatingNeutrinoDaughterVerticesAlgorithm::Run ( )
private

Definition at line 27 of file CheatingNeutrinoDaughterVerticesAlgorithm.cc.

References GetMCPrimaryMap(), lar_content::LArPfoHelper::GetRecoNeutrinos(), m_neutrinoListName, and ProcessRecoNeutrinos().

28 {
29  const PfoList *pPfoList(nullptr);
30  PANDORA_THROW_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*this, m_neutrinoListName, pPfoList));
31 
32  if (!pPfoList)
33  {
34  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
35  std::cout << "CheatingNeutrinoDaughterVerticesAlgorithm: pfo list unavailable." << std::endl;
36 
37  return STATUS_CODE_SUCCESS;
38  }
39 
41  this->GetMCPrimaryMap(mcPrimaryMap);
42 
43  PfoList neutrinoPfos;
44  LArPfoHelper::GetRecoNeutrinos(pPfoList, neutrinoPfos);
45 
46  this->ProcessRecoNeutrinos(neutrinoPfos, mcPrimaryMap);
47 
48  return STATUS_CODE_SUCCESS;
49 }
static void GetRecoNeutrinos(const pandora::PfoList *const pPfoList, pandora::PfoList &recoNeutrinos)
Get neutrino pfos from an input pfo list.
void GetMCPrimaryMap(LArMCParticleHelper::MCRelationMap &mcPrimaryMap) const
Get the mapping from mc particle to primary, only required if collapsed mc particle hierarchy specifi...
void ProcessRecoNeutrinos(const pandora::PfoList &neutrinoPfos, const LArMCParticleHelper::MCRelationMap &mcPrimaryMap) const
Process the list of reconstructed neutrinos.
std::unordered_map< const pandora::MCParticle *, const pandora::MCParticle * > MCRelationMap

Member Data Documentation

bool lar_content::CheatingNeutrinoDaughterVerticesAlgorithm::m_collapseToPrimaryMCParticles
private

Whether to collapse mc particle hierarchies to primary particles.

Definition at line 57 of file CheatingNeutrinoDaughterVerticesAlgorithm.h.

Referenced by GetMCPrimaryMap(), ProcessDaughterPfo(), and ReadSettings().

std::string lar_content::CheatingNeutrinoDaughterVerticesAlgorithm::m_mcParticleListName
private

The mc particle list name, required if want to collapse mc particle hierarchy.

Definition at line 58 of file CheatingNeutrinoDaughterVerticesAlgorithm.h.

Referenced by GetMCPrimaryMap(), and ReadSettings().

std::string lar_content::CheatingNeutrinoDaughterVerticesAlgorithm::m_neutrinoListName
private

The input list of pfo list names.

Definition at line 60 of file CheatingNeutrinoDaughterVerticesAlgorithm.h.

Referenced by ReadSettings(), and Run().

std::string lar_content::CheatingNeutrinoDaughterVerticesAlgorithm::m_vertexListName
private

The name of the output cosmic-ray vertex list.

Definition at line 61 of file CheatingNeutrinoDaughterVerticesAlgorithm.h.

Referenced by ProcessDaughterPfo(), and ReadSettings().


The documentation for this class was generated from the following files: