Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
CheatingNeutrinoDaughterVerticesAlgorithm.cc
Go to the documentation of this file.
1
10
12
14
15using namespace pandora;
16
17namespace lar_content
18{
19
23
24//------------------------------------------------------------------------------------------------------------------------------------------
25
27{
28 const PfoList *pPfoList(nullptr);
29 PANDORA_THROW_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*this, m_neutrinoListName, pPfoList));
30
31 if (!pPfoList)
32 {
34 std::cout << "CheatingNeutrinoDaughterVerticesAlgorithm: pfo list unavailable." << std::endl;
35
36 return STATUS_CODE_SUCCESS;
37 }
38
40 this->GetMCPrimaryMap(mcPrimaryMap);
41
42 PfoList neutrinoPfos;
43 LArPfoHelper::GetRecoNeutrinos(pPfoList, neutrinoPfos);
44
45 this->ProcessRecoNeutrinos(neutrinoPfos, mcPrimaryMap);
46
47 return STATUS_CODE_SUCCESS;
48}
49
50//------------------------------------------------------------------------------------------------------------------------------------------
51
53{
55 {
56 const MCParticleList *pMCParticleList(nullptr);
57 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*this, m_mcParticleListName, pMCParticleList));
58
59 LArMCParticleHelper::GetMCPrimaryMap(pMCParticleList, mcPrimaryMap);
60 }
61}
62
63//------------------------------------------------------------------------------------------------------------------------------------------
64
66{
67 for (const ParticleFlowObject *const pNeutrinoPfo : neutrinoPfos)
68 {
69 PfoList daughterPfos;
70 LArPfoHelper::GetAllDownstreamPfos(pNeutrinoPfo, daughterPfos);
71
72 PfoList::iterator neutrinoIter(std::find(daughterPfos.begin(), daughterPfos.end(), pNeutrinoPfo));
73
74 if (daughterPfos.end() != neutrinoIter)
75 daughterPfos.erase(neutrinoIter);
76
77 for (const ParticleFlowObject *const pDaughterPfo : daughterPfos)
78 {
79 try
80 {
81 this->ProcessDaughterPfo(pDaughterPfo, mcPrimaryMap);
82 }
83 catch (const StatusCodeException &)
84 {
85 }
86 }
87 }
88}
89
90//------------------------------------------------------------------------------------------------------------------------------------------
91
93 const ParticleFlowObject *const pDaughterPfo, const LArMCParticleHelper::MCRelationMap &mcPrimaryMap) const
94{
95 const MCParticle *pMCParticle(LArMCParticleHelper::GetMainMCParticle(pDaughterPfo));
96
98 {
99 LArMCParticleHelper::MCRelationMap::const_iterator primaryIter = mcPrimaryMap.find(pMCParticle);
100
101 if (mcPrimaryMap.end() == primaryIter)
102 throw StatusCodeException(STATUS_CODE_NOT_FOUND);
103
104 pMCParticle = primaryIter->second;
105 }
106
107 const VertexList *pVertexList(nullptr);
108 std::string vertexListName;
109 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CreateTemporaryListAndSetCurrent(*this, pVertexList, vertexListName));
110
111 PandoraContentApi::Vertex::Parameters parameters;
112 parameters.m_position = pMCParticle->GetVertex();
113 parameters.m_vertexLabel = VERTEX_INTERACTION;
114 parameters.m_vertexType = VERTEX_3D;
115
116 const Vertex *pVertex(nullptr);
117 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Vertex::Create(*this, parameters, pVertex));
118
119 if (!pVertexList->empty())
120 {
122 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToPfo<Vertex>(*this, pDaughterPfo, pVertex));
123 }
124}
125
126//------------------------------------------------------------------------------------------------------------------------------------------
127
129{
130 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
131 XmlHelper::ReadValue(xmlHandle, "CollapseToPrimaryMCParticles", m_collapseToPrimaryMCParticles));
132
134 {
135 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "MCParticleListName", m_mcParticleListName));
136 }
137
138 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "NeutrinoPfoListName", m_neutrinoListName));
139
140 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "OutputVertexListName", m_vertexListName));
141
142 return STATUS_CODE_SUCCESS;
143}
144
145} // namespace lar_content
Grouping of header files for many classes of use in particle flow algorithms.
Header file for the cheating neutrino daughter vertices algorithm class.
Header file for the pfo helper class.
#define PANDORA_THROW_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
Definition StatusCodes.h:55
#define PANDORA_THROW_RESULT_IF(StatusCode1, Operator, Command)
Definition StatusCodes.h:43
#define PANDORA_RETURN_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
Definition StatusCodes.h:31
#define PANDORA_RETURN_RESULT_IF(StatusCode1, Operator, Command)
Definition StatusCodes.h:19
static pandora::StatusCode ReplaceCurrentList(const pandora::Algorithm &algorithm, const std::string &newListName)
Replace the current list with a pre-saved list; use this new list as a permanent replacement for the ...
static pandora::StatusCode CreateTemporaryListAndSetCurrent(const pandora::Algorithm &algorithm, const T *&pT, std::string &temporaryListName)
Create a temporary list and set it to be the current list, enabling object creation.
static pandora::StatusCode GetList(const pandora::Algorithm &algorithm, const std::string &listName, const T *&pT)
Get a named list.
static const pandora::PandoraSettings * GetSettings(const pandora::Algorithm &algorithm)
Get the pandora settings instance.
void ProcessDaughterPfo(const pandora::ParticleFlowObject *const pDaughterPfo, const LArMCParticleHelper::MCRelationMap &mcPrimaryMap) const
Process a daughter pfo.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
void ProcessRecoNeutrinos(const pandora::PfoList &neutrinoPfos, const LArMCParticleHelper::MCRelationMap &mcPrimaryMap) const
Process the list of reconstructed neutrinos.
bool m_collapseToPrimaryMCParticles
Whether to collapse mc particle hierarchies to primary particles.
void GetMCPrimaryMap(LArMCParticleHelper::MCRelationMap &mcPrimaryMap) const
Get the mapping from mc particle to primary, only required if collapsed mc particle hierarchy specifi...
std::string m_vertexListName
The name of the output cosmic-ray vertex list.
std::string m_mcParticleListName
The mc particle list name, required if want to collapse mc particle hierarchy.
std::unordered_map< const pandora::MCParticle *, const pandora::MCParticle * > MCRelationMap
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.
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.
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 void GetRecoNeutrinos(const pandora::PfoList *const pPfoList, pandora::PfoList &recoNeutrinos)
Get neutrino pfos from an input pfo list.
MCParticle class.
Definition MCParticle.h:26
const CartesianVector & GetVertex() const
Get the production vertex of the mc particle, units mm.
Definition MCParticle.h:257
bool ShouldDisplayAlgorithmInfo() const
Whether to display algorithm information during processing.
ParticleFlowObject class.
StatusCodeException class.
Vertex class.
Definition Vertex.h:26
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
Definition XmlHelper.h:136
MANAGED_CONTAINER< const MCParticle * > MCParticleList
MANAGED_CONTAINER< const Vertex * > VertexList
StatusCode
The StatusCode enum.
MANAGED_CONTAINER< const ParticleFlowObject * > PfoList